babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502
  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 = linear */
  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. * Classed 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. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  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. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  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. * Creates a right-handed perspective projection matrix
  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 defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. private _alignTangentsWithPath;
  4784. private readonly _pointAtData;
  4785. /**
  4786. * new Path3D(path, normal, raw)
  4787. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4788. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4789. * @param path an array of Vector3, the curve axis of the Path3D
  4790. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4791. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4792. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4793. */
  4794. constructor(
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getCurve(): Vector3[];
  4804. /**
  4805. * Returns the Path3D array of successive Vector3 designing its curve.
  4806. * @returns the Path3D array of successive Vector3 designing its curve.
  4807. */
  4808. getPoints(): Vector3[];
  4809. /**
  4810. * @returns the computed length (float) of the path.
  4811. */
  4812. length(): number;
  4813. /**
  4814. * Returns an array populated with tangent vectors on each Path3D curve point.
  4815. * @returns an array populated with tangent vectors on each Path3D curve point.
  4816. */
  4817. getTangents(): Vector3[];
  4818. /**
  4819. * Returns an array populated with normal vectors on each Path3D curve point.
  4820. * @returns an array populated with normal vectors on each Path3D curve point.
  4821. */
  4822. getNormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with binormal vectors on each Path3D curve point.
  4825. * @returns an array populated with binormal vectors on each Path3D curve point.
  4826. */
  4827. getBinormals(): Vector3[];
  4828. /**
  4829. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4830. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4831. */
  4832. getDistances(): number[];
  4833. /**
  4834. * Returns an interpolated point along this path
  4835. * @param position the position of the point along this path, from 0.0 to 1.0
  4836. * @returns a new Vector3 as the point
  4837. */
  4838. getPointAt(position: number): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4843. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4844. */
  4845. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4850. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4851. */
  4852. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4857. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4858. */
  4859. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4860. /**
  4861. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4864. */
  4865. getDistanceAt(position: number): number;
  4866. /**
  4867. * Returns the array index of the previous point of an interpolated point along this path
  4868. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4869. * @returns the array index
  4870. */
  4871. getPreviousPointIndexAt(position: number): number;
  4872. /**
  4873. * 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)
  4874. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4875. * @returns the sub position
  4876. */
  4877. getSubPositionAt(position: number): number;
  4878. /**
  4879. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4880. * @param target the vector of which to get the closest position to
  4881. * @returns the position of the closest virtual point on this path to the target vector
  4882. */
  4883. getClosestPositionTo(target: Vector3): number;
  4884. /**
  4885. * Returns a sub path (slice) of this path
  4886. * @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
  4887. * @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
  4888. * @returns a sub path (slice) of this path
  4889. */
  4890. slice(start?: number, end?: number): Path3D;
  4891. /**
  4892. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4893. * @param path path which all values are copied into the curves points
  4894. * @param firstNormal which should be projected onto the curve
  4895. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4896. * @returns the same object updated.
  4897. */
  4898. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4899. private _compute;
  4900. private _getFirstNonNullVector;
  4901. private _getLastNonNullVector;
  4902. private _normalVector;
  4903. /**
  4904. * Updates the point at data for an interpolated point along this curve
  4905. * @param position the position of the point along this curve, from 0.0 to 1.0
  4906. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4907. * @returns the (updated) point at data
  4908. */
  4909. private _updatePointAtData;
  4910. /**
  4911. * Updates the point at data from the specified parameters
  4912. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4913. * @param point the interpolated point
  4914. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4915. */
  4916. private _setPointAtData;
  4917. /**
  4918. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4919. */
  4920. private _updateInterpolationMatrix;
  4921. }
  4922. /**
  4923. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4924. * A Curve3 is designed from a series of successive Vector3.
  4925. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4926. */
  4927. export class Curve3 {
  4928. private _points;
  4929. private _length;
  4930. /**
  4931. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4932. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4933. * @param v1 (Vector3) the control point
  4934. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4935. * @param nbPoints (integer) the wanted number of points in the curve
  4936. * @returns the created Curve3
  4937. */
  4938. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4939. /**
  4940. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4941. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4942. * @param v1 (Vector3) the first control point
  4943. * @param v2 (Vector3) the second control point
  4944. * @param v3 (Vector3) the end point of the Cubic Bezier
  4945. * @param nbPoints (integer) the wanted number of points in the curve
  4946. * @returns the created Curve3
  4947. */
  4948. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4949. /**
  4950. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4951. * @param p1 (Vector3) the origin point of the Hermite Spline
  4952. * @param t1 (Vector3) the tangent vector at the origin point
  4953. * @param p2 (Vector3) the end point of the Hermite Spline
  4954. * @param t2 (Vector3) the tangent vector at the end point
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a CatmullRom Spline curve :
  4961. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4962. * @param nbPoints (integer) the wanted number of points between each curve control points
  4963. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4971. * @param points points which make up the curve
  4972. */
  4973. constructor(points: Vector3[]);
  4974. /**
  4975. * @returns the Curve3 stored array of successive Vector3
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the curve.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4984. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4985. * curveA and curveB keep unchanged.
  4986. * @param curve the curve to continue from this curve
  4987. * @returns the newly constructed curve
  4988. */
  4989. continue(curve: DeepImmutable<Curve3>): Curve3;
  4990. private _computeLength;
  4991. }
  4992. }
  4993. declare module "babylonjs/Animations/easing" {
  4994. /**
  4995. * This represents the main contract an easing function should follow.
  4996. * Easing functions are used throughout the animation system.
  4997. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4998. */
  4999. export interface IEasingFunction {
  5000. /**
  5001. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5002. * of the easing function.
  5003. * The link below provides some of the most common examples of easing functions.
  5004. * @see https://easings.net/
  5005. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5006. * @returns the corresponding value on the curve defined by the easing function
  5007. */
  5008. ease(gradient: number): number;
  5009. }
  5010. /**
  5011. * Base class used for every default easing function.
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class EasingFunction implements IEasingFunction {
  5015. /**
  5016. * Interpolation follows the mathematical formula associated with the easing function.
  5017. */
  5018. static readonly EASINGMODE_EASEIN: number;
  5019. /**
  5020. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5021. */
  5022. static readonly EASINGMODE_EASEOUT: number;
  5023. /**
  5024. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5025. */
  5026. static readonly EASINGMODE_EASEINOUT: number;
  5027. private _easingMode;
  5028. /**
  5029. * Sets the easing mode of the current function.
  5030. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5031. */
  5032. setEasingMode(easingMode: number): void;
  5033. /**
  5034. * Gets the current easing mode.
  5035. * @returns the easing mode
  5036. */
  5037. getEasingMode(): number;
  5038. /**
  5039. * @hidden
  5040. */
  5041. easeInCore(gradient: number): number;
  5042. /**
  5043. * Given an input gradient between 0 and 1, this returns the corresponding value
  5044. * of the easing function.
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Easing function with a circle shape (see link below).
  5052. * @see https://easings.net/#easeInCirc
  5053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5054. */
  5055. export class CircleEase extends EasingFunction implements IEasingFunction {
  5056. /** @hidden */
  5057. easeInCore(gradient: number): number;
  5058. }
  5059. /**
  5060. * Easing function with a ease back shape (see link below).
  5061. * @see https://easings.net/#easeInBack
  5062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5063. */
  5064. export class BackEase extends EasingFunction implements IEasingFunction {
  5065. /** Defines the amplitude of the function */
  5066. amplitude: number;
  5067. /**
  5068. * Instantiates a back ease easing
  5069. * @see https://easings.net/#easeInBack
  5070. * @param amplitude Defines the amplitude of the function
  5071. */
  5072. constructor(
  5073. /** Defines the amplitude of the function */
  5074. amplitude?: number);
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bouncing shape (see link below).
  5080. * @see https://easings.net/#easeInBounce
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BounceEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the number of bounces */
  5085. bounces: number;
  5086. /** Defines the amplitude of the bounce */
  5087. bounciness: number;
  5088. /**
  5089. * Instantiates a bounce easing
  5090. * @see https://easings.net/#easeInBounce
  5091. * @param bounces Defines the number of bounces
  5092. * @param bounciness Defines the amplitude of the bounce
  5093. */
  5094. constructor(
  5095. /** Defines the number of bounces */
  5096. bounces?: number,
  5097. /** Defines the amplitude of the bounce */
  5098. bounciness?: number);
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 3 shape (see link below).
  5104. * @see https://easings.net/#easeInCubic
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class CubicEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with an elastic shape (see link below).
  5113. * @see https://easings.net/#easeInElastic
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5117. /** Defines the number of oscillations*/
  5118. oscillations: number;
  5119. /** Defines the amplitude of the oscillations*/
  5120. springiness: number;
  5121. /**
  5122. * Instantiates an elastic easing function
  5123. * @see https://easings.net/#easeInElastic
  5124. * @param oscillations Defines the number of oscillations
  5125. * @param springiness Defines the amplitude of the oscillations
  5126. */
  5127. constructor(
  5128. /** Defines the number of oscillations*/
  5129. oscillations?: number,
  5130. /** Defines the amplitude of the oscillations*/
  5131. springiness?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with an exponential shape (see link below).
  5137. * @see https://easings.net/#easeInExpo
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the exponent of the function */
  5142. exponent: number;
  5143. /**
  5144. * Instantiates an exponential easing function
  5145. * @see https://easings.net/#easeInExpo
  5146. * @param exponent Defines the exponent of the function
  5147. */
  5148. constructor(
  5149. /** Defines the exponent of the function */
  5150. exponent?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with a power shape (see link below).
  5156. * @see https://easings.net/#easeInQuad
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class PowerEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the power of the function */
  5161. power: number;
  5162. /**
  5163. * Instantiates an power base easing function
  5164. * @see https://easings.net/#easeInQuad
  5165. * @param power Defines the power of the function
  5166. */
  5167. constructor(
  5168. /** Defines the power of the function */
  5169. power?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 2 shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 4 shape (see link below).
  5184. * @see https://easings.net/#easeInQuart
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 5 shape (see link below).
  5193. * @see https://easings.net/#easeInQuint
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a sin shape (see link below).
  5202. * @see https://easings.net/#easeInSine
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class SineEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a bezier shape (see link below).
  5211. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the x component of the start tangent in the bezier curve */
  5216. x1: number;
  5217. /** Defines the y component of the start tangent in the bezier curve */
  5218. y1: number;
  5219. /** Defines the x component of the end tangent in the bezier curve */
  5220. x2: number;
  5221. /** Defines the y component of the end tangent in the bezier curve */
  5222. y2: number;
  5223. /**
  5224. * Instantiates a bezier function
  5225. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5226. * @param x1 Defines the x component of the start tangent in the bezier curve
  5227. * @param y1 Defines the y component of the start tangent in the bezier curve
  5228. * @param x2 Defines the x component of the end tangent in the bezier curve
  5229. * @param y2 Defines the y component of the end tangent in the bezier curve
  5230. */
  5231. constructor(
  5232. /** Defines the x component of the start tangent in the bezier curve */
  5233. x1?: number,
  5234. /** Defines the y component of the start tangent in the bezier curve */
  5235. y1?: number,
  5236. /** Defines the x component of the end tangent in the bezier curve */
  5237. x2?: number,
  5238. /** Defines the y component of the end tangent in the bezier curve */
  5239. y2?: number);
  5240. /** @hidden */
  5241. easeInCore(gradient: number): number;
  5242. }
  5243. }
  5244. declare module "babylonjs/Maths/math.color" {
  5245. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5246. /**
  5247. * Class used to hold a RBG color
  5248. */
  5249. export class Color3 {
  5250. /**
  5251. * Defines the red component (between 0 and 1, default is 0)
  5252. */
  5253. r: number;
  5254. /**
  5255. * Defines the green component (between 0 and 1, default is 0)
  5256. */
  5257. g: number;
  5258. /**
  5259. * Defines the blue component (between 0 and 1, default is 0)
  5260. */
  5261. b: number;
  5262. /**
  5263. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5264. * @param r defines the red component (between 0 and 1, default is 0)
  5265. * @param g defines the green component (between 0 and 1, default is 0)
  5266. * @param b defines the blue component (between 0 and 1, default is 0)
  5267. */
  5268. constructor(
  5269. /**
  5270. * Defines the red component (between 0 and 1, default is 0)
  5271. */
  5272. r?: number,
  5273. /**
  5274. * Defines the green component (between 0 and 1, default is 0)
  5275. */
  5276. g?: number,
  5277. /**
  5278. * Defines the blue component (between 0 and 1, default is 0)
  5279. */
  5280. b?: number);
  5281. /**
  5282. * Creates a string with the Color3 current values
  5283. * @returns the string representation of the Color3 object
  5284. */
  5285. toString(): string;
  5286. /**
  5287. * Returns the string "Color3"
  5288. * @returns "Color3"
  5289. */
  5290. getClassName(): string;
  5291. /**
  5292. * Compute the Color3 hash code
  5293. * @returns an unique number that can be used to hash Color3 objects
  5294. */
  5295. getHashCode(): number;
  5296. /**
  5297. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5298. * @param array defines the array where to store the r,g,b components
  5299. * @param index defines an optional index in the target array to define where to start storing values
  5300. * @returns the current Color3 object
  5301. */
  5302. toArray(array: FloatArray, index?: number): Color3;
  5303. /**
  5304. * Returns a new Color4 object from the current Color3 and the given alpha
  5305. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5306. * @returns a new Color4 object
  5307. */
  5308. toColor4(alpha?: number): Color4;
  5309. /**
  5310. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5311. * @returns the new array
  5312. */
  5313. asArray(): number[];
  5314. /**
  5315. * Returns the luminance value
  5316. * @returns a float value
  5317. */
  5318. toLuminance(): number;
  5319. /**
  5320. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5321. * @param otherColor defines the second operand
  5322. * @returns the new Color3 object
  5323. */
  5324. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5325. /**
  5326. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5327. * @param otherColor defines the second operand
  5328. * @param result defines the Color3 object where to store the result
  5329. * @returns the current Color3
  5330. */
  5331. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5332. /**
  5333. * Determines equality between Color3 objects
  5334. * @param otherColor defines the second operand
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equals(otherColor: DeepImmutable<Color3>): boolean;
  5338. /**
  5339. * Determines equality between the current Color3 object and a set of r,b,g values
  5340. * @param r defines the red component to check
  5341. * @param g defines the green component to check
  5342. * @param b defines the blue component to check
  5343. * @returns true if the rgb values are equal to the given ones
  5344. */
  5345. equalsFloats(r: number, g: number, b: number): boolean;
  5346. /**
  5347. * Multiplies in place each rgb value by scale
  5348. * @param scale defines the scaling factor
  5349. * @returns the updated Color3
  5350. */
  5351. scale(scale: number): Color3;
  5352. /**
  5353. * Multiplies the rgb values by scale and stores the result into "result"
  5354. * @param scale defines the scaling factor
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the unmodified current Color3
  5357. */
  5358. scaleToRef(scale: number, result: Color3): Color3;
  5359. /**
  5360. * Scale the current Color3 values by a factor and add the result to a given Color3
  5361. * @param scale defines the scale factor
  5362. * @param result defines color to store the result into
  5363. * @returns the unmodified current Color3
  5364. */
  5365. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5366. /**
  5367. * Clamps the rgb values by the min and max values and stores the result into "result"
  5368. * @param min defines minimum clamping value (default is 0)
  5369. * @param max defines maximum clamping value (default is 1)
  5370. * @param result defines color to store the result into
  5371. * @returns the original Color3
  5372. */
  5373. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5374. /**
  5375. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. add(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5389. * @param otherColor defines the second operand
  5390. * @returns the new Color3
  5391. */
  5392. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5393. /**
  5394. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5395. * @param otherColor defines the second operand
  5396. * @param result defines Color3 object to store the result into
  5397. * @returns the unmodified current Color3
  5398. */
  5399. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5400. /**
  5401. * Copy the current object
  5402. * @returns a new Color3 copied the current one
  5403. */
  5404. clone(): Color3;
  5405. /**
  5406. * Copies the rgb values from the source in the current Color3
  5407. * @param source defines the source Color3 object
  5408. * @returns the updated Color3 object
  5409. */
  5410. copyFrom(source: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. copyFromFloats(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Updates the Color3 rgb values from the given floats
  5421. * @param r defines the red component to read from
  5422. * @param g defines the green component to read from
  5423. * @param b defines the blue component to read from
  5424. * @returns the current Color3 object
  5425. */
  5426. set(r: number, g: number, b: number): Color3;
  5427. /**
  5428. * Compute the Color3 hexadecimal code as a string
  5429. * @returns a string containing the hexadecimal representation of the Color3 object
  5430. */
  5431. toHexString(): string;
  5432. /**
  5433. * Computes a new Color3 converted from the current one to linear space
  5434. * @returns a new Color3 object
  5435. */
  5436. toLinearSpace(): Color3;
  5437. /**
  5438. * Converts current color in rgb space to HSV values
  5439. * @returns a new color3 representing the HSV values
  5440. */
  5441. toHSV(): Color3;
  5442. /**
  5443. * Converts current color in rgb space to HSV values
  5444. * @param result defines the Color3 where to store the HSV values
  5445. */
  5446. toHSVToRef(result: Color3): void;
  5447. /**
  5448. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5449. * @param convertedColor defines the Color3 object where to store the linear space version
  5450. * @returns the unmodified Color3
  5451. */
  5452. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to gamma space
  5455. * @returns a new Color3 object
  5456. */
  5457. toGammaSpace(): Color3;
  5458. /**
  5459. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5460. * @param convertedColor defines the Color3 object where to store the gamma space version
  5461. * @returns the unmodified Color3
  5462. */
  5463. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5464. private static _BlackReadOnly;
  5465. /**
  5466. * Convert Hue, saturation and value to a Color3 (RGB)
  5467. * @param hue defines the hue
  5468. * @param saturation defines the saturation
  5469. * @param value defines the value
  5470. * @param result defines the Color3 where to store the RGB values
  5471. */
  5472. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5473. /**
  5474. * Creates a new Color3 from the string containing valid hexadecimal values
  5475. * @param hex defines a string containing valid hexadecimal values
  5476. * @returns a new Color3 object
  5477. */
  5478. static FromHexString(hex: string): Color3;
  5479. /**
  5480. * Creates a new Color3 from the starting index of the given array
  5481. * @param array defines the source array
  5482. * @param offset defines an offset in the source array
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5486. /**
  5487. * Creates a new Color3 from integer values (< 256)
  5488. * @param r defines the red component to read from (value between 0 and 255)
  5489. * @param g defines the green component to read from (value between 0 and 255)
  5490. * @param b defines the blue component to read from (value between 0 and 255)
  5491. * @returns a new Color3 object
  5492. */
  5493. static FromInts(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param start defines the start Color3 value
  5497. * @param end defines the end Color3 value
  5498. * @param amount defines the gradient value between start and end
  5499. * @returns a new Color3 object
  5500. */
  5501. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5502. /**
  5503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5504. * @param left defines the start value
  5505. * @param right defines the end value
  5506. * @param amount defines the gradient factor
  5507. * @param result defines the Color3 object where to store the result
  5508. */
  5509. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5510. /**
  5511. * Returns a Color3 value containing a red color
  5512. * @returns a new Color3 object
  5513. */
  5514. static Red(): Color3;
  5515. /**
  5516. * Returns a Color3 value containing a green color
  5517. * @returns a new Color3 object
  5518. */
  5519. static Green(): Color3;
  5520. /**
  5521. * Returns a Color3 value containing a blue color
  5522. * @returns a new Color3 object
  5523. */
  5524. static Blue(): Color3;
  5525. /**
  5526. * Returns a Color3 value containing a black color
  5527. * @returns a new Color3 object
  5528. */
  5529. static Black(): Color3;
  5530. /**
  5531. * Gets a Color3 value containing a black color that must not be updated
  5532. */
  5533. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5534. /**
  5535. * Returns a Color3 value containing a white color
  5536. * @returns a new Color3 object
  5537. */
  5538. static White(): Color3;
  5539. /**
  5540. * Returns a Color3 value containing a purple color
  5541. * @returns a new Color3 object
  5542. */
  5543. static Purple(): Color3;
  5544. /**
  5545. * Returns a Color3 value containing a magenta color
  5546. * @returns a new Color3 object
  5547. */
  5548. static Magenta(): Color3;
  5549. /**
  5550. * Returns a Color3 value containing a yellow color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Yellow(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a gray color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Gray(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a teal color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Teal(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a random color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Random(): Color3;
  5569. }
  5570. /**
  5571. * Class used to hold a RBGA color
  5572. */
  5573. export class Color4 {
  5574. /**
  5575. * Defines the red component (between 0 and 1, default is 0)
  5576. */
  5577. r: number;
  5578. /**
  5579. * Defines the green component (between 0 and 1, default is 0)
  5580. */
  5581. g: number;
  5582. /**
  5583. * Defines the blue component (between 0 and 1, default is 0)
  5584. */
  5585. b: number;
  5586. /**
  5587. * Defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. a: number;
  5590. /**
  5591. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5592. * @param r defines the red component (between 0 and 1, default is 0)
  5593. * @param g defines the green component (between 0 and 1, default is 0)
  5594. * @param b defines the blue component (between 0 and 1, default is 0)
  5595. * @param a defines the alpha component (between 0 and 1, default is 1)
  5596. */
  5597. constructor(
  5598. /**
  5599. * Defines the red component (between 0 and 1, default is 0)
  5600. */
  5601. r?: number,
  5602. /**
  5603. * Defines the green component (between 0 and 1, default is 0)
  5604. */
  5605. g?: number,
  5606. /**
  5607. * Defines the blue component (between 0 and 1, default is 0)
  5608. */
  5609. b?: number,
  5610. /**
  5611. * Defines the alpha component (between 0 and 1, default is 1)
  5612. */
  5613. a?: number);
  5614. /**
  5615. * Adds in place the given Color4 values to the current Color4 object
  5616. * @param right defines the second operand
  5617. * @returns the current updated Color4 object
  5618. */
  5619. addInPlace(right: DeepImmutable<Color4>): Color4;
  5620. /**
  5621. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5622. * @returns the new array
  5623. */
  5624. asArray(): number[];
  5625. /**
  5626. * Stores from the starting index in the given array the Color4 successive values
  5627. * @param array defines the array where to store the r,g,b components
  5628. * @param index defines an optional index in the target array to define where to start storing values
  5629. * @returns the current Color4 object
  5630. */
  5631. toArray(array: number[], index?: number): Color4;
  5632. /**
  5633. * Determines equality between Color4 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgba values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color4>): boolean;
  5638. /**
  5639. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. add(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5646. * @param right defines the second operand
  5647. * @returns a new Color4 object
  5648. */
  5649. subtract(right: DeepImmutable<Color4>): Color4;
  5650. /**
  5651. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5652. * @param right defines the second operand
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current Color4 object
  5655. */
  5656. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5657. /**
  5658. * Creates a new Color4 with the current Color4 values multiplied by scale
  5659. * @param scale defines the scaling factor to apply
  5660. * @returns a new Color4 object
  5661. */
  5662. scale(scale: number): Color4;
  5663. /**
  5664. * Multiplies the current Color4 values by scale and stores the result in "result"
  5665. * @param scale defines the scaling factor to apply
  5666. * @param result defines the Color4 object where to store the result
  5667. * @returns the current unmodified Color4
  5668. */
  5669. scaleToRef(scale: number, result: Color4): Color4;
  5670. /**
  5671. * Scale the current Color4 values by a factor and add the result to a given Color4
  5672. * @param scale defines the scale factor
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the unmodified current Color4
  5675. */
  5676. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5677. /**
  5678. * Clamps the rgb values by the min and max values and stores the result into "result"
  5679. * @param min defines minimum clamping value (default is 0)
  5680. * @param max defines maximum clamping value (default is 1)
  5681. * @param result defines color to store the result into.
  5682. * @returns the cuurent Color4
  5683. */
  5684. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5685. /**
  5686. * Multipy an Color4 value by another and return a new Color4 object
  5687. * @param color defines the Color4 value to multiply by
  5688. * @returns a new Color4 object
  5689. */
  5690. multiply(color: Color4): Color4;
  5691. /**
  5692. * Multipy a Color4 value by another and push the result in a reference value
  5693. * @param color defines the Color4 value to multiply by
  5694. * @param result defines the Color4 to fill the result in
  5695. * @returns the result Color4
  5696. */
  5697. multiplyToRef(color: Color4, result: Color4): Color4;
  5698. /**
  5699. * Creates a string with the Color4 current values
  5700. * @returns the string representation of the Color4 object
  5701. */
  5702. toString(): string;
  5703. /**
  5704. * Returns the string "Color4"
  5705. * @returns "Color4"
  5706. */
  5707. getClassName(): string;
  5708. /**
  5709. * Compute the Color4 hash code
  5710. * @returns an unique number that can be used to hash Color4 objects
  5711. */
  5712. getHashCode(): number;
  5713. /**
  5714. * Creates a new Color4 copied from the current one
  5715. * @returns a new Color4 object
  5716. */
  5717. clone(): Color4;
  5718. /**
  5719. * Copies the given Color4 values into the current one
  5720. * @param source defines the source Color4 object
  5721. * @returns the current updated Color4 object
  5722. */
  5723. copyFrom(source: Color4): Color4;
  5724. /**
  5725. * Copies the given float values into the current one
  5726. * @param r defines the red component to read from
  5727. * @param g defines the green component to read from
  5728. * @param b defines the blue component to read from
  5729. * @param a defines the alpha component to read from
  5730. * @returns the current updated Color4 object
  5731. */
  5732. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5733. /**
  5734. * Copies the given float values into the current one
  5735. * @param r defines the red component to read from
  5736. * @param g defines the green component to read from
  5737. * @param b defines the blue component to read from
  5738. * @param a defines the alpha component to read from
  5739. * @returns the current updated Color4 object
  5740. */
  5741. set(r: number, g: number, b: number, a: number): Color4;
  5742. /**
  5743. * Compute the Color4 hexadecimal code as a string
  5744. * @returns a string containing the hexadecimal representation of the Color4 object
  5745. */
  5746. toHexString(): string;
  5747. /**
  5748. * Computes a new Color4 converted from the current one to linear space
  5749. * @returns a new Color4 object
  5750. */
  5751. toLinearSpace(): Color4;
  5752. /**
  5753. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5754. * @param convertedColor defines the Color4 object where to store the linear space version
  5755. * @returns the unmodified Color4
  5756. */
  5757. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5758. /**
  5759. * Computes a new Color4 converted from the current one to gamma space
  5760. * @returns a new Color4 object
  5761. */
  5762. toGammaSpace(): Color4;
  5763. /**
  5764. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5765. * @param convertedColor defines the Color4 object where to store the gamma space version
  5766. * @returns the unmodified Color4
  5767. */
  5768. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5769. /**
  5770. * Creates a new Color4 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color4 object
  5773. */
  5774. static FromHexString(hex: string): Color4;
  5775. /**
  5776. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @returns a new Color4 object
  5781. */
  5782. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5783. /**
  5784. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5785. * @param left defines the start value
  5786. * @param right defines the end value
  5787. * @param amount defines the gradient factor
  5788. * @param result defines the Color4 object where to store data
  5789. */
  5790. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5791. /**
  5792. * Creates a new Color4 from a Color3 and an alpha value
  5793. * @param color3 defines the source Color3 to read from
  5794. * @param alpha defines the alpha component (1.0 by default)
  5795. * @returns a new Color4 object
  5796. */
  5797. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5798. /**
  5799. * Creates a new Color4 from the starting index element of the given array
  5800. * @param array defines the source array to read from
  5801. * @param offset defines the offset in the source array
  5802. * @returns a new Color4 object
  5803. */
  5804. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5805. /**
  5806. * Creates a new Color3 from integer values (< 256)
  5807. * @param r defines the red component to read from (value between 0 and 255)
  5808. * @param g defines the green component to read from (value between 0 and 255)
  5809. * @param b defines the blue component to read from (value between 0 and 255)
  5810. * @param a defines the alpha component to read from (value between 0 and 255)
  5811. * @returns a new Color3 object
  5812. */
  5813. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5814. /**
  5815. * Check the content of a given array and convert it to an array containing RGBA data
  5816. * If the original array was already containing count * 4 values then it is returned directly
  5817. * @param colors defines the array to check
  5818. * @param count defines the number of RGBA data to expect
  5819. * @returns an array containing count * 4 values (RGBA)
  5820. */
  5821. static CheckColors4(colors: number[], count: number): number[];
  5822. }
  5823. /**
  5824. * @hidden
  5825. */
  5826. export class TmpColors {
  5827. static Color3: Color3[];
  5828. static Color4: Color4[];
  5829. }
  5830. }
  5831. declare module "babylonjs/Animations/animationKey" {
  5832. /**
  5833. * Defines an interface which represents an animation key frame
  5834. */
  5835. export interface IAnimationKey {
  5836. /**
  5837. * Frame of the key frame
  5838. */
  5839. frame: number;
  5840. /**
  5841. * Value at the specifies key frame
  5842. */
  5843. value: any;
  5844. /**
  5845. * The input tangent for the cubic hermite spline
  5846. */
  5847. inTangent?: any;
  5848. /**
  5849. * The output tangent for the cubic hermite spline
  5850. */
  5851. outTangent?: any;
  5852. /**
  5853. * The animation interpolation type
  5854. */
  5855. interpolation?: AnimationKeyInterpolation;
  5856. }
  5857. /**
  5858. * Enum for the animation key frame interpolation type
  5859. */
  5860. export enum AnimationKeyInterpolation {
  5861. /**
  5862. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5863. */
  5864. STEP = 1
  5865. }
  5866. }
  5867. declare module "babylonjs/Animations/animationRange" {
  5868. /**
  5869. * Represents the range of an animation
  5870. */
  5871. export class AnimationRange {
  5872. /**The name of the animation range**/
  5873. name: string;
  5874. /**The starting frame of the animation */
  5875. from: number;
  5876. /**The ending frame of the animation*/
  5877. to: number;
  5878. /**
  5879. * Initializes the range of an animation
  5880. * @param name The name of the animation range
  5881. * @param from The starting frame of the animation
  5882. * @param to The ending frame of the animation
  5883. */
  5884. constructor(
  5885. /**The name of the animation range**/
  5886. name: string,
  5887. /**The starting frame of the animation */
  5888. from: number,
  5889. /**The ending frame of the animation*/
  5890. to: number);
  5891. /**
  5892. * Makes a copy of the animation range
  5893. * @returns A copy of the animation range
  5894. */
  5895. clone(): AnimationRange;
  5896. }
  5897. }
  5898. declare module "babylonjs/Animations/animationEvent" {
  5899. /**
  5900. * Composed of a frame, and an action function
  5901. */
  5902. export class AnimationEvent {
  5903. /** The frame for which the event is triggered **/
  5904. frame: number;
  5905. /** The event to perform when triggered **/
  5906. action: (currentFrame: number) => void;
  5907. /** Specifies if the event should be triggered only once**/
  5908. onlyOnce?: boolean | undefined;
  5909. /**
  5910. * Specifies if the animation event is done
  5911. */
  5912. isDone: boolean;
  5913. /**
  5914. * Initializes the animation event
  5915. * @param frame The frame for which the event is triggered
  5916. * @param action The event to perform when triggered
  5917. * @param onlyOnce Specifies if the event should be triggered only once
  5918. */
  5919. constructor(
  5920. /** The frame for which the event is triggered **/
  5921. frame: number,
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void,
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined);
  5926. /** @hidden */
  5927. _clone(): AnimationEvent;
  5928. }
  5929. }
  5930. declare module "babylonjs/Behaviors/behavior" {
  5931. import { Nullable } from "babylonjs/types";
  5932. /**
  5933. * Interface used to define a behavior
  5934. */
  5935. export interface Behavior<T> {
  5936. /** gets or sets behavior's name */
  5937. name: string;
  5938. /**
  5939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5940. */
  5941. init(): void;
  5942. /**
  5943. * Called when the behavior is attached to a target
  5944. * @param target defines the target where the behavior is attached to
  5945. */
  5946. attach(target: T): void;
  5947. /**
  5948. * Called when the behavior is detached from its target
  5949. */
  5950. detach(): void;
  5951. }
  5952. /**
  5953. * Interface implemented by classes supporting behaviors
  5954. */
  5955. export interface IBehaviorAware<T> {
  5956. /**
  5957. * Attach a behavior
  5958. * @param behavior defines the behavior to attach
  5959. * @returns the current host
  5960. */
  5961. addBehavior(behavior: Behavior<T>): T;
  5962. /**
  5963. * Remove a behavior from the current object
  5964. * @param behavior defines the behavior to detach
  5965. * @returns the current host
  5966. */
  5967. removeBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Gets a behavior using its name to search
  5970. * @param name defines the name to search
  5971. * @returns the behavior or null if not found
  5972. */
  5973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5974. }
  5975. }
  5976. declare module "babylonjs/Misc/smartArray" {
  5977. /**
  5978. * Defines an array and its length.
  5979. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5980. */
  5981. export interface ISmartArrayLike<T> {
  5982. /**
  5983. * The data of the array.
  5984. */
  5985. data: Array<T>;
  5986. /**
  5987. * The active length of the array.
  5988. */
  5989. length: number;
  5990. }
  5991. /**
  5992. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5993. */
  5994. export class SmartArray<T> implements ISmartArrayLike<T> {
  5995. /**
  5996. * The full set of data from the array.
  5997. */
  5998. data: Array<T>;
  5999. /**
  6000. * The active length of the array.
  6001. */
  6002. length: number;
  6003. protected _id: number;
  6004. /**
  6005. * Instantiates a Smart Array.
  6006. * @param capacity defines the default capacity of the array.
  6007. */
  6008. constructor(capacity: number);
  6009. /**
  6010. * Pushes a value at the end of the active data.
  6011. * @param value defines the object to push in the array.
  6012. */
  6013. push(value: T): void;
  6014. /**
  6015. * Iterates over the active data and apply the lambda to them.
  6016. * @param func defines the action to apply on each value.
  6017. */
  6018. forEach(func: (content: T) => void): void;
  6019. /**
  6020. * Sorts the full sets of data.
  6021. * @param compareFn defines the comparison function to apply.
  6022. */
  6023. sort(compareFn: (a: T, b: T) => number): void;
  6024. /**
  6025. * Resets the active data to an empty array.
  6026. */
  6027. reset(): void;
  6028. /**
  6029. * Releases all the data from the array as well as the array.
  6030. */
  6031. dispose(): void;
  6032. /**
  6033. * Concats the active data with a given array.
  6034. * @param array defines the data to concatenate with.
  6035. */
  6036. concat(array: any): void;
  6037. /**
  6038. * Returns the position of a value in the active data.
  6039. * @param value defines the value to find the index for
  6040. * @returns the index if found in the active data otherwise -1
  6041. */
  6042. indexOf(value: T): number;
  6043. /**
  6044. * Returns whether an element is part of the active data.
  6045. * @param value defines the value to look for
  6046. * @returns true if found in the active data otherwise false
  6047. */
  6048. contains(value: T): boolean;
  6049. private static _GlobalId;
  6050. }
  6051. /**
  6052. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6053. * The data in this array can only be present once
  6054. */
  6055. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6056. private _duplicateId;
  6057. /**
  6058. * Pushes a value at the end of the active data.
  6059. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6060. * @param value defines the object to push in the array.
  6061. */
  6062. push(value: T): void;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * If the data is already present, it won t be added again
  6066. * @param value defines the object to push in the array.
  6067. * @returns true if added false if it was already present
  6068. */
  6069. pushNoDuplicate(value: T): boolean;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Concats the active data with a given array.
  6076. * This ensures no dupplicate will be present in the result.
  6077. * @param array defines the data to concatenate with.
  6078. */
  6079. concatWithNoDuplicate(array: any): void;
  6080. }
  6081. }
  6082. declare module "babylonjs/Cameras/cameraInputsManager" {
  6083. import { Nullable } from "babylonjs/types";
  6084. import { Camera } from "babylonjs/Cameras/camera";
  6085. /**
  6086. * @ignore
  6087. * This is a list of all the different input types that are available in the application.
  6088. * Fo instance: ArcRotateCameraGamepadInput...
  6089. */
  6090. export var CameraInputTypes: {};
  6091. /**
  6092. * This is the contract to implement in order to create a new input class.
  6093. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6094. */
  6095. export interface ICameraInput<TCamera extends Camera> {
  6096. /**
  6097. * Defines the camera the input is attached to.
  6098. */
  6099. camera: Nullable<TCamera>;
  6100. /**
  6101. * Gets the class name of the current intput.
  6102. * @returns the class name
  6103. */
  6104. getClassName(): string;
  6105. /**
  6106. * Get the friendly name associated with the input class.
  6107. * @returns the input friendly name
  6108. */
  6109. getSimpleName(): string;
  6110. /**
  6111. * Attach the input controls to a specific dom element to get the input from.
  6112. * @param element Defines the element the controls should be listened from
  6113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6114. */
  6115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6116. /**
  6117. * Detach the current controls from the specified dom element.
  6118. * @param element Defines the element to stop listening the inputs from
  6119. */
  6120. detachControl(element: Nullable<HTMLElement>): void;
  6121. /**
  6122. * Update the current camera state depending on the inputs that have been used this frame.
  6123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6124. */
  6125. checkInputs?: () => void;
  6126. }
  6127. /**
  6128. * Represents a map of input types to input instance or input index to input instance.
  6129. */
  6130. export interface CameraInputsMap<TCamera extends Camera> {
  6131. /**
  6132. * Accessor to the input by input type.
  6133. */
  6134. [name: string]: ICameraInput<TCamera>;
  6135. /**
  6136. * Accessor to the input by input index.
  6137. */
  6138. [idx: number]: ICameraInput<TCamera>;
  6139. }
  6140. /**
  6141. * This represents the input manager used within a camera.
  6142. * It helps dealing with all the different kind of input attached to a camera.
  6143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6144. */
  6145. export class CameraInputsManager<TCamera extends Camera> {
  6146. /**
  6147. * Defines the list of inputs attahed to the camera.
  6148. */
  6149. attached: CameraInputsMap<TCamera>;
  6150. /**
  6151. * Defines the dom element the camera is collecting inputs from.
  6152. * This is null if the controls have not been attached.
  6153. */
  6154. attachedElement: Nullable<HTMLElement>;
  6155. /**
  6156. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. noPreventDefault: boolean;
  6159. /**
  6160. * Defined the camera the input manager belongs to.
  6161. */
  6162. camera: TCamera;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs: () => void;
  6168. /**
  6169. * Instantiate a new Camera Input Manager.
  6170. * @param camera Defines the camera the input manager blongs to
  6171. */
  6172. constructor(camera: TCamera);
  6173. /**
  6174. * Add an input method to a camera
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. * @param input camera input method
  6177. */
  6178. add(input: ICameraInput<TCamera>): void;
  6179. /**
  6180. * Remove a specific input method from a camera
  6181. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6182. * @param inputToRemove camera input method
  6183. */
  6184. remove(inputToRemove: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input type from a camera
  6187. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6188. * @param inputType the type of the input to remove
  6189. */
  6190. removeByType(inputType: string): void;
  6191. private _addCheckInputs;
  6192. /**
  6193. * Attach the input controls to the currently attached dom element to listen the events from.
  6194. * @param input Defines the input to attach
  6195. */
  6196. attachInput(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6199. * @param element Defines the dom element to collect the events from
  6200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6203. /**
  6204. * Detach the current manager inputs controls from a specific dom element.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6207. */
  6208. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6209. /**
  6210. * Rebuild the dynamic inputCheck function from the current list of
  6211. * defined inputs in the manager.
  6212. */
  6213. rebuildInputCheck(): void;
  6214. /**
  6215. * Remove all attached input methods from a camera
  6216. */
  6217. clear(): void;
  6218. /**
  6219. * Serialize the current input manager attached to a camera.
  6220. * This ensures than once parsed,
  6221. * the input associated to the camera will be identical to the current ones
  6222. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6223. */
  6224. serialize(serializedCamera: any): void;
  6225. /**
  6226. * Parses an input manager serialized JSON to restore the previous list of inputs
  6227. * and states associated to a camera.
  6228. * @param parsedCamera Defines the JSON to parse
  6229. */
  6230. parse(parsedCamera: any): void;
  6231. }
  6232. }
  6233. declare module "babylonjs/Meshes/buffer" {
  6234. import { Nullable, DataArray } from "babylonjs/types";
  6235. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6236. /**
  6237. * Class used to store data that will be store in GPU memory
  6238. */
  6239. export class Buffer {
  6240. private _engine;
  6241. private _buffer;
  6242. /** @hidden */
  6243. _data: Nullable<DataArray>;
  6244. private _updatable;
  6245. private _instanced;
  6246. private _divisor;
  6247. /**
  6248. * Gets the byte stride.
  6249. */
  6250. readonly byteStride: number;
  6251. /**
  6252. * Constructor
  6253. * @param engine the engine
  6254. * @param data the data to use for this buffer
  6255. * @param updatable whether the data is updatable
  6256. * @param stride the stride (optional)
  6257. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6258. * @param instanced whether the buffer is instanced (optional)
  6259. * @param useBytes set to true if the stride in in bytes (optional)
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. */
  6262. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6263. /**
  6264. * Create a new VertexBuffer based on the current buffer
  6265. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6266. * @param offset defines offset in the buffer (0 by default)
  6267. * @param size defines the size in floats of attributes (position is 3 for instance)
  6268. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6269. * @param instanced defines if the vertex buffer contains indexed data
  6270. * @param useBytes defines if the offset and stride are in bytes *
  6271. * @param divisor sets an optional divisor for instances (1 by default)
  6272. * @returns the new vertex buffer
  6273. */
  6274. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6275. /**
  6276. * Gets a boolean indicating if the Buffer is updatable?
  6277. * @returns true if the buffer is updatable
  6278. */
  6279. isUpdatable(): boolean;
  6280. /**
  6281. * Gets current buffer's data
  6282. * @returns a DataArray or null
  6283. */
  6284. getData(): Nullable<DataArray>;
  6285. /**
  6286. * Gets underlying native buffer
  6287. * @returns underlying native buffer
  6288. */
  6289. getBuffer(): Nullable<DataBuffer>;
  6290. /**
  6291. * Gets the stride in float32 units (i.e. byte stride / 4).
  6292. * May not be an integer if the byte stride is not divisible by 4.
  6293. * DEPRECATED. Use byteStride instead.
  6294. * @returns the stride in float32 units
  6295. */
  6296. getStrideSize(): number;
  6297. /**
  6298. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6299. * @param data defines the data to store
  6300. */
  6301. create(data?: Nullable<DataArray>): void;
  6302. /** @hidden */
  6303. _rebuild(): void;
  6304. /**
  6305. * Update current buffer data
  6306. * @param data defines the data to store
  6307. */
  6308. update(data: DataArray): void;
  6309. /**
  6310. * Updates the data directly.
  6311. * @param data the new data
  6312. * @param offset the new offset
  6313. * @param vertexCount the vertex count (optional)
  6314. * @param useBytes set to true if the offset is in bytes
  6315. */
  6316. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6317. /**
  6318. * Release all resources
  6319. */
  6320. dispose(): void;
  6321. }
  6322. /**
  6323. * Specialized buffer used to store vertex data
  6324. */
  6325. export class VertexBuffer {
  6326. /** @hidden */
  6327. _buffer: Buffer;
  6328. private _kind;
  6329. private _size;
  6330. private _ownsBuffer;
  6331. private _instanced;
  6332. private _instanceDivisor;
  6333. /**
  6334. * The byte type.
  6335. */
  6336. static readonly BYTE: number;
  6337. /**
  6338. * The unsigned byte type.
  6339. */
  6340. static readonly UNSIGNED_BYTE: number;
  6341. /**
  6342. * The short type.
  6343. */
  6344. static readonly SHORT: number;
  6345. /**
  6346. * The unsigned short type.
  6347. */
  6348. static readonly UNSIGNED_SHORT: number;
  6349. /**
  6350. * The integer type.
  6351. */
  6352. static readonly INT: number;
  6353. /**
  6354. * The unsigned integer type.
  6355. */
  6356. static readonly UNSIGNED_INT: number;
  6357. /**
  6358. * The float type.
  6359. */
  6360. static readonly FLOAT: number;
  6361. /**
  6362. * Gets or sets the instance divisor when in instanced mode
  6363. */
  6364. instanceDivisor: number;
  6365. /**
  6366. * Gets the byte stride.
  6367. */
  6368. readonly byteStride: number;
  6369. /**
  6370. * Gets the byte offset.
  6371. */
  6372. readonly byteOffset: number;
  6373. /**
  6374. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6375. */
  6376. readonly normalized: boolean;
  6377. /**
  6378. * Gets the data type of each component in the array.
  6379. */
  6380. readonly type: number;
  6381. /**
  6382. * Constructor
  6383. * @param engine the engine
  6384. * @param data the data to use for this vertex buffer
  6385. * @param kind the vertex buffer kind
  6386. * @param updatable whether the data is updatable
  6387. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6388. * @param stride the stride (optional)
  6389. * @param instanced whether the buffer is instanced (optional)
  6390. * @param offset the offset of the data (optional)
  6391. * @param size the number of components (optional)
  6392. * @param type the type of the component (optional)
  6393. * @param normalized whether the data contains normalized data (optional)
  6394. * @param useBytes set to true if stride and offset are in bytes (optional)
  6395. * @param divisor defines the instance divisor to use (1 by default)
  6396. */
  6397. 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);
  6398. /** @hidden */
  6399. _rebuild(): void;
  6400. /**
  6401. * Returns the kind of the VertexBuffer (string)
  6402. * @returns a string
  6403. */
  6404. getKind(): string;
  6405. /**
  6406. * Gets a boolean indicating if the VertexBuffer is updatable?
  6407. * @returns true if the buffer is updatable
  6408. */
  6409. isUpdatable(): boolean;
  6410. /**
  6411. * Gets current buffer's data
  6412. * @returns a DataArray or null
  6413. */
  6414. getData(): Nullable<DataArray>;
  6415. /**
  6416. * Gets underlying native buffer
  6417. * @returns underlying native buffer
  6418. */
  6419. getBuffer(): Nullable<DataBuffer>;
  6420. /**
  6421. * Gets the stride in float32 units (i.e. byte stride / 4).
  6422. * May not be an integer if the byte stride is not divisible by 4.
  6423. * DEPRECATED. Use byteStride instead.
  6424. * @returns the stride in float32 units
  6425. */
  6426. getStrideSize(): number;
  6427. /**
  6428. * Returns the offset as a multiple of the type byte length.
  6429. * DEPRECATED. Use byteOffset instead.
  6430. * @returns the offset in bytes
  6431. */
  6432. getOffset(): number;
  6433. /**
  6434. * Returns the number of components per vertex attribute (integer)
  6435. * @returns the size in float
  6436. */
  6437. getSize(): number;
  6438. /**
  6439. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6440. * @returns true if this buffer is instanced
  6441. */
  6442. getIsInstanced(): boolean;
  6443. /**
  6444. * Returns the instancing divisor, zero for non-instanced (integer).
  6445. * @returns a number
  6446. */
  6447. getInstanceDivisor(): number;
  6448. /**
  6449. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6450. * @param data defines the data to store
  6451. */
  6452. create(data?: DataArray): void;
  6453. /**
  6454. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6455. * This function will create a new buffer if the current one is not updatable
  6456. * @param data defines the data to store
  6457. */
  6458. update(data: DataArray): void;
  6459. /**
  6460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6461. * Returns the directly updated WebGLBuffer.
  6462. * @param data the new data
  6463. * @param offset the new offset
  6464. * @param useBytes set to true if the offset is in bytes
  6465. */
  6466. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6467. /**
  6468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6469. */
  6470. dispose(): void;
  6471. /**
  6472. * Enumerates each value of this vertex buffer as numbers.
  6473. * @param count the number of values to enumerate
  6474. * @param callback the callback function called for each value
  6475. */
  6476. forEach(count: number, callback: (value: number, index: number) => void): void;
  6477. /**
  6478. * Positions
  6479. */
  6480. static readonly PositionKind: string;
  6481. /**
  6482. * Normals
  6483. */
  6484. static readonly NormalKind: string;
  6485. /**
  6486. * Tangents
  6487. */
  6488. static readonly TangentKind: string;
  6489. /**
  6490. * Texture coordinates
  6491. */
  6492. static readonly UVKind: string;
  6493. /**
  6494. * Texture coordinates 2
  6495. */
  6496. static readonly UV2Kind: string;
  6497. /**
  6498. * Texture coordinates 3
  6499. */
  6500. static readonly UV3Kind: string;
  6501. /**
  6502. * Texture coordinates 4
  6503. */
  6504. static readonly UV4Kind: string;
  6505. /**
  6506. * Texture coordinates 5
  6507. */
  6508. static readonly UV5Kind: string;
  6509. /**
  6510. * Texture coordinates 6
  6511. */
  6512. static readonly UV6Kind: string;
  6513. /**
  6514. * Colors
  6515. */
  6516. static readonly ColorKind: string;
  6517. /**
  6518. * Matrix indices (for bones)
  6519. */
  6520. static readonly MatricesIndicesKind: string;
  6521. /**
  6522. * Matrix weights (for bones)
  6523. */
  6524. static readonly MatricesWeightsKind: string;
  6525. /**
  6526. * Additional matrix indices (for bones)
  6527. */
  6528. static readonly MatricesIndicesExtraKind: string;
  6529. /**
  6530. * Additional matrix weights (for bones)
  6531. */
  6532. static readonly MatricesWeightsExtraKind: string;
  6533. /**
  6534. * Deduces the stride given a kind.
  6535. * @param kind The kind string to deduce
  6536. * @returns The deduced stride
  6537. */
  6538. static DeduceStride(kind: string): number;
  6539. /**
  6540. * Gets the byte length of the given type.
  6541. * @param type the type
  6542. * @returns the number of bytes
  6543. */
  6544. static GetTypeByteLength(type: number): number;
  6545. /**
  6546. * Enumerates each value of the given parameters as numbers.
  6547. * @param data the data to enumerate
  6548. * @param byteOffset the byte offset of the data
  6549. * @param byteStride the byte stride of the data
  6550. * @param componentCount the number of components per element
  6551. * @param componentType the type of the component
  6552. * @param count the number of values to enumerate
  6553. * @param normalized whether the data is normalized
  6554. * @param callback the callback function called for each value
  6555. */
  6556. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6557. private static _GetFloatValue;
  6558. }
  6559. }
  6560. declare module "babylonjs/Collisions/intersectionInfo" {
  6561. import { Nullable } from "babylonjs/types";
  6562. /**
  6563. * @hidden
  6564. */
  6565. export class IntersectionInfo {
  6566. bu: Nullable<number>;
  6567. bv: Nullable<number>;
  6568. distance: number;
  6569. faceId: number;
  6570. subMeshId: number;
  6571. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6572. }
  6573. }
  6574. declare module "babylonjs/Maths/math.plane" {
  6575. import { DeepImmutable } from "babylonjs/types";
  6576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6577. /**
  6578. * Represens a plane by the equation ax + by + cz + d = 0
  6579. */
  6580. export class Plane {
  6581. private static _TmpMatrix;
  6582. /**
  6583. * Normal of the plane (a,b,c)
  6584. */
  6585. normal: Vector3;
  6586. /**
  6587. * d component of the plane
  6588. */
  6589. d: number;
  6590. /**
  6591. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6592. * @param a a component of the plane
  6593. * @param b b component of the plane
  6594. * @param c c component of the plane
  6595. * @param d d component of the plane
  6596. */
  6597. constructor(a: number, b: number, c: number, d: number);
  6598. /**
  6599. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6600. */
  6601. asArray(): number[];
  6602. /**
  6603. * @returns a new plane copied from the current Plane.
  6604. */
  6605. clone(): Plane;
  6606. /**
  6607. * @returns the string "Plane".
  6608. */
  6609. getClassName(): string;
  6610. /**
  6611. * @returns the Plane hash code.
  6612. */
  6613. getHashCode(): number;
  6614. /**
  6615. * Normalize the current Plane in place.
  6616. * @returns the updated Plane.
  6617. */
  6618. normalize(): Plane;
  6619. /**
  6620. * Applies a transformation the plane and returns the result
  6621. * @param transformation the transformation matrix to be applied to the plane
  6622. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6623. */
  6624. transform(transformation: DeepImmutable<Matrix>): Plane;
  6625. /**
  6626. * Calcualtte the dot product between the point and the plane normal
  6627. * @param point point to calculate the dot product with
  6628. * @returns the dot product (float) of the point coordinates and the plane normal.
  6629. */
  6630. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Updates the current Plane from the plane defined by the three given points.
  6633. * @param point1 one of the points used to contruct the plane
  6634. * @param point2 one of the points used to contruct the plane
  6635. * @param point3 one of the points used to contruct the plane
  6636. * @returns the updated Plane.
  6637. */
  6638. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6639. /**
  6640. * Checks if the plane is facing a given direction
  6641. * @param direction the direction to check if the plane is facing
  6642. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6643. * @returns True is the vector "direction" is the same side than the plane normal.
  6644. */
  6645. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6646. /**
  6647. * Calculates the distance to a point
  6648. * @param point point to calculate distance to
  6649. * @returns the signed distance (float) from the given point to the Plane.
  6650. */
  6651. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6652. /**
  6653. * Creates a plane from an array
  6654. * @param array the array to create a plane from
  6655. * @returns a new Plane from the given array.
  6656. */
  6657. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6658. /**
  6659. * Creates a plane from three points
  6660. * @param point1 point used to create the plane
  6661. * @param point2 point used to create the plane
  6662. * @param point3 point used to create the plane
  6663. * @returns a new Plane defined by the three given points.
  6664. */
  6665. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6666. /**
  6667. * Creates a plane from an origin point and a normal
  6668. * @param origin origin of the plane to be constructed
  6669. * @param normal normal of the plane to be constructed
  6670. * @returns a new Plane the normal vector to this plane at the given origin point.
  6671. * Note : the vector "normal" is updated because normalized.
  6672. */
  6673. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6674. /**
  6675. * Calculates the distance from a plane and a point
  6676. * @param origin origin of the plane to be constructed
  6677. * @param normal normal of the plane to be constructed
  6678. * @param point point to calculate distance to
  6679. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6680. */
  6681. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingSphere" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { Plane } from "babylonjs/Maths/math.plane";
  6688. /**
  6689. * Class used to store bounding sphere information
  6690. */
  6691. export class BoundingSphere {
  6692. /**
  6693. * Gets the center of the bounding sphere in local space
  6694. */
  6695. readonly center: Vector3;
  6696. /**
  6697. * Radius of the bounding sphere in local space
  6698. */
  6699. radius: number;
  6700. /**
  6701. * Gets the center of the bounding sphere in world space
  6702. */
  6703. readonly centerWorld: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in world space
  6706. */
  6707. radiusWorld: number;
  6708. /**
  6709. * Gets the minimum vector in local space
  6710. */
  6711. readonly minimum: Vector3;
  6712. /**
  6713. * Gets the maximum vector in local space
  6714. */
  6715. readonly maximum: Vector3;
  6716. private _worldMatrix;
  6717. private static readonly TmpVector3;
  6718. /**
  6719. * Creates a new bounding sphere
  6720. * @param min defines the minimum vector (in local space)
  6721. * @param max defines the maximum vector (in local space)
  6722. * @param worldMatrix defines the new world matrix
  6723. */
  6724. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6725. /**
  6726. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6727. * @param min defines the new minimum vector (in local space)
  6728. * @param max defines the new maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6732. /**
  6733. * Scale the current bounding sphere by applying a scale factor
  6734. * @param factor defines the scale factor to apply
  6735. * @returns the current bounding box
  6736. */
  6737. scale(factor: number): BoundingSphere;
  6738. /**
  6739. * Gets the world matrix of the bounding box
  6740. * @returns a matrix
  6741. */
  6742. getWorldMatrix(): DeepImmutable<Matrix>;
  6743. /** @hidden */
  6744. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6745. /**
  6746. * Tests if the bounding sphere is intersecting the frustum planes
  6747. * @param frustumPlanes defines the frustum planes to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6751. /**
  6752. * Tests if the bounding sphere center is in between the frustum planes.
  6753. * Used for optimistic fast inclusion.
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if the sphere center is in between the frustum planes
  6756. */
  6757. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a point is inside the bounding sphere
  6760. * @param point defines the point to test
  6761. * @returns true if the point is inside the bounding sphere
  6762. */
  6763. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6764. /**
  6765. * Checks if two sphere intersct
  6766. * @param sphere0 sphere 0
  6767. * @param sphere1 sphere 1
  6768. * @returns true if the speres intersect
  6769. */
  6770. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6771. }
  6772. }
  6773. declare module "babylonjs/Culling/boundingBox" {
  6774. import { DeepImmutable } from "babylonjs/types";
  6775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6776. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6777. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /**
  6780. * Class used to store bounding box information
  6781. */
  6782. export class BoundingBox implements ICullable {
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in local space
  6785. */
  6786. readonly vectors: Vector3[];
  6787. /**
  6788. * Gets the center of the bounding box in local space
  6789. */
  6790. readonly center: Vector3;
  6791. /**
  6792. * Gets the center of the bounding box in world space
  6793. */
  6794. readonly centerWorld: Vector3;
  6795. /**
  6796. * Gets the extend size in local space
  6797. */
  6798. readonly extendSize: Vector3;
  6799. /**
  6800. * Gets the extend size in world space
  6801. */
  6802. readonly extendSizeWorld: Vector3;
  6803. /**
  6804. * Gets the OBB (object bounding box) directions
  6805. */
  6806. readonly directions: Vector3[];
  6807. /**
  6808. * Gets the 8 vectors representing the bounding box in world space
  6809. */
  6810. readonly vectorsWorld: Vector3[];
  6811. /**
  6812. * Gets the minimum vector in world space
  6813. */
  6814. readonly minimumWorld: Vector3;
  6815. /**
  6816. * Gets the maximum vector in world space
  6817. */
  6818. readonly maximumWorld: Vector3;
  6819. /**
  6820. * Gets the minimum vector in local space
  6821. */
  6822. readonly minimum: Vector3;
  6823. /**
  6824. * Gets the maximum vector in local space
  6825. */
  6826. readonly maximum: Vector3;
  6827. private _worldMatrix;
  6828. private static readonly TmpVector3;
  6829. /**
  6830. * @hidden
  6831. */
  6832. _tag: number;
  6833. /**
  6834. * Creates a new bounding box
  6835. * @param min defines the minimum vector (in local space)
  6836. * @param max defines the maximum vector (in local space)
  6837. * @param worldMatrix defines the new world matrix
  6838. */
  6839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6840. /**
  6841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6842. * @param min defines the new minimum vector (in local space)
  6843. * @param max defines the new maximum vector (in local space)
  6844. * @param worldMatrix defines the new world matrix
  6845. */
  6846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6847. /**
  6848. * Scale the current bounding box by applying a scale factor
  6849. * @param factor defines the scale factor to apply
  6850. * @returns the current bounding box
  6851. */
  6852. scale(factor: number): BoundingBox;
  6853. /**
  6854. * Gets the world matrix of the bounding box
  6855. * @returns a matrix
  6856. */
  6857. getWorldMatrix(): DeepImmutable<Matrix>;
  6858. /** @hidden */
  6859. _update(world: DeepImmutable<Matrix>): void;
  6860. /**
  6861. * Tests if the bounding box is intersecting the frustum planes
  6862. * @param frustumPlanes defines the frustum planes to test
  6863. * @returns true if there is an intersection
  6864. */
  6865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6866. /**
  6867. * Tests if the bounding box is entirely inside the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an inclusion
  6870. */
  6871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if a point is inside the bounding box
  6874. * @param point defines the point to test
  6875. * @returns true if the point is inside the bounding box
  6876. */
  6877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6878. /**
  6879. * Tests if the bounding box intersects with a bounding sphere
  6880. * @param sphere defines the sphere to test
  6881. * @returns true if there is an intersection
  6882. */
  6883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6886. * @param min defines the min vector to use
  6887. * @param max defines the max vector to use
  6888. * @returns true if there is an intersection
  6889. */
  6890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6891. /**
  6892. * Tests if two bounding boxes are intersections
  6893. * @param box0 defines the first box to test
  6894. * @param box1 defines the second box to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6898. /**
  6899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6900. * @param minPoint defines the minimum vector of the bounding box
  6901. * @param maxPoint defines the maximum vector of the bounding box
  6902. * @param sphereCenter defines the sphere center
  6903. * @param sphereRadius defines the sphere radius
  6904. * @returns true if there is an intersection
  6905. */
  6906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6907. /**
  6908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6910. * @param frustumPlanes defines the frustum planes to test
  6911. * @return true if there is an inclusion
  6912. */
  6913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6914. /**
  6915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6917. * @param frustumPlanes defines the frustum planes to test
  6918. * @return true if there is an intersection
  6919. */
  6920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6921. }
  6922. }
  6923. declare module "babylonjs/Collisions/collider" {
  6924. import { Nullable, IndicesArray } from "babylonjs/types";
  6925. import { Vector3 } from "babylonjs/Maths/math.vector";
  6926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6927. import { Plane } from "babylonjs/Maths/math.plane";
  6928. /** @hidden */
  6929. export class Collider {
  6930. /** Define if a collision was found */
  6931. collisionFound: boolean;
  6932. /**
  6933. * Define last intersection point in local space
  6934. */
  6935. intersectionPoint: Vector3;
  6936. /**
  6937. * Define last collided mesh
  6938. */
  6939. collidedMesh: Nullable<AbstractMesh>;
  6940. private _collisionPoint;
  6941. private _planeIntersectionPoint;
  6942. private _tempVector;
  6943. private _tempVector2;
  6944. private _tempVector3;
  6945. private _tempVector4;
  6946. private _edge;
  6947. private _baseToVertex;
  6948. private _destinationPoint;
  6949. private _slidePlaneNormal;
  6950. private _displacementVector;
  6951. /** @hidden */
  6952. _radius: Vector3;
  6953. /** @hidden */
  6954. _retry: number;
  6955. private _velocity;
  6956. private _basePoint;
  6957. private _epsilon;
  6958. /** @hidden */
  6959. _velocityWorldLength: number;
  6960. /** @hidden */
  6961. _basePointWorld: Vector3;
  6962. private _velocityWorld;
  6963. private _normalizedVelocity;
  6964. /** @hidden */
  6965. _initialVelocity: Vector3;
  6966. /** @hidden */
  6967. _initialPosition: Vector3;
  6968. private _nearestDistance;
  6969. private _collisionMask;
  6970. collisionMask: number;
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. readonly slidePlaneNormal: Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module "babylonjs/Culling/boundingInfo" {
  6990. import { DeepImmutable } from "babylonjs/types";
  6991. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6992. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6993. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6994. import { Plane } from "babylonjs/Maths/math.plane";
  6995. import { Collider } from "babylonjs/Collisions/collider";
  6996. /**
  6997. * Interface for cullable objects
  6998. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6999. */
  7000. export interface ICullable {
  7001. /**
  7002. * Checks if the object or part of the object is in the frustum
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isInFrustum(frustumPlanes: Plane[]): boolean;
  7007. /**
  7008. * Checks if a cullable object (mesh...) is in the camera frustum
  7009. * Unlike isInFrustum this cheks the full bounding box
  7010. * @param frustumPlanes Camera near/planes
  7011. * @returns true if the object is in frustum otherwise false
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7014. }
  7015. /**
  7016. * Info for a bounding data of a mesh
  7017. */
  7018. export class BoundingInfo implements ICullable {
  7019. /**
  7020. * Bounding box for the mesh
  7021. */
  7022. readonly boundingBox: BoundingBox;
  7023. /**
  7024. * Bounding sphere for the mesh
  7025. */
  7026. readonly boundingSphere: BoundingSphere;
  7027. private _isLocked;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * Constructs bounding info
  7031. * @param minimum min vector of the bounding box/sphere
  7032. * @param maximum max vector of the bounding box/sphere
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * min vector of the bounding box/sphere
  7045. */
  7046. readonly minimum: Vector3;
  7047. /**
  7048. * max vector of the bounding box/sphere
  7049. */
  7050. readonly maximum: Vector3;
  7051. /**
  7052. * If the info is locked and won't be updated to avoid perf overhead
  7053. */
  7054. isLocked: boolean;
  7055. /**
  7056. * Updates the bounding sphere and box
  7057. * @param world world matrix to be used to update
  7058. */
  7059. update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7062. * @param center New center of the bounding info
  7063. * @param extend New extend of the bounding info
  7064. * @returns the current bounding info
  7065. */
  7066. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7067. /**
  7068. * Scale the current bounding info by applying a scale factor
  7069. * @param factor defines the scale factor to apply
  7070. * @returns the current bounding info
  7071. */
  7072. scale(factor: number): BoundingInfo;
  7073. /**
  7074. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7075. * @param frustumPlanes defines the frustum to test
  7076. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7077. * @returns true if the bounding info is in the frustum planes
  7078. */
  7079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7080. /**
  7081. * Gets the world distance between the min and max points of the bounding box
  7082. */
  7083. readonly diagonalLength: number;
  7084. /**
  7085. * Checks if a cullable object (mesh...) is in the camera frustum
  7086. * Unlike isInFrustum this cheks the full bounding box
  7087. * @param frustumPlanes Camera near/planes
  7088. * @returns true if the object is in frustum otherwise false
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /** @hidden */
  7092. _checkCollision(collider: Collider): boolean;
  7093. /**
  7094. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7095. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7096. * @param point the point to check intersection with
  7097. * @returns if the point intersects
  7098. */
  7099. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7100. /**
  7101. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7102. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7103. * @param boundingInfo the bounding info to check intersection with
  7104. * @param precise if the intersection should be done using OBB
  7105. * @returns if the bounding info intersects
  7106. */
  7107. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7108. }
  7109. }
  7110. declare module "babylonjs/Maths/math.functions" {
  7111. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7112. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7113. /**
  7114. * Extracts minimum and maximum values from a list of indexed positions
  7115. * @param positions defines the positions to use
  7116. * @param indices defines the indices to the positions
  7117. * @param indexStart defines the start index
  7118. * @param indexCount defines the end index
  7119. * @param bias defines bias value to add to the result
  7120. * @return minimum and maximum values
  7121. */
  7122. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7123. minimum: Vector3;
  7124. maximum: Vector3;
  7125. };
  7126. /**
  7127. * Extracts minimum and maximum values from a list of positions
  7128. * @param positions defines the positions to use
  7129. * @param start defines the start index in the positions array
  7130. * @param count defines the number of positions to handle
  7131. * @param bias defines bias value to add to the result
  7132. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7133. * @return minimum and maximum values
  7134. */
  7135. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7136. minimum: Vector3;
  7137. maximum: Vector3;
  7138. };
  7139. }
  7140. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7141. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7142. /** @hidden */
  7143. export class WebGLDataBuffer extends DataBuffer {
  7144. private _buffer;
  7145. constructor(resource: WebGLBuffer);
  7146. readonly underlyingResource: any;
  7147. }
  7148. }
  7149. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7150. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7151. import { Nullable } from "babylonjs/types";
  7152. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7153. /** @hidden */
  7154. export class WebGLPipelineContext implements IPipelineContext {
  7155. engine: ThinEngine;
  7156. program: Nullable<WebGLProgram>;
  7157. context?: WebGLRenderingContext;
  7158. vertexShader?: WebGLShader;
  7159. fragmentShader?: WebGLShader;
  7160. isParallelCompiled: boolean;
  7161. onCompiled?: () => void;
  7162. transformFeedback?: WebGLTransformFeedback | null;
  7163. readonly isAsync: boolean;
  7164. readonly isReady: boolean;
  7165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7166. }
  7167. }
  7168. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7169. import { FloatArray, Nullable } from "babylonjs/types";
  7170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7171. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7172. module "babylonjs/Engines/thinEngine" {
  7173. interface ThinEngine {
  7174. /**
  7175. * Create an uniform buffer
  7176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7177. * @param elements defines the content of the uniform buffer
  7178. * @returns the webGL uniform buffer
  7179. */
  7180. createUniformBuffer(elements: FloatArray): DataBuffer;
  7181. /**
  7182. * Create a dynamic uniform buffer
  7183. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7184. * @param elements defines the content of the uniform buffer
  7185. * @returns the webGL uniform buffer
  7186. */
  7187. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7188. /**
  7189. * Update an existing uniform buffer
  7190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7191. * @param uniformBuffer defines the target uniform buffer
  7192. * @param elements defines the content to update
  7193. * @param offset defines the offset in the uniform buffer where update should start
  7194. * @param count defines the size of the data to update
  7195. */
  7196. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7197. /**
  7198. * Bind an uniform buffer to the current webGL context
  7199. * @param buffer defines the buffer to bind
  7200. */
  7201. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7202. /**
  7203. * Bind a buffer to the current webGL context at a given location
  7204. * @param buffer defines the buffer to bind
  7205. * @param location defines the index where to bind the buffer
  7206. */
  7207. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7208. /**
  7209. * Bind a specific block at a given index in a specific shader program
  7210. * @param pipelineContext defines the pipeline context to use
  7211. * @param blockName defines the block name
  7212. * @param index defines the index where to bind the block
  7213. */
  7214. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7215. }
  7216. }
  7217. }
  7218. declare module "babylonjs/Materials/uniformBuffer" {
  7219. import { Nullable, FloatArray } from "babylonjs/types";
  7220. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7221. import { Engine } from "babylonjs/Engines/engine";
  7222. import { Effect } from "babylonjs/Materials/effect";
  7223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7224. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7225. import { Color3 } from "babylonjs/Maths/math.color";
  7226. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /**
  7672. * @hidden
  7673. */
  7674. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7675. }
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7679. import { Nullable } from "babylonjs/types";
  7680. import { Scene } from "babylonjs/scene";
  7681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7683. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7684. /**
  7685. * Class for creating a cube texture
  7686. */
  7687. export class CubeTexture extends BaseTexture {
  7688. private _delayedOnLoad;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. /**
  7707. * Returns the bounding box size
  7708. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7709. */
  7710. boundingBoxSize: Vector3;
  7711. protected _rotationY: number;
  7712. /**
  7713. * Sets texture matrix rotation angle around Y axis in radians.
  7714. */
  7715. /**
  7716. * Gets texture matrix rotation angle around Y axis radians.
  7717. */
  7718. rotationY: number;
  7719. /**
  7720. * Are mip maps generated for this texture or not.
  7721. */
  7722. readonly noMipmap: boolean;
  7723. private _noMipmap;
  7724. private _files;
  7725. protected _forcedExtension: Nullable<string>;
  7726. private _extensions;
  7727. private _textureMatrix;
  7728. private _format;
  7729. private _createPolynomials;
  7730. /** @hidden */
  7731. _prefiltered: boolean;
  7732. /**
  7733. * Creates a cube texture from an array of image urls
  7734. * @param files defines an array of image urls
  7735. * @param scene defines the hosting scene
  7736. * @param noMipmap specifies if mip maps are not used
  7737. * @returns a cube texture
  7738. */
  7739. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7740. /**
  7741. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7742. * @param url defines the url of the prefiltered texture
  7743. * @param scene defines the scene the texture is attached to
  7744. * @param forcedExtension defines the extension of the file if different from the url
  7745. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7746. * @return the prefiltered texture
  7747. */
  7748. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7749. /**
  7750. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7751. * as prefiltered data.
  7752. * @param rootUrl defines the url of the texture or the root name of the six images
  7753. * @param scene defines the scene the texture is attached to
  7754. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7755. * @param noMipmap defines if mipmaps should be created or not
  7756. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7757. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7758. * @param onError defines a callback triggered in case of error during load
  7759. * @param format defines the internal format to use for the texture once loaded
  7760. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7761. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @return the cube texture
  7766. */
  7767. 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);
  7768. /**
  7769. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7770. */
  7771. readonly isPrefiltered: boolean;
  7772. /**
  7773. * Get the current class name of the texture useful for serialization or dynamic coding.
  7774. * @returns "CubeTexture"
  7775. */
  7776. getClassName(): string;
  7777. /**
  7778. * Update the url (and optional buffer) of this texture if url was null during construction.
  7779. * @param url the url of the texture
  7780. * @param forcedExtension defines the extension to use
  7781. * @param onLoad callback called when the texture is loaded (defaults to null)
  7782. */
  7783. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7784. /**
  7785. * Delays loading of the cube texture
  7786. * @param forcedExtension defines the extension to use
  7787. */
  7788. delayLoad(forcedExtension?: string): void;
  7789. /**
  7790. * Returns the reflection texture matrix
  7791. * @returns the reflection texture matrix
  7792. */
  7793. getReflectionTextureMatrix(): Matrix;
  7794. /**
  7795. * Sets the reflection texture matrix
  7796. * @param value Reflection texture matrix
  7797. */
  7798. setReflectionTextureMatrix(value: Matrix): void;
  7799. /**
  7800. * Parses text to create a cube texture
  7801. * @param parsedTexture define the serialized text to read from
  7802. * @param scene defines the hosting scene
  7803. * @param rootUrl defines the root url of the cube texture
  7804. * @returns a cube texture
  7805. */
  7806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7807. /**
  7808. * Makes a clone, or deep copy, of the cube texture
  7809. * @returns a new cube texture
  7810. */
  7811. clone(): CubeTexture;
  7812. }
  7813. }
  7814. declare module "babylonjs/Materials/materialDefines" {
  7815. /**
  7816. * Manages the defines for the Material
  7817. */
  7818. export class MaterialDefines {
  7819. /** @hidden */
  7820. protected _keys: string[];
  7821. private _isDirty;
  7822. /** @hidden */
  7823. _renderId: number;
  7824. /** @hidden */
  7825. _areLightsDirty: boolean;
  7826. /** @hidden */
  7827. _areLightsDisposed: boolean;
  7828. /** @hidden */
  7829. _areAttributesDirty: boolean;
  7830. /** @hidden */
  7831. _areTexturesDirty: boolean;
  7832. /** @hidden */
  7833. _areFresnelDirty: boolean;
  7834. /** @hidden */
  7835. _areMiscDirty: boolean;
  7836. /** @hidden */
  7837. _areImageProcessingDirty: boolean;
  7838. /** @hidden */
  7839. _normals: boolean;
  7840. /** @hidden */
  7841. _uvs: boolean;
  7842. /** @hidden */
  7843. _needNormals: boolean;
  7844. /** @hidden */
  7845. _needUVs: boolean;
  7846. [id: string]: any;
  7847. /**
  7848. * Specifies if the material needs to be re-calculated
  7849. */
  7850. readonly isDirty: boolean;
  7851. /**
  7852. * Marks the material to indicate that it has been re-calculated
  7853. */
  7854. markAsProcessed(): void;
  7855. /**
  7856. * Marks the material to indicate that it needs to be re-calculated
  7857. */
  7858. markAsUnprocessed(): void;
  7859. /**
  7860. * Marks the material to indicate all of its defines need to be re-calculated
  7861. */
  7862. markAllAsDirty(): void;
  7863. /**
  7864. * Marks the material to indicate that image processing needs to be re-calculated
  7865. */
  7866. markAsImageProcessingDirty(): void;
  7867. /**
  7868. * Marks the material to indicate the lights need to be re-calculated
  7869. * @param disposed Defines whether the light is dirty due to dispose or not
  7870. */
  7871. markAsLightDirty(disposed?: boolean): void;
  7872. /**
  7873. * Marks the attribute state as changed
  7874. */
  7875. markAsAttributesDirty(): void;
  7876. /**
  7877. * Marks the texture state as changed
  7878. */
  7879. markAsTexturesDirty(): void;
  7880. /**
  7881. * Marks the fresnel state as changed
  7882. */
  7883. markAsFresnelDirty(): void;
  7884. /**
  7885. * Marks the misc state as changed
  7886. */
  7887. markAsMiscDirty(): void;
  7888. /**
  7889. * Rebuilds the material defines
  7890. */
  7891. rebuild(): void;
  7892. /**
  7893. * Specifies if two material defines are equal
  7894. * @param other - A material define instance to compare to
  7895. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7896. */
  7897. isEqual(other: MaterialDefines): boolean;
  7898. /**
  7899. * Clones this instance's defines to another instance
  7900. * @param other - material defines to clone values to
  7901. */
  7902. cloneTo(other: MaterialDefines): void;
  7903. /**
  7904. * Resets the material define values
  7905. */
  7906. reset(): void;
  7907. /**
  7908. * Converts the material define values to a string
  7909. * @returns - String of material define information
  7910. */
  7911. toString(): string;
  7912. }
  7913. }
  7914. declare module "babylonjs/Materials/colorCurves" {
  7915. import { Effect } from "babylonjs/Materials/effect";
  7916. /**
  7917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7919. * 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;
  7920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7921. */
  7922. export class ColorCurves {
  7923. private _dirty;
  7924. private _tempColor;
  7925. private _globalCurve;
  7926. private _highlightsCurve;
  7927. private _midtonesCurve;
  7928. private _shadowsCurve;
  7929. private _positiveCurve;
  7930. private _negativeCurve;
  7931. private _globalHue;
  7932. private _globalDensity;
  7933. private _globalSaturation;
  7934. private _globalExposure;
  7935. /**
  7936. * Gets the global Hue value.
  7937. * 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).
  7938. */
  7939. /**
  7940. * Sets the global Hue value.
  7941. * 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).
  7942. */
  7943. globalHue: number;
  7944. /**
  7945. * Gets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. /**
  7950. * Sets the global Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. globalDensity: number;
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * 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.
  7958. */
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * 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.
  7962. */
  7963. globalSaturation: number;
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * 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.
  7967. */
  7968. /**
  7969. * Sets the global Exposure value.
  7970. * 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.
  7971. */
  7972. globalExposure: number;
  7973. private _highlightsHue;
  7974. private _highlightsDensity;
  7975. private _highlightsSaturation;
  7976. private _highlightsExposure;
  7977. /**
  7978. * Gets the highlights Hue value.
  7979. * 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).
  7980. */
  7981. /**
  7982. * Sets the highlights Hue value.
  7983. * 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).
  7984. */
  7985. highlightsHue: number;
  7986. /**
  7987. * Gets the highlights Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. /**
  7992. * Sets the highlights Density value.
  7993. * 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.
  7994. * Values less than zero provide a filter of opposite hue.
  7995. */
  7996. highlightsDensity: number;
  7997. /**
  7998. * Gets the highlights Saturation value.
  7999. * 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.
  8000. */
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * 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.
  8004. */
  8005. highlightsSaturation: number;
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. highlightsExposure: number;
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * 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).
  8026. */
  8027. midtonesHue: number;
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. /**
  8034. * Sets the midtones Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. midtonesDensity: number;
  8039. /**
  8040. * Gets the midtones Saturation value.
  8041. * 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.
  8042. */
  8043. /**
  8044. * Sets the midtones Saturation value.
  8045. * 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.
  8046. */
  8047. midtonesSaturation: number;
  8048. /**
  8049. * Gets the midtones Exposure value.
  8050. * 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.
  8051. */
  8052. /**
  8053. * Sets the midtones Exposure value.
  8054. * 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.
  8055. */
  8056. midtonesExposure: number;
  8057. private _shadowsHue;
  8058. private _shadowsDensity;
  8059. private _shadowsSaturation;
  8060. private _shadowsExposure;
  8061. /**
  8062. * Gets the shadows Hue value.
  8063. * 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).
  8064. */
  8065. /**
  8066. * Sets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. shadowsHue: number;
  8070. /**
  8071. * Gets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. /**
  8076. * Sets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. shadowsDensity: number;
  8081. /**
  8082. * Gets the shadows Saturation value.
  8083. * 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.
  8084. */
  8085. /**
  8086. * Sets the shadows Saturation value.
  8087. * 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.
  8088. */
  8089. shadowsSaturation: number;
  8090. /**
  8091. * Gets the shadows Exposure value.
  8092. * 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.
  8093. */
  8094. /**
  8095. * Sets the shadows Exposure value.
  8096. * 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.
  8097. */
  8098. shadowsExposure: number;
  8099. /**
  8100. * Returns the class name
  8101. * @returns The class name
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Binds the color curves to the shader.
  8106. * @param colorCurves The color curve to bind
  8107. * @param effect The effect to bind to
  8108. * @param positiveUniform The positive uniform shader parameter
  8109. * @param neutralUniform The neutral uniform shader parameter
  8110. * @param negativeUniform The negative uniform shader parameter
  8111. */
  8112. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8113. /**
  8114. * Prepare the list of uniforms associated with the ColorCurves effects.
  8115. * @param uniformsList The list of uniforms used in the effect
  8116. */
  8117. static PrepareUniforms(uniformsList: string[]): void;
  8118. /**
  8119. * Returns color grading data based on a hue, density, saturation and exposure value.
  8120. * @param filterHue The hue of the color filter.
  8121. * @param filterDensity The density of the color filter.
  8122. * @param saturation The saturation.
  8123. * @param exposure The exposure.
  8124. * @param result The result data container.
  8125. */
  8126. private getColorGradingDataToRef;
  8127. /**
  8128. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8129. * @param value The input slider value in range [-100,100].
  8130. * @returns Adjusted value.
  8131. */
  8132. private static applyColorGradingSliderNonlinear;
  8133. /**
  8134. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8135. * @param hue The hue (H) input.
  8136. * @param saturation The saturation (S) input.
  8137. * @param brightness The brightness (B) input.
  8138. * @result An RGBA color represented as Vector4.
  8139. */
  8140. private static fromHSBToRef;
  8141. /**
  8142. * Returns a value clamped between min and max
  8143. * @param value The value to clamp
  8144. * @param min The minimum of value
  8145. * @param max The maximum of value
  8146. * @returns The clamped value.
  8147. */
  8148. private static clamp;
  8149. /**
  8150. * Clones the current color curve instance.
  8151. * @return The cloned curves
  8152. */
  8153. clone(): ColorCurves;
  8154. /**
  8155. * Serializes the current color curve instance to a json representation.
  8156. * @return a JSON representation
  8157. */
  8158. serialize(): any;
  8159. /**
  8160. * Parses the color curve from a json representation.
  8161. * @param source the JSON source to parse
  8162. * @return The parsed curves
  8163. */
  8164. static Parse(source: any): ColorCurves;
  8165. }
  8166. }
  8167. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8168. import { Observable } from "babylonjs/Misc/observable";
  8169. import { Nullable } from "babylonjs/types";
  8170. import { Color4 } from "babylonjs/Maths/math.color";
  8171. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8172. import { Effect } from "babylonjs/Materials/effect";
  8173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. /**
  8240. * Sets wether the color curves effect is enabled.
  8241. */
  8242. colorCurvesEnabled: boolean;
  8243. private _colorGradingTexture;
  8244. /**
  8245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8246. */
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. colorGradingTexture: Nullable<BaseTexture>;
  8251. private _colorGradingEnabled;
  8252. /**
  8253. * Gets wether the color grading effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color grading effect is enabled.
  8257. */
  8258. colorGradingEnabled: boolean;
  8259. private _colorGradingWithGreenDepth;
  8260. /**
  8261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8262. */
  8263. /**
  8264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. colorGradingWithGreenDepth: boolean;
  8267. private _colorGradingBGR;
  8268. /**
  8269. * Gets wether the color grading texture contains BGR values.
  8270. */
  8271. /**
  8272. * Sets wether the color grading texture contains BGR values.
  8273. */
  8274. colorGradingBGR: boolean;
  8275. /** @hidden */
  8276. _exposure: number;
  8277. /**
  8278. * Gets the Exposure used in the effect.
  8279. */
  8280. /**
  8281. * Sets the Exposure used in the effect.
  8282. */
  8283. exposure: number;
  8284. private _toneMappingEnabled;
  8285. /**
  8286. * Gets wether the tone mapping effect is enabled.
  8287. */
  8288. /**
  8289. * Sets wether the tone mapping effect is enabled.
  8290. */
  8291. toneMappingEnabled: boolean;
  8292. private _toneMappingType;
  8293. /**
  8294. * Gets the type of tone mapping effect.
  8295. */
  8296. /**
  8297. * Sets the type of tone mapping effect used in BabylonJS.
  8298. */
  8299. toneMappingType: number;
  8300. protected _contrast: number;
  8301. /**
  8302. * Gets the contrast used in the effect.
  8303. */
  8304. /**
  8305. * Sets the contrast used in the effect.
  8306. */
  8307. contrast: number;
  8308. /**
  8309. * Vignette stretch size.
  8310. */
  8311. vignetteStretch: number;
  8312. /**
  8313. * Vignette centre X Offset.
  8314. */
  8315. vignetteCentreX: number;
  8316. /**
  8317. * Vignette centre Y Offset.
  8318. */
  8319. vignetteCentreY: number;
  8320. /**
  8321. * Vignette weight or intensity of the vignette effect.
  8322. */
  8323. vignetteWeight: number;
  8324. /**
  8325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8326. * if vignetteEnabled is set to true.
  8327. */
  8328. vignetteColor: Color4;
  8329. /**
  8330. * Camera field of view used by the Vignette effect.
  8331. */
  8332. vignetteCameraFov: number;
  8333. private _vignetteBlendMode;
  8334. /**
  8335. * Gets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. /**
  8338. * Sets the vignette blend mode allowing different kind of effect.
  8339. */
  8340. vignetteBlendMode: number;
  8341. private _vignetteEnabled;
  8342. /**
  8343. * Gets wether the vignette effect is enabled.
  8344. */
  8345. /**
  8346. * Sets wether the vignette effect is enabled.
  8347. */
  8348. vignetteEnabled: boolean;
  8349. private _applyByPostProcess;
  8350. /**
  8351. * Gets wether the image processing is applied through a post process or not.
  8352. */
  8353. /**
  8354. * Sets wether the image processing is applied through a post process or not.
  8355. */
  8356. applyByPostProcess: boolean;
  8357. private _isEnabled;
  8358. /**
  8359. * Gets wether the image processing is enabled or not.
  8360. */
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. isEnabled: boolean;
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_MULTIPLY: number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static readonly VIGNETTEMODE_OPAQUE: number;
  8433. }
  8434. }
  8435. declare module "babylonjs/Shaders/postprocess.vertex" {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8445. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8446. module "babylonjs/Engines/thinEngine" {
  8447. interface ThinEngine {
  8448. /**
  8449. * Creates a new render target texture
  8450. * @param size defines the size of the texture
  8451. * @param options defines the options used to create the texture
  8452. * @returns a new render target texture stored in an InternalTexture
  8453. */
  8454. createRenderTargetTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8458. /**
  8459. * Creates a depth stencil texture.
  8460. * This is only available in WebGL 2 or with the depth texture extension available.
  8461. * @param size The size of face edge in the texture.
  8462. * @param options The options defining the texture.
  8463. * @returns The texture
  8464. */
  8465. createDepthStencilTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. }, options: DepthTextureCreationOptions): InternalTexture;
  8469. /** @hidden */
  8470. _createDepthStencilTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. }, options: DepthTextureCreationOptions): InternalTexture;
  8474. }
  8475. }
  8476. }
  8477. declare module "babylonjs/Maths/math.axis" {
  8478. import { Vector3 } from "babylonjs/Maths/math.vector";
  8479. /** Defines supported spaces */
  8480. export enum Space {
  8481. /** Local (object) space */
  8482. LOCAL = 0,
  8483. /** World space */
  8484. WORLD = 1,
  8485. /** Bone space */
  8486. BONE = 2
  8487. }
  8488. /** Defines the 3 main axes */
  8489. export class Axis {
  8490. /** X axis */
  8491. static X: Vector3;
  8492. /** Y axis */
  8493. static Y: Vector3;
  8494. /** Z axis */
  8495. static Z: Vector3;
  8496. }
  8497. }
  8498. declare module "babylonjs/Cameras/targetCamera" {
  8499. import { Nullable } from "babylonjs/types";
  8500. import { Camera } from "babylonjs/Cameras/camera";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8503. /**
  8504. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8505. * This is the base of the follow, arc rotate cameras and Free camera
  8506. * @see http://doc.babylonjs.com/features/cameras
  8507. */
  8508. export class TargetCamera extends Camera {
  8509. private static _RigCamTransformMatrix;
  8510. private static _TargetTransformMatrix;
  8511. private static _TargetFocalPoint;
  8512. /**
  8513. * Define the current direction the camera is moving to
  8514. */
  8515. cameraDirection: Vector3;
  8516. /**
  8517. * Define the current rotation the camera is rotating to
  8518. */
  8519. cameraRotation: Vector2;
  8520. /**
  8521. * When set, the up vector of the camera will be updated by the rotation of the camera
  8522. */
  8523. updateUpVectorFromRotation: boolean;
  8524. private _tmpQuaternion;
  8525. /**
  8526. * Define the current rotation of the camera
  8527. */
  8528. rotation: Vector3;
  8529. /**
  8530. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8531. */
  8532. rotationQuaternion: Quaternion;
  8533. /**
  8534. * Define the current speed of the camera
  8535. */
  8536. speed: number;
  8537. /**
  8538. * Add constraint to the camera to prevent it to move freely in all directions and
  8539. * around all axis.
  8540. */
  8541. noRotationConstraint: boolean;
  8542. /**
  8543. * Define the current target of the camera as an object or a position.
  8544. */
  8545. lockedTarget: any;
  8546. /** @hidden */
  8547. _currentTarget: Vector3;
  8548. /** @hidden */
  8549. _initialFocalDistance: number;
  8550. /** @hidden */
  8551. _viewMatrix: Matrix;
  8552. /** @hidden */
  8553. _camMatrix: Matrix;
  8554. /** @hidden */
  8555. _cameraTransformMatrix: Matrix;
  8556. /** @hidden */
  8557. _cameraRotationMatrix: Matrix;
  8558. /** @hidden */
  8559. _referencePoint: Vector3;
  8560. /** @hidden */
  8561. _transformedReferencePoint: Vector3;
  8562. protected _globalCurrentTarget: Vector3;
  8563. protected _globalCurrentUpVector: Vector3;
  8564. /** @hidden */
  8565. _reset: () => void;
  8566. private _defaultUp;
  8567. /**
  8568. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8569. * This is the base of the follow, arc rotate cameras and Free camera
  8570. * @see http://doc.babylonjs.com/features/cameras
  8571. * @param name Defines the name of the camera in the scene
  8572. * @param position Defines the start position of the camera in the scene
  8573. * @param scene Defines the scene the camera belongs to
  8574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8575. */
  8576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8577. /**
  8578. * Gets the position in front of the camera at a given distance.
  8579. * @param distance The distance from the camera we want the position to be
  8580. * @returns the position
  8581. */
  8582. getFrontPosition(distance: number): Vector3;
  8583. /** @hidden */
  8584. _getLockedTargetPosition(): Nullable<Vector3>;
  8585. private _storedPosition;
  8586. private _storedRotation;
  8587. private _storedRotationQuaternion;
  8588. /**
  8589. * Store current camera state of the camera (fov, position, rotation, etc..)
  8590. * @returns the camera
  8591. */
  8592. storeState(): Camera;
  8593. /**
  8594. * Restored camera state. You must call storeState() first
  8595. * @returns whether it was successful or not
  8596. * @hidden
  8597. */
  8598. _restoreStateValues(): boolean;
  8599. /** @hidden */
  8600. _initCache(): void;
  8601. /** @hidden */
  8602. _updateCache(ignoreParentClass?: boolean): void;
  8603. /** @hidden */
  8604. _isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */
  8606. _computeLocalCameraSpeed(): number;
  8607. /**
  8608. * Defines the target the camera should look at.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */
  8618. _decideIfNeedsToMove(): boolean;
  8619. /** @hidden */
  8620. _updatePosition(): void;
  8621. /** @hidden */
  8622. _checkInputs(): void;
  8623. protected _updateCameraRotationMatrix(): void;
  8624. /**
  8625. * 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)
  8626. * @returns the current camera
  8627. */
  8628. private _rotateUpVectorWithCameraRotationMatrix;
  8629. private _cachedRotationZ;
  8630. private _cachedQuaternionRotationZ;
  8631. /** @hidden */
  8632. _getViewMatrix(): Matrix;
  8633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8634. /**
  8635. * @hidden
  8636. */
  8637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8638. /**
  8639. * @hidden
  8640. */
  8641. _updateRigCameras(): void;
  8642. private _getRigCamPositionAndTarget;
  8643. /**
  8644. * Gets the current object class name.
  8645. * @return the class name
  8646. */
  8647. getClassName(): string;
  8648. }
  8649. }
  8650. declare module "babylonjs/Events/keyboardEvents" {
  8651. /**
  8652. * Gather the list of keyboard event types as constants.
  8653. */
  8654. export class KeyboardEventTypes {
  8655. /**
  8656. * The keydown event is fired when a key becomes active (pressed).
  8657. */
  8658. static readonly KEYDOWN: number;
  8659. /**
  8660. * The keyup event is fired when a key has been released.
  8661. */
  8662. static readonly KEYUP: number;
  8663. }
  8664. /**
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. */
  8667. export class KeyboardInfo {
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number;
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent;
  8676. /**
  8677. * Instantiates a new keyboard info.
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. * @param type Defines the type of event (KeyboardEventTypes)
  8680. * @param event Defines the related dom event
  8681. */
  8682. constructor(
  8683. /**
  8684. * Defines the type of event (KeyboardEventTypes)
  8685. */
  8686. type: number,
  8687. /**
  8688. * Defines the related dom event
  8689. */
  8690. event: KeyboardEvent);
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8695. */
  8696. export class KeyboardInfoPre extends KeyboardInfo {
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number;
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent;
  8705. /**
  8706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8707. */
  8708. skipOnPointerObservable: boolean;
  8709. /**
  8710. * Instantiates a new keyboard pre info.
  8711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8712. * @param type Defines the type of event (KeyboardEventTypes)
  8713. * @param event Defines the related dom event
  8714. */
  8715. constructor(
  8716. /**
  8717. * Defines the type of event (KeyboardEventTypes)
  8718. */
  8719. type: number,
  8720. /**
  8721. * Defines the related dom event
  8722. */
  8723. event: KeyboardEvent);
  8724. }
  8725. }
  8726. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8727. import { Nullable } from "babylonjs/types";
  8728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8730. /**
  8731. * Manage the keyboard inputs to control the movement of a free camera.
  8732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8733. */
  8734. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8735. /**
  8736. * Defines the camera the input is attached to.
  8737. */
  8738. camera: FreeCamera;
  8739. /**
  8740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8741. */
  8742. keysUp: number[];
  8743. /**
  8744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8745. */
  8746. keysDown: number[];
  8747. /**
  8748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8749. */
  8750. keysLeft: number[];
  8751. /**
  8752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8753. */
  8754. keysRight: number[];
  8755. private _keys;
  8756. private _onCanvasBlurObserver;
  8757. private _onKeyboardObserver;
  8758. private _engine;
  8759. private _scene;
  8760. /**
  8761. * Attach the input controls to a specific dom element to get the input from.
  8762. * @param element Defines the element the controls should be listened from
  8763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8764. */
  8765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8766. /**
  8767. * Detach the current controls from the specified dom element.
  8768. * @param element Defines the element to stop listening the inputs from
  8769. */
  8770. detachControl(element: Nullable<HTMLElement>): void;
  8771. /**
  8772. * Update the current camera state depending on the inputs that have been used this frame.
  8773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8774. */
  8775. checkInputs(): void;
  8776. /**
  8777. * Gets the class name of the current intput.
  8778. * @returns the class name
  8779. */
  8780. getClassName(): string;
  8781. /** @hidden */
  8782. _onLostFocus(): void;
  8783. /**
  8784. * Get the friendly name associated with the input class.
  8785. * @returns the input friendly name
  8786. */
  8787. getSimpleName(): string;
  8788. }
  8789. }
  8790. declare module "babylonjs/Lights/shadowLight" {
  8791. import { Camera } from "babylonjs/Cameras/camera";
  8792. import { Scene } from "babylonjs/scene";
  8793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8795. import { Light } from "babylonjs/Lights/light";
  8796. /**
  8797. * Interface describing all the common properties and methods a shadow light needs to implement.
  8798. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8799. * as well as binding the different shadow properties to the effects.
  8800. */
  8801. export interface IShadowLight extends Light {
  8802. /**
  8803. * The light id in the scene (used in scene.findLighById for instance)
  8804. */
  8805. id: string;
  8806. /**
  8807. * The position the shdow will be casted from.
  8808. */
  8809. position: Vector3;
  8810. /**
  8811. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8812. */
  8813. direction: Vector3;
  8814. /**
  8815. * The transformed position. Position of the light in world space taking parenting in account.
  8816. */
  8817. transformedPosition: Vector3;
  8818. /**
  8819. * The transformed direction. Direction of the light in world space taking parenting in account.
  8820. */
  8821. transformedDirection: Vector3;
  8822. /**
  8823. * The friendly name of the light in the scene.
  8824. */
  8825. name: string;
  8826. /**
  8827. * Defines the shadow projection clipping minimum z value.
  8828. */
  8829. shadowMinZ: number;
  8830. /**
  8831. * Defines the shadow projection clipping maximum z value.
  8832. */
  8833. shadowMaxZ: number;
  8834. /**
  8835. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8836. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8837. */
  8838. computeTransformedInformation(): boolean;
  8839. /**
  8840. * Gets the scene the light belongs to.
  8841. * @returns The scene
  8842. */
  8843. getScene(): Scene;
  8844. /**
  8845. * Callback defining a custom Projection Matrix Builder.
  8846. * This can be used to override the default projection matrix computation.
  8847. */
  8848. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. /**
  8858. * Gets the current depth scale used in ESM.
  8859. * @returns The scale
  8860. */
  8861. getDepthScale(): number;
  8862. /**
  8863. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8864. * @returns true if a cube texture needs to be use
  8865. */
  8866. needCube(): boolean;
  8867. /**
  8868. * Detects if the projection matrix requires to be recomputed this frame.
  8869. * @returns true if it requires to be recomputed otherwise, false.
  8870. */
  8871. needProjectionMatrixCompute(): boolean;
  8872. /**
  8873. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8874. */
  8875. forceProjectionMatrixCompute(): void;
  8876. /**
  8877. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8878. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8879. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8880. */
  8881. getShadowDirection(faceIndex?: number): Vector3;
  8882. /**
  8883. * Gets the minZ used for shadow according to both the scene and the light.
  8884. * @param activeCamera The camera we are returning the min for
  8885. * @returns the depth min z
  8886. */
  8887. getDepthMinZ(activeCamera: Camera): number;
  8888. /**
  8889. * Gets the maxZ used for shadow according to both the scene and the light.
  8890. * @param activeCamera The camera we are returning the max for
  8891. * @returns the depth max z
  8892. */
  8893. getDepthMaxZ(activeCamera: Camera): number;
  8894. }
  8895. /**
  8896. * Base implementation IShadowLight
  8897. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8898. */
  8899. export abstract class ShadowLight extends Light implements IShadowLight {
  8900. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8901. protected _position: Vector3;
  8902. protected _setPosition(value: Vector3): void;
  8903. /**
  8904. * Sets the position the shadow will be casted from. Also use as the light position for both
  8905. * point and spot lights.
  8906. */
  8907. /**
  8908. * Sets the position the shadow will be casted from. Also use as the light position for both
  8909. * point and spot lights.
  8910. */
  8911. position: Vector3;
  8912. protected _direction: Vector3;
  8913. protected _setDirection(value: Vector3): void;
  8914. /**
  8915. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8916. * Also use as the light direction on spot and directional lights.
  8917. */
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. direction: Vector3;
  8923. private _shadowMinZ;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. /**
  8928. * Sets the shadow projection clipping minimum z value.
  8929. */
  8930. shadowMinZ: number;
  8931. private _shadowMaxZ;
  8932. /**
  8933. * Sets the shadow projection clipping maximum z value.
  8934. */
  8935. /**
  8936. * Gets the shadow projection clipping maximum z value.
  8937. */
  8938. shadowMaxZ: number;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * The transformed position. Position of the light in world space taking parenting in account.
  8946. */
  8947. transformedPosition: Vector3;
  8948. /**
  8949. * The transformed direction. Direction of the light in world space taking parenting in account.
  8950. */
  8951. transformedDirection: Vector3;
  8952. private _needProjectionMatrixCompute;
  8953. /**
  8954. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8955. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8956. */
  8957. computeTransformedInformation(): boolean;
  8958. /**
  8959. * Return the depth scale used for the shadow map.
  8960. * @returns the depth scale.
  8961. */
  8962. getDepthScale(): number;
  8963. /**
  8964. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8965. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8966. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8967. */
  8968. getShadowDirection(faceIndex?: number): Vector3;
  8969. /**
  8970. * Returns the ShadowLight absolute position in the World.
  8971. * @returns the position vector in world space
  8972. */
  8973. getAbsolutePosition(): Vector3;
  8974. /**
  8975. * Sets the ShadowLight direction toward the passed target.
  8976. * @param target The point to target in local space
  8977. * @returns the updated ShadowLight direction
  8978. */
  8979. setDirectionToTarget(target: Vector3): Vector3;
  8980. /**
  8981. * Returns the light rotation in euler definition.
  8982. * @returns the x y z rotation in local space.
  8983. */
  8984. getRotation(): Vector3;
  8985. /**
  8986. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8987. * @returns true if a cube texture needs to be use
  8988. */
  8989. needCube(): boolean;
  8990. /**
  8991. * Detects if the projection matrix requires to be recomputed this frame.
  8992. * @returns true if it requires to be recomputed otherwise, false.
  8993. */
  8994. needProjectionMatrixCompute(): boolean;
  8995. /**
  8996. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8997. */
  8998. forceProjectionMatrixCompute(): void;
  8999. /** @hidden */
  9000. _initCache(): void;
  9001. /** @hidden */
  9002. _isSynchronized(): boolean;
  9003. /**
  9004. * Computes the world matrix of the node
  9005. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9006. * @returns the world matrix
  9007. */
  9008. computeWorldMatrix(force?: boolean): Matrix;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. /**
  9022. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9023. * @param matrix The materix to updated with the projection information
  9024. * @param viewMatrix The transform matrix of the light
  9025. * @param renderList The list of mesh to render in the map
  9026. * @returns The current light
  9027. */
  9028. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9029. }
  9030. }
  9031. declare module "babylonjs/Materials/effectFallbacks" {
  9032. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9033. import { Effect } from "babylonjs/Materials/effect";
  9034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9035. /**
  9036. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9037. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9038. */
  9039. export class EffectFallbacks implements IEffectFallbacks {
  9040. private _defines;
  9041. private _currentRank;
  9042. private _maxRank;
  9043. private _mesh;
  9044. /**
  9045. * Removes the fallback from the bound mesh.
  9046. */
  9047. unBindMesh(): void;
  9048. /**
  9049. * Adds a fallback on the specified property.
  9050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9051. * @param define The name of the define in the shader
  9052. */
  9053. addFallback(rank: number, define: string): void;
  9054. /**
  9055. * Sets the mesh to use CPU skinning when needing to fallback.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param mesh The mesh to use the fallbacks.
  9058. */
  9059. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9060. /**
  9061. * Checks to see if more fallbacks are still availible.
  9062. */
  9063. readonly hasMoreFallbacks: boolean;
  9064. /**
  9065. * Removes the defines that should be removed when falling back.
  9066. * @param currentDefines defines the current define statements for the shader.
  9067. * @param effect defines the current effect we try to compile
  9068. * @returns The resulting defines with defines of the current rank removed.
  9069. */
  9070. reduce(currentDefines: string, effect: Effect): string;
  9071. }
  9072. }
  9073. declare module "babylonjs/Materials/materialHelper" {
  9074. import { Nullable } from "babylonjs/types";
  9075. import { Scene } from "babylonjs/scene";
  9076. import { Engine } from "babylonjs/Engines/engine";
  9077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9078. import { Light } from "babylonjs/Lights/light";
  9079. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9080. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9084. /**
  9085. * "Static Class" containing the most commonly used helper while dealing with material for
  9086. * rendering purpose.
  9087. *
  9088. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9089. *
  9090. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9091. */
  9092. export class MaterialHelper {
  9093. /**
  9094. * Bind the current view position to an effect.
  9095. * @param effect The effect to be bound
  9096. * @param scene The scene the eyes position is used from
  9097. */
  9098. static BindEyePosition(effect: Effect, scene: Scene): void;
  9099. /**
  9100. * Helps preparing the defines values about the UVs in used in the effect.
  9101. * UVs are shared as much as we can accross channels in the shaders.
  9102. * @param texture The texture we are preparing the UVs for
  9103. * @param defines The defines to update
  9104. * @param key The channel key "diffuse", "specular"... used in the shader
  9105. */
  9106. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9107. /**
  9108. * Binds a texture matrix value to its corrsponding uniform
  9109. * @param texture The texture to bind the matrix for
  9110. * @param uniformBuffer The uniform buffer receivin the data
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9114. /**
  9115. * Gets the current status of the fog (should it be enabled?)
  9116. * @param mesh defines the mesh to evaluate for fog support
  9117. * @param scene defines the hosting scene
  9118. * @returns true if fog must be enabled
  9119. */
  9120. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9123. * @param mesh defines the current mesh
  9124. * @param scene defines the current scene
  9125. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9126. * @param pointsCloud defines if point cloud rendering has to be turned on
  9127. * @param fogEnabled defines if fog has to be turned on
  9128. * @param alphaTest defines if alpha testing has to be turned on
  9129. * @param defines defines the current list of defines
  9130. */
  9131. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9132. /**
  9133. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9134. * @param scene defines the current scene
  9135. * @param engine defines the current engine
  9136. * @param defines specifies the list of active defines
  9137. * @param useInstances defines if instances have to be turned on
  9138. * @param useClipPlane defines if clip plane have to be turned on
  9139. */
  9140. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9141. /**
  9142. * Prepares the defines for bones
  9143. * @param mesh The mesh containing the geometry data we will draw
  9144. * @param defines The defines to update
  9145. */
  9146. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9147. /**
  9148. * Prepares the defines for morph targets
  9149. * @param mesh The mesh containing the geometry data we will draw
  9150. * @param defines The defines to update
  9151. */
  9152. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9153. /**
  9154. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9158. * @param useBones Precise whether bones should be used or not (override mesh info)
  9159. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9160. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9161. * @returns false if defines are considered not dirty and have not been checked
  9162. */
  9163. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9164. /**
  9165. * Prepares the defines related to multiview
  9166. * @param scene The scene we are intending to draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9170. /**
  9171. * Prepares the defines related to the light information passed in parameter
  9172. * @param scene The scene we are intending to draw
  9173. * @param mesh The mesh the effect is compiling for
  9174. * @param light The light the effect is compiling for
  9175. * @param lightIndex The index of the light
  9176. * @param defines The defines to update
  9177. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9178. * @param state Defines the current state regarding what is needed (normals, etc...)
  9179. */
  9180. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9181. needNormals: boolean;
  9182. needRebuild: boolean;
  9183. shadowEnabled: boolean;
  9184. specularEnabled: boolean;
  9185. lightmapMode: boolean;
  9186. }): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param defines The defines to update
  9192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9193. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9194. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9195. * @returns true if normals will be required for the rest of the effect
  9196. */
  9197. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9198. /**
  9199. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9200. * @param lightIndex defines the light index
  9201. * @param uniformsList The uniform list
  9202. * @param samplersList The sampler list
  9203. * @param projectedLightTexture defines if projected texture must be used
  9204. * @param uniformBuffersList defines an optional list of uniform buffers
  9205. */
  9206. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The sampler list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. private static _TmpMorphInfluencers;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param influencers The number of influencers
  9230. */
  9231. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param defines The current Defines of the effect
  9237. */
  9238. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9239. /**
  9240. * Prepares the list of attributes required for bones according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the bones attributes for
  9243. * @param defines The current Defines of the effect
  9244. * @param fallbacks The current efffect fallback strategy
  9245. */
  9246. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9247. /**
  9248. * Check and prepare the list of attributes required for instances according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param defines The current MaterialDefines of the effect
  9251. */
  9252. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9253. /**
  9254. * Add the list of attributes required for instances to the attribs array.
  9255. * @param attribs The current list of supported attribs
  9256. */
  9257. static PushAttributesForInstances(attribs: string[]): void;
  9258. /**
  9259. * Binds the light information to the effect.
  9260. * @param light The light containing the generator
  9261. * @param effect The effect we are binding the data to
  9262. * @param lightIndex The light index in the effect used to render
  9263. */
  9264. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9265. /**
  9266. * Binds the lights information from the scene to the effect for the given mesh.
  9267. * @param light Light to bind
  9268. * @param lightIndex Light index
  9269. * @param scene The scene where the light belongs to
  9270. * @param effect The effect we are binding the data to
  9271. * @param useSpecular Defines if specular is supported
  9272. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9273. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9274. */
  9275. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9276. /**
  9277. * Binds the lights information from the scene to the effect for the given mesh.
  9278. * @param scene The scene the lights belongs to
  9279. * @param mesh The mesh we are binding the information to render
  9280. * @param effect The effect we are binding the data to
  9281. * @param defines The generated defines for the effect
  9282. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9283. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9287. private static _tempFogColor;
  9288. /**
  9289. * Binds the fog information from the scene to the effect for the given mesh.
  9290. * @param scene The scene the lights belongs to
  9291. * @param mesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. * @param linearSpace Defines if the fog effect is applied in linear space
  9294. */
  9295. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9296. /**
  9297. * Binds the bones information from the mesh to the effect.
  9298. * @param mesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9302. /**
  9303. * Binds the morph targets information from the mesh to the effect.
  9304. * @param abstractMesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9308. /**
  9309. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9310. * @param defines The generated defines used in the effect
  9311. * @param effect The effect we are binding the data to
  9312. * @param scene The scene we are willing to render with logarithmic scale for
  9313. */
  9314. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9315. /**
  9316. * Binds the clip plane information from the scene to the effect.
  9317. * @param scene The scene the clip plane information are extracted from
  9318. * @param effect The effect we are binding the data to
  9319. */
  9320. static BindClipPlane(effect: Effect, scene: Scene): void;
  9321. }
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9324. /** @hidden */
  9325. export var packingFunctions: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9331. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9399. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9403. /** @hidden */
  9404. export var shadowMapVertexShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9410. /** @hidden */
  9411. export var depthBoxBlurPixelShader: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9417. import { Nullable } from "babylonjs/types";
  9418. import { Scene } from "babylonjs/scene";
  9419. import { Matrix } from "babylonjs/Maths/math.vector";
  9420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9422. import { Mesh } from "babylonjs/Meshes/mesh";
  9423. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9424. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9425. import { Effect } from "babylonjs/Materials/effect";
  9426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9427. import "babylonjs/Shaders/shadowMap.fragment";
  9428. import "babylonjs/Shaders/shadowMap.vertex";
  9429. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9430. import { Observable } from "babylonjs/Misc/observable";
  9431. /**
  9432. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9433. */
  9434. export interface ICustomShaderOptions {
  9435. /**
  9436. * Gets or sets the custom shader name to use
  9437. */
  9438. shaderName: string;
  9439. /**
  9440. * The list of attribute names used in the shader
  9441. */
  9442. attributes?: string[];
  9443. /**
  9444. * The list of unifrom names used in the shader
  9445. */
  9446. uniforms?: string[];
  9447. /**
  9448. * The list of sampler names used in the shader
  9449. */
  9450. samplers?: string[];
  9451. /**
  9452. * The list of defines used in the shader
  9453. */
  9454. defines?: string[];
  9455. }
  9456. /**
  9457. * Interface to implement to create a shadow generator compatible with BJS.
  9458. */
  9459. export interface IShadowGenerator {
  9460. /**
  9461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9462. * @returns The render target texture if present otherwise, null
  9463. */
  9464. getShadowMap(): Nullable<RenderTargetTexture>;
  9465. /**
  9466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9467. * @returns The render target texture if the shadow map is present otherwise, null
  9468. */
  9469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9470. /**
  9471. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9472. * @param subMesh The submesh we want to render in the shadow map
  9473. * @param useInstances Defines wether will draw in the map using instances
  9474. * @returns true if ready otherwise, false
  9475. */
  9476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9477. /**
  9478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9479. * @param defines Defines of the material we want to update
  9480. * @param lightIndex Index of the light in the enabled light list of the material
  9481. */
  9482. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9483. /**
  9484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9485. * defined in the generator but impacting the effect).
  9486. * It implies the unifroms available on the materials are the standard BJS ones.
  9487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9488. * @param effect The effect we are binfing the information for
  9489. */
  9490. bindShadowLight(lightIndex: string, effect: Effect): void;
  9491. /**
  9492. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9493. * (eq to shadow prjection matrix * light transform matrix)
  9494. * @returns The transform matrix used to create the shadow map
  9495. */
  9496. getTransformMatrix(): Matrix;
  9497. /**
  9498. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9499. * Cube and 2D textures for instance.
  9500. */
  9501. recreateShadowMap(): void;
  9502. /**
  9503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9504. * @param onCompiled Callback triggered at the and of the effects compilation
  9505. * @param options Sets of optional options forcing the compilation with different modes
  9506. */
  9507. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9508. useInstances: boolean;
  9509. }>): void;
  9510. /**
  9511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9512. * @param options Sets of optional options forcing the compilation with different modes
  9513. * @returns A promise that resolves when the compilation completes
  9514. */
  9515. forceCompilationAsync(options?: Partial<{
  9516. useInstances: boolean;
  9517. }>): Promise<void>;
  9518. /**
  9519. * Serializes the shadow generator setup to a json object.
  9520. * @returns The serialized JSON object
  9521. */
  9522. serialize(): any;
  9523. /**
  9524. * Disposes the Shadow map and related Textures and effects.
  9525. */
  9526. dispose(): void;
  9527. }
  9528. /**
  9529. * Default implementation IShadowGenerator.
  9530. * This is the main object responsible of generating shadows in the framework.
  9531. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9532. */
  9533. export class ShadowGenerator implements IShadowGenerator {
  9534. /**
  9535. * Shadow generator mode None: no filtering applied.
  9536. */
  9537. static readonly FILTER_NONE: number;
  9538. /**
  9539. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9541. */
  9542. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9543. /**
  9544. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9545. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9546. */
  9547. static readonly FILTER_POISSONSAMPLING: number;
  9548. /**
  9549. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9550. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9551. */
  9552. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9553. /**
  9554. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9555. * edge artifacts on steep falloff.
  9556. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9557. */
  9558. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9559. /**
  9560. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9561. * edge artifacts on steep falloff.
  9562. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9563. */
  9564. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9565. /**
  9566. * Shadow generator mode PCF: Percentage Closer Filtering
  9567. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9568. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9569. */
  9570. static readonly FILTER_PCF: number;
  9571. /**
  9572. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9573. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9574. * Contact Hardening
  9575. */
  9576. static readonly FILTER_PCSS: number;
  9577. /**
  9578. * Reserved for PCF and PCSS
  9579. * Highest Quality.
  9580. *
  9581. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9582. *
  9583. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9584. */
  9585. static readonly QUALITY_HIGH: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * Good tradeoff for quality/perf cross devices
  9589. *
  9590. * Execute PCF on a 3*3 kernel.
  9591. *
  9592. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9593. */
  9594. static readonly QUALITY_MEDIUM: number;
  9595. /**
  9596. * Reserved for PCF and PCSS
  9597. * The lowest quality but the fastest.
  9598. *
  9599. * Execute PCF on a 1*1 kernel.
  9600. *
  9601. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9602. */
  9603. static readonly QUALITY_LOW: number;
  9604. /** Gets or sets the custom shader name to use */
  9605. customShaderOptions: ICustomShaderOptions;
  9606. /**
  9607. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9608. */
  9609. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9610. /**
  9611. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9612. */
  9613. onAfterShadowMapRenderObservable: Observable<Effect>;
  9614. /**
  9615. * Observable triggered before a mesh is rendered in the shadow map.
  9616. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9617. */
  9618. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9619. /**
  9620. * Observable triggered after a mesh is rendered in the shadow map.
  9621. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9622. */
  9623. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9624. private _bias;
  9625. /**
  9626. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9627. */
  9628. /**
  9629. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9630. */
  9631. bias: number;
  9632. private _normalBias;
  9633. /**
  9634. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9635. */
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. normalBias: number;
  9640. private _blurBoxOffset;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. /**
  9646. * Sets the blur box offset: offset applied during the blur pass.
  9647. * Only useful if useKernelBlur = false
  9648. */
  9649. blurBoxOffset: number;
  9650. private _blurScale;
  9651. /**
  9652. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9653. * 2 means half of the size.
  9654. */
  9655. /**
  9656. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9657. * 2 means half of the size.
  9658. */
  9659. blurScale: number;
  9660. private _blurKernel;
  9661. /**
  9662. * Gets the blur kernel: kernel size of the blur pass.
  9663. * Only useful if useKernelBlur = true
  9664. */
  9665. /**
  9666. * Sets the blur kernel: kernel size of the blur pass.
  9667. * Only useful if useKernelBlur = true
  9668. */
  9669. blurKernel: number;
  9670. private _useKernelBlur;
  9671. /**
  9672. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9673. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9674. */
  9675. /**
  9676. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9677. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9678. */
  9679. useKernelBlur: boolean;
  9680. private _depthScale;
  9681. /**
  9682. * Gets the depth scale used in ESM mode.
  9683. */
  9684. /**
  9685. * Sets the depth scale used in ESM mode.
  9686. * This can override the scale stored on the light.
  9687. */
  9688. depthScale: number;
  9689. private _filter;
  9690. /**
  9691. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9692. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9693. */
  9694. /**
  9695. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9696. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9697. */
  9698. filter: number;
  9699. /**
  9700. * Gets if the current filter is set to Poisson Sampling.
  9701. */
  9702. /**
  9703. * Sets the current filter to Poisson Sampling.
  9704. */
  9705. usePoissonSampling: boolean;
  9706. /**
  9707. * Gets if the current filter is set to ESM.
  9708. */
  9709. /**
  9710. * Sets the current filter is to ESM.
  9711. */
  9712. useExponentialShadowMap: boolean;
  9713. /**
  9714. * Gets if the current filter is set to filtered ESM.
  9715. */
  9716. /**
  9717. * Gets if the current filter is set to filtered ESM.
  9718. */
  9719. useBlurExponentialShadowMap: boolean;
  9720. /**
  9721. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9722. * exponential to prevent steep falloff artifacts).
  9723. */
  9724. /**
  9725. * Sets the current filter to "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. useCloseExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. /**
  9734. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9735. * exponential to prevent steep falloff artifacts).
  9736. */
  9737. useBlurCloseExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9740. */
  9741. /**
  9742. * Sets the current filter to "PCF" (percentage closer filtering).
  9743. */
  9744. usePercentageCloserFiltering: boolean;
  9745. private _filteringQuality;
  9746. /**
  9747. * Gets the PCF or PCSS Quality.
  9748. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9749. */
  9750. /**
  9751. * Sets the PCF or PCSS Quality.
  9752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9753. */
  9754. filteringQuality: number;
  9755. /**
  9756. * Gets if the current filter is set to "PCSS" (contact hardening).
  9757. */
  9758. /**
  9759. * Sets the current filter to "PCSS" (contact hardening).
  9760. */
  9761. useContactHardeningShadow: boolean;
  9762. private _contactHardeningLightSizeUVRatio;
  9763. /**
  9764. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9765. * Using a ratio helps keeping shape stability independently of the map size.
  9766. *
  9767. * It does not account for the light projection as it was having too much
  9768. * instability during the light setup or during light position changes.
  9769. *
  9770. * Only valid if useContactHardeningShadow is true.
  9771. */
  9772. /**
  9773. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9774. * Using a ratio helps keeping shape stability independently of the map size.
  9775. *
  9776. * It does not account for the light projection as it was having too much
  9777. * instability during the light setup or during light position changes.
  9778. *
  9779. * Only valid if useContactHardeningShadow is true.
  9780. */
  9781. contactHardeningLightSizeUVRatio: number;
  9782. private _darkness;
  9783. /** Gets or sets the actual darkness of a shadow */
  9784. darkness: number;
  9785. /**
  9786. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9787. * 0 means strongest and 1 would means no shadow.
  9788. * @returns the darkness.
  9789. */
  9790. getDarkness(): number;
  9791. /**
  9792. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9793. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9794. * @returns the shadow generator allowing fluent coding.
  9795. */
  9796. setDarkness(darkness: number): ShadowGenerator;
  9797. private _transparencyShadow;
  9798. /** Gets or sets the ability to have transparent shadow */
  9799. transparencyShadow: boolean;
  9800. /**
  9801. * Sets the ability to have transparent shadow (boolean).
  9802. * @param transparent True if transparent else False
  9803. * @returns the shadow generator allowing fluent coding
  9804. */
  9805. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9806. private _shadowMap;
  9807. private _shadowMap2;
  9808. /**
  9809. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9810. * @returns The render target texture if present otherwise, null
  9811. */
  9812. getShadowMap(): Nullable<RenderTargetTexture>;
  9813. /**
  9814. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9815. * @returns The render target texture if the shadow map is present otherwise, null
  9816. */
  9817. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9818. /**
  9819. * Gets the class name of that object
  9820. * @returns "ShadowGenerator"
  9821. */
  9822. getClassName(): string;
  9823. /**
  9824. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9825. * @param mesh Mesh to add
  9826. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9827. * @returns the Shadow Generator itself
  9828. */
  9829. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9830. /**
  9831. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9832. * @param mesh Mesh to remove
  9833. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9834. * @returns the Shadow Generator itself
  9835. */
  9836. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9837. /**
  9838. * Controls the extent to which the shadows fade out at the edge of the frustum
  9839. * Used only by directionals and spots
  9840. */
  9841. frustumEdgeFalloff: number;
  9842. private _light;
  9843. /**
  9844. * Returns the associated light object.
  9845. * @returns the light generating the shadow
  9846. */
  9847. getLight(): IShadowLight;
  9848. /**
  9849. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9850. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9851. * It might on the other hand introduce peter panning.
  9852. */
  9853. forceBackFacesOnly: boolean;
  9854. private _scene;
  9855. private _lightDirection;
  9856. private _effect;
  9857. private _viewMatrix;
  9858. private _projectionMatrix;
  9859. private _transformMatrix;
  9860. private _cachedPosition;
  9861. private _cachedDirection;
  9862. private _cachedDefines;
  9863. private _currentRenderID;
  9864. private _boxBlurPostprocess;
  9865. private _kernelBlurXPostprocess;
  9866. private _kernelBlurYPostprocess;
  9867. private _blurPostProcesses;
  9868. private _mapSize;
  9869. private _currentFaceIndex;
  9870. private _currentFaceIndexCache;
  9871. private _textureType;
  9872. private _defaultTextureMatrix;
  9873. private _storedUniqueId;
  9874. /** @hidden */
  9875. static _SceneComponentInitialization: (scene: Scene) => void;
  9876. /**
  9877. * Creates a ShadowGenerator object.
  9878. * A ShadowGenerator is the required tool to use the shadows.
  9879. * Each light casting shadows needs to use its own ShadowGenerator.
  9880. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9881. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9882. * @param light The light object generating the shadows.
  9883. * @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.
  9884. */
  9885. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9886. private _initializeGenerator;
  9887. private _initializeShadowMap;
  9888. private _initializeBlurRTTAndPostProcesses;
  9889. private _renderForShadowMap;
  9890. private _renderSubMeshForShadowMap;
  9891. private _applyFilterValues;
  9892. /**
  9893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9894. * @param onCompiled Callback triggered at the and of the effects compilation
  9895. * @param options Sets of optional options forcing the compilation with different modes
  9896. */
  9897. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9898. useInstances: boolean;
  9899. }>): void;
  9900. /**
  9901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9902. * @param options Sets of optional options forcing the compilation with different modes
  9903. * @returns A promise that resolves when the compilation completes
  9904. */
  9905. forceCompilationAsync(options?: Partial<{
  9906. useInstances: boolean;
  9907. }>): Promise<void>;
  9908. /**
  9909. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9910. * @param subMesh The submesh we want to render in the shadow map
  9911. * @param useInstances Defines wether will draw in the map using instances
  9912. * @returns true if ready otherwise, false
  9913. */
  9914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9915. /**
  9916. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9917. * @param defines Defines of the material we want to update
  9918. * @param lightIndex Index of the light in the enabled light list of the material
  9919. */
  9920. prepareDefines(defines: any, lightIndex: number): void;
  9921. /**
  9922. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9923. * defined in the generator but impacting the effect).
  9924. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9925. * @param effect The effect we are binfing the information for
  9926. */
  9927. bindShadowLight(lightIndex: string, effect: Effect): void;
  9928. /**
  9929. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9930. * (eq to shadow prjection matrix * light transform matrix)
  9931. * @returns The transform matrix used to create the shadow map
  9932. */
  9933. getTransformMatrix(): Matrix;
  9934. /**
  9935. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9936. * Cube and 2D textures for instance.
  9937. */
  9938. recreateShadowMap(): void;
  9939. private _disposeBlurPostProcesses;
  9940. private _disposeRTTandPostProcesses;
  9941. /**
  9942. * Disposes the ShadowGenerator.
  9943. * Returns nothing.
  9944. */
  9945. dispose(): void;
  9946. /**
  9947. * Serializes the shadow generator setup to a json object.
  9948. * @returns The serialized JSON object
  9949. */
  9950. serialize(): any;
  9951. /**
  9952. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9953. * @param parsedShadowGenerator The JSON object to parse
  9954. * @param scene The scene to create the shadow map for
  9955. * @returns The parsed shadow generator
  9956. */
  9957. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9958. }
  9959. }
  9960. declare module "babylonjs/Lights/light" {
  9961. import { Nullable } from "babylonjs/types";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Vector3 } from "babylonjs/Maths/math.vector";
  9964. import { Color3 } from "babylonjs/Maths/math.color";
  9965. import { Node } from "babylonjs/node";
  9966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9967. import { Effect } from "babylonjs/Materials/effect";
  9968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9969. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9970. /**
  9971. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9972. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9973. * 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.
  9974. */
  9975. export abstract class Light extends Node {
  9976. /**
  9977. * Falloff Default: light is falling off following the material specification:
  9978. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9979. */
  9980. static readonly FALLOFF_DEFAULT: number;
  9981. /**
  9982. * Falloff Physical: light is falling off following the inverse squared distance law.
  9983. */
  9984. static readonly FALLOFF_PHYSICAL: number;
  9985. /**
  9986. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9987. * to enhance interoperability with other engines.
  9988. */
  9989. static readonly FALLOFF_GLTF: number;
  9990. /**
  9991. * Falloff Standard: light is falling off like in the standard material
  9992. * to enhance interoperability with other materials.
  9993. */
  9994. static readonly FALLOFF_STANDARD: number;
  9995. /**
  9996. * If every light affecting the material is in this lightmapMode,
  9997. * material.lightmapTexture adds or multiplies
  9998. * (depends on material.useLightmapAsShadowmap)
  9999. * after every other light calculations.
  10000. */
  10001. static readonly LIGHTMAP_DEFAULT: number;
  10002. /**
  10003. * material.lightmapTexture as only diffuse lighting from this light
  10004. * adds only specular lighting from this light
  10005. * adds dynamic shadows
  10006. */
  10007. static readonly LIGHTMAP_SPECULAR: number;
  10008. /**
  10009. * material.lightmapTexture as only lighting
  10010. * no light calculation from this light
  10011. * only adds dynamic shadows from this light
  10012. */
  10013. static readonly LIGHTMAP_SHADOWSONLY: number;
  10014. /**
  10015. * Each light type uses the default quantity according to its type:
  10016. * point/spot lights use luminous intensity
  10017. * directional lights use illuminance
  10018. */
  10019. static readonly INTENSITYMODE_AUTOMATIC: number;
  10020. /**
  10021. * lumen (lm)
  10022. */
  10023. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10024. /**
  10025. * candela (lm/sr)
  10026. */
  10027. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10028. /**
  10029. * lux (lm/m^2)
  10030. */
  10031. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10032. /**
  10033. * nit (cd/m^2)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINANCE: number;
  10036. /**
  10037. * Light type const id of the point light.
  10038. */
  10039. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10040. /**
  10041. * Light type const id of the directional light.
  10042. */
  10043. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10044. /**
  10045. * Light type const id of the spot light.
  10046. */
  10047. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10048. /**
  10049. * Light type const id of the hemispheric light.
  10050. */
  10051. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10052. /**
  10053. * Diffuse gives the basic color to an object.
  10054. */
  10055. diffuse: Color3;
  10056. /**
  10057. * Specular produces a highlight color on an object.
  10058. * Note: This is note affecting PBR materials.
  10059. */
  10060. specular: Color3;
  10061. /**
  10062. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10063. * falling off base on range or angle.
  10064. * This can be set to any values in Light.FALLOFF_x.
  10065. *
  10066. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10067. * other types of materials.
  10068. */
  10069. falloffType: number;
  10070. /**
  10071. * Strength of the light.
  10072. * Note: By default it is define in the framework own unit.
  10073. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10074. */
  10075. intensity: number;
  10076. private _range;
  10077. protected _inverseSquaredRange: number;
  10078. /**
  10079. * Defines how far from the source the light is impacting in scene units.
  10080. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10081. */
  10082. /**
  10083. * Defines how far from the source the light is impacting in scene units.
  10084. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10085. */
  10086. range: number;
  10087. /**
  10088. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10089. * of light.
  10090. */
  10091. private _photometricScale;
  10092. private _intensityMode;
  10093. /**
  10094. * Gets the photometric scale used to interpret the intensity.
  10095. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10096. */
  10097. /**
  10098. * Sets the photometric scale used to interpret the intensity.
  10099. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10100. */
  10101. intensityMode: number;
  10102. private _radius;
  10103. /**
  10104. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10105. */
  10106. /**
  10107. * sets the light radius used by PBR Materials to simulate soft area lights.
  10108. */
  10109. radius: number;
  10110. private _renderPriority;
  10111. /**
  10112. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10113. * exceeding the number allowed of the materials.
  10114. */
  10115. renderPriority: number;
  10116. private _shadowEnabled;
  10117. /**
  10118. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10119. * the current shadow generator.
  10120. */
  10121. /**
  10122. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10123. * the current shadow generator.
  10124. */
  10125. shadowEnabled: boolean;
  10126. private _includedOnlyMeshes;
  10127. /**
  10128. * Gets the only meshes impacted by this light.
  10129. */
  10130. /**
  10131. * Sets the only meshes impacted by this light.
  10132. */
  10133. includedOnlyMeshes: AbstractMesh[];
  10134. private _excludedMeshes;
  10135. /**
  10136. * Gets the meshes not impacted by this light.
  10137. */
  10138. /**
  10139. * Sets the meshes not impacted by this light.
  10140. */
  10141. excludedMeshes: AbstractMesh[];
  10142. private _excludeWithLayerMask;
  10143. /**
  10144. * Gets the layer id use to find what meshes are not impacted by the light.
  10145. * Inactive if 0
  10146. */
  10147. /**
  10148. * Sets the layer id use to find what meshes are not impacted by the light.
  10149. * Inactive if 0
  10150. */
  10151. excludeWithLayerMask: number;
  10152. private _includeOnlyWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. includeOnlyWithLayerMask: number;
  10162. private _lightmapMode;
  10163. /**
  10164. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10165. */
  10166. /**
  10167. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10168. */
  10169. lightmapMode: number;
  10170. /**
  10171. * Shadow generator associted to the light.
  10172. * @hidden Internal use only.
  10173. */
  10174. _shadowGenerator: Nullable<IShadowGenerator>;
  10175. /**
  10176. * @hidden Internal use only.
  10177. */
  10178. _excludedMeshesIds: string[];
  10179. /**
  10180. * @hidden Internal use only.
  10181. */
  10182. _includedOnlyMeshesIds: string[];
  10183. /**
  10184. * The current light unifom buffer.
  10185. * @hidden Internal use only.
  10186. */
  10187. _uniformBuffer: UniformBuffer;
  10188. /** @hidden */
  10189. _renderId: number;
  10190. /**
  10191. * Creates a Light object in the scene.
  10192. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10193. * @param name The firendly name of the light
  10194. * @param scene The scene the light belongs too
  10195. */
  10196. constructor(name: string, scene: Scene);
  10197. protected abstract _buildUniformLayout(): void;
  10198. /**
  10199. * Sets the passed Effect "effect" with the Light information.
  10200. * @param effect The effect to update
  10201. * @param lightIndex The index of the light in the effect to update
  10202. * @returns The light
  10203. */
  10204. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10205. /**
  10206. * Sets the passed Effect "effect" with the Light information.
  10207. * @param effect The effect to update
  10208. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10209. * @returns The light
  10210. */
  10211. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10212. /**
  10213. * Returns the string "Light".
  10214. * @returns the class name
  10215. */
  10216. getClassName(): string;
  10217. /** @hidden */
  10218. readonly _isLight: boolean;
  10219. /**
  10220. * Converts the light information to a readable string for debug purpose.
  10221. * @param fullDetails Supports for multiple levels of logging within scene loading
  10222. * @returns the human readable light info
  10223. */
  10224. toString(fullDetails?: boolean): string;
  10225. /** @hidden */
  10226. protected _syncParentEnabledState(): void;
  10227. /**
  10228. * Set the enabled state of this node.
  10229. * @param value - the new enabled state
  10230. */
  10231. setEnabled(value: boolean): void;
  10232. /**
  10233. * Returns the Light associated shadow generator if any.
  10234. * @return the associated shadow generator.
  10235. */
  10236. getShadowGenerator(): Nullable<IShadowGenerator>;
  10237. /**
  10238. * Returns a Vector3, the absolute light position in the World.
  10239. * @returns the world space position of the light
  10240. */
  10241. getAbsolutePosition(): Vector3;
  10242. /**
  10243. * Specifies if the light will affect the passed mesh.
  10244. * @param mesh The mesh to test against the light
  10245. * @return true the mesh is affected otherwise, false.
  10246. */
  10247. canAffectMesh(mesh: AbstractMesh): boolean;
  10248. /**
  10249. * Sort function to order lights for rendering.
  10250. * @param a First Light object to compare to second.
  10251. * @param b Second Light object to compare first.
  10252. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10253. */
  10254. static CompareLightsPriority(a: Light, b: Light): number;
  10255. /**
  10256. * Releases resources associated with this node.
  10257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10259. */
  10260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10261. /**
  10262. * Returns the light type ID (integer).
  10263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10264. */
  10265. getTypeID(): number;
  10266. /**
  10267. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10268. * @returns the scaled intensity in intensity mode unit
  10269. */
  10270. getScaledIntensity(): number;
  10271. /**
  10272. * Returns a new Light object, named "name", from the current one.
  10273. * @param name The name of the cloned light
  10274. * @returns the new created light
  10275. */
  10276. clone(name: string): Nullable<Light>;
  10277. /**
  10278. * Serializes the current light into a Serialization object.
  10279. * @returns the serialized object.
  10280. */
  10281. serialize(): any;
  10282. /**
  10283. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10284. * This new light is named "name" and added to the passed scene.
  10285. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10286. * @param name The friendly name of the light
  10287. * @param scene The scene the new light will belong to
  10288. * @returns the constructor function
  10289. */
  10290. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10291. /**
  10292. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10293. * @param parsedLight The JSON representation of the light
  10294. * @param scene The scene to create the parsed light in
  10295. * @returns the created light after parsing
  10296. */
  10297. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10298. private _hookArrayForExcluded;
  10299. private _hookArrayForIncludedOnly;
  10300. private _resyncMeshes;
  10301. /**
  10302. * Forces the meshes to update their light related information in their rendering used effects
  10303. * @hidden Internal Use Only
  10304. */
  10305. _markMeshesAsLightDirty(): void;
  10306. /**
  10307. * Recomputes the cached photometric scale if needed.
  10308. */
  10309. private _computePhotometricScale;
  10310. /**
  10311. * Returns the Photometric Scale according to the light type and intensity mode.
  10312. */
  10313. private _getPhotometricScale;
  10314. /**
  10315. * Reorder the light in the scene according to their defined priority.
  10316. * @hidden Internal Use Only
  10317. */
  10318. _reorderLightsInScene(): void;
  10319. /**
  10320. * Prepares the list of defines specific to the light type.
  10321. * @param defines the list of defines
  10322. * @param lightIndex defines the index of the light for the effect
  10323. */
  10324. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Actions/action" {
  10328. import { Observable } from "babylonjs/Misc/observable";
  10329. import { Condition } from "babylonjs/Actions/condition";
  10330. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. _prepare(): void;
  10364. /**
  10365. * Internal only - manager for action
  10366. * @hidden
  10367. */
  10368. _actionManager: AbstractActionManager;
  10369. /**
  10370. * Adds action to chain of actions, may be a DoNothingAction
  10371. * @param action defines the next action to execute
  10372. * @returns The action passed in
  10373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10374. */
  10375. then(action: IAction): IAction;
  10376. }
  10377. /**
  10378. * The action to be carried out following a trigger
  10379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10380. */
  10381. export class Action implements IAction {
  10382. /** the trigger, with or without parameters, for the action */
  10383. triggerOptions: any;
  10384. /**
  10385. * Trigger for the action
  10386. */
  10387. trigger: number;
  10388. /**
  10389. * Internal only - manager for action
  10390. * @hidden
  10391. */
  10392. _actionManager: ActionManager;
  10393. private _nextActiveAction;
  10394. private _child;
  10395. private _condition?;
  10396. private _triggerParameter;
  10397. /**
  10398. * An event triggered prior to action being executed.
  10399. */
  10400. onBeforeExecuteObservable: Observable<Action>;
  10401. /**
  10402. * Creates a new Action
  10403. * @param triggerOptions the trigger, with or without parameters, for the action
  10404. * @param condition an optional determinant of action
  10405. */
  10406. constructor(
  10407. /** the trigger, with or without parameters, for the action */
  10408. triggerOptions: any, condition?: Condition);
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. _prepare(): void;
  10414. /**
  10415. * Gets the trigger parameters
  10416. * @returns the trigger parameters
  10417. */
  10418. getTriggerParameter(): any;
  10419. /**
  10420. * Internal only - executes current action event
  10421. * @hidden
  10422. */
  10423. _executeCurrent(evt?: ActionEvent): void;
  10424. /**
  10425. * Execute placeholder for child classes
  10426. * @param evt optional action event
  10427. */
  10428. execute(evt?: ActionEvent): void;
  10429. /**
  10430. * Skips to next active action
  10431. */
  10432. skipToNextActiveAction(): void;
  10433. /**
  10434. * Adds action to chain of actions, may be a DoNothingAction
  10435. * @param action defines the next action to execute
  10436. * @returns The action passed in
  10437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10438. */
  10439. then(action: Action): Action;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _getProperty(propertyPath: string): string;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. _getEffectiveTarget(target: any, propertyPath: string): any;
  10450. /**
  10451. * Serialize placeholder for child classes
  10452. * @param parent of child
  10453. * @returns the serialized object
  10454. */
  10455. serialize(parent: any): any;
  10456. /**
  10457. * Internal only called by serialize
  10458. * @hidden
  10459. */
  10460. protected _serialize(serializedAction: any, parent?: any): any;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. static _SerializeValueAsString: (value: any) => string;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10471. name: string;
  10472. targetType: string;
  10473. value: string;
  10474. };
  10475. }
  10476. }
  10477. declare module "babylonjs/Actions/condition" {
  10478. import { ActionManager } from "babylonjs/Actions/actionManager";
  10479. /**
  10480. * A Condition applied to an Action
  10481. */
  10482. export class Condition {
  10483. /**
  10484. * Internal only - manager for action
  10485. * @hidden
  10486. */
  10487. _actionManager: ActionManager;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. _evaluationId: number;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. _currentResult: boolean;
  10498. /**
  10499. * Creates a new Condition
  10500. * @param actionManager the manager of the action the condition is applied to
  10501. */
  10502. constructor(actionManager: ActionManager);
  10503. /**
  10504. * Check if the current condition is valid
  10505. * @returns a boolean
  10506. */
  10507. isValid(): boolean;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _getProperty(propertyPath: string): string;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _getEffectiveTarget(target: any, propertyPath: string): any;
  10518. /**
  10519. * Serialize placeholder for child classes
  10520. * @returns the serialized object
  10521. */
  10522. serialize(): any;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. protected _serialize(serializedCondition: any): any;
  10528. }
  10529. /**
  10530. * Defines specific conditional operators as extensions of Condition
  10531. */
  10532. export class ValueCondition extends Condition {
  10533. /** path to specify the property of the target the conditional operator uses */
  10534. propertyPath: string;
  10535. /** the value compared by the conditional operator against the current value of the property */
  10536. value: any;
  10537. /** the conditional operator, default ValueCondition.IsEqual */
  10538. operator: number;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. private static _IsEqual;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. private static _IsDifferent;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private static _IsGreater;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsLesser;
  10559. /**
  10560. * returns the number for IsEqual
  10561. */
  10562. static readonly IsEqual: number;
  10563. /**
  10564. * Returns the number for IsDifferent
  10565. */
  10566. static readonly IsDifferent: number;
  10567. /**
  10568. * Returns the number for IsGreater
  10569. */
  10570. static readonly IsGreater: number;
  10571. /**
  10572. * Returns the number for IsLesser
  10573. */
  10574. static readonly IsLesser: number;
  10575. /**
  10576. * Internal only The action manager for the condition
  10577. * @hidden
  10578. */
  10579. _actionManager: ActionManager;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private _target;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private _effectiveTarget;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private _property;
  10595. /**
  10596. * Creates a new ValueCondition
  10597. * @param actionManager manager for the action the condition applies to
  10598. * @param target for the action
  10599. * @param propertyPath path to specify the property of the target the conditional operator uses
  10600. * @param value the value compared by the conditional operator against the current value of the property
  10601. * @param operator the conditional operator, default ValueCondition.IsEqual
  10602. */
  10603. constructor(actionManager: ActionManager, target: any,
  10604. /** path to specify the property of the target the conditional operator uses */
  10605. propertyPath: string,
  10606. /** the value compared by the conditional operator against the current value of the property */
  10607. value: any,
  10608. /** the conditional operator, default ValueCondition.IsEqual */
  10609. operator?: number);
  10610. /**
  10611. * Compares the given value with the property value for the specified conditional operator
  10612. * @returns the result of the comparison
  10613. */
  10614. isValid(): boolean;
  10615. /**
  10616. * Serialize the ValueCondition into a JSON compatible object
  10617. * @returns serialization object
  10618. */
  10619. serialize(): any;
  10620. /**
  10621. * Gets the name of the conditional operator for the ValueCondition
  10622. * @param operator the conditional operator
  10623. * @returns the name
  10624. */
  10625. static GetOperatorName(operator: number): string;
  10626. }
  10627. /**
  10628. * Defines a predicate condition as an extension of Condition
  10629. */
  10630. export class PredicateCondition extends Condition {
  10631. /** defines the predicate function used to validate the condition */
  10632. predicate: () => boolean;
  10633. /**
  10634. * Internal only - manager for action
  10635. * @hidden
  10636. */
  10637. _actionManager: ActionManager;
  10638. /**
  10639. * Creates a new PredicateCondition
  10640. * @param actionManager manager for the action the condition applies to
  10641. * @param predicate defines the predicate function used to validate the condition
  10642. */
  10643. constructor(actionManager: ActionManager,
  10644. /** defines the predicate function used to validate the condition */
  10645. predicate: () => boolean);
  10646. /**
  10647. * @returns the validity of the predicate condition
  10648. */
  10649. isValid(): boolean;
  10650. }
  10651. /**
  10652. * Defines a state condition as an extension of Condition
  10653. */
  10654. export class StateCondition extends Condition {
  10655. /** Value to compare with target state */
  10656. value: string;
  10657. /**
  10658. * Internal only - manager for action
  10659. * @hidden
  10660. */
  10661. _actionManager: ActionManager;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. private _target;
  10667. /**
  10668. * Creates a new StateCondition
  10669. * @param actionManager manager for the action the condition applies to
  10670. * @param target of the condition
  10671. * @param value to compare with target state
  10672. */
  10673. constructor(actionManager: ActionManager, target: any,
  10674. /** Value to compare with target state */
  10675. value: string);
  10676. /**
  10677. * Gets a boolean indicating if the current condition is met
  10678. * @returns the validity of the state
  10679. */
  10680. isValid(): boolean;
  10681. /**
  10682. * Serialize the StateCondition into a JSON compatible object
  10683. * @returns serialization object
  10684. */
  10685. serialize(): any;
  10686. }
  10687. }
  10688. declare module "babylonjs/Actions/directActions" {
  10689. import { Action } from "babylonjs/Actions/action";
  10690. import { Condition } from "babylonjs/Actions/condition";
  10691. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10692. /**
  10693. * This defines an action responsible to toggle a boolean once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SwitchBooleanAction extends Action {
  10697. /**
  10698. * The path to the boolean property in the target object
  10699. */
  10700. propertyPath: string;
  10701. private _target;
  10702. private _effectiveTarget;
  10703. private _property;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the boolean
  10708. * @param propertyPath defines the path to the boolean property in the target object
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10712. /** @hidden */
  10713. _prepare(): void;
  10714. /**
  10715. * Execute the action toggle the boolean value.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to set a the state field of the target
  10727. * to a desired value once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class SetStateAction extends Action {
  10731. /**
  10732. * The value to store in the state field.
  10733. */
  10734. value: string;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the state property
  10740. * @param value defines the value to store in the state field
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10744. /**
  10745. * Execute the action and store the value on the target state property.
  10746. */
  10747. execute(): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to set a property of the target
  10757. * to a desired value once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class SetValueAction extends Action {
  10761. /**
  10762. * The path of the property to set in the target.
  10763. */
  10764. propertyPath: string;
  10765. /**
  10766. * The value to set in the property
  10767. */
  10768. value: any;
  10769. private _target;
  10770. private _effectiveTarget;
  10771. private _property;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the property
  10776. * @param propertyPath defines the path of the property to set in the target
  10777. * @param value defines the value to set in the property
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10781. /** @hidden */
  10782. _prepare(): void;
  10783. /**
  10784. * Execute the action and set the targetted property to the desired value.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to increment the target value
  10796. * to a desired value once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class IncrementValueAction extends Action {
  10800. /**
  10801. * The path of the property to increment in the target.
  10802. */
  10803. propertyPath: string;
  10804. /**
  10805. * The value we should increment the property by.
  10806. */
  10807. value: any;
  10808. private _target;
  10809. private _effectiveTarget;
  10810. private _property;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the object containing the property
  10815. * @param propertyPath defines the path of the property to increment in the target
  10816. * @param value defines the value value we should increment the property by
  10817. * @param condition defines the trigger related conditions
  10818. */
  10819. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10820. /** @hidden */
  10821. _prepare(): void;
  10822. /**
  10823. * Execute the action and increment the target of the value amount.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to start an animation once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class PlayAnimationAction extends Action {
  10838. /**
  10839. * Where the animation should start (animation frame)
  10840. */
  10841. from: number;
  10842. /**
  10843. * Where the animation should stop (animation frame)
  10844. */
  10845. to: number;
  10846. /**
  10847. * Define if the animation should loop or stop after the first play.
  10848. */
  10849. loop?: boolean;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target animation or animation name
  10855. * @param from defines from where the animation should start (animation frame)
  10856. * @param end defines where the animation should stop (animation frame)
  10857. * @param loop defines if the animation should loop or stop after the first play
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10861. /** @hidden */
  10862. _prepare(): void;
  10863. /**
  10864. * Execute the action and play the animation.
  10865. */
  10866. execute(): void;
  10867. /**
  10868. * Serializes the actions and its related information.
  10869. * @param parent defines the object to serialize in
  10870. * @returns the serialized object
  10871. */
  10872. serialize(parent: any): any;
  10873. }
  10874. /**
  10875. * This defines an action responsible to stop an animation once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class StopAnimationAction extends Action {
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action and stop the animation.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible that does nothing once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class DoNothingAction extends Action {
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions?: any, condition?: Condition);
  10911. /**
  10912. * Execute the action and do nothing.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to trigger several actions once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class CombineAction extends Action {
  10927. /**
  10928. * The list of aggregated animations to run.
  10929. */
  10930. children: Action[];
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param children defines the list of aggregated animations to run
  10935. * @param condition defines the trigger related conditions
  10936. */
  10937. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10938. /** @hidden */
  10939. _prepare(): void;
  10940. /**
  10941. * Execute the action and executes all the aggregated actions.
  10942. */
  10943. execute(evt: ActionEvent): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to run code (external event) once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class ExecuteCodeAction extends Action {
  10956. /**
  10957. * The callback function to run.
  10958. */
  10959. func: (evt: ActionEvent) => void;
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param func defines the callback function to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10967. /**
  10968. * Execute the action and run the attached code.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. }
  10972. /**
  10973. * This defines an action responsible to set the parent property of the target once triggered.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class SetParentAction extends Action {
  10977. private _parent;
  10978. private _target;
  10979. /**
  10980. * Instantiate the action
  10981. * @param triggerOptions defines the trigger options
  10982. * @param target defines the target containing the parent property
  10983. * @param parent defines from where the animation should start (animation frame)
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10987. /** @hidden */
  10988. _prepare(): void;
  10989. /**
  10990. * Execute the action and set the parent property.
  10991. */
  10992. execute(): void;
  10993. /**
  10994. * Serializes the actions and its related information.
  10995. * @param parent defines the object to serialize in
  10996. * @returns the serialized object
  10997. */
  10998. serialize(parent: any): any;
  10999. }
  11000. }
  11001. declare module "babylonjs/Actions/actionManager" {
  11002. import { Nullable } from "babylonjs/types";
  11003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11004. import { Scene } from "babylonjs/scene";
  11005. import { IAction } from "babylonjs/Actions/action";
  11006. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11007. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11008. /**
  11009. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11010. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class ActionManager extends AbstractActionManager {
  11014. /**
  11015. * Nothing
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11017. */
  11018. static readonly NothingTrigger: number;
  11019. /**
  11020. * On pick
  11021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11022. */
  11023. static readonly OnPickTrigger: number;
  11024. /**
  11025. * On left pick
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnLeftPickTrigger: number;
  11029. /**
  11030. * On right pick
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnRightPickTrigger: number;
  11034. /**
  11035. * On center pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnCenterPickTrigger: number;
  11039. /**
  11040. * On pick down
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickDownTrigger: number;
  11044. /**
  11045. * On double pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnDoublePickTrigger: number;
  11049. /**
  11050. * On pick up
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnPickUpTrigger: number;
  11054. /**
  11055. * On pick out.
  11056. * This trigger will only be raised if you also declared a OnPickDown
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickOutTrigger: number;
  11060. /**
  11061. * On long press
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnLongPressTrigger: number;
  11065. /**
  11066. * On pointer over
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPointerOverTrigger: number;
  11070. /**
  11071. * On pointer out
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPointerOutTrigger: number;
  11075. /**
  11076. * On every frame
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnEveryFrameTrigger: number;
  11080. /**
  11081. * On intersection enter
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnIntersectionEnterTrigger: number;
  11085. /**
  11086. * On intersection exit
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnIntersectionExitTrigger: number;
  11090. /**
  11091. * On key down
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnKeyDownTrigger: number;
  11095. /**
  11096. * On key up
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnKeyUpTrigger: number;
  11100. private _scene;
  11101. /**
  11102. * Creates a new action manager
  11103. * @param scene defines the hosting scene
  11104. */
  11105. constructor(scene: Scene);
  11106. /**
  11107. * Releases all associated resources
  11108. */
  11109. dispose(): void;
  11110. /**
  11111. * Gets hosting scene
  11112. * @returns the hosting scene
  11113. */
  11114. getScene(): Scene;
  11115. /**
  11116. * Does this action manager handles actions of any of the given triggers
  11117. * @param triggers defines the triggers to be tested
  11118. * @return a boolean indicating whether one (or more) of the triggers is handled
  11119. */
  11120. hasSpecificTriggers(triggers: number[]): boolean;
  11121. /**
  11122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11123. * speed.
  11124. * @param triggerA defines the trigger to be tested
  11125. * @param triggerB defines the trigger to be tested
  11126. * @return a boolean indicating whether one (or more) of the triggers is handled
  11127. */
  11128. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11129. /**
  11130. * Does this action manager handles actions of a given trigger
  11131. * @param trigger defines the trigger to be tested
  11132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11133. * @return whether the trigger is handled
  11134. */
  11135. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11136. /**
  11137. * Does this action manager has pointer triggers
  11138. */
  11139. readonly hasPointerTriggers: boolean;
  11140. /**
  11141. * Does this action manager has pick triggers
  11142. */
  11143. readonly hasPickTriggers: boolean;
  11144. /**
  11145. * Registers an action to this action manager
  11146. * @param action defines the action to be registered
  11147. * @return the action amended (prepared) after registration
  11148. */
  11149. registerAction(action: IAction): Nullable<IAction>;
  11150. /**
  11151. * Unregisters an action to this action manager
  11152. * @param action defines the action to be unregistered
  11153. * @return a boolean indicating whether the action has been unregistered
  11154. */
  11155. unregisterAction(action: IAction): Boolean;
  11156. /**
  11157. * Process a specific trigger
  11158. * @param trigger defines the trigger to process
  11159. * @param evt defines the event details to be processed
  11160. */
  11161. processTrigger(trigger: number, evt?: IActionEvent): void;
  11162. /** @hidden */
  11163. _getEffectiveTarget(target: any, propertyPath: string): any;
  11164. /** @hidden */
  11165. _getProperty(propertyPath: string): string;
  11166. /**
  11167. * Serialize this manager to a JSON object
  11168. * @param name defines the property name to store this manager
  11169. * @returns a JSON representation of this manager
  11170. */
  11171. serialize(name: string): any;
  11172. /**
  11173. * Creates a new ActionManager from a JSON data
  11174. * @param parsedActions defines the JSON data to read from
  11175. * @param object defines the hosting mesh
  11176. * @param scene defines the hosting scene
  11177. */
  11178. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11179. /**
  11180. * Get a trigger name by index
  11181. * @param trigger defines the trigger index
  11182. * @returns a trigger name
  11183. */
  11184. static GetTriggerName(trigger: number): string;
  11185. }
  11186. }
  11187. declare module "babylonjs/Culling/ray" {
  11188. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11192. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11193. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11194. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11195. import { Plane } from "babylonjs/Maths/math.plane";
  11196. /**
  11197. * Class representing a ray with position and direction
  11198. */
  11199. export class Ray {
  11200. /** origin point */
  11201. origin: Vector3;
  11202. /** direction */
  11203. direction: Vector3;
  11204. /** length of the ray */
  11205. length: number;
  11206. private static readonly TmpVector3;
  11207. private _tmpRay;
  11208. /**
  11209. * Creates a new ray
  11210. * @param origin origin point
  11211. * @param direction direction
  11212. * @param length length of the ray
  11213. */
  11214. constructor(
  11215. /** origin point */
  11216. origin: Vector3,
  11217. /** direction */
  11218. direction: Vector3,
  11219. /** length of the ray */
  11220. length?: number);
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param minimum bound of the box
  11224. * @param maximum bound of the box
  11225. * @param intersectionTreshold extra extend to be added to the box in all direction
  11226. * @returns if the box was hit
  11227. */
  11228. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param box the bounding box to check
  11232. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * If the ray hits a sphere
  11238. * @param sphere the bounding sphere to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11240. * @returns true if it hits the sphere
  11241. */
  11242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a triange
  11245. * @param vertex0 triangle vertex
  11246. * @param vertex1 triangle vertex
  11247. * @param vertex2 triangle vertex
  11248. * @returns intersection information if hit
  11249. */
  11250. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11251. /**
  11252. * Checks if ray intersects a plane
  11253. * @param plane the plane to check
  11254. * @returns the distance away it was hit
  11255. */
  11256. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11257. /**
  11258. * Calculate the intercept of a ray on a given axis
  11259. * @param axis to check 'x' | 'y' | 'z'
  11260. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11261. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11262. */
  11263. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11264. /**
  11265. * Checks if ray intersects a mesh
  11266. * @param mesh the mesh to check
  11267. * @param fastCheck if only the bounding box should checked
  11268. * @returns picking info of the intersecton
  11269. */
  11270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param meshes the meshes to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @param results array to store result in
  11276. * @returns Array of picking infos
  11277. */
  11278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11279. private _comparePickingInfo;
  11280. private static smallnum;
  11281. private static rayl;
  11282. /**
  11283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11284. * @param sega the first point of the segment to test the intersection against
  11285. * @param segb the second point of the segment to test the intersection against
  11286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11288. */
  11289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11290. /**
  11291. * Update the ray from viewport position
  11292. * @param x position
  11293. * @param y y position
  11294. * @param viewportWidth viewport width
  11295. * @param viewportHeight viewport height
  11296. * @param world world matrix
  11297. * @param view view matrix
  11298. * @param projection projection matrix
  11299. * @returns this ray updated
  11300. */
  11301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Creates a ray with origin and direction of 0,0,0
  11304. * @returns the new ray
  11305. */
  11306. static Zero(): Ray;
  11307. /**
  11308. * Creates a new ray from screen space and viewport
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns new ray
  11317. */
  11318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * 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
  11321. * transformed to the given world matrix.
  11322. * @param origin The origin point
  11323. * @param end The end point
  11324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11325. * @returns the new ray
  11326. */
  11327. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11328. /**
  11329. * Transforms a ray by a matrix
  11330. * @param ray ray to transform
  11331. * @param matrix matrix to apply
  11332. * @returns the resulting new ray
  11333. */
  11334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @param result ray to store result in
  11340. */
  11341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11342. /**
  11343. * Unproject a ray from screen space to object space
  11344. * @param sourceX defines the screen space x coordinate to use
  11345. * @param sourceY defines the screen space y coordinate to use
  11346. * @param viewportWidth defines the current width of the viewport
  11347. * @param viewportHeight defines the current height of the viewport
  11348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11349. * @param view defines the view matrix to use
  11350. * @param projection defines the projection matrix to use
  11351. */
  11352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11353. }
  11354. /**
  11355. * Type used to define predicate used to select faces when a mesh intersection is detected
  11356. */
  11357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11358. module "babylonjs/scene" {
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. }
  11373. declare module "babylonjs/sceneComponent" {
  11374. import { Scene } from "babylonjs/scene";
  11375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11377. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11378. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11382. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11383. import { AbstractScene } from "babylonjs/abstractScene";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. /**
  11386. * Groups all the scene component constants in one place to ease maintenance.
  11387. * @hidden
  11388. */
  11389. export class SceneComponentConstants {
  11390. static readonly NAME_EFFECTLAYER: string;
  11391. static readonly NAME_LAYER: string;
  11392. static readonly NAME_LENSFLARESYSTEM: string;
  11393. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11394. static readonly NAME_PARTICLESYSTEM: string;
  11395. static readonly NAME_GAMEPAD: string;
  11396. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11397. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11398. static readonly NAME_DEPTHRENDERER: string;
  11399. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11400. static readonly NAME_SPRITE: string;
  11401. static readonly NAME_OUTLINERENDERER: string;
  11402. static readonly NAME_PROCEDURALTEXTURE: string;
  11403. static readonly NAME_SHADOWGENERATOR: string;
  11404. static readonly NAME_OCTREE: string;
  11405. static readonly NAME_PHYSICSENGINE: string;
  11406. static readonly NAME_AUDIO: string;
  11407. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11408. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11412. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11414. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11416. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11419. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11421. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11422. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11423. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11425. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11426. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11427. static readonly STEP_AFTERRENDER_AUDIO: number;
  11428. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11432. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11433. static readonly STEP_POINTERMOVE_SPRITE: number;
  11434. static readonly STEP_POINTERDOWN_SPRITE: number;
  11435. static readonly STEP_POINTERUP_SPRITE: number;
  11436. }
  11437. /**
  11438. * This represents a scene component.
  11439. *
  11440. * This is used to decouple the dependency the scene is having on the different workloads like
  11441. * layers, post processes...
  11442. */
  11443. export interface ISceneComponent {
  11444. /**
  11445. * The name of the component. Each component must have a unique name.
  11446. */
  11447. name: string;
  11448. /**
  11449. * The scene the component belongs to.
  11450. */
  11451. scene: Scene;
  11452. /**
  11453. * Register the component to one instance of a scene.
  11454. */
  11455. register(): void;
  11456. /**
  11457. * Rebuilds the elements related to this component in case of
  11458. * context lost for instance.
  11459. */
  11460. rebuild(): void;
  11461. /**
  11462. * Disposes the component and the associated ressources.
  11463. */
  11464. dispose(): void;
  11465. }
  11466. /**
  11467. * This represents a SERIALIZABLE scene component.
  11468. *
  11469. * This extends Scene Component to add Serialization methods on top.
  11470. */
  11471. export interface ISceneSerializableComponent extends ISceneComponent {
  11472. /**
  11473. * Adds all the elements from the container to the scene
  11474. * @param container the container holding the elements
  11475. */
  11476. addFromContainer(container: AbstractScene): void;
  11477. /**
  11478. * Removes all the elements in the container from the scene
  11479. * @param container contains the elements to remove
  11480. * @param dispose if the removed element should be disposed (default: false)
  11481. */
  11482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11483. /**
  11484. * Serializes the component data to the specified json object
  11485. * @param serializationObject The object to serialize to
  11486. */
  11487. serialize(serializationObject: any): void;
  11488. }
  11489. /**
  11490. * Strong typing of a Mesh related stage step action
  11491. */
  11492. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11493. /**
  11494. * Strong typing of a Evaluate Sub Mesh related stage step action
  11495. */
  11496. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11497. /**
  11498. * Strong typing of a Active Mesh related stage step action
  11499. */
  11500. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11501. /**
  11502. * Strong typing of a Camera related stage step action
  11503. */
  11504. export type CameraStageAction = (camera: Camera) => void;
  11505. /**
  11506. * Strong typing of a Camera Frame buffer related stage step action
  11507. */
  11508. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Representation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Scene } from "babylonjs/scene";
  11573. import { Sprite } from "babylonjs/Sprites/sprite";
  11574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11575. import { Ray } from "babylonjs/Culling/ray";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11578. import { ISceneComponent } from "babylonjs/sceneComponent";
  11579. module "babylonjs/scene" {
  11580. interface Scene {
  11581. /** @hidden */
  11582. _pointerOverSprite: Nullable<Sprite>;
  11583. /** @hidden */
  11584. _pickedDownSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _tempSpritePickingRay: Nullable<Ray>;
  11587. /**
  11588. * All of the sprite managers added to this scene
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. spriteManagers: Array<ISpriteManager>;
  11592. /**
  11593. * An event triggered when sprites rendering is about to start
  11594. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11595. */
  11596. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11597. /**
  11598. * An event triggered when sprites rendering is done
  11599. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11600. */
  11601. onAfterSpritesRenderingObservable: Observable<Scene>;
  11602. /** @hidden */
  11603. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Launch a ray to try to pick a sprite in the scene
  11605. * @param x position on screen
  11606. * @param y position on screen
  11607. * @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
  11608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11610. * @returns a PickingInfo
  11611. */
  11612. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11613. /** Use the given ray to pick a sprite in the scene
  11614. * @param ray The ray (in world space) to use to pick meshes
  11615. * @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
  11616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11617. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11618. * @returns a PickingInfo
  11619. */
  11620. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11621. /** @hidden */
  11622. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11623. /** Launch a ray to try to pick sprites in the scene
  11624. * @param x position on screen
  11625. * @param y position on screen
  11626. * @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
  11627. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11628. * @returns a PickingInfo array
  11629. */
  11630. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11631. /** Use the given ray to pick sprites in the scene
  11632. * @param ray The ray (in world space) to use to pick meshes
  11633. * @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
  11634. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11635. * @returns a PickingInfo array
  11636. */
  11637. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11638. /**
  11639. * Force the sprite under the pointer
  11640. * @param sprite defines the sprite to use
  11641. */
  11642. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11643. /**
  11644. * Gets the sprite under the pointer
  11645. * @returns a Sprite or null if no sprite is under the pointer
  11646. */
  11647. getPointerOverSprite(): Nullable<Sprite>;
  11648. }
  11649. }
  11650. /**
  11651. * Defines the sprite scene component responsible to manage sprites
  11652. * in a given scene.
  11653. */
  11654. export class SpriteSceneComponent implements ISceneComponent {
  11655. /**
  11656. * The component name helpfull to identify the component in the list of scene components.
  11657. */
  11658. readonly name: string;
  11659. /**
  11660. * The scene the component belongs to.
  11661. */
  11662. scene: Scene;
  11663. /** @hidden */
  11664. private _spritePredicate;
  11665. /**
  11666. * Creates a new instance of the component for the given scene
  11667. * @param scene Defines the scene to register the component in
  11668. */
  11669. constructor(scene: Scene);
  11670. /**
  11671. * Registers the component in a given scene
  11672. */
  11673. register(): void;
  11674. /**
  11675. * Rebuilds the elements related to this component in case of
  11676. * context lost for instance.
  11677. */
  11678. rebuild(): void;
  11679. /**
  11680. * Disposes the component and the associated ressources.
  11681. */
  11682. dispose(): void;
  11683. private _pickSpriteButKeepRay;
  11684. private _pointerMove;
  11685. private _pointerDown;
  11686. private _pointerUp;
  11687. }
  11688. }
  11689. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11690. /** @hidden */
  11691. export var fogFragmentDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11697. /** @hidden */
  11698. export var fogFragment: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.fragment" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11705. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11706. /** @hidden */
  11707. export var spritesPixelShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11713. /** @hidden */
  11714. export var fogVertexDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/sprites.vertex" {
  11720. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11721. /** @hidden */
  11722. export var spritesVertexShader: {
  11723. name: string;
  11724. shader: string;
  11725. };
  11726. }
  11727. declare module "babylonjs/Sprites/spriteManager" {
  11728. import { IDisposable, Scene } from "babylonjs/scene";
  11729. import { Nullable } from "babylonjs/types";
  11730. import { Observable } from "babylonjs/Misc/observable";
  11731. import { Sprite } from "babylonjs/Sprites/sprite";
  11732. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { Texture } from "babylonjs/Materials/Textures/texture";
  11735. import "babylonjs/Shaders/sprites.fragment";
  11736. import "babylonjs/Shaders/sprites.vertex";
  11737. import { Ray } from "babylonjs/Culling/ray";
  11738. /**
  11739. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11740. */
  11741. export interface ISpriteManager extends IDisposable {
  11742. /**
  11743. * Restricts the camera to viewing objects with the same layerMask.
  11744. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11745. */
  11746. layerMask: number;
  11747. /**
  11748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11749. */
  11750. isPickable: boolean;
  11751. /**
  11752. * Specifies the rendering group id for this mesh (0 by default)
  11753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11754. */
  11755. renderingGroupId: number;
  11756. /**
  11757. * Defines the list of sprites managed by the manager.
  11758. */
  11759. sprites: Array<Sprite>;
  11760. /**
  11761. * Tests the intersection of a sprite with a specific ray.
  11762. * @param ray The ray we are sending to test the collision
  11763. * @param camera The camera space we are sending rays in
  11764. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11765. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11766. * @returns picking info or null.
  11767. */
  11768. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11769. /**
  11770. * Intersects the sprites with a ray
  11771. * @param ray defines the ray to intersect with
  11772. * @param camera defines the current active camera
  11773. * @param predicate defines a predicate used to select candidate sprites
  11774. * @returns null if no hit or a PickingInfo array
  11775. */
  11776. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11777. /**
  11778. * Renders the list of sprites on screen.
  11779. */
  11780. render(): void;
  11781. }
  11782. /**
  11783. * Class used to manage multiple sprites on the same spritesheet
  11784. * @see http://doc.babylonjs.com/babylon101/sprites
  11785. */
  11786. export class SpriteManager implements ISpriteManager {
  11787. /** defines the manager's name */
  11788. name: string;
  11789. /** Gets the list of sprites */
  11790. sprites: Sprite[];
  11791. /** Gets or sets the rendering group id (0 by default) */
  11792. renderingGroupId: number;
  11793. /** Gets or sets camera layer mask */
  11794. layerMask: number;
  11795. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11796. fogEnabled: boolean;
  11797. /** Gets or sets a boolean indicating if the sprites are pickable */
  11798. isPickable: boolean;
  11799. /** Defines the default width of a cell in the spritesheet */
  11800. cellWidth: number;
  11801. /** Defines the default height of a cell in the spritesheet */
  11802. cellHeight: number;
  11803. /** Associative array from JSON sprite data file */
  11804. private _cellData;
  11805. /** Array of sprite names from JSON sprite data file */
  11806. private _spriteMap;
  11807. /** True when packed cell data from JSON file is ready*/
  11808. private _packedAndReady;
  11809. /**
  11810. * An event triggered when the manager is disposed.
  11811. */
  11812. onDisposeObservable: Observable<SpriteManager>;
  11813. private _onDisposeObserver;
  11814. /**
  11815. * Callback called when the manager is disposed
  11816. */
  11817. onDispose: () => void;
  11818. private _capacity;
  11819. private _fromPacked;
  11820. private _spriteTexture;
  11821. private _epsilon;
  11822. private _scene;
  11823. private _vertexData;
  11824. private _buffer;
  11825. private _vertexBuffers;
  11826. private _indexBuffer;
  11827. private _effectBase;
  11828. private _effectFog;
  11829. /**
  11830. * Gets or sets the spritesheet texture
  11831. */
  11832. texture: Texture;
  11833. /**
  11834. * Creates a new sprite manager
  11835. * @param name defines the manager's name
  11836. * @param imgUrl defines the sprite sheet url
  11837. * @param capacity defines the maximum allowed number of sprites
  11838. * @param cellSize defines the size of a sprite cell
  11839. * @param scene defines the hosting scene
  11840. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11841. * @param samplingMode defines the smapling mode to use with spritesheet
  11842. * @param fromPacked set to false; do not alter
  11843. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11844. */
  11845. constructor(
  11846. /** defines the manager's name */
  11847. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11848. private _makePacked;
  11849. private _appendSpriteVertex;
  11850. /**
  11851. * Intersects the sprites with a ray
  11852. * @param ray defines the ray to intersect with
  11853. * @param camera defines the current active camera
  11854. * @param predicate defines a predicate used to select candidate sprites
  11855. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11856. * @returns null if no hit or a PickingInfo
  11857. */
  11858. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11859. /**
  11860. * Intersects the sprites with a ray
  11861. * @param ray defines the ray to intersect with
  11862. * @param camera defines the current active camera
  11863. * @param predicate defines a predicate used to select candidate sprites
  11864. * @returns null if no hit or a PickingInfo array
  11865. */
  11866. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11867. /**
  11868. * Render all child sprites
  11869. */
  11870. render(): void;
  11871. /**
  11872. * Release associated resources
  11873. */
  11874. dispose(): void;
  11875. }
  11876. }
  11877. declare module "babylonjs/Sprites/sprite" {
  11878. import { Vector3 } from "babylonjs/Maths/math.vector";
  11879. import { Nullable } from "babylonjs/types";
  11880. import { ActionManager } from "babylonjs/Actions/actionManager";
  11881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11882. import { Color4 } from "babylonjs/Maths/math.color";
  11883. /**
  11884. * Class used to represent a sprite
  11885. * @see http://doc.babylonjs.com/babylon101/sprites
  11886. */
  11887. export class Sprite {
  11888. /** defines the name */
  11889. name: string;
  11890. /** Gets or sets the current world position */
  11891. position: Vector3;
  11892. /** Gets or sets the main color */
  11893. color: Color4;
  11894. /** Gets or sets the width */
  11895. width: number;
  11896. /** Gets or sets the height */
  11897. height: number;
  11898. /** Gets or sets rotation angle */
  11899. angle: number;
  11900. /** Gets or sets the cell index in the sprite sheet */
  11901. cellIndex: number;
  11902. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11903. cellRef: string;
  11904. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11905. invertU: number;
  11906. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11907. invertV: number;
  11908. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11909. disposeWhenFinishedAnimating: boolean;
  11910. /** Gets the list of attached animations */
  11911. animations: Animation[];
  11912. /** Gets or sets a boolean indicating if the sprite can be picked */
  11913. isPickable: boolean;
  11914. /**
  11915. * Gets or sets the associated action manager
  11916. */
  11917. actionManager: Nullable<ActionManager>;
  11918. private _animationStarted;
  11919. private _loopAnimation;
  11920. private _fromIndex;
  11921. private _toIndex;
  11922. private _delay;
  11923. private _direction;
  11924. private _manager;
  11925. private _time;
  11926. private _onAnimationEnd;
  11927. /**
  11928. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11929. */
  11930. isVisible: boolean;
  11931. /**
  11932. * Gets or sets the sprite size
  11933. */
  11934. size: number;
  11935. /**
  11936. * Creates a new Sprite
  11937. * @param name defines the name
  11938. * @param manager defines the manager
  11939. */
  11940. constructor(
  11941. /** defines the name */
  11942. name: string, manager: ISpriteManager);
  11943. /**
  11944. * Starts an animation
  11945. * @param from defines the initial key
  11946. * @param to defines the end key
  11947. * @param loop defines if the animation must loop
  11948. * @param delay defines the start delay (in ms)
  11949. * @param onAnimationEnd defines a callback to call when animation ends
  11950. */
  11951. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11952. /** Stops current animation (if any) */
  11953. stopAnimation(): void;
  11954. /** @hidden */
  11955. _animate(deltaTime: number): void;
  11956. /** Release associated resources */
  11957. dispose(): void;
  11958. }
  11959. }
  11960. declare module "babylonjs/Collisions/pickingInfo" {
  11961. import { Nullable } from "babylonjs/types";
  11962. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11964. import { Sprite } from "babylonjs/Sprites/sprite";
  11965. import { Ray } from "babylonjs/Culling/ray";
  11966. /**
  11967. * Information about the result of picking within a scene
  11968. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11969. */
  11970. export class PickingInfo {
  11971. /** @hidden */
  11972. _pickingUnavailable: boolean;
  11973. /**
  11974. * If the pick collided with an object
  11975. */
  11976. hit: boolean;
  11977. /**
  11978. * Distance away where the pick collided
  11979. */
  11980. distance: number;
  11981. /**
  11982. * The location of pick collision
  11983. */
  11984. pickedPoint: Nullable<Vector3>;
  11985. /**
  11986. * The mesh corresponding the the pick collision
  11987. */
  11988. pickedMesh: Nullable<AbstractMesh>;
  11989. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11990. bu: number;
  11991. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11992. bv: number;
  11993. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11994. faceId: number;
  11995. /** Id of the the submesh that was picked */
  11996. subMeshId: number;
  11997. /** If a sprite was picked, this will be the sprite the pick collided with */
  11998. pickedSprite: Nullable<Sprite>;
  11999. /**
  12000. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12001. */
  12002. originMesh: Nullable<AbstractMesh>;
  12003. /**
  12004. * The ray that was used to perform the picking.
  12005. */
  12006. ray: Nullable<Ray>;
  12007. /**
  12008. * Gets the normal correspodning to the face the pick collided with
  12009. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12010. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12011. * @returns The normal correspodning to the face the pick collided with
  12012. */
  12013. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12014. /**
  12015. * Gets the texture coordinates of where the pick occured
  12016. * @returns the vector containing the coordnates of the texture
  12017. */
  12018. getTextureCoordinates(): Nullable<Vector2>;
  12019. }
  12020. }
  12021. declare module "babylonjs/Events/pointerEvents" {
  12022. import { Nullable } from "babylonjs/types";
  12023. import { Vector2 } from "babylonjs/Maths/math.vector";
  12024. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12025. import { Ray } from "babylonjs/Culling/ray";
  12026. /**
  12027. * Gather the list of pointer event types as constants.
  12028. */
  12029. export class PointerEventTypes {
  12030. /**
  12031. * 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.
  12032. */
  12033. static readonly POINTERDOWN: number;
  12034. /**
  12035. * The pointerup event is fired when a pointer is no longer active.
  12036. */
  12037. static readonly POINTERUP: number;
  12038. /**
  12039. * The pointermove event is fired when a pointer changes coordinates.
  12040. */
  12041. static readonly POINTERMOVE: number;
  12042. /**
  12043. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12044. */
  12045. static readonly POINTERWHEEL: number;
  12046. /**
  12047. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12048. */
  12049. static readonly POINTERPICK: number;
  12050. /**
  12051. * The pointertap event is fired when a the object has been touched and released without drag.
  12052. */
  12053. static readonly POINTERTAP: number;
  12054. /**
  12055. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12056. */
  12057. static readonly POINTERDOUBLETAP: number;
  12058. }
  12059. /**
  12060. * Base class of pointer info types.
  12061. */
  12062. export class PointerInfoBase {
  12063. /**
  12064. * Defines the type of event (PointerEventTypes)
  12065. */
  12066. type: number;
  12067. /**
  12068. * Defines the related dom event
  12069. */
  12070. event: PointerEvent | MouseWheelEvent;
  12071. /**
  12072. * Instantiates the base class of pointers info.
  12073. * @param type Defines the type of event (PointerEventTypes)
  12074. * @param event Defines the related dom event
  12075. */
  12076. constructor(
  12077. /**
  12078. * Defines the type of event (PointerEventTypes)
  12079. */
  12080. type: number,
  12081. /**
  12082. * Defines the related dom event
  12083. */
  12084. event: PointerEvent | MouseWheelEvent);
  12085. }
  12086. /**
  12087. * This class is used to store pointer related info for the onPrePointerObservable event.
  12088. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12089. */
  12090. export class PointerInfoPre extends PointerInfoBase {
  12091. /**
  12092. * Ray from a pointer if availible (eg. 6dof controller)
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Defines the local position of the pointer on the canvas.
  12097. */
  12098. localPosition: Vector2;
  12099. /**
  12100. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12101. */
  12102. skipOnPointerObservable: boolean;
  12103. /**
  12104. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12105. * @param type Defines the type of event (PointerEventTypes)
  12106. * @param event Defines the related dom event
  12107. * @param localX Defines the local x coordinates of the pointer when the event occured
  12108. * @param localY Defines the local y coordinates of the pointer when the event occured
  12109. */
  12110. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12111. }
  12112. /**
  12113. * This type contains all the data related to a pointer event in Babylon.js.
  12114. * 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.
  12115. */
  12116. export class PointerInfo extends PointerInfoBase {
  12117. /**
  12118. * Defines the picking info associated to the info (if any)\
  12119. */
  12120. pickInfo: Nullable<PickingInfo>;
  12121. /**
  12122. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12123. * @param type Defines the type of event (PointerEventTypes)
  12124. * @param event Defines the related dom event
  12125. * @param pickInfo Defines the picking info associated to the info (if any)\
  12126. */
  12127. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12128. /**
  12129. * Defines the picking info associated to the info (if any)\
  12130. */
  12131. pickInfo: Nullable<PickingInfo>);
  12132. }
  12133. /**
  12134. * Data relating to a touch event on the screen.
  12135. */
  12136. export interface PointerTouch {
  12137. /**
  12138. * X coordinate of touch.
  12139. */
  12140. x: number;
  12141. /**
  12142. * Y coordinate of touch.
  12143. */
  12144. y: number;
  12145. /**
  12146. * Id of touch. Unique for each finger.
  12147. */
  12148. pointerId: number;
  12149. /**
  12150. * Event type passed from DOM.
  12151. */
  12152. type: any;
  12153. }
  12154. }
  12155. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12156. import { Observable } from "babylonjs/Misc/observable";
  12157. import { Nullable } from "babylonjs/types";
  12158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12159. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12160. /**
  12161. * Manage the mouse inputs to control the movement of a free camera.
  12162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12163. */
  12164. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12165. /**
  12166. * Define if touch is enabled in the mouse input
  12167. */
  12168. touchEnabled: boolean;
  12169. /**
  12170. * Defines the camera the input is attached to.
  12171. */
  12172. camera: FreeCamera;
  12173. /**
  12174. * Defines the buttons associated with the input to handle camera move.
  12175. */
  12176. buttons: number[];
  12177. /**
  12178. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12179. */
  12180. angularSensibility: number;
  12181. private _pointerInput;
  12182. private _onMouseMove;
  12183. private _observer;
  12184. private previousPosition;
  12185. /**
  12186. * Observable for when a pointer move event occurs containing the move offset
  12187. */
  12188. onPointerMovedObservable: Observable<{
  12189. offsetX: number;
  12190. offsetY: number;
  12191. }>;
  12192. /**
  12193. * @hidden
  12194. * If the camera should be rotated automatically based on pointer movement
  12195. */
  12196. _allowCameraRotation: boolean;
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. * @param touchEnabled Defines if touch is enabled or not
  12201. */
  12202. constructor(
  12203. /**
  12204. * Define if touch is enabled in the mouse input
  12205. */
  12206. touchEnabled?: boolean);
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Called on JS contextmenu event.
  12215. * Override this method to provide functionality.
  12216. */
  12217. protected onContextMenu(evt: PointerEvent): void;
  12218. /**
  12219. * Detach the current controls from the specified dom element.
  12220. * @param element Defines the element to stop listening the inputs from
  12221. */
  12222. detachControl(element: Nullable<HTMLElement>): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12236. import { Nullable } from "babylonjs/types";
  12237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12239. /**
  12240. * Manage the touch inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12244. /**
  12245. * Defines the camera the input is attached to.
  12246. */
  12247. camera: FreeCamera;
  12248. /**
  12249. * Defines the touch sensibility for rotation.
  12250. * The higher the faster.
  12251. */
  12252. touchAngularSensibility: number;
  12253. /**
  12254. * Defines the touch sensibility for move.
  12255. * The higher the faster.
  12256. */
  12257. touchMoveSensibility: number;
  12258. private _offsetX;
  12259. private _offsetY;
  12260. private _pointerPressed;
  12261. private _pointerInput;
  12262. private _observer;
  12263. private _onLostFocus;
  12264. /**
  12265. * Attach the input controls to a specific dom element to get the input from.
  12266. * @param element Defines the element the controls should be listened from
  12267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12268. */
  12269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12270. /**
  12271. * Detach the current controls from the specified dom element.
  12272. * @param element Defines the element to stop listening the inputs from
  12273. */
  12274. detachControl(element: Nullable<HTMLElement>): void;
  12275. /**
  12276. * Update the current camera state depending on the inputs that have been used this frame.
  12277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12278. */
  12279. checkInputs(): void;
  12280. /**
  12281. * Gets the class name of the current intput.
  12282. * @returns the class name
  12283. */
  12284. getClassName(): string;
  12285. /**
  12286. * Get the friendly name associated with the input class.
  12287. * @returns the input friendly name
  12288. */
  12289. getSimpleName(): string;
  12290. }
  12291. }
  12292. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12295. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12296. import { Nullable } from "babylonjs/types";
  12297. /**
  12298. * Default Inputs manager for the FreeCamera.
  12299. * It groups all the default supported inputs for ease of use.
  12300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12301. */
  12302. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12303. /**
  12304. * @hidden
  12305. */
  12306. _mouseInput: Nullable<FreeCameraMouseInput>;
  12307. /**
  12308. * Instantiates a new FreeCameraInputsManager.
  12309. * @param camera Defines the camera the inputs belong to
  12310. */
  12311. constructor(camera: FreeCamera);
  12312. /**
  12313. * Add keyboard input support to the input manager.
  12314. * @returns the current input manager
  12315. */
  12316. addKeyboard(): FreeCameraInputsManager;
  12317. /**
  12318. * Add mouse input support to the input manager.
  12319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12320. * @returns the current input manager
  12321. */
  12322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12323. /**
  12324. * Removes the mouse input support from the manager
  12325. * @returns the current input manager
  12326. */
  12327. removeMouse(): FreeCameraInputsManager;
  12328. /**
  12329. * Add touch input support to the input manager.
  12330. * @returns the current input manager
  12331. */
  12332. addTouch(): FreeCameraInputsManager;
  12333. /**
  12334. * Remove all attached input methods from a camera
  12335. */
  12336. clear(): void;
  12337. }
  12338. }
  12339. declare module "babylonjs/Cameras/freeCamera" {
  12340. import { Vector3 } from "babylonjs/Maths/math.vector";
  12341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12342. import { Scene } from "babylonjs/scene";
  12343. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12344. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12345. /**
  12346. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12347. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12349. */
  12350. export class FreeCamera extends TargetCamera {
  12351. /**
  12352. * Define the collision ellipsoid of the camera.
  12353. * This is helpful to simulate a camera body like the player body around the camera
  12354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12355. */
  12356. ellipsoid: Vector3;
  12357. /**
  12358. * Define an offset for the position of the ellipsoid around the camera.
  12359. * This can be helpful to determine the center of the body near the gravity center of the body
  12360. * instead of its head.
  12361. */
  12362. ellipsoidOffset: Vector3;
  12363. /**
  12364. * Enable or disable collisions of the camera with the rest of the scene objects.
  12365. */
  12366. checkCollisions: boolean;
  12367. /**
  12368. * Enable or disable gravity on the camera.
  12369. */
  12370. applyGravity: boolean;
  12371. /**
  12372. * Define the input manager associated to the camera.
  12373. */
  12374. inputs: FreeCameraInputsManager;
  12375. /**
  12376. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12377. * Higher values reduce sensitivity.
  12378. */
  12379. /**
  12380. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12381. * Higher values reduce sensitivity.
  12382. */
  12383. angularSensibility: number;
  12384. /**
  12385. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12386. */
  12387. keysUp: number[];
  12388. /**
  12389. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12390. */
  12391. keysDown: number[];
  12392. /**
  12393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12394. */
  12395. keysLeft: number[];
  12396. /**
  12397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12398. */
  12399. keysRight: number[];
  12400. /**
  12401. * Event raised when the camera collide with a mesh in the scene.
  12402. */
  12403. onCollide: (collidedMesh: AbstractMesh) => void;
  12404. private _collider;
  12405. private _needMoveForGravity;
  12406. private _oldPosition;
  12407. private _diffPosition;
  12408. private _newPosition;
  12409. /** @hidden */
  12410. _localDirection: Vector3;
  12411. /** @hidden */
  12412. _transformedDirection: Vector3;
  12413. /**
  12414. * Instantiates a Free Camera.
  12415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12417. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12418. * @param name Define the name of the camera in the scene
  12419. * @param position Define the start position of the camera in the scene
  12420. * @param scene Define the scene the camera belongs to
  12421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12422. */
  12423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12424. /**
  12425. * Attached controls to the current camera.
  12426. * @param element Defines the element the controls should be listened from
  12427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12428. */
  12429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12430. /**
  12431. * Detach the current controls from the camera.
  12432. * The camera will stop reacting to inputs.
  12433. * @param element Defines the element to stop listening the inputs from
  12434. */
  12435. detachControl(element: HTMLElement): void;
  12436. private _collisionMask;
  12437. /**
  12438. * Define a collision mask to limit the list of object the camera can collide with
  12439. */
  12440. collisionMask: number;
  12441. /** @hidden */
  12442. _collideWithWorld(displacement: Vector3): void;
  12443. private _onCollisionPositionChange;
  12444. /** @hidden */
  12445. _checkInputs(): void;
  12446. /** @hidden */
  12447. _decideIfNeedsToMove(): boolean;
  12448. /** @hidden */
  12449. _updatePosition(): void;
  12450. /**
  12451. * Destroy the camera and release the current resources hold by it.
  12452. */
  12453. dispose(): void;
  12454. /**
  12455. * Gets the current object class name.
  12456. * @return the class name
  12457. */
  12458. getClassName(): string;
  12459. }
  12460. }
  12461. declare module "babylonjs/Gamepads/gamepad" {
  12462. import { Observable } from "babylonjs/Misc/observable";
  12463. /**
  12464. * Represents a gamepad control stick position
  12465. */
  12466. export class StickValues {
  12467. /**
  12468. * The x component of the control stick
  12469. */
  12470. x: number;
  12471. /**
  12472. * The y component of the control stick
  12473. */
  12474. y: number;
  12475. /**
  12476. * Initializes the gamepad x and y control stick values
  12477. * @param x The x component of the gamepad control stick value
  12478. * @param y The y component of the gamepad control stick value
  12479. */
  12480. constructor(
  12481. /**
  12482. * The x component of the control stick
  12483. */
  12484. x: number,
  12485. /**
  12486. * The y component of the control stick
  12487. */
  12488. y: number);
  12489. }
  12490. /**
  12491. * An interface which manages callbacks for gamepad button changes
  12492. */
  12493. export interface GamepadButtonChanges {
  12494. /**
  12495. * Called when a gamepad has been changed
  12496. */
  12497. changed: boolean;
  12498. /**
  12499. * Called when a gamepad press event has been triggered
  12500. */
  12501. pressChanged: boolean;
  12502. /**
  12503. * Called when a touch event has been triggered
  12504. */
  12505. touchChanged: boolean;
  12506. /**
  12507. * Called when a value has changed
  12508. */
  12509. valueChanged: boolean;
  12510. }
  12511. /**
  12512. * Represents a gamepad
  12513. */
  12514. export class Gamepad {
  12515. /**
  12516. * The id of the gamepad
  12517. */
  12518. id: string;
  12519. /**
  12520. * The index of the gamepad
  12521. */
  12522. index: number;
  12523. /**
  12524. * The browser gamepad
  12525. */
  12526. browserGamepad: any;
  12527. /**
  12528. * Specifies what type of gamepad this represents
  12529. */
  12530. type: number;
  12531. private _leftStick;
  12532. private _rightStick;
  12533. /** @hidden */
  12534. _isConnected: boolean;
  12535. private _leftStickAxisX;
  12536. private _leftStickAxisY;
  12537. private _rightStickAxisX;
  12538. private _rightStickAxisY;
  12539. /**
  12540. * Triggered when the left control stick has been changed
  12541. */
  12542. private _onleftstickchanged;
  12543. /**
  12544. * Triggered when the right control stick has been changed
  12545. */
  12546. private _onrightstickchanged;
  12547. /**
  12548. * Represents a gamepad controller
  12549. */
  12550. static GAMEPAD: number;
  12551. /**
  12552. * Represents a generic controller
  12553. */
  12554. static GENERIC: number;
  12555. /**
  12556. * Represents an XBox controller
  12557. */
  12558. static XBOX: number;
  12559. /**
  12560. * Represents a pose-enabled controller
  12561. */
  12562. static POSE_ENABLED: number;
  12563. /**
  12564. * Represents an Dual Shock controller
  12565. */
  12566. static DUALSHOCK: number;
  12567. /**
  12568. * Specifies whether the left control stick should be Y-inverted
  12569. */
  12570. protected _invertLeftStickY: boolean;
  12571. /**
  12572. * Specifies if the gamepad has been connected
  12573. */
  12574. readonly isConnected: boolean;
  12575. /**
  12576. * Initializes the gamepad
  12577. * @param id The id of the gamepad
  12578. * @param index The index of the gamepad
  12579. * @param browserGamepad The browser gamepad
  12580. * @param leftStickX The x component of the left joystick
  12581. * @param leftStickY The y component of the left joystick
  12582. * @param rightStickX The x component of the right joystick
  12583. * @param rightStickY The y component of the right joystick
  12584. */
  12585. constructor(
  12586. /**
  12587. * The id of the gamepad
  12588. */
  12589. id: string,
  12590. /**
  12591. * The index of the gamepad
  12592. */
  12593. index: number,
  12594. /**
  12595. * The browser gamepad
  12596. */
  12597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12598. /**
  12599. * Callback triggered when the left joystick has changed
  12600. * @param callback
  12601. */
  12602. onleftstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Callback triggered when the right joystick has changed
  12605. * @param callback
  12606. */
  12607. onrightstickchanged(callback: (values: StickValues) => void): void;
  12608. /**
  12609. * Gets the left joystick
  12610. */
  12611. /**
  12612. * Sets the left joystick values
  12613. */
  12614. leftStick: StickValues;
  12615. /**
  12616. * Gets the right joystick
  12617. */
  12618. /**
  12619. * Sets the right joystick value
  12620. */
  12621. rightStick: StickValues;
  12622. /**
  12623. * Updates the gamepad joystick positions
  12624. */
  12625. update(): void;
  12626. /**
  12627. * Disposes the gamepad
  12628. */
  12629. dispose(): void;
  12630. }
  12631. /**
  12632. * Represents a generic gamepad
  12633. */
  12634. export class GenericPad extends Gamepad {
  12635. private _buttons;
  12636. private _onbuttondown;
  12637. private _onbuttonup;
  12638. /**
  12639. * Observable triggered when a button has been pressed
  12640. */
  12641. onButtonDownObservable: Observable<number>;
  12642. /**
  12643. * Observable triggered when a button has been released
  12644. */
  12645. onButtonUpObservable: Observable<number>;
  12646. /**
  12647. * Callback triggered when a button has been pressed
  12648. * @param callback Called when a button has been pressed
  12649. */
  12650. onbuttondown(callback: (buttonPressed: number) => void): void;
  12651. /**
  12652. * Callback triggered when a button has been released
  12653. * @param callback Called when a button has been released
  12654. */
  12655. onbuttonup(callback: (buttonReleased: number) => void): void;
  12656. /**
  12657. * Initializes the generic gamepad
  12658. * @param id The id of the generic gamepad
  12659. * @param index The index of the generic gamepad
  12660. * @param browserGamepad The browser gamepad
  12661. */
  12662. constructor(id: string, index: number, browserGamepad: any);
  12663. private _setButtonValue;
  12664. /**
  12665. * Updates the generic gamepad
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the generic gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. }
  12674. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12675. import { Nullable } from "babylonjs/types";
  12676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12677. import { Scene } from "babylonjs/scene";
  12678. module "babylonjs/Engines/engine" {
  12679. interface Engine {
  12680. /**
  12681. * Creates a raw texture
  12682. * @param data defines the data to store in the texture
  12683. * @param width defines the width of the texture
  12684. * @param height defines the height of the texture
  12685. * @param format defines the format of the data
  12686. * @param generateMipMaps defines if the engine should generate the mip levels
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12689. * @param compression defines the compression used (null by default)
  12690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12691. * @returns the raw texture inside an InternalTexture
  12692. */
  12693. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12694. /**
  12695. * Update a raw texture
  12696. * @param texture defines the texture to update
  12697. * @param data defines the data to store in the texture
  12698. * @param format defines the format of the data
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. */
  12701. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12702. /**
  12703. * Update a raw texture
  12704. * @param texture defines the texture to update
  12705. * @param data defines the data to store in the texture
  12706. * @param format defines the format of the data
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param compression defines the compression used (null by default)
  12709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12710. */
  12711. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12712. /**
  12713. * Creates a new raw cube texture
  12714. * @param data defines the array of data to use to create each face
  12715. * @param size defines the size of the textures
  12716. * @param format defines the format of the data
  12717. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12718. * @param generateMipMaps defines if the engine should generate the mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compression used (null by default)
  12722. * @returns the cube texture as an InternalTexture
  12723. */
  12724. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12725. /**
  12726. * Update a raw cube texture
  12727. * @param texture defines the texture to udpdate
  12728. * @param data defines the data to store
  12729. * @param format defines the data format
  12730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw cube texture
  12736. * @param texture defines the texture to udpdate
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12740. * @param invertY defines if data must be stored with Y axis inverted
  12741. * @param compression defines the compression used (null by default)
  12742. */
  12743. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12744. /**
  12745. * Update a raw cube texture
  12746. * @param texture defines the texture to udpdate
  12747. * @param data defines the data to store
  12748. * @param format defines the data format
  12749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12750. * @param invertY defines if data must be stored with Y axis inverted
  12751. * @param compression defines the compression used (null by default)
  12752. * @param level defines which level of the texture to update
  12753. */
  12754. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12755. /**
  12756. * Creates a new raw cube texture from a specified url
  12757. * @param url defines the url where the data is located
  12758. * @param scene defines the current scene
  12759. * @param size defines the size of the textures
  12760. * @param format defines the format of the data
  12761. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12762. * @param noMipmap defines if the engine should avoid generating the mip levels
  12763. * @param callback defines a callback used to extract texture data from loaded data
  12764. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12765. * @param onLoad defines a callback called when texture is loaded
  12766. * @param onError defines a callback called if there is an error
  12767. * @returns the cube texture as an InternalTexture
  12768. */
  12769. 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;
  12770. /**
  12771. * Creates a new raw cube texture from a specified url
  12772. * @param url defines the url where the data is located
  12773. * @param scene defines the current scene
  12774. * @param size defines the size of the textures
  12775. * @param format defines the format of the data
  12776. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12777. * @param noMipmap defines if the engine should avoid generating the mip levels
  12778. * @param callback defines a callback used to extract texture data from loaded data
  12779. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12780. * @param onLoad defines a callback called when texture is loaded
  12781. * @param onError defines a callback called if there is an error
  12782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @returns the cube texture as an InternalTexture
  12785. */
  12786. 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;
  12787. /**
  12788. * Creates a new raw 3D texture
  12789. * @param data defines the data used to create the texture
  12790. * @param width defines the width of the texture
  12791. * @param height defines the height of the texture
  12792. * @param depth defines the depth of the texture
  12793. * @param format defines the format of the texture
  12794. * @param generateMipMaps defines if the engine must generate mip levels
  12795. * @param invertY defines if data must be stored with Y axis inverted
  12796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12797. * @param compression defines the compressed used (can be null)
  12798. * @param textureType defines the compressed used (can be null)
  12799. * @returns a new raw 3D texture (stored in an InternalTexture)
  12800. */
  12801. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12802. /**
  12803. * Update a raw 3D texture
  12804. * @param texture defines the texture to update
  12805. * @param data defines the data to store
  12806. * @param format defines the data format
  12807. * @param invertY defines if data must be stored with Y axis inverted
  12808. */
  12809. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12810. /**
  12811. * Update a raw 3D texture
  12812. * @param texture defines the texture to update
  12813. * @param data defines the data to store
  12814. * @param format defines the data format
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param compression defines the used compression (can be null)
  12817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12818. */
  12819. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12820. /**
  12821. * Creates a new raw 2D array texture
  12822. * @param data defines the data used to create the texture
  12823. * @param width defines the width of the texture
  12824. * @param height defines the height of the texture
  12825. * @param depth defines the number of layers of the texture
  12826. * @param format defines the format of the texture
  12827. * @param generateMipMaps defines if the engine must generate mip levels
  12828. * @param invertY defines if data must be stored with Y axis inverted
  12829. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12830. * @param compression defines the compressed used (can be null)
  12831. * @param textureType defines the compressed used (can be null)
  12832. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12833. */
  12834. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12835. /**
  12836. * Update a raw 2D array texture
  12837. * @param texture defines the texture to update
  12838. * @param data defines the data to store
  12839. * @param format defines the data format
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. */
  12842. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12843. /**
  12844. * Update a raw 2D array texture
  12845. * @param texture defines the texture to update
  12846. * @param data defines the data to store
  12847. * @param format defines the data format
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param compression defines the used compression (can be null)
  12850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12851. */
  12852. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12853. }
  12854. }
  12855. }
  12856. declare module "babylonjs/Materials/Textures/rawTexture" {
  12857. import { Scene } from "babylonjs/scene";
  12858. import { Texture } from "babylonjs/Materials/Textures/texture";
  12859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12860. /**
  12861. * Raw texture can help creating a texture directly from an array of data.
  12862. * This can be super useful if you either get the data from an uncompressed source or
  12863. * if you wish to create your texture pixel by pixel.
  12864. */
  12865. export class RawTexture extends Texture {
  12866. /**
  12867. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12868. */
  12869. format: number;
  12870. private _engine;
  12871. /**
  12872. * Instantiates a new RawTexture.
  12873. * Raw texture can help creating a texture directly from an array of data.
  12874. * This can be super useful if you either get the data from an uncompressed source or
  12875. * if you wish to create your texture pixel by pixel.
  12876. * @param data define the array of data to use to create the texture
  12877. * @param width define the width of the texture
  12878. * @param height define the height of the texture
  12879. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12880. * @param scene define the scene the texture belongs to
  12881. * @param generateMipMaps define whether mip maps should be generated or not
  12882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12884. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12885. */
  12886. constructor(data: ArrayBufferView, width: number, height: number,
  12887. /**
  12888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12889. */
  12890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12891. /**
  12892. * Updates the texture underlying data.
  12893. * @param data Define the new data of the texture
  12894. */
  12895. update(data: ArrayBufferView): void;
  12896. /**
  12897. * Creates a luminance texture from some data.
  12898. * @param data Define the texture data
  12899. * @param width Define the width of the texture
  12900. * @param height Define the height of the texture
  12901. * @param scene Define the scene the texture belongs to
  12902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12905. * @returns the luminance texture
  12906. */
  12907. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12908. /**
  12909. * Creates a luminance alpha texture from some data.
  12910. * @param data Define the texture data
  12911. * @param width Define the width of the texture
  12912. * @param height Define the height of the texture
  12913. * @param scene Define the scene the texture belongs to
  12914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12917. * @returns the luminance alpha texture
  12918. */
  12919. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12920. /**
  12921. * Creates an alpha texture from some data.
  12922. * @param data Define the texture data
  12923. * @param width Define the width of the texture
  12924. * @param height Define the height of the texture
  12925. * @param scene Define the scene the texture belongs to
  12926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12929. * @returns the alpha texture
  12930. */
  12931. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12932. /**
  12933. * Creates a RGB texture from some data.
  12934. * @param data Define the texture data
  12935. * @param width Define the width of the texture
  12936. * @param height Define the height of the texture
  12937. * @param scene Define the scene the texture belongs to
  12938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12941. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12942. * @returns the RGB alpha texture
  12943. */
  12944. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12945. /**
  12946. * Creates a RGBA texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12955. * @returns the RGBA texture
  12956. */
  12957. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12958. /**
  12959. * Creates a R texture from some data.
  12960. * @param data Define the texture data
  12961. * @param width Define the width of the texture
  12962. * @param height Define the height of the texture
  12963. * @param scene Define the scene the texture belongs to
  12964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12967. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12968. * @returns the R texture
  12969. */
  12970. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12971. }
  12972. }
  12973. declare module "babylonjs/Maths/math.size" {
  12974. /**
  12975. * Interface for the size containing width and height
  12976. */
  12977. export interface ISize {
  12978. /**
  12979. * Width
  12980. */
  12981. width: number;
  12982. /**
  12983. * Heighht
  12984. */
  12985. height: number;
  12986. }
  12987. /**
  12988. * Size containing widht and height
  12989. */
  12990. export class Size implements ISize {
  12991. /**
  12992. * Width
  12993. */
  12994. width: number;
  12995. /**
  12996. * Height
  12997. */
  12998. height: number;
  12999. /**
  13000. * Creates a Size object from the given width and height (floats).
  13001. * @param width width of the new size
  13002. * @param height height of the new size
  13003. */
  13004. constructor(width: number, height: number);
  13005. /**
  13006. * Returns a string with the Size width and height
  13007. * @returns a string with the Size width and height
  13008. */
  13009. toString(): string;
  13010. /**
  13011. * "Size"
  13012. * @returns the string "Size"
  13013. */
  13014. getClassName(): string;
  13015. /**
  13016. * Returns the Size hash code.
  13017. * @returns a hash code for a unique width and height
  13018. */
  13019. getHashCode(): number;
  13020. /**
  13021. * Updates the current size from the given one.
  13022. * @param src the given size
  13023. */
  13024. copyFrom(src: Size): void;
  13025. /**
  13026. * Updates in place the current Size from the given floats.
  13027. * @param width width of the new size
  13028. * @param height height of the new size
  13029. * @returns the updated Size.
  13030. */
  13031. copyFromFloats(width: number, height: number): Size;
  13032. /**
  13033. * Updates in place the current Size from the given floats.
  13034. * @param width width to set
  13035. * @param height height to set
  13036. * @returns the updated Size.
  13037. */
  13038. set(width: number, height: number): Size;
  13039. /**
  13040. * Multiplies the width and height by numbers
  13041. * @param w factor to multiple the width by
  13042. * @param h factor to multiple the height by
  13043. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13044. */
  13045. multiplyByFloats(w: number, h: number): Size;
  13046. /**
  13047. * Clones the size
  13048. * @returns a new Size copied from the given one.
  13049. */
  13050. clone(): Size;
  13051. /**
  13052. * True if the current Size and the given one width and height are strictly equal.
  13053. * @param other the other size to compare against
  13054. * @returns True if the current Size and the given one width and height are strictly equal.
  13055. */
  13056. equals(other: Size): boolean;
  13057. /**
  13058. * The surface of the Size : width * height (float).
  13059. */
  13060. readonly surface: number;
  13061. /**
  13062. * Create a new size of zero
  13063. * @returns a new Size set to (0.0, 0.0)
  13064. */
  13065. static Zero(): Size;
  13066. /**
  13067. * Sums the width and height of two sizes
  13068. * @param otherSize size to add to this size
  13069. * @returns a new Size set as the addition result of the current Size and the given one.
  13070. */
  13071. add(otherSize: Size): Size;
  13072. /**
  13073. * Subtracts the width and height of two
  13074. * @param otherSize size to subtract to this size
  13075. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13076. */
  13077. subtract(otherSize: Size): Size;
  13078. /**
  13079. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13080. * @param start starting size to lerp between
  13081. * @param end end size to lerp between
  13082. * @param amount amount to lerp between the start and end values
  13083. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13084. */
  13085. static Lerp(start: Size, end: Size, amount: number): Size;
  13086. }
  13087. }
  13088. declare module "babylonjs/Animations/runtimeAnimation" {
  13089. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13090. import { Animatable } from "babylonjs/Animations/animatable";
  13091. import { Scene } from "babylonjs/scene";
  13092. /**
  13093. * Defines a runtime animation
  13094. */
  13095. export class RuntimeAnimation {
  13096. private _events;
  13097. /**
  13098. * The current frame of the runtime animation
  13099. */
  13100. private _currentFrame;
  13101. /**
  13102. * The animation used by the runtime animation
  13103. */
  13104. private _animation;
  13105. /**
  13106. * The target of the runtime animation
  13107. */
  13108. private _target;
  13109. /**
  13110. * The initiating animatable
  13111. */
  13112. private _host;
  13113. /**
  13114. * The original value of the runtime animation
  13115. */
  13116. private _originalValue;
  13117. /**
  13118. * The original blend value of the runtime animation
  13119. */
  13120. private _originalBlendValue;
  13121. /**
  13122. * The offsets cache of the runtime animation
  13123. */
  13124. private _offsetsCache;
  13125. /**
  13126. * The high limits cache of the runtime animation
  13127. */
  13128. private _highLimitsCache;
  13129. /**
  13130. * Specifies if the runtime animation has been stopped
  13131. */
  13132. private _stopped;
  13133. /**
  13134. * The blending factor of the runtime animation
  13135. */
  13136. private _blendingFactor;
  13137. /**
  13138. * The BabylonJS scene
  13139. */
  13140. private _scene;
  13141. /**
  13142. * The current value of the runtime animation
  13143. */
  13144. private _currentValue;
  13145. /** @hidden */
  13146. _animationState: _IAnimationState;
  13147. /**
  13148. * The active target of the runtime animation
  13149. */
  13150. private _activeTargets;
  13151. private _currentActiveTarget;
  13152. private _directTarget;
  13153. /**
  13154. * The target path of the runtime animation
  13155. */
  13156. private _targetPath;
  13157. /**
  13158. * The weight of the runtime animation
  13159. */
  13160. private _weight;
  13161. /**
  13162. * The ratio offset of the runtime animation
  13163. */
  13164. private _ratioOffset;
  13165. /**
  13166. * The previous delay of the runtime animation
  13167. */
  13168. private _previousDelay;
  13169. /**
  13170. * The previous ratio of the runtime animation
  13171. */
  13172. private _previousRatio;
  13173. private _enableBlending;
  13174. private _keys;
  13175. private _minFrame;
  13176. private _maxFrame;
  13177. private _minValue;
  13178. private _maxValue;
  13179. private _targetIsArray;
  13180. /**
  13181. * Gets the current frame of the runtime animation
  13182. */
  13183. readonly currentFrame: number;
  13184. /**
  13185. * Gets the weight of the runtime animation
  13186. */
  13187. readonly weight: number;
  13188. /**
  13189. * Gets the current value of the runtime animation
  13190. */
  13191. readonly currentValue: any;
  13192. /**
  13193. * Gets the target path of the runtime animation
  13194. */
  13195. readonly targetPath: string;
  13196. /**
  13197. * Gets the actual target of the runtime animation
  13198. */
  13199. readonly target: any;
  13200. /** @hidden */
  13201. _onLoop: () => void;
  13202. /**
  13203. * Create a new RuntimeAnimation object
  13204. * @param target defines the target of the animation
  13205. * @param animation defines the source animation object
  13206. * @param scene defines the hosting scene
  13207. * @param host defines the initiating Animatable
  13208. */
  13209. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13210. private _preparePath;
  13211. /**
  13212. * Gets the animation from the runtime animation
  13213. */
  13214. readonly animation: Animation;
  13215. /**
  13216. * Resets the runtime animation to the beginning
  13217. * @param restoreOriginal defines whether to restore the target property to the original value
  13218. */
  13219. reset(restoreOriginal?: boolean): void;
  13220. /**
  13221. * Specifies if the runtime animation is stopped
  13222. * @returns Boolean specifying if the runtime animation is stopped
  13223. */
  13224. isStopped(): boolean;
  13225. /**
  13226. * Disposes of the runtime animation
  13227. */
  13228. dispose(): void;
  13229. /**
  13230. * Apply the interpolated value to the target
  13231. * @param currentValue defines the value computed by the animation
  13232. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13233. */
  13234. setValue(currentValue: any, weight: number): void;
  13235. private _getOriginalValues;
  13236. private _setValue;
  13237. /**
  13238. * Gets the loop pmode of the runtime animation
  13239. * @returns Loop Mode
  13240. */
  13241. private _getCorrectLoopMode;
  13242. /**
  13243. * Move the current animation to a given frame
  13244. * @param frame defines the frame to move to
  13245. */
  13246. goToFrame(frame: number): void;
  13247. /**
  13248. * @hidden Internal use only
  13249. */
  13250. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13251. /**
  13252. * Execute the current animation
  13253. * @param delay defines the delay to add to the current frame
  13254. * @param from defines the lower bound of the animation range
  13255. * @param to defines the upper bound of the animation range
  13256. * @param loop defines if the current animation must loop
  13257. * @param speedRatio defines the current speed ratio
  13258. * @param weight defines the weight of the animation (default is -1 so no weight)
  13259. * @param onLoop optional callback called when animation loops
  13260. * @returns a boolean indicating if the animation is running
  13261. */
  13262. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13263. }
  13264. }
  13265. declare module "babylonjs/Animations/animatable" {
  13266. import { Animation } from "babylonjs/Animations/animation";
  13267. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { Scene } from "babylonjs/scene";
  13271. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13272. import { Node } from "babylonjs/node";
  13273. /**
  13274. * Class used to store an actual running animation
  13275. */
  13276. export class Animatable {
  13277. /** defines the target object */
  13278. target: any;
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame: number;
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame: number;
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation: boolean;
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined;
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined;
  13289. private _localDelayOffset;
  13290. private _pausedDelay;
  13291. private _runtimeAnimations;
  13292. private _paused;
  13293. private _scene;
  13294. private _speedRatio;
  13295. private _weight;
  13296. private _syncRoot;
  13297. /**
  13298. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13299. * This will only apply for non looping animation (default is true)
  13300. */
  13301. disposeOnEnd: boolean;
  13302. /**
  13303. * Gets a boolean indicating if the animation has started
  13304. */
  13305. animationStarted: boolean;
  13306. /**
  13307. * Observer raised when the animation ends
  13308. */
  13309. onAnimationEndObservable: Observable<Animatable>;
  13310. /**
  13311. * Observer raised when the animation loops
  13312. */
  13313. onAnimationLoopObservable: Observable<Animatable>;
  13314. /**
  13315. * Gets the root Animatable used to synchronize and normalize animations
  13316. */
  13317. readonly syncRoot: Nullable<Animatable>;
  13318. /**
  13319. * Gets the current frame of the first RuntimeAnimation
  13320. * Used to synchronize Animatables
  13321. */
  13322. readonly masterFrame: number;
  13323. /**
  13324. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13325. */
  13326. weight: number;
  13327. /**
  13328. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13329. */
  13330. speedRatio: number;
  13331. /**
  13332. * Creates a new Animatable
  13333. * @param scene defines the hosting scene
  13334. * @param target defines the target object
  13335. * @param fromFrame defines the starting frame number (default is 0)
  13336. * @param toFrame defines the ending frame number (default is 100)
  13337. * @param loopAnimation defines if the animation must loop (default is false)
  13338. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13339. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13340. * @param animations defines a group of animation to add to the new Animatable
  13341. * @param onAnimationLoop defines a callback to call when animation loops
  13342. */
  13343. constructor(scene: Scene,
  13344. /** defines the target object */
  13345. target: any,
  13346. /** defines the starting frame number (default is 0) */
  13347. fromFrame?: number,
  13348. /** defines the ending frame number (default is 100) */
  13349. toFrame?: number,
  13350. /** defines if the animation must loop (default is false) */
  13351. loopAnimation?: boolean, speedRatio?: number,
  13352. /** defines a callback to call when animation ends if it is not looping */
  13353. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13354. /** defines a callback to call when animation loops */
  13355. onAnimationLoop?: (() => void) | null | undefined);
  13356. /**
  13357. * Synchronize and normalize current Animatable with a source Animatable
  13358. * This is useful when using animation weights and when animations are not of the same length
  13359. * @param root defines the root Animatable to synchronize with
  13360. * @returns the current Animatable
  13361. */
  13362. syncWith(root: Animatable): Animatable;
  13363. /**
  13364. * Gets the list of runtime animations
  13365. * @returns an array of RuntimeAnimation
  13366. */
  13367. getAnimations(): RuntimeAnimation[];
  13368. /**
  13369. * Adds more animations to the current animatable
  13370. * @param target defines the target of the animations
  13371. * @param animations defines the new animations to add
  13372. */
  13373. appendAnimations(target: any, animations: Animation[]): void;
  13374. /**
  13375. * Gets the source animation for a specific property
  13376. * @param property defines the propertyu to look for
  13377. * @returns null or the source animation for the given property
  13378. */
  13379. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13380. /**
  13381. * Gets the runtime animation for a specific property
  13382. * @param property defines the propertyu to look for
  13383. * @returns null or the runtime animation for the given property
  13384. */
  13385. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13386. /**
  13387. * Resets the animatable to its original state
  13388. */
  13389. reset(): void;
  13390. /**
  13391. * Allows the animatable to blend with current running animations
  13392. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13393. * @param blendingSpeed defines the blending speed to use
  13394. */
  13395. enableBlending(blendingSpeed: number): void;
  13396. /**
  13397. * Disable animation blending
  13398. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13399. */
  13400. disableBlending(): void;
  13401. /**
  13402. * Jump directly to a given frame
  13403. * @param frame defines the frame to jump to
  13404. */
  13405. goToFrame(frame: number): void;
  13406. /**
  13407. * Pause the animation
  13408. */
  13409. pause(): void;
  13410. /**
  13411. * Restart the animation
  13412. */
  13413. restart(): void;
  13414. private _raiseOnAnimationEnd;
  13415. /**
  13416. * Stop and delete the current animation
  13417. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13418. * @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)
  13419. */
  13420. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13421. /**
  13422. * Wait asynchronously for the animation to end
  13423. * @returns a promise which will be fullfilled when the animation ends
  13424. */
  13425. waitAsync(): Promise<Animatable>;
  13426. /** @hidden */
  13427. _animate(delay: number): boolean;
  13428. }
  13429. module "babylonjs/scene" {
  13430. interface Scene {
  13431. /** @hidden */
  13432. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13433. /** @hidden */
  13434. _processLateAnimationBindingsForMatrices(holder: {
  13435. totalWeight: number;
  13436. animations: RuntimeAnimation[];
  13437. originalValue: Matrix;
  13438. }): any;
  13439. /** @hidden */
  13440. _processLateAnimationBindingsForQuaternions(holder: {
  13441. totalWeight: number;
  13442. animations: RuntimeAnimation[];
  13443. originalValue: Quaternion;
  13444. }, refQuaternion: Quaternion): Quaternion;
  13445. /** @hidden */
  13446. _processLateAnimationBindings(): void;
  13447. /**
  13448. * Will start the animation sequence of a given target
  13449. * @param target defines the target
  13450. * @param from defines from which frame should animation start
  13451. * @param to defines until which frame should animation run.
  13452. * @param weight defines the weight to apply to the animation (1.0 by default)
  13453. * @param loop defines if the animation loops
  13454. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13455. * @param onAnimationEnd defines the function to be executed when the animation ends
  13456. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13457. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13458. * @param onAnimationLoop defines the callback to call when an animation loops
  13459. * @returns the animatable object created for this animation
  13460. */
  13461. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13462. /**
  13463. * Will start the animation sequence of a given target
  13464. * @param target defines the target
  13465. * @param from defines from which frame should animation start
  13466. * @param to defines until which frame should animation run.
  13467. * @param loop defines if the animation loops
  13468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13469. * @param onAnimationEnd defines the function to be executed when the animation ends
  13470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13471. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13472. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13473. * @param onAnimationLoop defines the callback to call when an animation loops
  13474. * @returns the animatable object created for this animation
  13475. */
  13476. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13477. /**
  13478. * Will start the animation sequence of a given target and its hierarchy
  13479. * @param target defines the target
  13480. * @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.
  13481. * @param from defines from which frame should animation start
  13482. * @param to defines until which frame should animation run.
  13483. * @param loop defines if the animation loops
  13484. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13485. * @param onAnimationEnd defines the function to be executed when the animation ends
  13486. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13487. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13488. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13489. * @param onAnimationLoop defines the callback to call when an animation loops
  13490. * @returns the list of created animatables
  13491. */
  13492. 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[];
  13493. /**
  13494. * Begin a new animation on a given node
  13495. * @param target defines the target where the animation will take place
  13496. * @param animations defines the list of animations to start
  13497. * @param from defines the initial value
  13498. * @param to defines the final value
  13499. * @param loop defines if you want animation to loop (off by default)
  13500. * @param speedRatio defines the speed ratio to apply to all animations
  13501. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13502. * @param onAnimationLoop defines the callback to call when an animation loops
  13503. * @returns the list of created animatables
  13504. */
  13505. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13506. /**
  13507. * Begin a new animation on a given node and its hierarchy
  13508. * @param target defines the root node where the animation will take place
  13509. * @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.
  13510. * @param animations defines the list of animations to start
  13511. * @param from defines the initial value
  13512. * @param to defines the final value
  13513. * @param loop defines if you want animation to loop (off by default)
  13514. * @param speedRatio defines the speed ratio to apply to all animations
  13515. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13516. * @param onAnimationLoop defines the callback to call when an animation loops
  13517. * @returns the list of animatables created for all nodes
  13518. */
  13519. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13520. /**
  13521. * Gets the animatable associated with a specific target
  13522. * @param target defines the target of the animatable
  13523. * @returns the required animatable if found
  13524. */
  13525. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13526. /**
  13527. * Gets all animatables associated with a given target
  13528. * @param target defines the target to look animatables for
  13529. * @returns an array of Animatables
  13530. */
  13531. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13532. /**
  13533. * Stops and removes all animations that have been applied to the scene
  13534. */
  13535. stopAllAnimations(): void;
  13536. /**
  13537. * Gets the current delta time used by animation engine
  13538. */
  13539. deltaTime: number;
  13540. }
  13541. }
  13542. module "babylonjs/Bones/bone" {
  13543. interface Bone {
  13544. /**
  13545. * Copy an animation range from another bone
  13546. * @param source defines the source bone
  13547. * @param rangeName defines the range name to copy
  13548. * @param frameOffset defines the frame offset
  13549. * @param rescaleAsRequired defines if rescaling must be applied if required
  13550. * @param skelDimensionsRatio defines the scaling ratio
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13554. }
  13555. }
  13556. }
  13557. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13558. /**
  13559. * Class used to override all child animations of a given target
  13560. */
  13561. export class AnimationPropertiesOverride {
  13562. /**
  13563. * Gets or sets a value indicating if animation blending must be used
  13564. */
  13565. enableBlending: boolean;
  13566. /**
  13567. * Gets or sets the blending speed to use when enableBlending is true
  13568. */
  13569. blendingSpeed: number;
  13570. /**
  13571. * Gets or sets the default loop mode to use
  13572. */
  13573. loopMode: number;
  13574. }
  13575. }
  13576. declare module "babylonjs/Bones/skeleton" {
  13577. import { Bone } from "babylonjs/Bones/bone";
  13578. import { Observable } from "babylonjs/Misc/observable";
  13579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13580. import { Scene } from "babylonjs/scene";
  13581. import { Nullable } from "babylonjs/types";
  13582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13583. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13584. import { Animatable } from "babylonjs/Animations/animatable";
  13585. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13586. import { Animation } from "babylonjs/Animations/animation";
  13587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13588. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13590. /**
  13591. * Class used to handle skinning animations
  13592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13593. */
  13594. export class Skeleton implements IAnimatable {
  13595. /** defines the skeleton name */
  13596. name: string;
  13597. /** defines the skeleton Id */
  13598. id: string;
  13599. /**
  13600. * Defines the list of child bones
  13601. */
  13602. bones: Bone[];
  13603. /**
  13604. * Defines an estimate of the dimension of the skeleton at rest
  13605. */
  13606. dimensionsAtRest: Vector3;
  13607. /**
  13608. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13609. */
  13610. needInitialSkinMatrix: boolean;
  13611. /**
  13612. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13613. */
  13614. overrideMesh: Nullable<AbstractMesh>;
  13615. /**
  13616. * Gets the list of animations attached to this skeleton
  13617. */
  13618. animations: Array<Animation>;
  13619. private _scene;
  13620. private _isDirty;
  13621. private _transformMatrices;
  13622. private _transformMatrixTexture;
  13623. private _meshesWithPoseMatrix;
  13624. private _animatables;
  13625. private _identity;
  13626. private _synchronizedWithMesh;
  13627. private _ranges;
  13628. private _lastAbsoluteTransformsUpdateId;
  13629. private _canUseTextureForBones;
  13630. private _uniqueId;
  13631. /** @hidden */
  13632. _numBonesWithLinkedTransformNode: number;
  13633. /** @hidden */
  13634. _hasWaitingData: Nullable<boolean>;
  13635. /**
  13636. * Specifies if the skeleton should be serialized
  13637. */
  13638. doNotSerialize: boolean;
  13639. private _useTextureToStoreBoneMatrices;
  13640. /**
  13641. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13642. * Please note that this option is not available if the hardware does not support it
  13643. */
  13644. useTextureToStoreBoneMatrices: boolean;
  13645. private _animationPropertiesOverride;
  13646. /**
  13647. * Gets or sets the animation properties override
  13648. */
  13649. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * An observable triggered before computing the skeleton's matrices
  13657. */
  13658. onBeforeComputeObservable: Observable<Skeleton>;
  13659. /**
  13660. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13661. */
  13662. readonly isUsingTextureForMatrices: boolean;
  13663. /**
  13664. * Gets the unique ID of this skeleton
  13665. */
  13666. readonly uniqueId: number;
  13667. /**
  13668. * Creates a new skeleton
  13669. * @param name defines the skeleton name
  13670. * @param id defines the skeleton Id
  13671. * @param scene defines the hosting scene
  13672. */
  13673. constructor(
  13674. /** defines the skeleton name */
  13675. name: string,
  13676. /** defines the skeleton Id */
  13677. id: string, scene: Scene);
  13678. /**
  13679. * Gets the current object class name.
  13680. * @return the class name
  13681. */
  13682. getClassName(): string;
  13683. /**
  13684. * Returns an array containing the root bones
  13685. * @returns an array containing the root bones
  13686. */
  13687. getChildren(): Array<Bone>;
  13688. /**
  13689. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13690. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13691. * @returns a Float32Array containing matrices data
  13692. */
  13693. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13694. /**
  13695. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13696. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13697. * @returns a raw texture containing the data
  13698. */
  13699. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13700. /**
  13701. * Gets the current hosting scene
  13702. * @returns a scene object
  13703. */
  13704. getScene(): Scene;
  13705. /**
  13706. * Gets a string representing the current skeleton data
  13707. * @param fullDetails defines a boolean indicating if we want a verbose version
  13708. * @returns a string representing the current skeleton data
  13709. */
  13710. toString(fullDetails?: boolean): string;
  13711. /**
  13712. * Get bone's index searching by name
  13713. * @param name defines bone's name to search for
  13714. * @return the indice of the bone. Returns -1 if not found
  13715. */
  13716. getBoneIndexByName(name: string): number;
  13717. /**
  13718. * Creater a new animation range
  13719. * @param name defines the name of the range
  13720. * @param from defines the start key
  13721. * @param to defines the end key
  13722. */
  13723. createAnimationRange(name: string, from: number, to: number): void;
  13724. /**
  13725. * Delete a specific animation range
  13726. * @param name defines the name of the range
  13727. * @param deleteFrames defines if frames must be removed as well
  13728. */
  13729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13730. /**
  13731. * Gets a specific animation range
  13732. * @param name defines the name of the range to look for
  13733. * @returns the requested animation range or null if not found
  13734. */
  13735. getAnimationRange(name: string): Nullable<AnimationRange>;
  13736. /**
  13737. * Gets the list of all animation ranges defined on this skeleton
  13738. * @returns an array
  13739. */
  13740. getAnimationRanges(): Nullable<AnimationRange>[];
  13741. /**
  13742. * Copy animation range from a source skeleton.
  13743. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13744. * @param source defines the source skeleton
  13745. * @param name defines the name of the range to copy
  13746. * @param rescaleAsRequired defines if rescaling must be applied if required
  13747. * @returns true if operation was successful
  13748. */
  13749. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13750. /**
  13751. * Forces the skeleton to go to rest pose
  13752. */
  13753. returnToRest(): void;
  13754. private _getHighestAnimationFrame;
  13755. /**
  13756. * Begin a specific animation range
  13757. * @param name defines the name of the range to start
  13758. * @param loop defines if looping must be turned on (false by default)
  13759. * @param speedRatio defines the speed ratio to apply (1 by default)
  13760. * @param onAnimationEnd defines a callback which will be called when animation will end
  13761. * @returns a new animatable
  13762. */
  13763. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13764. /** @hidden */
  13765. _markAsDirty(): void;
  13766. /** @hidden */
  13767. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13768. /** @hidden */
  13769. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13770. private _computeTransformMatrices;
  13771. /**
  13772. * Build all resources required to render a skeleton
  13773. */
  13774. prepare(): void;
  13775. /**
  13776. * Gets the list of animatables currently running for this skeleton
  13777. * @returns an array of animatables
  13778. */
  13779. getAnimatables(): IAnimatable[];
  13780. /**
  13781. * Clone the current skeleton
  13782. * @param name defines the name of the new skeleton
  13783. * @param id defines the id of the new skeleton
  13784. * @returns the new skeleton
  13785. */
  13786. clone(name: string, id?: string): Skeleton;
  13787. /**
  13788. * Enable animation blending for this skeleton
  13789. * @param blendingSpeed defines the blending speed to apply
  13790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13791. */
  13792. enableBlending(blendingSpeed?: number): void;
  13793. /**
  13794. * Releases all resources associated with the current skeleton
  13795. */
  13796. dispose(): void;
  13797. /**
  13798. * Serialize the skeleton in a JSON object
  13799. * @returns a JSON object
  13800. */
  13801. serialize(): any;
  13802. /**
  13803. * Creates a new skeleton from serialized data
  13804. * @param parsedSkeleton defines the serialized data
  13805. * @param scene defines the hosting scene
  13806. * @returns a new skeleton
  13807. */
  13808. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13809. /**
  13810. * Compute all node absolute transforms
  13811. * @param forceUpdate defines if computation must be done even if cache is up to date
  13812. */
  13813. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13814. /**
  13815. * Gets the root pose matrix
  13816. * @returns a matrix
  13817. */
  13818. getPoseMatrix(): Nullable<Matrix>;
  13819. /**
  13820. * Sorts bones per internal index
  13821. */
  13822. sortBones(): void;
  13823. private _sortBones;
  13824. }
  13825. }
  13826. declare module "babylonjs/Bones/bone" {
  13827. import { Skeleton } from "babylonjs/Bones/skeleton";
  13828. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13829. import { Nullable } from "babylonjs/types";
  13830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13832. import { Node } from "babylonjs/node";
  13833. import { Space } from "babylonjs/Maths/math.axis";
  13834. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13835. /**
  13836. * Class used to store bone information
  13837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13838. */
  13839. export class Bone extends Node {
  13840. /**
  13841. * defines the bone name
  13842. */
  13843. name: string;
  13844. private static _tmpVecs;
  13845. private static _tmpQuat;
  13846. private static _tmpMats;
  13847. /**
  13848. * Gets the list of child bones
  13849. */
  13850. children: Bone[];
  13851. /** Gets the animations associated with this bone */
  13852. animations: import("babylonjs/Animations/animation").Animation[];
  13853. /**
  13854. * Gets or sets bone length
  13855. */
  13856. length: number;
  13857. /**
  13858. * @hidden Internal only
  13859. * Set this value to map this bone to a different index in the transform matrices
  13860. * Set this value to -1 to exclude the bone from the transform matrices
  13861. */
  13862. _index: Nullable<number>;
  13863. private _skeleton;
  13864. private _localMatrix;
  13865. private _restPose;
  13866. private _baseMatrix;
  13867. private _absoluteTransform;
  13868. private _invertedAbsoluteTransform;
  13869. private _parent;
  13870. private _scalingDeterminant;
  13871. private _worldTransform;
  13872. private _localScaling;
  13873. private _localRotation;
  13874. private _localPosition;
  13875. private _needToDecompose;
  13876. private _needToCompose;
  13877. /** @hidden */
  13878. _linkedTransformNode: Nullable<TransformNode>;
  13879. /** @hidden */
  13880. _waitingTransformNodeId: Nullable<string>;
  13881. /** @hidden */
  13882. /** @hidden */
  13883. _matrix: Matrix;
  13884. /**
  13885. * Create a new bone
  13886. * @param name defines the bone name
  13887. * @param skeleton defines the parent skeleton
  13888. * @param parentBone defines the parent (can be null if the bone is the root)
  13889. * @param localMatrix defines the local matrix
  13890. * @param restPose defines the rest pose matrix
  13891. * @param baseMatrix defines the base matrix
  13892. * @param index defines index of the bone in the hiearchy
  13893. */
  13894. constructor(
  13895. /**
  13896. * defines the bone name
  13897. */
  13898. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13899. /**
  13900. * Gets the current object class name.
  13901. * @return the class name
  13902. */
  13903. getClassName(): string;
  13904. /**
  13905. * Gets the parent skeleton
  13906. * @returns a skeleton
  13907. */
  13908. getSkeleton(): Skeleton;
  13909. /**
  13910. * Gets parent bone
  13911. * @returns a bone or null if the bone is the root of the bone hierarchy
  13912. */
  13913. getParent(): Nullable<Bone>;
  13914. /**
  13915. * Returns an array containing the root bones
  13916. * @returns an array containing the root bones
  13917. */
  13918. getChildren(): Array<Bone>;
  13919. /**
  13920. * Gets the node index in matrix array generated for rendering
  13921. * @returns the node index
  13922. */
  13923. getIndex(): number;
  13924. /**
  13925. * Sets the parent bone
  13926. * @param parent defines the parent (can be null if the bone is the root)
  13927. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13928. */
  13929. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13930. /**
  13931. * Gets the local matrix
  13932. * @returns a matrix
  13933. */
  13934. getLocalMatrix(): Matrix;
  13935. /**
  13936. * Gets the base matrix (initial matrix which remains unchanged)
  13937. * @returns a matrix
  13938. */
  13939. getBaseMatrix(): Matrix;
  13940. /**
  13941. * Gets the rest pose matrix
  13942. * @returns a matrix
  13943. */
  13944. getRestPose(): Matrix;
  13945. /**
  13946. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13947. */
  13948. getWorldMatrix(): Matrix;
  13949. /**
  13950. * Sets the local matrix to rest pose matrix
  13951. */
  13952. returnToRest(): void;
  13953. /**
  13954. * Gets the inverse of the absolute transform matrix.
  13955. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13956. * @returns a matrix
  13957. */
  13958. getInvertedAbsoluteTransform(): Matrix;
  13959. /**
  13960. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13961. * @returns a matrix
  13962. */
  13963. getAbsoluteTransform(): Matrix;
  13964. /**
  13965. * Links with the given transform node.
  13966. * The local matrix of this bone is copied from the transform node every frame.
  13967. * @param transformNode defines the transform node to link to
  13968. */
  13969. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13970. /**
  13971. * Gets the node used to drive the bone's transformation
  13972. * @returns a transform node or null
  13973. */
  13974. getTransformNode(): Nullable<TransformNode>;
  13975. /** Gets or sets current position (in local space) */
  13976. position: Vector3;
  13977. /** Gets or sets current rotation (in local space) */
  13978. rotation: Vector3;
  13979. /** Gets or sets current rotation quaternion (in local space) */
  13980. rotationQuaternion: Quaternion;
  13981. /** Gets or sets current scaling (in local space) */
  13982. scaling: Vector3;
  13983. /**
  13984. * Gets the animation properties override
  13985. */
  13986. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13987. private _decompose;
  13988. private _compose;
  13989. /**
  13990. * Update the base and local matrices
  13991. * @param matrix defines the new base or local matrix
  13992. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13993. * @param updateLocalMatrix defines if the local matrix should be updated
  13994. */
  13995. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13996. /** @hidden */
  13997. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13998. /**
  13999. * Flag the bone as dirty (Forcing it to update everything)
  14000. */
  14001. markAsDirty(): void;
  14002. /** @hidden */
  14003. _markAsDirtyAndCompose(): void;
  14004. private _markAsDirtyAndDecompose;
  14005. /**
  14006. * Translate the bone in local or world space
  14007. * @param vec The amount to translate the bone
  14008. * @param space The space that the translation is in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. */
  14011. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14012. /**
  14013. * Set the postion of the bone in local or world space
  14014. * @param position The position to set the bone
  14015. * @param space The space that the position is in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. */
  14018. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14019. /**
  14020. * Set the absolute position of the bone (world space)
  14021. * @param position The position to set the bone
  14022. * @param mesh The mesh that this bone is attached to
  14023. */
  14024. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14025. /**
  14026. * Scale the bone on the x, y and z axes (in local space)
  14027. * @param x The amount to scale the bone on the x axis
  14028. * @param y The amount to scale the bone on the y axis
  14029. * @param z The amount to scale the bone on the z axis
  14030. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14031. */
  14032. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14033. /**
  14034. * Set the bone scaling in local space
  14035. * @param scale defines the scaling vector
  14036. */
  14037. setScale(scale: Vector3): void;
  14038. /**
  14039. * Gets the current scaling in local space
  14040. * @returns the current scaling vector
  14041. */
  14042. getScale(): Vector3;
  14043. /**
  14044. * Gets the current scaling in local space and stores it in a target vector
  14045. * @param result defines the target vector
  14046. */
  14047. getScaleToRef(result: Vector3): void;
  14048. /**
  14049. * Set the yaw, pitch, and roll of the bone in local or world space
  14050. * @param yaw The rotation of the bone on the y axis
  14051. * @param pitch The rotation of the bone on the x axis
  14052. * @param roll The rotation of the bone on the z axis
  14053. * @param space The space that the axes of rotation are in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. */
  14056. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14057. /**
  14058. * Add a rotation to the bone on an axis in local or world space
  14059. * @param axis The axis to rotate the bone on
  14060. * @param amount The amount to rotate the bone
  14061. * @param space The space that the axis is in
  14062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14063. */
  14064. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14065. /**
  14066. * Set the rotation of the bone to a particular axis angle in local or world space
  14067. * @param axis The axis to rotate the bone on
  14068. * @param angle The angle that the bone should be rotated to
  14069. * @param space The space that the axis is in
  14070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14071. */
  14072. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14073. /**
  14074. * Set the euler rotation of the bone in local of world space
  14075. * @param rotation The euler rotation that the bone should be set to
  14076. * @param space The space that the rotation is in
  14077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14078. */
  14079. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14080. /**
  14081. * Set the quaternion rotation of the bone in local of world space
  14082. * @param quat The quaternion rotation that the bone should be set to
  14083. * @param space The space that the rotation is in
  14084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14085. */
  14086. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14087. /**
  14088. * Set the rotation matrix of the bone in local of world space
  14089. * @param rotMat The rotation matrix that the bone should be set to
  14090. * @param space The space that the rotation is in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14094. private _rotateWithMatrix;
  14095. private _getNegativeRotationToRef;
  14096. /**
  14097. * Get the position of the bone in local or world space
  14098. * @param space The space that the returned position is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The position of the bone
  14101. */
  14102. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14103. /**
  14104. * Copy the position of the bone to a vector3 in local or world space
  14105. * @param space The space that the returned position is in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The vector3 to copy the position to
  14108. */
  14109. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14110. /**
  14111. * Get the absolute position of the bone (world space)
  14112. * @param mesh The mesh that this bone is attached to
  14113. * @returns The absolute position of the bone
  14114. */
  14115. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14116. /**
  14117. * Copy the absolute position of the bone (world space) to the result param
  14118. * @param mesh The mesh that this bone is attached to
  14119. * @param result The vector3 to copy the absolute position to
  14120. */
  14121. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14122. /**
  14123. * Compute the absolute transforms of this bone and its children
  14124. */
  14125. computeAbsoluteTransforms(): void;
  14126. /**
  14127. * Get the world direction from an axis that is in the local space of the bone
  14128. * @param localAxis The local direction that is used to compute the world direction
  14129. * @param mesh The mesh that this bone is attached to
  14130. * @returns The world direction
  14131. */
  14132. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14133. /**
  14134. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14135. * @param localAxis The local direction that is used to compute the world direction
  14136. * @param mesh The mesh that this bone is attached to
  14137. * @param result The vector3 that the world direction will be copied to
  14138. */
  14139. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14140. /**
  14141. * Get the euler rotation of the bone in local or world space
  14142. * @param space The space that the rotation should be in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @returns The euler rotation
  14145. */
  14146. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14147. /**
  14148. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14149. * @param space The space that the rotation should be in
  14150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14151. * @param result The vector3 that the rotation should be copied to
  14152. */
  14153. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14154. /**
  14155. * Get the quaternion rotation of the bone in either local or world space
  14156. * @param space The space that the rotation should be in
  14157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14158. * @returns The quaternion rotation
  14159. */
  14160. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14161. /**
  14162. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14163. * @param space The space that the rotation should be in
  14164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14165. * @param result The quaternion that the rotation should be copied to
  14166. */
  14167. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14168. /**
  14169. * Get the rotation matrix of the bone in local or world space
  14170. * @param space The space that the rotation should be in
  14171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14172. * @returns The rotation matrix
  14173. */
  14174. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14175. /**
  14176. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14177. * @param space The space that the rotation should be in
  14178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14179. * @param result The quaternion that the rotation should be copied to
  14180. */
  14181. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14182. /**
  14183. * Get the world position of a point that is in the local space of the bone
  14184. * @param position The local position
  14185. * @param mesh The mesh that this bone is attached to
  14186. * @returns The world position
  14187. */
  14188. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14191. * @param position The local position
  14192. * @param mesh The mesh that this bone is attached to
  14193. * @param result The vector3 that the world position should be copied to
  14194. */
  14195. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the local position of a point that is in world space
  14198. * @param position The world position
  14199. * @param mesh The mesh that this bone is attached to
  14200. * @returns The local position
  14201. */
  14202. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14203. /**
  14204. * Get the local position of a point that is in world space and copy it to the result param
  14205. * @param position The world position
  14206. * @param mesh The mesh that this bone is attached to
  14207. * @param result The vector3 that the local position should be copied to
  14208. */
  14209. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14210. }
  14211. }
  14212. declare module "babylonjs/Meshes/transformNode" {
  14213. import { DeepImmutable } from "babylonjs/types";
  14214. import { Observable } from "babylonjs/Misc/observable";
  14215. import { Nullable } from "babylonjs/types";
  14216. import { Camera } from "babylonjs/Cameras/camera";
  14217. import { Scene } from "babylonjs/scene";
  14218. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14219. import { Node } from "babylonjs/node";
  14220. import { Bone } from "babylonjs/Bones/bone";
  14221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14222. import { Space } from "babylonjs/Maths/math.axis";
  14223. /**
  14224. * 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.
  14225. * @see https://doc.babylonjs.com/how_to/transformnode
  14226. */
  14227. export class TransformNode extends Node {
  14228. /**
  14229. * Object will not rotate to face the camera
  14230. */
  14231. static BILLBOARDMODE_NONE: number;
  14232. /**
  14233. * Object will rotate to face the camera but only on the x axis
  14234. */
  14235. static BILLBOARDMODE_X: number;
  14236. /**
  14237. * Object will rotate to face the camera but only on the y axis
  14238. */
  14239. static BILLBOARDMODE_Y: number;
  14240. /**
  14241. * Object will rotate to face the camera but only on the z axis
  14242. */
  14243. static BILLBOARDMODE_Z: number;
  14244. /**
  14245. * Object will rotate to face the camera
  14246. */
  14247. static BILLBOARDMODE_ALL: number;
  14248. /**
  14249. * Object will rotate to face the camera's position instead of orientation
  14250. */
  14251. static BILLBOARDMODE_USE_POSITION: number;
  14252. private _forward;
  14253. private _forwardInverted;
  14254. private _up;
  14255. private _right;
  14256. private _rightInverted;
  14257. private _position;
  14258. private _rotation;
  14259. private _rotationQuaternion;
  14260. protected _scaling: Vector3;
  14261. protected _isDirty: boolean;
  14262. private _transformToBoneReferal;
  14263. private _isAbsoluteSynced;
  14264. private _billboardMode;
  14265. /**
  14266. * Gets or sets the billboard mode. Default is 0.
  14267. *
  14268. * | Value | Type | Description |
  14269. * | --- | --- | --- |
  14270. * | 0 | BILLBOARDMODE_NONE | |
  14271. * | 1 | BILLBOARDMODE_X | |
  14272. * | 2 | BILLBOARDMODE_Y | |
  14273. * | 4 | BILLBOARDMODE_Z | |
  14274. * | 7 | BILLBOARDMODE_ALL | |
  14275. *
  14276. */
  14277. billboardMode: number;
  14278. private _preserveParentRotationForBillboard;
  14279. /**
  14280. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14281. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14282. */
  14283. preserveParentRotationForBillboard: boolean;
  14284. /**
  14285. * 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
  14286. */
  14287. scalingDeterminant: number;
  14288. private _infiniteDistance;
  14289. /**
  14290. * Gets or sets the distance of the object to max, often used by skybox
  14291. */
  14292. infiniteDistance: boolean;
  14293. /**
  14294. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14295. * By default the system will update normals to compensate
  14296. */
  14297. ignoreNonUniformScaling: boolean;
  14298. /**
  14299. * 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
  14300. */
  14301. reIntegrateRotationIntoRotationQuaternion: boolean;
  14302. /** @hidden */
  14303. _poseMatrix: Nullable<Matrix>;
  14304. /** @hidden */
  14305. _localMatrix: Matrix;
  14306. private _usePivotMatrix;
  14307. private _absolutePosition;
  14308. private _absoluteScaling;
  14309. private _absoluteRotationQuaternion;
  14310. private _pivotMatrix;
  14311. private _pivotMatrixInverse;
  14312. protected _postMultiplyPivotMatrix: boolean;
  14313. protected _isWorldMatrixFrozen: boolean;
  14314. /** @hidden */
  14315. _indexInSceneTransformNodesArray: number;
  14316. /**
  14317. * An event triggered after the world matrix is updated
  14318. */
  14319. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14320. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14321. /**
  14322. * Gets a string identifying the name of the class
  14323. * @returns "TransformNode" string
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14328. */
  14329. position: Vector3;
  14330. /**
  14331. * 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)).
  14332. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14333. */
  14334. rotation: Vector3;
  14335. /**
  14336. * 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)).
  14337. */
  14338. scaling: Vector3;
  14339. /**
  14340. * 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).
  14341. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14342. */
  14343. rotationQuaternion: Nullable<Quaternion>;
  14344. /**
  14345. * The forward direction of that transform in world space.
  14346. */
  14347. readonly forward: Vector3;
  14348. /**
  14349. * The up direction of that transform in world space.
  14350. */
  14351. readonly up: Vector3;
  14352. /**
  14353. * The right direction of that transform in world space.
  14354. */
  14355. readonly right: Vector3;
  14356. /**
  14357. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14358. * @param matrix the matrix to copy the pose from
  14359. * @returns this TransformNode.
  14360. */
  14361. updatePoseMatrix(matrix: Matrix): TransformNode;
  14362. /**
  14363. * Returns the mesh Pose matrix.
  14364. * @returns the pose matrix
  14365. */
  14366. getPoseMatrix(): Matrix;
  14367. /** @hidden */
  14368. _isSynchronized(): boolean;
  14369. /** @hidden */
  14370. _initCache(): void;
  14371. /**
  14372. * Flag the transform node as dirty (Forcing it to update everything)
  14373. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14374. * @returns this transform node
  14375. */
  14376. markAsDirty(property: string): TransformNode;
  14377. /**
  14378. * Returns the current mesh absolute position.
  14379. * Returns a Vector3.
  14380. */
  14381. readonly absolutePosition: Vector3;
  14382. /**
  14383. * Returns the current mesh absolute scaling.
  14384. * Returns a Vector3.
  14385. */
  14386. readonly absoluteScaling: Vector3;
  14387. /**
  14388. * Returns the current mesh absolute rotation.
  14389. * Returns a Quaternion.
  14390. */
  14391. readonly absoluteRotationQuaternion: Quaternion;
  14392. /**
  14393. * Sets a new matrix to apply before all other transformation
  14394. * @param matrix defines the transform matrix
  14395. * @returns the current TransformNode
  14396. */
  14397. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14398. /**
  14399. * Sets a new pivot matrix to the current node
  14400. * @param matrix defines the new pivot matrix to use
  14401. * @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
  14402. * @returns the current TransformNode
  14403. */
  14404. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14405. /**
  14406. * Returns the mesh pivot matrix.
  14407. * Default : Identity.
  14408. * @returns the matrix
  14409. */
  14410. getPivotMatrix(): Matrix;
  14411. /**
  14412. * Instantiate (when possible) or clone that node with its hierarchy
  14413. * @param newParent defines the new parent to use for the instance (or clone)
  14414. * @param options defines options to configure how copy is done
  14415. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14416. * @returns an instance (or a clone) of the current node with its hiearchy
  14417. */
  14418. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14419. doNotInstantiate: boolean;
  14420. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14421. /**
  14422. * Prevents the World matrix to be computed any longer
  14423. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14424. * @returns the TransformNode.
  14425. */
  14426. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14427. /**
  14428. * Allows back the World matrix computation.
  14429. * @returns the TransformNode.
  14430. */
  14431. unfreezeWorldMatrix(): this;
  14432. /**
  14433. * True if the World matrix has been frozen.
  14434. */
  14435. readonly isWorldMatrixFrozen: boolean;
  14436. /**
  14437. * Retuns the mesh absolute position in the World.
  14438. * @returns a Vector3.
  14439. */
  14440. getAbsolutePosition(): Vector3;
  14441. /**
  14442. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14443. * @param absolutePosition the absolute position to set
  14444. * @returns the TransformNode.
  14445. */
  14446. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14447. /**
  14448. * Sets the mesh position in its local space.
  14449. * @param vector3 the position to set in localspace
  14450. * @returns the TransformNode.
  14451. */
  14452. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14453. /**
  14454. * Returns the mesh position in the local space from the current World matrix values.
  14455. * @returns a new Vector3.
  14456. */
  14457. getPositionExpressedInLocalSpace(): Vector3;
  14458. /**
  14459. * Translates the mesh along the passed Vector3 in its local space.
  14460. * @param vector3 the distance to translate in localspace
  14461. * @returns the TransformNode.
  14462. */
  14463. locallyTranslate(vector3: Vector3): TransformNode;
  14464. private static _lookAtVectorCache;
  14465. /**
  14466. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14467. * @param targetPoint the position (must be in same space as current mesh) to look at
  14468. * @param yawCor optional yaw (y-axis) correction in radians
  14469. * @param pitchCor optional pitch (x-axis) correction in radians
  14470. * @param rollCor optional roll (z-axis) correction in radians
  14471. * @param space the choosen space of the target
  14472. * @returns the TransformNode.
  14473. */
  14474. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14475. /**
  14476. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14477. * This Vector3 is expressed in the World space.
  14478. * @param localAxis axis to rotate
  14479. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14480. */
  14481. getDirection(localAxis: Vector3): Vector3;
  14482. /**
  14483. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14484. * localAxis is expressed in the mesh local space.
  14485. * result is computed in the Wordl space from the mesh World matrix.
  14486. * @param localAxis axis to rotate
  14487. * @param result the resulting transformnode
  14488. * @returns this TransformNode.
  14489. */
  14490. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14491. /**
  14492. * Sets this transform node rotation to the given local axis.
  14493. * @param localAxis the axis in local space
  14494. * @param yawCor optional yaw (y-axis) correction in radians
  14495. * @param pitchCor optional pitch (x-axis) correction in radians
  14496. * @param rollCor optional roll (z-axis) correction in radians
  14497. * @returns this TransformNode
  14498. */
  14499. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14500. /**
  14501. * Sets a new pivot point to the current node
  14502. * @param point defines the new pivot point to use
  14503. * @param space defines if the point is in world or local space (local by default)
  14504. * @returns the current TransformNode
  14505. */
  14506. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14507. /**
  14508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14509. * @returns the pivot point
  14510. */
  14511. getPivotPoint(): Vector3;
  14512. /**
  14513. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14514. * @param result the vector3 to store the result
  14515. * @returns this TransformNode.
  14516. */
  14517. getPivotPointToRef(result: Vector3): TransformNode;
  14518. /**
  14519. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14520. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14521. */
  14522. getAbsolutePivotPoint(): Vector3;
  14523. /**
  14524. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14525. * @param result vector3 to store the result
  14526. * @returns this TransformNode.
  14527. */
  14528. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14529. /**
  14530. * Defines the passed node as the parent of the current node.
  14531. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14532. * @see https://doc.babylonjs.com/how_to/parenting
  14533. * @param node the node ot set as the parent
  14534. * @returns this TransformNode.
  14535. */
  14536. setParent(node: Nullable<Node>): TransformNode;
  14537. private _nonUniformScaling;
  14538. /**
  14539. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14540. */
  14541. readonly nonUniformScaling: boolean;
  14542. /** @hidden */
  14543. _updateNonUniformScalingState(value: boolean): boolean;
  14544. /**
  14545. * Attach the current TransformNode to another TransformNode associated with a bone
  14546. * @param bone Bone affecting the TransformNode
  14547. * @param affectedTransformNode TransformNode associated with the bone
  14548. * @returns this object
  14549. */
  14550. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14551. /**
  14552. * Detach the transform node if its associated with a bone
  14553. * @returns this object
  14554. */
  14555. detachFromBone(): TransformNode;
  14556. private static _rotationAxisCache;
  14557. /**
  14558. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14559. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14560. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14561. * The passed axis is also normalized.
  14562. * @param axis the axis to rotate around
  14563. * @param amount the amount to rotate in radians
  14564. * @param space Space to rotate in (Default: local)
  14565. * @returns the TransformNode.
  14566. */
  14567. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14568. /**
  14569. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14571. * The passed axis is also normalized. .
  14572. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14573. * @param point the point to rotate around
  14574. * @param axis the axis to rotate around
  14575. * @param amount the amount to rotate in radians
  14576. * @returns the TransformNode
  14577. */
  14578. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14579. /**
  14580. * Translates the mesh along the axis vector for the passed distance in the given space.
  14581. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14582. * @param axis the axis to translate in
  14583. * @param distance the distance to translate
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14588. /**
  14589. * Adds a rotation step to the mesh current rotation.
  14590. * x, y, z are Euler angles expressed in radians.
  14591. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14592. * This means this rotation is made in the mesh local space only.
  14593. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14594. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14595. * ```javascript
  14596. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14597. * ```
  14598. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14599. * 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.
  14600. * @param x Rotation to add
  14601. * @param y Rotation to add
  14602. * @param z Rotation to add
  14603. * @returns the TransformNode.
  14604. */
  14605. addRotation(x: number, y: number, z: number): TransformNode;
  14606. /**
  14607. * @hidden
  14608. */
  14609. protected _getEffectiveParent(): Nullable<Node>;
  14610. /**
  14611. * Computes the world matrix of the node
  14612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14613. * @returns the world matrix
  14614. */
  14615. computeWorldMatrix(force?: boolean): Matrix;
  14616. protected _afterComputeWorldMatrix(): void;
  14617. /**
  14618. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14619. * @param func callback function to add
  14620. *
  14621. * @returns the TransformNode.
  14622. */
  14623. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14624. /**
  14625. * Removes a registered callback function.
  14626. * @param func callback function to remove
  14627. * @returns the TransformNode.
  14628. */
  14629. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14630. /**
  14631. * Gets the position of the current mesh in camera space
  14632. * @param camera defines the camera to use
  14633. * @returns a position
  14634. */
  14635. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14636. /**
  14637. * Returns the distance from the mesh to the active camera
  14638. * @param camera defines the camera to use
  14639. * @returns the distance
  14640. */
  14641. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14642. /**
  14643. * Clone the current transform node
  14644. * @param name Name of the new clone
  14645. * @param newParent New parent for the clone
  14646. * @param doNotCloneChildren Do not clone children hierarchy
  14647. * @returns the new transform node
  14648. */
  14649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14650. /**
  14651. * Serializes the objects information.
  14652. * @param currentSerializationObject defines the object to serialize in
  14653. * @returns the serialized object
  14654. */
  14655. serialize(currentSerializationObject?: any): any;
  14656. /**
  14657. * Returns a new TransformNode object parsed from the source provided.
  14658. * @param parsedTransformNode is the source.
  14659. * @param scene the scne the object belongs to
  14660. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14661. * @returns a new TransformNode object parsed from the source provided.
  14662. */
  14663. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14664. /**
  14665. * Get all child-transformNodes of this node
  14666. * @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
  14667. * @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
  14668. * @returns an array of TransformNode
  14669. */
  14670. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14671. /**
  14672. * Releases resources associated with this transform node.
  14673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14675. */
  14676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14677. /**
  14678. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14679. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14680. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14681. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14682. * @returns the current mesh
  14683. */
  14684. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14685. private _syncAbsoluteScalingAndRotation;
  14686. }
  14687. }
  14688. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14689. import { Observable } from "babylonjs/Misc/observable";
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14694. import { Ray } from "babylonjs/Culling/ray";
  14695. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14696. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14697. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14698. /**
  14699. * Defines the types of pose enabled controllers that are supported
  14700. */
  14701. export enum PoseEnabledControllerType {
  14702. /**
  14703. * HTC Vive
  14704. */
  14705. VIVE = 0,
  14706. /**
  14707. * Oculus Rift
  14708. */
  14709. OCULUS = 1,
  14710. /**
  14711. * Windows mixed reality
  14712. */
  14713. WINDOWS = 2,
  14714. /**
  14715. * Samsung gear VR
  14716. */
  14717. GEAR_VR = 3,
  14718. /**
  14719. * Google Daydream
  14720. */
  14721. DAYDREAM = 4,
  14722. /**
  14723. * Generic
  14724. */
  14725. GENERIC = 5
  14726. }
  14727. /**
  14728. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14729. */
  14730. export interface MutableGamepadButton {
  14731. /**
  14732. * Value of the button/trigger
  14733. */
  14734. value: number;
  14735. /**
  14736. * If the button/trigger is currently touched
  14737. */
  14738. touched: boolean;
  14739. /**
  14740. * If the button/trigger is currently pressed
  14741. */
  14742. pressed: boolean;
  14743. }
  14744. /**
  14745. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14746. * @hidden
  14747. */
  14748. export interface ExtendedGamepadButton extends GamepadButton {
  14749. /**
  14750. * If the button/trigger is currently pressed
  14751. */
  14752. readonly pressed: boolean;
  14753. /**
  14754. * If the button/trigger is currently touched
  14755. */
  14756. readonly touched: boolean;
  14757. /**
  14758. * Value of the button/trigger
  14759. */
  14760. readonly value: number;
  14761. }
  14762. /** @hidden */
  14763. export interface _GamePadFactory {
  14764. /**
  14765. * Returns wether or not the current gamepad can be created for this type of controller.
  14766. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14767. * @returns true if it can be created, otherwise false
  14768. */
  14769. canCreate(gamepadInfo: any): boolean;
  14770. /**
  14771. * Creates a new instance of the Gamepad.
  14772. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14773. * @returns the new gamepad instance
  14774. */
  14775. create(gamepadInfo: any): Gamepad;
  14776. }
  14777. /**
  14778. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14779. */
  14780. export class PoseEnabledControllerHelper {
  14781. /** @hidden */
  14782. static _ControllerFactories: _GamePadFactory[];
  14783. /** @hidden */
  14784. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14785. /**
  14786. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14787. * @param vrGamepad the gamepad to initialized
  14788. * @returns a vr controller of the type the gamepad identified as
  14789. */
  14790. static InitiateController(vrGamepad: any): Gamepad;
  14791. }
  14792. /**
  14793. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14794. */
  14795. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14796. /**
  14797. * If the controller is used in a webXR session
  14798. */
  14799. isXR: boolean;
  14800. private _deviceRoomPosition;
  14801. private _deviceRoomRotationQuaternion;
  14802. /**
  14803. * The device position in babylon space
  14804. */
  14805. devicePosition: Vector3;
  14806. /**
  14807. * The device rotation in babylon space
  14808. */
  14809. deviceRotationQuaternion: Quaternion;
  14810. /**
  14811. * The scale factor of the device in babylon space
  14812. */
  14813. deviceScaleFactor: number;
  14814. /**
  14815. * (Likely devicePosition should be used instead) The device position in its room space
  14816. */
  14817. position: Vector3;
  14818. /**
  14819. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14820. */
  14821. rotationQuaternion: Quaternion;
  14822. /**
  14823. * The type of controller (Eg. Windows mixed reality)
  14824. */
  14825. controllerType: PoseEnabledControllerType;
  14826. protected _calculatedPosition: Vector3;
  14827. private _calculatedRotation;
  14828. /**
  14829. * The raw pose from the device
  14830. */
  14831. rawPose: DevicePose;
  14832. private _trackPosition;
  14833. private _maxRotationDistFromHeadset;
  14834. private _draggedRoomRotation;
  14835. /**
  14836. * @hidden
  14837. */
  14838. _disableTrackPosition(fixedPosition: Vector3): void;
  14839. /**
  14840. * Internal, the mesh attached to the controller
  14841. * @hidden
  14842. */
  14843. _mesh: Nullable<AbstractMesh>;
  14844. private _poseControlledCamera;
  14845. private _leftHandSystemQuaternion;
  14846. /**
  14847. * Internal, matrix used to convert room space to babylon space
  14848. * @hidden
  14849. */
  14850. _deviceToWorld: Matrix;
  14851. /**
  14852. * Node to be used when casting a ray from the controller
  14853. * @hidden
  14854. */
  14855. _pointingPoseNode: Nullable<TransformNode>;
  14856. /**
  14857. * Name of the child mesh that can be used to cast a ray from the controller
  14858. */
  14859. static readonly POINTING_POSE: string;
  14860. /**
  14861. * Creates a new PoseEnabledController from a gamepad
  14862. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14863. */
  14864. constructor(browserGamepad: any);
  14865. private _workingMatrix;
  14866. /**
  14867. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14868. */
  14869. update(): void;
  14870. /**
  14871. * Updates only the pose device and mesh without doing any button event checking
  14872. */
  14873. protected _updatePoseAndMesh(): void;
  14874. /**
  14875. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14876. * @param poseData raw pose fromthe device
  14877. */
  14878. updateFromDevice(poseData: DevicePose): void;
  14879. /**
  14880. * @hidden
  14881. */
  14882. _meshAttachedObservable: Observable<AbstractMesh>;
  14883. /**
  14884. * Attaches a mesh to the controller
  14885. * @param mesh the mesh to be attached
  14886. */
  14887. attachToMesh(mesh: AbstractMesh): void;
  14888. /**
  14889. * Attaches the controllers mesh to a camera
  14890. * @param camera the camera the mesh should be attached to
  14891. */
  14892. attachToPoseControlledCamera(camera: TargetCamera): void;
  14893. /**
  14894. * Disposes of the controller
  14895. */
  14896. dispose(): void;
  14897. /**
  14898. * The mesh that is attached to the controller
  14899. */
  14900. readonly mesh: Nullable<AbstractMesh>;
  14901. /**
  14902. * Gets the ray of the controller in the direction the controller is pointing
  14903. * @param length the length the resulting ray should be
  14904. * @returns a ray in the direction the controller is pointing
  14905. */
  14906. getForwardRay(length?: number): Ray;
  14907. }
  14908. }
  14909. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14910. import { Observable } from "babylonjs/Misc/observable";
  14911. import { Scene } from "babylonjs/scene";
  14912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14913. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14914. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14915. import { Nullable } from "babylonjs/types";
  14916. /**
  14917. * Defines the WebVRController object that represents controllers tracked in 3D space
  14918. */
  14919. export abstract class WebVRController extends PoseEnabledController {
  14920. /**
  14921. * Internal, the default controller model for the controller
  14922. */
  14923. protected _defaultModel: Nullable<AbstractMesh>;
  14924. /**
  14925. * Fired when the trigger state has changed
  14926. */
  14927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14928. /**
  14929. * Fired when the main button state has changed
  14930. */
  14931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14932. /**
  14933. * Fired when the secondary button state has changed
  14934. */
  14935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14936. /**
  14937. * Fired when the pad state has changed
  14938. */
  14939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14940. /**
  14941. * Fired when controllers stick values have changed
  14942. */
  14943. onPadValuesChangedObservable: Observable<StickValues>;
  14944. /**
  14945. * Array of button availible on the controller
  14946. */
  14947. protected _buttons: Array<MutableGamepadButton>;
  14948. private _onButtonStateChange;
  14949. /**
  14950. * Fired when a controller button's state has changed
  14951. * @param callback the callback containing the button that was modified
  14952. */
  14953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14954. /**
  14955. * X and Y axis corresponding to the controllers joystick
  14956. */
  14957. pad: StickValues;
  14958. /**
  14959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14960. */
  14961. hand: string;
  14962. /**
  14963. * The default controller model for the controller
  14964. */
  14965. readonly defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Creates a new WebVRController from a gamepad
  14968. * @param vrGamepad the gamepad that the WebVRController should be created from
  14969. */
  14970. constructor(vrGamepad: any);
  14971. /**
  14972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14973. */
  14974. update(): void;
  14975. /**
  14976. * Function to be called when a button is modified
  14977. */
  14978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14979. /**
  14980. * Loads a mesh and attaches it to the controller
  14981. * @param scene the scene the mesh should be added to
  14982. * @param meshLoaded callback for when the mesh has been loaded
  14983. */
  14984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14985. private _setButtonValue;
  14986. private _changes;
  14987. private _checkChanges;
  14988. /**
  14989. * Disposes of th webVRCOntroller
  14990. */
  14991. dispose(): void;
  14992. }
  14993. }
  14994. declare module "babylonjs/Lights/hemisphericLight" {
  14995. import { Nullable } from "babylonjs/types";
  14996. import { Scene } from "babylonjs/scene";
  14997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14998. import { Color3 } from "babylonjs/Maths/math.color";
  14999. import { Effect } from "babylonjs/Materials/effect";
  15000. import { Light } from "babylonjs/Lights/light";
  15001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15002. /**
  15003. * The HemisphericLight simulates the ambient environment light,
  15004. * so the passed direction is the light reflection direction, not the incoming direction.
  15005. */
  15006. export class HemisphericLight extends Light {
  15007. /**
  15008. * The groundColor is the light in the opposite direction to the one specified during creation.
  15009. * 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.
  15010. */
  15011. groundColor: Color3;
  15012. /**
  15013. * The light reflection direction, not the incoming direction.
  15014. */
  15015. direction: Vector3;
  15016. /**
  15017. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15018. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15019. * The HemisphericLight can't cast shadows.
  15020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15021. * @param name The friendly name of the light
  15022. * @param direction The direction of the light reflection
  15023. * @param scene The scene the light belongs to
  15024. */
  15025. constructor(name: string, direction: Vector3, scene: Scene);
  15026. protected _buildUniformLayout(): void;
  15027. /**
  15028. * Returns the string "HemisphericLight".
  15029. * @return The class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15034. * Returns the updated direction.
  15035. * @param target The target the direction should point to
  15036. * @return The computed direction
  15037. */
  15038. setDirectionToTarget(target: Vector3): Vector3;
  15039. /**
  15040. * Returns the shadow generator associated to the light.
  15041. * @returns Always null for hemispheric lights because it does not support shadows.
  15042. */
  15043. getShadowGenerator(): Nullable<IShadowGenerator>;
  15044. /**
  15045. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15046. * @param effect The effect to update
  15047. * @param lightIndex The index of the light in the effect to update
  15048. * @returns The hemispheric light
  15049. */
  15050. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15051. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15052. /**
  15053. * Computes the world matrix of the node
  15054. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15055. * @param useWasUpdatedFlag defines a reserved property
  15056. * @returns the world matrix
  15057. */
  15058. computeWorldMatrix(): Matrix;
  15059. /**
  15060. * Returns the integer 3.
  15061. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15062. */
  15063. getTypeID(): number;
  15064. /**
  15065. * Prepares the list of defines specific to the light type.
  15066. * @param defines the list of defines
  15067. * @param lightIndex defines the index of the light for the effect
  15068. */
  15069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15070. }
  15071. }
  15072. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15073. /** @hidden */
  15074. export var vrMultiviewToSingleviewPixelShader: {
  15075. name: string;
  15076. shader: string;
  15077. };
  15078. }
  15079. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15081. import { Scene } from "babylonjs/scene";
  15082. /**
  15083. * Renders to multiple views with a single draw call
  15084. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15085. */
  15086. export class MultiviewRenderTarget extends RenderTargetTexture {
  15087. /**
  15088. * Creates a multiview render target
  15089. * @param scene scene used with the render target
  15090. * @param size the size of the render target (used for each view)
  15091. */
  15092. constructor(scene: Scene, size?: number | {
  15093. width: number;
  15094. height: number;
  15095. } | {
  15096. ratio: number;
  15097. });
  15098. /**
  15099. * @hidden
  15100. * @param faceIndex the face index, if its a cube texture
  15101. */
  15102. _bindFrameBuffer(faceIndex?: number): void;
  15103. /**
  15104. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15105. * @returns the view count
  15106. */
  15107. getViewCount(): number;
  15108. }
  15109. }
  15110. declare module "babylonjs/Maths/math.frustum" {
  15111. import { Matrix } from "babylonjs/Maths/math.vector";
  15112. import { DeepImmutable } from "babylonjs/types";
  15113. import { Plane } from "babylonjs/Maths/math.plane";
  15114. /**
  15115. * Represents a camera frustum
  15116. */
  15117. export class Frustum {
  15118. /**
  15119. * Gets the planes representing the frustum
  15120. * @param transform matrix to be applied to the returned planes
  15121. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15122. */
  15123. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15124. /**
  15125. * Gets the near frustum plane transformed by the transform matrix
  15126. * @param transform transformation matrix to be applied to the resulting frustum plane
  15127. * @param frustumPlane the resuling frustum plane
  15128. */
  15129. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15130. /**
  15131. * Gets the far frustum plane transformed by the transform matrix
  15132. * @param transform transformation matrix to be applied to the resulting frustum plane
  15133. * @param frustumPlane the resuling frustum plane
  15134. */
  15135. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15136. /**
  15137. * Gets the left frustum plane transformed by the transform matrix
  15138. * @param transform transformation matrix to be applied to the resulting frustum plane
  15139. * @param frustumPlane the resuling frustum plane
  15140. */
  15141. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15142. /**
  15143. * Gets the right frustum plane transformed by the transform matrix
  15144. * @param transform transformation matrix to be applied to the resulting frustum plane
  15145. * @param frustumPlane the resuling frustum plane
  15146. */
  15147. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15148. /**
  15149. * Gets the top frustum plane transformed by the transform matrix
  15150. * @param transform transformation matrix to be applied to the resulting frustum plane
  15151. * @param frustumPlane the resuling frustum plane
  15152. */
  15153. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15154. /**
  15155. * Gets the bottom frustum plane transformed by the transform matrix
  15156. * @param transform transformation matrix to be applied to the resulting frustum plane
  15157. * @param frustumPlane the resuling frustum plane
  15158. */
  15159. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15160. /**
  15161. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15162. * @param transform transformation matrix to be applied to the resulting frustum planes
  15163. * @param frustumPlanes the resuling frustum planes
  15164. */
  15165. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15166. }
  15167. }
  15168. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15169. import { Camera } from "babylonjs/Cameras/camera";
  15170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15171. import { Nullable } from "babylonjs/types";
  15172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15173. import { Matrix } from "babylonjs/Maths/math.vector";
  15174. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /**
  15178. * Creates a new multiview render target
  15179. * @param width defines the width of the texture
  15180. * @param height defines the height of the texture
  15181. * @returns the created multiview texture
  15182. */
  15183. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15184. /**
  15185. * Binds a multiview framebuffer to be drawn to
  15186. * @param multiviewTexture texture to bind
  15187. */
  15188. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15189. }
  15190. }
  15191. module "babylonjs/Cameras/camera" {
  15192. interface Camera {
  15193. /**
  15194. * @hidden
  15195. * 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)
  15196. */
  15197. _useMultiviewToSingleView: boolean;
  15198. /**
  15199. * @hidden
  15200. * 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)
  15201. */
  15202. _multiviewTexture: Nullable<RenderTargetTexture>;
  15203. /**
  15204. * @hidden
  15205. * ensures the multiview texture of the camera exists and has the specified width/height
  15206. * @param width height to set on the multiview texture
  15207. * @param height width to set on the multiview texture
  15208. */
  15209. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15210. }
  15211. }
  15212. module "babylonjs/scene" {
  15213. interface Scene {
  15214. /** @hidden */
  15215. _transformMatrixR: Matrix;
  15216. /** @hidden */
  15217. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15218. /** @hidden */
  15219. _createMultiviewUbo(): void;
  15220. /** @hidden */
  15221. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15222. /** @hidden */
  15223. _renderMultiviewToSingleView(camera: Camera): void;
  15224. }
  15225. }
  15226. }
  15227. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15228. import { Camera } from "babylonjs/Cameras/camera";
  15229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15230. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15231. import "babylonjs/Engines/Extensions/engine.multiview";
  15232. /**
  15233. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15234. * This will not be used for webXR as it supports displaying texture arrays directly
  15235. */
  15236. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15237. /**
  15238. * Initializes a VRMultiviewToSingleview
  15239. * @param name name of the post process
  15240. * @param camera camera to be applied to
  15241. * @param scaleFactor scaling factor to the size of the output texture
  15242. */
  15243. constructor(name: string, camera: Camera, scaleFactor: number);
  15244. }
  15245. }
  15246. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15247. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15248. import { Nullable } from "babylonjs/types";
  15249. import { Size } from "babylonjs/Maths/math.size";
  15250. import { Observable } from "babylonjs/Misc/observable";
  15251. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15252. /**
  15253. * Interface used to define additional presentation attributes
  15254. */
  15255. export interface IVRPresentationAttributes {
  15256. /**
  15257. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15258. */
  15259. highRefreshRate: boolean;
  15260. /**
  15261. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15262. */
  15263. foveationLevel: number;
  15264. }
  15265. module "babylonjs/Engines/engine" {
  15266. interface Engine {
  15267. /** @hidden */
  15268. _vrDisplay: any;
  15269. /** @hidden */
  15270. _vrSupported: boolean;
  15271. /** @hidden */
  15272. _oldSize: Size;
  15273. /** @hidden */
  15274. _oldHardwareScaleFactor: number;
  15275. /** @hidden */
  15276. _vrExclusivePointerMode: boolean;
  15277. /** @hidden */
  15278. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15279. /** @hidden */
  15280. _onVRDisplayPointerRestricted: () => void;
  15281. /** @hidden */
  15282. _onVRDisplayPointerUnrestricted: () => void;
  15283. /** @hidden */
  15284. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15285. /** @hidden */
  15286. _onVrDisplayDisconnect: Nullable<() => void>;
  15287. /** @hidden */
  15288. _onVrDisplayPresentChange: Nullable<() => void>;
  15289. /**
  15290. * Observable signaled when VR display mode changes
  15291. */
  15292. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15293. /**
  15294. * Observable signaled when VR request present is complete
  15295. */
  15296. onVRRequestPresentComplete: Observable<boolean>;
  15297. /**
  15298. * Observable signaled when VR request present starts
  15299. */
  15300. onVRRequestPresentStart: Observable<Engine>;
  15301. /**
  15302. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15303. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15304. */
  15305. isInVRExclusivePointerMode: boolean;
  15306. /**
  15307. * Gets a boolean indicating if a webVR device was detected
  15308. * @returns true if a webVR device was detected
  15309. */
  15310. isVRDevicePresent(): boolean;
  15311. /**
  15312. * Gets the current webVR device
  15313. * @returns the current webVR device (or null)
  15314. */
  15315. getVRDevice(): any;
  15316. /**
  15317. * Initializes a webVR display and starts listening to display change events
  15318. * The onVRDisplayChangedObservable will be notified upon these changes
  15319. * @returns A promise containing a VRDisplay and if vr is supported
  15320. */
  15321. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15322. /** @hidden */
  15323. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15324. /**
  15325. * Gets or sets the presentation attributes used to configure VR rendering
  15326. */
  15327. vrPresentationAttributes?: IVRPresentationAttributes;
  15328. /**
  15329. * Call this function to switch to webVR mode
  15330. * Will do nothing if webVR is not supported or if there is no webVR device
  15331. * @param options the webvr options provided to the camera. mainly used for multiview
  15332. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15333. */
  15334. enableVR(options: WebVROptions): void;
  15335. /** @hidden */
  15336. _onVRFullScreenTriggered(): void;
  15337. }
  15338. }
  15339. }
  15340. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15341. import { Nullable } from "babylonjs/types";
  15342. import { Observable } from "babylonjs/Misc/observable";
  15343. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15344. import { Scene } from "babylonjs/scene";
  15345. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15346. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15347. import { Node } from "babylonjs/node";
  15348. import { Ray } from "babylonjs/Culling/ray";
  15349. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15350. import "babylonjs/Engines/Extensions/engine.webVR";
  15351. /**
  15352. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15353. * IMPORTANT!! The data is right-hand data.
  15354. * @export
  15355. * @interface DevicePose
  15356. */
  15357. export interface DevicePose {
  15358. /**
  15359. * The position of the device, values in array are [x,y,z].
  15360. */
  15361. readonly position: Nullable<Float32Array>;
  15362. /**
  15363. * The linearVelocity of the device, values in array are [x,y,z].
  15364. */
  15365. readonly linearVelocity: Nullable<Float32Array>;
  15366. /**
  15367. * The linearAcceleration of the device, values in array are [x,y,z].
  15368. */
  15369. readonly linearAcceleration: Nullable<Float32Array>;
  15370. /**
  15371. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15372. */
  15373. readonly orientation: Nullable<Float32Array>;
  15374. /**
  15375. * The angularVelocity of the device, values in array are [x,y,z].
  15376. */
  15377. readonly angularVelocity: Nullable<Float32Array>;
  15378. /**
  15379. * The angularAcceleration of the device, values in array are [x,y,z].
  15380. */
  15381. readonly angularAcceleration: Nullable<Float32Array>;
  15382. }
  15383. /**
  15384. * Interface representing a pose controlled object in Babylon.
  15385. * A pose controlled object has both regular pose values as well as pose values
  15386. * from an external device such as a VR head mounted display
  15387. */
  15388. export interface PoseControlled {
  15389. /**
  15390. * The position of the object in babylon space.
  15391. */
  15392. position: Vector3;
  15393. /**
  15394. * The rotation quaternion of the object in babylon space.
  15395. */
  15396. rotationQuaternion: Quaternion;
  15397. /**
  15398. * The position of the device in babylon space.
  15399. */
  15400. devicePosition?: Vector3;
  15401. /**
  15402. * The rotation quaternion of the device in babylon space.
  15403. */
  15404. deviceRotationQuaternion: Quaternion;
  15405. /**
  15406. * The raw pose coming from the device.
  15407. */
  15408. rawPose: Nullable<DevicePose>;
  15409. /**
  15410. * The scale of the device to be used when translating from device space to babylon space.
  15411. */
  15412. deviceScaleFactor: number;
  15413. /**
  15414. * Updates the poseControlled values based on the input device pose.
  15415. * @param poseData the pose data to update the object with
  15416. */
  15417. updateFromDevice(poseData: DevicePose): void;
  15418. }
  15419. /**
  15420. * Set of options to customize the webVRCamera
  15421. */
  15422. export interface WebVROptions {
  15423. /**
  15424. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15425. */
  15426. trackPosition?: boolean;
  15427. /**
  15428. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15429. */
  15430. positionScale?: number;
  15431. /**
  15432. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15433. */
  15434. displayName?: string;
  15435. /**
  15436. * Should the native controller meshes be initialized. (default: true)
  15437. */
  15438. controllerMeshes?: boolean;
  15439. /**
  15440. * Creating a default HemiLight only on controllers. (default: true)
  15441. */
  15442. defaultLightingOnControllers?: boolean;
  15443. /**
  15444. * If you don't want to use the default VR button of the helper. (default: false)
  15445. */
  15446. useCustomVRButton?: boolean;
  15447. /**
  15448. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15449. */
  15450. customVRButton?: HTMLButtonElement;
  15451. /**
  15452. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15453. */
  15454. rayLength?: number;
  15455. /**
  15456. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15457. */
  15458. defaultHeight?: number;
  15459. /**
  15460. * If multiview should be used if availible (default: false)
  15461. */
  15462. useMultiview?: boolean;
  15463. }
  15464. /**
  15465. * This represents a WebVR camera.
  15466. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15467. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15468. */
  15469. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15470. private webVROptions;
  15471. /**
  15472. * @hidden
  15473. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15474. */
  15475. _vrDevice: any;
  15476. /**
  15477. * The rawPose of the vrDevice.
  15478. */
  15479. rawPose: Nullable<DevicePose>;
  15480. private _onVREnabled;
  15481. private _specsVersion;
  15482. private _attached;
  15483. private _frameData;
  15484. protected _descendants: Array<Node>;
  15485. private _deviceRoomPosition;
  15486. /** @hidden */
  15487. _deviceRoomRotationQuaternion: Quaternion;
  15488. private _standingMatrix;
  15489. /**
  15490. * Represents device position in babylon space.
  15491. */
  15492. devicePosition: Vector3;
  15493. /**
  15494. * Represents device rotation in babylon space.
  15495. */
  15496. deviceRotationQuaternion: Quaternion;
  15497. /**
  15498. * The scale of the device to be used when translating from device space to babylon space.
  15499. */
  15500. deviceScaleFactor: number;
  15501. private _deviceToWorld;
  15502. private _worldToDevice;
  15503. /**
  15504. * References to the webVR controllers for the vrDevice.
  15505. */
  15506. controllers: Array<WebVRController>;
  15507. /**
  15508. * Emits an event when a controller is attached.
  15509. */
  15510. onControllersAttachedObservable: Observable<WebVRController[]>;
  15511. /**
  15512. * Emits an event when a controller's mesh has been loaded;
  15513. */
  15514. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15515. /**
  15516. * Emits an event when the HMD's pose has been updated.
  15517. */
  15518. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15519. private _poseSet;
  15520. /**
  15521. * If the rig cameras be used as parent instead of this camera.
  15522. */
  15523. rigParenting: boolean;
  15524. private _lightOnControllers;
  15525. private _defaultHeight?;
  15526. /**
  15527. * Instantiates a WebVRFreeCamera.
  15528. * @param name The name of the WebVRFreeCamera
  15529. * @param position The starting anchor position for the camera
  15530. * @param scene The scene the camera belongs to
  15531. * @param webVROptions a set of customizable options for the webVRCamera
  15532. */
  15533. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15534. /**
  15535. * Gets the device distance from the ground in meters.
  15536. * @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.
  15537. */
  15538. deviceDistanceToRoomGround(): number;
  15539. /**
  15540. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15541. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15542. */
  15543. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15544. /**
  15545. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15546. * @returns A promise with a boolean set to if the standing matrix is supported.
  15547. */
  15548. useStandingMatrixAsync(): Promise<boolean>;
  15549. /**
  15550. * Disposes the camera
  15551. */
  15552. dispose(): void;
  15553. /**
  15554. * Gets a vrController by name.
  15555. * @param name The name of the controller to retreive
  15556. * @returns the controller matching the name specified or null if not found
  15557. */
  15558. getControllerByName(name: string): Nullable<WebVRController>;
  15559. private _leftController;
  15560. /**
  15561. * The controller corresponding to the users left hand.
  15562. */
  15563. readonly leftController: Nullable<WebVRController>;
  15564. private _rightController;
  15565. /**
  15566. * The controller corresponding to the users right hand.
  15567. */
  15568. readonly rightController: Nullable<WebVRController>;
  15569. /**
  15570. * Casts a ray forward from the vrCamera's gaze.
  15571. * @param length Length of the ray (default: 100)
  15572. * @returns the ray corresponding to the gaze
  15573. */
  15574. getForwardRay(length?: number): Ray;
  15575. /**
  15576. * @hidden
  15577. * Updates the camera based on device's frame data
  15578. */
  15579. _checkInputs(): void;
  15580. /**
  15581. * Updates the poseControlled values based on the input device pose.
  15582. * @param poseData Pose coming from the device
  15583. */
  15584. updateFromDevice(poseData: DevicePose): void;
  15585. private _htmlElementAttached;
  15586. private _detachIfAttached;
  15587. /**
  15588. * WebVR's attach control will start broadcasting frames to the device.
  15589. * Note that in certain browsers (chrome for example) this function must be called
  15590. * within a user-interaction callback. Example:
  15591. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15592. *
  15593. * @param element html element to attach the vrDevice to
  15594. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15595. */
  15596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15597. /**
  15598. * Detaches the camera from the html element and disables VR
  15599. *
  15600. * @param element html element to detach from
  15601. */
  15602. detachControl(element: HTMLElement): void;
  15603. /**
  15604. * @returns the name of this class
  15605. */
  15606. getClassName(): string;
  15607. /**
  15608. * Calls resetPose on the vrDisplay
  15609. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15610. */
  15611. resetToCurrentRotation(): void;
  15612. /**
  15613. * @hidden
  15614. * Updates the rig cameras (left and right eye)
  15615. */
  15616. _updateRigCameras(): void;
  15617. private _workingVector;
  15618. private _oneVector;
  15619. private _workingMatrix;
  15620. private updateCacheCalled;
  15621. private _correctPositionIfNotTrackPosition;
  15622. /**
  15623. * @hidden
  15624. * Updates the cached values of the camera
  15625. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15626. */
  15627. _updateCache(ignoreParentClass?: boolean): void;
  15628. /**
  15629. * @hidden
  15630. * Get current device position in babylon world
  15631. */
  15632. _computeDevicePosition(): void;
  15633. /**
  15634. * Updates the current device position and rotation in the babylon world
  15635. */
  15636. update(): void;
  15637. /**
  15638. * @hidden
  15639. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15640. * @returns an identity matrix
  15641. */
  15642. _getViewMatrix(): Matrix;
  15643. private _tmpMatrix;
  15644. /**
  15645. * This function is called by the two RIG cameras.
  15646. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15647. * @hidden
  15648. */
  15649. _getWebVRViewMatrix(): Matrix;
  15650. /** @hidden */
  15651. _getWebVRProjectionMatrix(): Matrix;
  15652. private _onGamepadConnectedObserver;
  15653. private _onGamepadDisconnectedObserver;
  15654. private _updateCacheWhenTrackingDisabledObserver;
  15655. /**
  15656. * Initializes the controllers and their meshes
  15657. */
  15658. initControllers(): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/PostProcesses/postProcess" {
  15662. import { Nullable } from "babylonjs/types";
  15663. import { SmartArray } from "babylonjs/Misc/smartArray";
  15664. import { Observable } from "babylonjs/Misc/observable";
  15665. import { Vector2 } from "babylonjs/Maths/math.vector";
  15666. import { Camera } from "babylonjs/Cameras/camera";
  15667. import { Effect } from "babylonjs/Materials/effect";
  15668. import "babylonjs/Shaders/postprocess.vertex";
  15669. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15670. import { Engine } from "babylonjs/Engines/engine";
  15671. import { Color4 } from "babylonjs/Maths/math.color";
  15672. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15674. /**
  15675. * Size options for a post process
  15676. */
  15677. export type PostProcessOptions = {
  15678. width: number;
  15679. height: number;
  15680. };
  15681. /**
  15682. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15683. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15684. */
  15685. export class PostProcess {
  15686. /** Name of the PostProcess. */
  15687. name: string;
  15688. /**
  15689. * Gets or sets the unique id of the post process
  15690. */
  15691. uniqueId: number;
  15692. /**
  15693. * Width of the texture to apply the post process on
  15694. */
  15695. width: number;
  15696. /**
  15697. * Height of the texture to apply the post process on
  15698. */
  15699. height: number;
  15700. /**
  15701. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15702. * @hidden
  15703. */
  15704. _outputTexture: Nullable<InternalTexture>;
  15705. /**
  15706. * Sampling mode used by the shader
  15707. * See https://doc.babylonjs.com/classes/3.1/texture
  15708. */
  15709. renderTargetSamplingMode: number;
  15710. /**
  15711. * Clear color to use when screen clearing
  15712. */
  15713. clearColor: Color4;
  15714. /**
  15715. * If the buffer needs to be cleared before applying the post process. (default: true)
  15716. * Should be set to false if shader will overwrite all previous pixels.
  15717. */
  15718. autoClear: boolean;
  15719. /**
  15720. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15721. */
  15722. alphaMode: number;
  15723. /**
  15724. * Sets the setAlphaBlendConstants of the babylon engine
  15725. */
  15726. alphaConstants: Color4;
  15727. /**
  15728. * Animations to be used for the post processing
  15729. */
  15730. animations: import("babylonjs/Animations/animation").Animation[];
  15731. /**
  15732. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15733. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15734. */
  15735. enablePixelPerfectMode: boolean;
  15736. /**
  15737. * Force the postprocess to be applied without taking in account viewport
  15738. */
  15739. forceFullscreenViewport: boolean;
  15740. /**
  15741. * List of inspectable custom properties (used by the Inspector)
  15742. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15743. */
  15744. inspectableCustomProperties: IInspectable[];
  15745. /**
  15746. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15747. *
  15748. * | Value | Type | Description |
  15749. * | ----- | ----------------------------------- | ----------- |
  15750. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15751. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15752. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15753. *
  15754. */
  15755. scaleMode: number;
  15756. /**
  15757. * Force textures to be a power of two (default: false)
  15758. */
  15759. alwaysForcePOT: boolean;
  15760. private _samples;
  15761. /**
  15762. * Number of sample textures (default: 1)
  15763. */
  15764. samples: number;
  15765. /**
  15766. * Modify the scale of the post process to be the same as the viewport (default: false)
  15767. */
  15768. adaptScaleToCurrentViewport: boolean;
  15769. private _camera;
  15770. private _scene;
  15771. private _engine;
  15772. private _options;
  15773. private _reusable;
  15774. private _textureType;
  15775. /**
  15776. * Smart array of input and output textures for the post process.
  15777. * @hidden
  15778. */
  15779. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15780. /**
  15781. * The index in _textures that corresponds to the output texture.
  15782. * @hidden
  15783. */
  15784. _currentRenderTextureInd: number;
  15785. private _effect;
  15786. private _samplers;
  15787. private _fragmentUrl;
  15788. private _vertexUrl;
  15789. private _parameters;
  15790. private _scaleRatio;
  15791. protected _indexParameters: any;
  15792. private _shareOutputWithPostProcess;
  15793. private _texelSize;
  15794. private _forcedOutputTexture;
  15795. /**
  15796. * Returns the fragment url or shader name used in the post process.
  15797. * @returns the fragment url or name in the shader store.
  15798. */
  15799. getEffectName(): string;
  15800. /**
  15801. * An event triggered when the postprocess is activated.
  15802. */
  15803. onActivateObservable: Observable<Camera>;
  15804. private _onActivateObserver;
  15805. /**
  15806. * A function that is added to the onActivateObservable
  15807. */
  15808. onActivate: Nullable<(camera: Camera) => void>;
  15809. /**
  15810. * An event triggered when the postprocess changes its size.
  15811. */
  15812. onSizeChangedObservable: Observable<PostProcess>;
  15813. private _onSizeChangedObserver;
  15814. /**
  15815. * A function that is added to the onSizeChangedObservable
  15816. */
  15817. onSizeChanged: (postProcess: PostProcess) => void;
  15818. /**
  15819. * An event triggered when the postprocess applies its effect.
  15820. */
  15821. onApplyObservable: Observable<Effect>;
  15822. private _onApplyObserver;
  15823. /**
  15824. * A function that is added to the onApplyObservable
  15825. */
  15826. onApply: (effect: Effect) => void;
  15827. /**
  15828. * An event triggered before rendering the postprocess
  15829. */
  15830. onBeforeRenderObservable: Observable<Effect>;
  15831. private _onBeforeRenderObserver;
  15832. /**
  15833. * A function that is added to the onBeforeRenderObservable
  15834. */
  15835. onBeforeRender: (effect: Effect) => void;
  15836. /**
  15837. * An event triggered after rendering the postprocess
  15838. */
  15839. onAfterRenderObservable: Observable<Effect>;
  15840. private _onAfterRenderObserver;
  15841. /**
  15842. * A function that is added to the onAfterRenderObservable
  15843. */
  15844. onAfterRender: (efect: Effect) => void;
  15845. /**
  15846. * 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
  15847. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15848. */
  15849. inputTexture: InternalTexture;
  15850. /**
  15851. * Gets the camera which post process is applied to.
  15852. * @returns The camera the post process is applied to.
  15853. */
  15854. getCamera(): Camera;
  15855. /**
  15856. * Gets the texel size of the postprocess.
  15857. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15858. */
  15859. readonly texelSize: Vector2;
  15860. /**
  15861. * Creates a new instance PostProcess
  15862. * @param name The name of the PostProcess.
  15863. * @param fragmentUrl The url of the fragment shader to be used.
  15864. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15865. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15866. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15867. * @param camera The camera to apply the render pass to.
  15868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15869. * @param engine The engine which the post process will be applied. (default: current engine)
  15870. * @param reusable If the post process can be reused on the same frame. (default: false)
  15871. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15872. * @param textureType Type of textures used when performing the post process. (default: 0)
  15873. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15874. * @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
  15875. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15876. */
  15877. constructor(
  15878. /** Name of the PostProcess. */
  15879. 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);
  15880. /**
  15881. * Gets a string idenfifying the name of the class
  15882. * @returns "PostProcess" string
  15883. */
  15884. getClassName(): string;
  15885. /**
  15886. * Gets the engine which this post process belongs to.
  15887. * @returns The engine the post process was enabled with.
  15888. */
  15889. getEngine(): Engine;
  15890. /**
  15891. * The effect that is created when initializing the post process.
  15892. * @returns The created effect corresponding the the postprocess.
  15893. */
  15894. getEffect(): Effect;
  15895. /**
  15896. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15897. * @param postProcess The post process to share the output with.
  15898. * @returns This post process.
  15899. */
  15900. shareOutputWith(postProcess: PostProcess): PostProcess;
  15901. /**
  15902. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15903. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15904. */
  15905. useOwnOutput(): void;
  15906. /**
  15907. * Updates the effect with the current post process compile time values and recompiles the shader.
  15908. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15909. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15910. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15911. * @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
  15912. * @param onCompiled Called when the shader has been compiled.
  15913. * @param onError Called if there is an error when compiling a shader.
  15914. */
  15915. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15916. /**
  15917. * The post process is reusable if it can be used multiple times within one frame.
  15918. * @returns If the post process is reusable
  15919. */
  15920. isReusable(): boolean;
  15921. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15922. markTextureDirty(): void;
  15923. /**
  15924. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15925. * 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.
  15926. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15927. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15928. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15929. * @returns The target texture that was bound to be written to.
  15930. */
  15931. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15932. /**
  15933. * If the post process is supported.
  15934. */
  15935. readonly isSupported: boolean;
  15936. /**
  15937. * The aspect ratio of the output texture.
  15938. */
  15939. readonly aspectRatio: number;
  15940. /**
  15941. * Get a value indicating if the post-process is ready to be used
  15942. * @returns true if the post-process is ready (shader is compiled)
  15943. */
  15944. isReady(): boolean;
  15945. /**
  15946. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15947. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15948. */
  15949. apply(): Nullable<Effect>;
  15950. private _disposeTextures;
  15951. /**
  15952. * Disposes the post process.
  15953. * @param camera The camera to dispose the post process on.
  15954. */
  15955. dispose(camera?: Camera): void;
  15956. }
  15957. }
  15958. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15959. /** @hidden */
  15960. export var kernelBlurVaryingDeclaration: {
  15961. name: string;
  15962. shader: string;
  15963. };
  15964. }
  15965. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15966. /** @hidden */
  15967. export var kernelBlurFragment: {
  15968. name: string;
  15969. shader: string;
  15970. };
  15971. }
  15972. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15973. /** @hidden */
  15974. export var kernelBlurFragment2: {
  15975. name: string;
  15976. shader: string;
  15977. };
  15978. }
  15979. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15980. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15981. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15982. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15983. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15984. /** @hidden */
  15985. export var kernelBlurPixelShader: {
  15986. name: string;
  15987. shader: string;
  15988. };
  15989. }
  15990. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15991. /** @hidden */
  15992. export var kernelBlurVertex: {
  15993. name: string;
  15994. shader: string;
  15995. };
  15996. }
  15997. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15998. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15999. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16000. /** @hidden */
  16001. export var kernelBlurVertexShader: {
  16002. name: string;
  16003. shader: string;
  16004. };
  16005. }
  16006. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16007. import { Vector2 } from "babylonjs/Maths/math.vector";
  16008. import { Nullable } from "babylonjs/types";
  16009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16010. import { Camera } from "babylonjs/Cameras/camera";
  16011. import { Effect } from "babylonjs/Materials/effect";
  16012. import { Engine } from "babylonjs/Engines/engine";
  16013. import "babylonjs/Shaders/kernelBlur.fragment";
  16014. import "babylonjs/Shaders/kernelBlur.vertex";
  16015. /**
  16016. * The Blur Post Process which blurs an image based on a kernel and direction.
  16017. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16018. */
  16019. export class BlurPostProcess extends PostProcess {
  16020. /** The direction in which to blur the image. */
  16021. direction: Vector2;
  16022. private blockCompilation;
  16023. protected _kernel: number;
  16024. protected _idealKernel: number;
  16025. protected _packedFloat: boolean;
  16026. private _staticDefines;
  16027. /**
  16028. * Sets the length in pixels of the blur sample region
  16029. */
  16030. /**
  16031. * Gets the length in pixels of the blur sample region
  16032. */
  16033. kernel: number;
  16034. /**
  16035. * Sets wether or not the blur needs to unpack/repack floats
  16036. */
  16037. /**
  16038. * Gets wether or not the blur is unpacking/repacking floats
  16039. */
  16040. packedFloat: boolean;
  16041. /**
  16042. * Creates a new instance BlurPostProcess
  16043. * @param name The name of the effect.
  16044. * @param direction The direction in which to blur the image.
  16045. * @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.
  16046. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16047. * @param camera The camera to apply the render pass to.
  16048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16049. * @param engine The engine which the post process will be applied. (default: current engine)
  16050. * @param reusable If the post process can be reused on the same frame. (default: false)
  16051. * @param textureType Type of textures used when performing the post process. (default: 0)
  16052. * @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)
  16053. */
  16054. constructor(name: string,
  16055. /** The direction in which to blur the image. */
  16056. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16057. /**
  16058. * Updates the effect with the current post process compile time values and recompiles the shader.
  16059. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16060. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16061. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16062. * @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
  16063. * @param onCompiled Called when the shader has been compiled.
  16064. * @param onError Called if there is an error when compiling a shader.
  16065. */
  16066. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16067. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16068. /**
  16069. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16070. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16071. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16072. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16073. * The gaps between physical kernels are compensated for in the weighting of the samples
  16074. * @param idealKernel Ideal blur kernel.
  16075. * @return Nearest best kernel.
  16076. */
  16077. protected _nearestBestKernel(idealKernel: number): number;
  16078. /**
  16079. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16080. * @param x The point on the Gaussian distribution to sample.
  16081. * @return the value of the Gaussian function at x.
  16082. */
  16083. protected _gaussianWeight(x: number): number;
  16084. /**
  16085. * Generates a string that can be used as a floating point number in GLSL.
  16086. * @param x Value to print.
  16087. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16088. * @return GLSL float string.
  16089. */
  16090. protected _glslFloat(x: number, decimalFigures?: number): string;
  16091. }
  16092. }
  16093. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16094. import { Scene } from "babylonjs/scene";
  16095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16096. import { Plane } from "babylonjs/Maths/math.plane";
  16097. /**
  16098. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16099. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16100. * You can then easily use it as a reflectionTexture on a flat surface.
  16101. * In case the surface is not a plane, please consider relying on reflection probes.
  16102. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16103. */
  16104. export class MirrorTexture extends RenderTargetTexture {
  16105. private scene;
  16106. /**
  16107. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16108. * 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.
  16109. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16110. */
  16111. mirrorPlane: Plane;
  16112. /**
  16113. * Define the blur ratio used to blur the reflection if needed.
  16114. */
  16115. blurRatio: number;
  16116. /**
  16117. * Define the adaptive blur kernel used to blur the reflection if needed.
  16118. * This will autocompute the closest best match for the `blurKernel`
  16119. */
  16120. adaptiveBlurKernel: number;
  16121. /**
  16122. * Define the blur kernel used to blur the reflection if needed.
  16123. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16124. */
  16125. blurKernel: number;
  16126. /**
  16127. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16128. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16129. */
  16130. blurKernelX: number;
  16131. /**
  16132. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16133. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16134. */
  16135. blurKernelY: number;
  16136. private _autoComputeBlurKernel;
  16137. protected _onRatioRescale(): void;
  16138. private _updateGammaSpace;
  16139. private _imageProcessingConfigChangeObserver;
  16140. private _transformMatrix;
  16141. private _mirrorMatrix;
  16142. private _savedViewMatrix;
  16143. private _blurX;
  16144. private _blurY;
  16145. private _adaptiveBlurKernel;
  16146. private _blurKernelX;
  16147. private _blurKernelY;
  16148. private _blurRatio;
  16149. /**
  16150. * Instantiates a Mirror Texture.
  16151. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16152. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16153. * You can then easily use it as a reflectionTexture on a flat surface.
  16154. * In case the surface is not a plane, please consider relying on reflection probes.
  16155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16156. * @param name
  16157. * @param size
  16158. * @param scene
  16159. * @param generateMipMaps
  16160. * @param type
  16161. * @param samplingMode
  16162. * @param generateDepthBuffer
  16163. */
  16164. constructor(name: string, size: number | {
  16165. width: number;
  16166. height: number;
  16167. } | {
  16168. ratio: number;
  16169. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16170. private _preparePostProcesses;
  16171. /**
  16172. * Clone the mirror texture.
  16173. * @returns the cloned texture
  16174. */
  16175. clone(): MirrorTexture;
  16176. /**
  16177. * Serialize the texture to a JSON representation you could use in Parse later on
  16178. * @returns the serialized JSON representation
  16179. */
  16180. serialize(): any;
  16181. /**
  16182. * Dispose the texture and release its associated resources.
  16183. */
  16184. dispose(): void;
  16185. }
  16186. }
  16187. declare module "babylonjs/Materials/Textures/texture" {
  16188. import { Observable } from "babylonjs/Misc/observable";
  16189. import { Nullable } from "babylonjs/types";
  16190. import { Matrix } from "babylonjs/Maths/math.vector";
  16191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16192. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16193. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16194. import { Scene } from "babylonjs/scene";
  16195. /**
  16196. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16197. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16198. */
  16199. export class Texture extends BaseTexture {
  16200. /**
  16201. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16202. */
  16203. static SerializeBuffers: boolean;
  16204. /** @hidden */
  16205. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16206. /** @hidden */
  16207. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16208. /** @hidden */
  16209. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16210. /** nearest is mag = nearest and min = nearest and mip = linear */
  16211. static readonly NEAREST_SAMPLINGMODE: number;
  16212. /** nearest is mag = nearest and min = nearest and mip = linear */
  16213. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16215. static readonly BILINEAR_SAMPLINGMODE: number;
  16216. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16217. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16218. /** Trilinear is mag = linear and min = linear and mip = linear */
  16219. static readonly TRILINEAR_SAMPLINGMODE: number;
  16220. /** Trilinear is mag = linear and min = linear and mip = linear */
  16221. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16222. /** mag = nearest and min = nearest and mip = nearest */
  16223. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16224. /** mag = nearest and min = linear and mip = nearest */
  16225. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16226. /** mag = nearest and min = linear and mip = linear */
  16227. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16228. /** mag = nearest and min = linear and mip = none */
  16229. static readonly NEAREST_LINEAR: number;
  16230. /** mag = nearest and min = nearest and mip = none */
  16231. static readonly NEAREST_NEAREST: number;
  16232. /** mag = linear and min = nearest and mip = nearest */
  16233. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16234. /** mag = linear and min = nearest and mip = linear */
  16235. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16236. /** mag = linear and min = linear and mip = none */
  16237. static readonly LINEAR_LINEAR: number;
  16238. /** mag = linear and min = nearest and mip = none */
  16239. static readonly LINEAR_NEAREST: number;
  16240. /** Explicit coordinates mode */
  16241. static readonly EXPLICIT_MODE: number;
  16242. /** Spherical coordinates mode */
  16243. static readonly SPHERICAL_MODE: number;
  16244. /** Planar coordinates mode */
  16245. static readonly PLANAR_MODE: number;
  16246. /** Cubic coordinates mode */
  16247. static readonly CUBIC_MODE: number;
  16248. /** Projection coordinates mode */
  16249. static readonly PROJECTION_MODE: number;
  16250. /** Inverse Cubic coordinates mode */
  16251. static readonly SKYBOX_MODE: number;
  16252. /** Inverse Cubic coordinates mode */
  16253. static readonly INVCUBIC_MODE: number;
  16254. /** Equirectangular coordinates mode */
  16255. static readonly EQUIRECTANGULAR_MODE: number;
  16256. /** Equirectangular Fixed coordinates mode */
  16257. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16258. /** Equirectangular Fixed Mirrored coordinates mode */
  16259. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16260. /** Texture is not repeating outside of 0..1 UVs */
  16261. static readonly CLAMP_ADDRESSMODE: number;
  16262. /** Texture is repeating outside of 0..1 UVs */
  16263. static readonly WRAP_ADDRESSMODE: number;
  16264. /** Texture is repeating and mirrored */
  16265. static readonly MIRROR_ADDRESSMODE: number;
  16266. /**
  16267. * 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
  16268. */
  16269. static UseSerializedUrlIfAny: boolean;
  16270. /**
  16271. * Define the url of the texture.
  16272. */
  16273. url: Nullable<string>;
  16274. /**
  16275. * Define an offset on the texture to offset the u coordinates of the UVs
  16276. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16277. */
  16278. uOffset: number;
  16279. /**
  16280. * Define an offset on the texture to offset the v coordinates of the UVs
  16281. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16282. */
  16283. vOffset: number;
  16284. /**
  16285. * Define an offset on the texture to scale the u coordinates of the UVs
  16286. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16287. */
  16288. uScale: number;
  16289. /**
  16290. * Define an offset on the texture to scale the v coordinates of the UVs
  16291. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16292. */
  16293. vScale: number;
  16294. /**
  16295. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials
  16297. */
  16298. uAng: number;
  16299. /**
  16300. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials
  16302. */
  16303. vAng: number;
  16304. /**
  16305. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16306. * @see http://doc.babylonjs.com/how_to/more_materials
  16307. */
  16308. wAng: number;
  16309. /**
  16310. * Defines the center of rotation (U)
  16311. */
  16312. uRotationCenter: number;
  16313. /**
  16314. * Defines the center of rotation (V)
  16315. */
  16316. vRotationCenter: number;
  16317. /**
  16318. * Defines the center of rotation (W)
  16319. */
  16320. wRotationCenter: number;
  16321. /**
  16322. * Are mip maps generated for this texture or not.
  16323. */
  16324. readonly noMipmap: boolean;
  16325. /**
  16326. * List of inspectable custom properties (used by the Inspector)
  16327. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16328. */
  16329. inspectableCustomProperties: Nullable<IInspectable[]>;
  16330. private _noMipmap;
  16331. /** @hidden */
  16332. _invertY: boolean;
  16333. private _rowGenerationMatrix;
  16334. private _cachedTextureMatrix;
  16335. private _projectionModeMatrix;
  16336. private _t0;
  16337. private _t1;
  16338. private _t2;
  16339. private _cachedUOffset;
  16340. private _cachedVOffset;
  16341. private _cachedUScale;
  16342. private _cachedVScale;
  16343. private _cachedUAng;
  16344. private _cachedVAng;
  16345. private _cachedWAng;
  16346. private _cachedProjectionMatrixId;
  16347. private _cachedCoordinatesMode;
  16348. /** @hidden */
  16349. protected _initialSamplingMode: number;
  16350. /** @hidden */
  16351. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16352. private _deleteBuffer;
  16353. protected _format: Nullable<number>;
  16354. private _delayedOnLoad;
  16355. private _delayedOnError;
  16356. private _mimeType?;
  16357. /**
  16358. * Observable triggered once the texture has been loaded.
  16359. */
  16360. onLoadObservable: Observable<Texture>;
  16361. protected _isBlocking: boolean;
  16362. /**
  16363. * Is the texture preventing material to render while loading.
  16364. * If false, a default texture will be used instead of the loading one during the preparation step.
  16365. */
  16366. isBlocking: boolean;
  16367. /**
  16368. * Get the current sampling mode associated with the texture.
  16369. */
  16370. readonly samplingMode: number;
  16371. /**
  16372. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16373. */
  16374. readonly invertY: boolean;
  16375. /**
  16376. * Instantiates a new texture.
  16377. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16378. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16379. * @param url defines the url of the picture to load as a texture
  16380. * @param scene defines the scene or engine the texture will belong to
  16381. * @param noMipmap defines if the texture will require mip maps or not
  16382. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16383. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16384. * @param onLoad defines a callback triggered when the texture has been loaded
  16385. * @param onError defines a callback triggered when an error occurred during the loading session
  16386. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16387. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16388. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16389. * @param mimeType defines an optional mime type information
  16390. */
  16391. 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);
  16392. /**
  16393. * Update the url (and optional buffer) of this texture if url was null during construction.
  16394. * @param url the url of the texture
  16395. * @param buffer the buffer of the texture (defaults to null)
  16396. * @param onLoad callback called when the texture is loaded (defaults to null)
  16397. */
  16398. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16399. /**
  16400. * Finish the loading sequence of a texture flagged as delayed load.
  16401. * @hidden
  16402. */
  16403. delayLoad(): void;
  16404. private _prepareRowForTextureGeneration;
  16405. /**
  16406. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16407. * @returns the transform matrix of the texture.
  16408. */
  16409. getTextureMatrix(): Matrix;
  16410. /**
  16411. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16412. * @returns The reflection texture transform
  16413. */
  16414. getReflectionTextureMatrix(): Matrix;
  16415. /**
  16416. * Clones the texture.
  16417. * @returns the cloned texture
  16418. */
  16419. clone(): Texture;
  16420. /**
  16421. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16422. * @returns The JSON representation of the texture
  16423. */
  16424. serialize(): any;
  16425. /**
  16426. * Get the current class name of the texture useful for serialization or dynamic coding.
  16427. * @returns "Texture"
  16428. */
  16429. getClassName(): string;
  16430. /**
  16431. * Dispose the texture and release its associated resources.
  16432. */
  16433. dispose(): void;
  16434. /**
  16435. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16436. * @param parsedTexture Define the JSON representation of the texture
  16437. * @param scene Define the scene the parsed texture should be instantiated in
  16438. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16439. * @returns The parsed texture if successful
  16440. */
  16441. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16442. /**
  16443. * Creates a texture from its base 64 representation.
  16444. * @param data Define the base64 payload without the data: prefix
  16445. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16446. * @param scene Define the scene the texture should belong to
  16447. * @param noMipmap Forces the texture to not create mip map information if true
  16448. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16449. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16450. * @param onLoad define a callback triggered when the texture has been loaded
  16451. * @param onError define a callback triggered when an error occurred during the loading session
  16452. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16453. * @returns the created texture
  16454. */
  16455. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16456. /**
  16457. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16458. * @param data Define the base64 payload without the data: prefix
  16459. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16460. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16461. * @param scene Define the scene the texture should belong to
  16462. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16463. * @param noMipmap Forces the texture to not create mip map information if true
  16464. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16465. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16466. * @param onLoad define a callback triggered when the texture has been loaded
  16467. * @param onError define a callback triggered when an error occurred during the loading session
  16468. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16469. * @returns the created texture
  16470. */
  16471. 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;
  16472. }
  16473. }
  16474. declare module "babylonjs/PostProcesses/postProcessManager" {
  16475. import { Nullable } from "babylonjs/types";
  16476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16478. import { Scene } from "babylonjs/scene";
  16479. /**
  16480. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16481. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16482. */
  16483. export class PostProcessManager {
  16484. private _scene;
  16485. private _indexBuffer;
  16486. private _vertexBuffers;
  16487. /**
  16488. * Creates a new instance PostProcess
  16489. * @param scene The scene that the post process is associated with.
  16490. */
  16491. constructor(scene: Scene);
  16492. private _prepareBuffers;
  16493. private _buildIndexBuffer;
  16494. /**
  16495. * Rebuilds the vertex buffers of the manager.
  16496. * @hidden
  16497. */
  16498. _rebuild(): void;
  16499. /**
  16500. * Prepares a frame to be run through a post process.
  16501. * @param sourceTexture The input texture to the post procesess. (default: null)
  16502. * @param postProcesses An array of post processes to be run. (default: null)
  16503. * @returns True if the post processes were able to be run.
  16504. * @hidden
  16505. */
  16506. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16507. /**
  16508. * Manually render a set of post processes to a texture.
  16509. * @param postProcesses An array of post processes to be run.
  16510. * @param targetTexture The target texture to render to.
  16511. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16512. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16513. * @param lodLevel defines which lod of the texture to render to
  16514. */
  16515. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16516. /**
  16517. * Finalize the result of the output of the postprocesses.
  16518. * @param doNotPresent If true the result will not be displayed to the screen.
  16519. * @param targetTexture The target texture to render to.
  16520. * @param faceIndex The index of the face to bind the target texture to.
  16521. * @param postProcesses The array of post processes to render.
  16522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16523. * @hidden
  16524. */
  16525. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16526. /**
  16527. * Disposes of the post process manager.
  16528. */
  16529. dispose(): void;
  16530. }
  16531. }
  16532. declare module "babylonjs/Misc/gradients" {
  16533. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16534. /** Interface used by value gradients (color, factor, ...) */
  16535. export interface IValueGradient {
  16536. /**
  16537. * Gets or sets the gradient value (between 0 and 1)
  16538. */
  16539. gradient: number;
  16540. }
  16541. /** Class used to store color4 gradient */
  16542. export class ColorGradient implements IValueGradient {
  16543. /**
  16544. * Gets or sets the gradient value (between 0 and 1)
  16545. */
  16546. gradient: number;
  16547. /**
  16548. * Gets or sets first associated color
  16549. */
  16550. color1: Color4;
  16551. /**
  16552. * Gets or sets second associated color
  16553. */
  16554. color2?: Color4;
  16555. /**
  16556. * Will get a color picked randomly between color1 and color2.
  16557. * If color2 is undefined then color1 will be used
  16558. * @param result defines the target Color4 to store the result in
  16559. */
  16560. getColorToRef(result: Color4): void;
  16561. }
  16562. /** Class used to store color 3 gradient */
  16563. export class Color3Gradient implements IValueGradient {
  16564. /**
  16565. * Gets or sets the gradient value (between 0 and 1)
  16566. */
  16567. gradient: number;
  16568. /**
  16569. * Gets or sets the associated color
  16570. */
  16571. color: Color3;
  16572. }
  16573. /** Class used to store factor gradient */
  16574. export class FactorGradient implements IValueGradient {
  16575. /**
  16576. * Gets or sets the gradient value (between 0 and 1)
  16577. */
  16578. gradient: number;
  16579. /**
  16580. * Gets or sets first associated factor
  16581. */
  16582. factor1: number;
  16583. /**
  16584. * Gets or sets second associated factor
  16585. */
  16586. factor2?: number;
  16587. /**
  16588. * Will get a number picked randomly between factor1 and factor2.
  16589. * If factor2 is undefined then factor1 will be used
  16590. * @returns the picked number
  16591. */
  16592. getFactor(): number;
  16593. }
  16594. /**
  16595. * Helper used to simplify some generic gradient tasks
  16596. */
  16597. export class GradientHelper {
  16598. /**
  16599. * Gets the current gradient from an array of IValueGradient
  16600. * @param ratio defines the current ratio to get
  16601. * @param gradients defines the array of IValueGradient
  16602. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16603. */
  16604. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16605. }
  16606. }
  16607. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16609. import { Nullable } from "babylonjs/types";
  16610. module "babylonjs/Engines/thinEngine" {
  16611. interface ThinEngine {
  16612. /**
  16613. * Creates a dynamic texture
  16614. * @param width defines the width of the texture
  16615. * @param height defines the height of the texture
  16616. * @param generateMipMaps defines if the engine should generate the mip levels
  16617. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16618. * @returns the dynamic texture inside an InternalTexture
  16619. */
  16620. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16621. /**
  16622. * Update the content of a dynamic texture
  16623. * @param texture defines the texture to update
  16624. * @param canvas defines the canvas containing the source
  16625. * @param invertY defines if data must be stored with Y axis inverted
  16626. * @param premulAlpha defines if alpha is stored as premultiplied
  16627. * @param format defines the format of the data
  16628. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16629. */
  16630. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16631. }
  16632. }
  16633. }
  16634. declare module "babylonjs/Misc/canvasGenerator" {
  16635. /**
  16636. * Helper class used to generate a canvas to manipulate images
  16637. */
  16638. export class CanvasGenerator {
  16639. /**
  16640. * Create a new canvas (or offscreen canvas depending on the context)
  16641. * @param width defines the expected width
  16642. * @param height defines the expected height
  16643. * @return a new canvas or offscreen canvas
  16644. */
  16645. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16646. }
  16647. }
  16648. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16649. import { Scene } from "babylonjs/scene";
  16650. import { Texture } from "babylonjs/Materials/Textures/texture";
  16651. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16652. /**
  16653. * A class extending Texture allowing drawing on a texture
  16654. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16655. */
  16656. export class DynamicTexture extends Texture {
  16657. private _generateMipMaps;
  16658. private _canvas;
  16659. private _context;
  16660. private _engine;
  16661. /**
  16662. * Creates a DynamicTexture
  16663. * @param name defines the name of the texture
  16664. * @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
  16665. * @param scene defines the scene where you want the texture
  16666. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16667. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16668. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16669. */
  16670. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16671. /**
  16672. * Get the current class name of the texture useful for serialization or dynamic coding.
  16673. * @returns "DynamicTexture"
  16674. */
  16675. getClassName(): string;
  16676. /**
  16677. * Gets the current state of canRescale
  16678. */
  16679. readonly canRescale: boolean;
  16680. private _recreate;
  16681. /**
  16682. * Scales the texture
  16683. * @param ratio the scale factor to apply to both width and height
  16684. */
  16685. scale(ratio: number): void;
  16686. /**
  16687. * Resizes the texture
  16688. * @param width the new width
  16689. * @param height the new height
  16690. */
  16691. scaleTo(width: number, height: number): void;
  16692. /**
  16693. * Gets the context of the canvas used by the texture
  16694. * @returns the canvas context of the dynamic texture
  16695. */
  16696. getContext(): CanvasRenderingContext2D;
  16697. /**
  16698. * Clears the texture
  16699. */
  16700. clear(): void;
  16701. /**
  16702. * Updates the texture
  16703. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16704. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16705. */
  16706. update(invertY?: boolean, premulAlpha?: boolean): void;
  16707. /**
  16708. * Draws text onto the texture
  16709. * @param text defines the text to be drawn
  16710. * @param x defines the placement of the text from the left
  16711. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16712. * @param font defines the font to be used with font-style, font-size, font-name
  16713. * @param color defines the color used for the text
  16714. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16715. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16716. * @param update defines whether texture is immediately update (default is true)
  16717. */
  16718. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16719. /**
  16720. * Clones the texture
  16721. * @returns the clone of the texture.
  16722. */
  16723. clone(): DynamicTexture;
  16724. /**
  16725. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16726. * @returns a serialized dynamic texture object
  16727. */
  16728. serialize(): any;
  16729. /** @hidden */
  16730. _rebuild(): void;
  16731. }
  16732. }
  16733. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16734. import { Scene } from "babylonjs/scene";
  16735. import { ISceneComponent } from "babylonjs/sceneComponent";
  16736. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16737. module "babylonjs/abstractScene" {
  16738. interface AbstractScene {
  16739. /**
  16740. * The list of procedural textures added to the scene
  16741. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16742. */
  16743. proceduralTextures: Array<ProceduralTexture>;
  16744. }
  16745. }
  16746. /**
  16747. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16748. * in a given scene.
  16749. */
  16750. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16751. /**
  16752. * The component name helpfull to identify the component in the list of scene components.
  16753. */
  16754. readonly name: string;
  16755. /**
  16756. * The scene the component belongs to.
  16757. */
  16758. scene: Scene;
  16759. /**
  16760. * Creates a new instance of the component for the given scene
  16761. * @param scene Defines the scene to register the component in
  16762. */
  16763. constructor(scene: Scene);
  16764. /**
  16765. * Registers the component in a given scene
  16766. */
  16767. register(): void;
  16768. /**
  16769. * Rebuilds the elements related to this component in case of
  16770. * context lost for instance.
  16771. */
  16772. rebuild(): void;
  16773. /**
  16774. * Disposes the component and the associated ressources.
  16775. */
  16776. dispose(): void;
  16777. private _beforeClear;
  16778. }
  16779. }
  16780. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16782. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16783. module "babylonjs/Engines/thinEngine" {
  16784. interface ThinEngine {
  16785. /**
  16786. * Creates a new render target cube texture
  16787. * @param size defines the size of the texture
  16788. * @param options defines the options used to create the texture
  16789. * @returns a new render target cube texture stored in an InternalTexture
  16790. */
  16791. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16792. }
  16793. }
  16794. }
  16795. declare module "babylonjs/Shaders/procedural.vertex" {
  16796. /** @hidden */
  16797. export var proceduralVertexShader: {
  16798. name: string;
  16799. shader: string;
  16800. };
  16801. }
  16802. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16803. import { Observable } from "babylonjs/Misc/observable";
  16804. import { Nullable } from "babylonjs/types";
  16805. import { Scene } from "babylonjs/scene";
  16806. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16807. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16808. import { Effect } from "babylonjs/Materials/effect";
  16809. import { Texture } from "babylonjs/Materials/Textures/texture";
  16810. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16811. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16812. import "babylonjs/Shaders/procedural.vertex";
  16813. /**
  16814. * 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.
  16815. * This is the base class of any Procedural texture and contains most of the shareable code.
  16816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16817. */
  16818. export class ProceduralTexture extends Texture {
  16819. isCube: boolean;
  16820. /**
  16821. * Define if the texture is enabled or not (disabled texture will not render)
  16822. */
  16823. isEnabled: boolean;
  16824. /**
  16825. * Define if the texture must be cleared before rendering (default is true)
  16826. */
  16827. autoClear: boolean;
  16828. /**
  16829. * Callback called when the texture is generated
  16830. */
  16831. onGenerated: () => void;
  16832. /**
  16833. * Event raised when the texture is generated
  16834. */
  16835. onGeneratedObservable: Observable<ProceduralTexture>;
  16836. /** @hidden */
  16837. _generateMipMaps: boolean;
  16838. /** @hidden **/
  16839. _effect: Effect;
  16840. /** @hidden */
  16841. _textures: {
  16842. [key: string]: Texture;
  16843. };
  16844. private _size;
  16845. private _currentRefreshId;
  16846. private _refreshRate;
  16847. private _vertexBuffers;
  16848. private _indexBuffer;
  16849. private _uniforms;
  16850. private _samplers;
  16851. private _fragment;
  16852. private _floats;
  16853. private _ints;
  16854. private _floatsArrays;
  16855. private _colors3;
  16856. private _colors4;
  16857. private _vectors2;
  16858. private _vectors3;
  16859. private _matrices;
  16860. private _fallbackTexture;
  16861. private _fallbackTextureUsed;
  16862. private _engine;
  16863. private _cachedDefines;
  16864. private _contentUpdateId;
  16865. private _contentData;
  16866. /**
  16867. * Instantiates a new procedural texture.
  16868. * 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.
  16869. * This is the base class of any Procedural texture and contains most of the shareable code.
  16870. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16871. * @param name Define the name of the texture
  16872. * @param size Define the size of the texture to create
  16873. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16874. * @param scene Define the scene the texture belongs to
  16875. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16876. * @param generateMipMaps Define if the texture should creates mip maps or not
  16877. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16878. */
  16879. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16880. /**
  16881. * The effect that is created when initializing the post process.
  16882. * @returns The created effect corresponding the the postprocess.
  16883. */
  16884. getEffect(): Effect;
  16885. /**
  16886. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16887. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16888. */
  16889. getContent(): Nullable<ArrayBufferView>;
  16890. private _createIndexBuffer;
  16891. /** @hidden */
  16892. _rebuild(): void;
  16893. /**
  16894. * Resets the texture in order to recreate its associated resources.
  16895. * This can be called in case of context loss
  16896. */
  16897. reset(): void;
  16898. protected _getDefines(): string;
  16899. /**
  16900. * Is the texture ready to be used ? (rendered at least once)
  16901. * @returns true if ready, otherwise, false.
  16902. */
  16903. isReady(): boolean;
  16904. /**
  16905. * Resets the refresh counter of the texture and start bak from scratch.
  16906. * Could be useful to regenerate the texture if it is setup to render only once.
  16907. */
  16908. resetRefreshCounter(): void;
  16909. /**
  16910. * Set the fragment shader to use in order to render the texture.
  16911. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16912. */
  16913. setFragment(fragment: any): void;
  16914. /**
  16915. * Define the refresh rate of the texture or the rendering frequency.
  16916. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16917. */
  16918. refreshRate: number;
  16919. /** @hidden */
  16920. _shouldRender(): boolean;
  16921. /**
  16922. * Get the size the texture is rendering at.
  16923. * @returns the size (texture is always squared)
  16924. */
  16925. getRenderSize(): number;
  16926. /**
  16927. * Resize the texture to new value.
  16928. * @param size Define the new size the texture should have
  16929. * @param generateMipMaps Define whether the new texture should create mip maps
  16930. */
  16931. resize(size: number, generateMipMaps: boolean): void;
  16932. private _checkUniform;
  16933. /**
  16934. * Set a texture in the shader program used to render.
  16935. * @param name Define the name of the uniform samplers as defined in the shader
  16936. * @param texture Define the texture to bind to this sampler
  16937. * @return the texture itself allowing "fluent" like uniform updates
  16938. */
  16939. setTexture(name: string, texture: Texture): ProceduralTexture;
  16940. /**
  16941. * Set a float in the shader.
  16942. * @param name Define the name of the uniform as defined in the shader
  16943. * @param value Define the value to give to the uniform
  16944. * @return the texture itself allowing "fluent" like uniform updates
  16945. */
  16946. setFloat(name: string, value: number): ProceduralTexture;
  16947. /**
  16948. * Set a int in the shader.
  16949. * @param name Define the name of the uniform as defined in the shader
  16950. * @param value Define the value to give to the uniform
  16951. * @return the texture itself allowing "fluent" like uniform updates
  16952. */
  16953. setInt(name: string, value: number): ProceduralTexture;
  16954. /**
  16955. * Set an array of floats in the shader.
  16956. * @param name Define the name of the uniform as defined in the shader
  16957. * @param value Define the value to give to the uniform
  16958. * @return the texture itself allowing "fluent" like uniform updates
  16959. */
  16960. setFloats(name: string, value: number[]): ProceduralTexture;
  16961. /**
  16962. * Set a vec3 in the shader from a Color3.
  16963. * @param name Define the name of the uniform as defined in the shader
  16964. * @param value Define the value to give to the uniform
  16965. * @return the texture itself allowing "fluent" like uniform updates
  16966. */
  16967. setColor3(name: string, value: Color3): ProceduralTexture;
  16968. /**
  16969. * Set a vec4 in the shader from a Color4.
  16970. * @param name Define the name of the uniform as defined in the shader
  16971. * @param value Define the value to give to the uniform
  16972. * @return the texture itself allowing "fluent" like uniform updates
  16973. */
  16974. setColor4(name: string, value: Color4): ProceduralTexture;
  16975. /**
  16976. * Set a vec2 in the shader from a Vector2.
  16977. * @param name Define the name of the uniform as defined in the shader
  16978. * @param value Define the value to give to the uniform
  16979. * @return the texture itself allowing "fluent" like uniform updates
  16980. */
  16981. setVector2(name: string, value: Vector2): ProceduralTexture;
  16982. /**
  16983. * Set a vec3 in the shader from a Vector3.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the texture itself allowing "fluent" like uniform updates
  16987. */
  16988. setVector3(name: string, value: Vector3): ProceduralTexture;
  16989. /**
  16990. * Set a mat4 in the shader from a MAtrix.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the texture itself allowing "fluent" like uniform updates
  16994. */
  16995. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16996. /**
  16997. * Render the texture to its associated render target.
  16998. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16999. */
  17000. render(useCameraPostProcess?: boolean): void;
  17001. /**
  17002. * Clone the texture.
  17003. * @returns the cloned texture
  17004. */
  17005. clone(): ProceduralTexture;
  17006. /**
  17007. * Dispose the texture and release its asoociated resources.
  17008. */
  17009. dispose(): void;
  17010. }
  17011. }
  17012. declare module "babylonjs/Particles/baseParticleSystem" {
  17013. import { Nullable } from "babylonjs/types";
  17014. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17016. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17017. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17018. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17019. import { Scene } from "babylonjs/scene";
  17020. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17021. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17022. import { Texture } from "babylonjs/Materials/Textures/texture";
  17023. import { Color4 } from "babylonjs/Maths/math.color";
  17024. import { Animation } from "babylonjs/Animations/animation";
  17025. /**
  17026. * This represents the base class for particle system in Babylon.
  17027. * 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.
  17028. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17029. * @example https://doc.babylonjs.com/babylon101/particles
  17030. */
  17031. export class BaseParticleSystem {
  17032. /**
  17033. * Source color is added to the destination color without alpha affecting the result
  17034. */
  17035. static BLENDMODE_ONEONE: number;
  17036. /**
  17037. * Blend current color and particle color using particle’s alpha
  17038. */
  17039. static BLENDMODE_STANDARD: number;
  17040. /**
  17041. * Add current color and particle color multiplied by particle’s alpha
  17042. */
  17043. static BLENDMODE_ADD: number;
  17044. /**
  17045. * Multiply current color with particle color
  17046. */
  17047. static BLENDMODE_MULTIPLY: number;
  17048. /**
  17049. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17050. */
  17051. static BLENDMODE_MULTIPLYADD: number;
  17052. /**
  17053. * List of animations used by the particle system.
  17054. */
  17055. animations: Animation[];
  17056. /**
  17057. * The id of the Particle system.
  17058. */
  17059. id: string;
  17060. /**
  17061. * The friendly name of the Particle system.
  17062. */
  17063. name: string;
  17064. /**
  17065. * The rendering group used by the Particle system to chose when to render.
  17066. */
  17067. renderingGroupId: number;
  17068. /**
  17069. * The emitter represents the Mesh or position we are attaching the particle system to.
  17070. */
  17071. emitter: Nullable<AbstractMesh | Vector3>;
  17072. /**
  17073. * The maximum number of particles to emit per frame
  17074. */
  17075. emitRate: number;
  17076. /**
  17077. * If you want to launch only a few particles at once, that can be done, as well.
  17078. */
  17079. manualEmitCount: number;
  17080. /**
  17081. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17082. */
  17083. updateSpeed: number;
  17084. /**
  17085. * The amount of time the particle system is running (depends of the overall update speed).
  17086. */
  17087. targetStopDuration: number;
  17088. /**
  17089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17090. */
  17091. disposeOnStop: boolean;
  17092. /**
  17093. * Minimum power of emitting particles.
  17094. */
  17095. minEmitPower: number;
  17096. /**
  17097. * Maximum power of emitting particles.
  17098. */
  17099. maxEmitPower: number;
  17100. /**
  17101. * Minimum life time of emitting particles.
  17102. */
  17103. minLifeTime: number;
  17104. /**
  17105. * Maximum life time of emitting particles.
  17106. */
  17107. maxLifeTime: number;
  17108. /**
  17109. * Minimum Size of emitting particles.
  17110. */
  17111. minSize: number;
  17112. /**
  17113. * Maximum Size of emitting particles.
  17114. */
  17115. maxSize: number;
  17116. /**
  17117. * Minimum scale of emitting particles on X axis.
  17118. */
  17119. minScaleX: number;
  17120. /**
  17121. * Maximum scale of emitting particles on X axis.
  17122. */
  17123. maxScaleX: number;
  17124. /**
  17125. * Minimum scale of emitting particles on Y axis.
  17126. */
  17127. minScaleY: number;
  17128. /**
  17129. * Maximum scale of emitting particles on Y axis.
  17130. */
  17131. maxScaleY: number;
  17132. /**
  17133. * Gets or sets the minimal initial rotation in radians.
  17134. */
  17135. minInitialRotation: number;
  17136. /**
  17137. * Gets or sets the maximal initial rotation in radians.
  17138. */
  17139. maxInitialRotation: number;
  17140. /**
  17141. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17142. */
  17143. minAngularSpeed: number;
  17144. /**
  17145. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17146. */
  17147. maxAngularSpeed: number;
  17148. /**
  17149. * The texture used to render each particle. (this can be a spritesheet)
  17150. */
  17151. particleTexture: Nullable<Texture>;
  17152. /**
  17153. * The layer mask we are rendering the particles through.
  17154. */
  17155. layerMask: number;
  17156. /**
  17157. * This can help using your own shader to render the particle system.
  17158. * The according effect will be created
  17159. */
  17160. customShader: any;
  17161. /**
  17162. * By default particle system starts as soon as they are created. This prevents the
  17163. * automatic start to happen and let you decide when to start emitting particles.
  17164. */
  17165. preventAutoStart: boolean;
  17166. private _noiseTexture;
  17167. /**
  17168. * Gets or sets a texture used to add random noise to particle positions
  17169. */
  17170. noiseTexture: Nullable<ProceduralTexture>;
  17171. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17172. noiseStrength: Vector3;
  17173. /**
  17174. * Callback triggered when the particle animation is ending.
  17175. */
  17176. onAnimationEnd: Nullable<() => void>;
  17177. /**
  17178. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17179. */
  17180. blendMode: number;
  17181. /**
  17182. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17183. * to override the particles.
  17184. */
  17185. forceDepthWrite: boolean;
  17186. /** 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 */
  17187. preWarmCycles: number;
  17188. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17189. preWarmStepOffset: number;
  17190. /**
  17191. * 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)
  17192. */
  17193. spriteCellChangeSpeed: number;
  17194. /**
  17195. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17196. */
  17197. startSpriteCellID: number;
  17198. /**
  17199. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17200. */
  17201. endSpriteCellID: number;
  17202. /**
  17203. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17204. */
  17205. spriteCellWidth: number;
  17206. /**
  17207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17208. */
  17209. spriteCellHeight: number;
  17210. /**
  17211. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17212. */
  17213. spriteRandomStartCell: boolean;
  17214. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17215. translationPivot: Vector2;
  17216. /** @hidden */
  17217. protected _isAnimationSheetEnabled: boolean;
  17218. /**
  17219. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17220. */
  17221. beginAnimationOnStart: boolean;
  17222. /**
  17223. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17224. */
  17225. beginAnimationFrom: number;
  17226. /**
  17227. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17228. */
  17229. beginAnimationTo: number;
  17230. /**
  17231. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17232. */
  17233. beginAnimationLoop: boolean;
  17234. /**
  17235. * Gets or sets a world offset applied to all particles
  17236. */
  17237. worldOffset: Vector3;
  17238. /**
  17239. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17240. */
  17241. isAnimationSheetEnabled: boolean;
  17242. /**
  17243. * Get hosting scene
  17244. * @returns the scene
  17245. */
  17246. getScene(): Scene;
  17247. /**
  17248. * You can use gravity if you want to give an orientation to your particles.
  17249. */
  17250. gravity: Vector3;
  17251. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17252. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17253. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17254. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17255. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17256. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17257. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17258. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17259. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17260. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17261. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17262. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17263. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17264. /**
  17265. * Defines the delay in milliseconds before starting the system (0 by default)
  17266. */
  17267. startDelay: number;
  17268. /**
  17269. * Gets the current list of drag gradients.
  17270. * You must use addDragGradient and removeDragGradient to udpate this list
  17271. * @returns the list of drag gradients
  17272. */
  17273. getDragGradients(): Nullable<Array<FactorGradient>>;
  17274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17275. limitVelocityDamping: number;
  17276. /**
  17277. * Gets the current list of limit velocity gradients.
  17278. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17279. * @returns the list of limit velocity gradients
  17280. */
  17281. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17282. /**
  17283. * Gets the current list of color gradients.
  17284. * You must use addColorGradient and removeColorGradient to udpate this list
  17285. * @returns the list of color gradients
  17286. */
  17287. getColorGradients(): Nullable<Array<ColorGradient>>;
  17288. /**
  17289. * Gets the current list of size gradients.
  17290. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17291. * @returns the list of size gradients
  17292. */
  17293. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17294. /**
  17295. * Gets the current list of color remap gradients.
  17296. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17297. * @returns the list of color remap gradients
  17298. */
  17299. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17300. /**
  17301. * Gets the current list of alpha remap gradients.
  17302. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17303. * @returns the list of alpha remap gradients
  17304. */
  17305. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17306. /**
  17307. * Gets the current list of life time gradients.
  17308. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17309. * @returns the list of life time gradients
  17310. */
  17311. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17312. /**
  17313. * Gets the current list of angular speed gradients.
  17314. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17315. * @returns the list of angular speed gradients
  17316. */
  17317. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17318. /**
  17319. * Gets the current list of velocity gradients.
  17320. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17321. * @returns the list of velocity gradients
  17322. */
  17323. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17324. /**
  17325. * Gets the current list of start size gradients.
  17326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17327. * @returns the list of start size gradients
  17328. */
  17329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17330. /**
  17331. * Gets the current list of emit rate gradients.
  17332. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17333. * @returns the list of emit rate gradients
  17334. */
  17335. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17336. /**
  17337. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17338. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17339. */
  17340. direction1: Vector3;
  17341. /**
  17342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17343. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17344. */
  17345. direction2: Vector3;
  17346. /**
  17347. * 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.
  17348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17349. */
  17350. minEmitBox: Vector3;
  17351. /**
  17352. * 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.
  17353. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17354. */
  17355. maxEmitBox: Vector3;
  17356. /**
  17357. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17358. */
  17359. color1: Color4;
  17360. /**
  17361. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17362. */
  17363. color2: Color4;
  17364. /**
  17365. * Color the particle will have at the end of its lifetime
  17366. */
  17367. colorDead: Color4;
  17368. /**
  17369. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17370. */
  17371. textureMask: Color4;
  17372. /**
  17373. * The particle emitter type defines the emitter used by the particle system.
  17374. * It can be for example box, sphere, or cone...
  17375. */
  17376. particleEmitterType: IParticleEmitterType;
  17377. /** @hidden */
  17378. _isSubEmitter: boolean;
  17379. /**
  17380. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17381. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17382. */
  17383. billboardMode: number;
  17384. protected _isBillboardBased: boolean;
  17385. /**
  17386. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17387. */
  17388. isBillboardBased: boolean;
  17389. /**
  17390. * The scene the particle system belongs to.
  17391. */
  17392. protected _scene: Scene;
  17393. /**
  17394. * Local cache of defines for image processing.
  17395. */
  17396. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17397. /**
  17398. * Default configuration related to image processing available in the standard Material.
  17399. */
  17400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17401. /**
  17402. * Gets the image processing configuration used either in this material.
  17403. */
  17404. /**
  17405. * Sets the Default image processing configuration used either in the this material.
  17406. *
  17407. * If sets to null, the scene one is in use.
  17408. */
  17409. imageProcessingConfiguration: ImageProcessingConfiguration;
  17410. /**
  17411. * Attaches a new image processing configuration to the Standard Material.
  17412. * @param configuration
  17413. */
  17414. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17415. /** @hidden */
  17416. protected _reset(): void;
  17417. /** @hidden */
  17418. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17419. /**
  17420. * Instantiates a particle system.
  17421. * 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.
  17422. * @param name The name of the particle system
  17423. */
  17424. constructor(name: string);
  17425. /**
  17426. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17429. * @returns the emitter
  17430. */
  17431. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17432. /**
  17433. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17434. * @param radius The radius of the hemisphere to emit from
  17435. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17436. * @returns the emitter
  17437. */
  17438. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17439. /**
  17440. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17441. * @param radius The radius of the sphere to emit from
  17442. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17443. * @returns the emitter
  17444. */
  17445. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17446. /**
  17447. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17448. * @param radius The radius of the sphere to emit from
  17449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17451. * @returns the emitter
  17452. */
  17453. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17454. /**
  17455. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17456. * @param radius The radius of the emission cylinder
  17457. * @param height The height of the emission cylinder
  17458. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17459. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17460. * @returns the emitter
  17461. */
  17462. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17463. /**
  17464. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17465. * @param radius The radius of the cylinder to emit from
  17466. * @param height The height of the emission cylinder
  17467. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17470. * @returns the emitter
  17471. */
  17472. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17473. /**
  17474. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17475. * @param radius The radius of the cone to emit from
  17476. * @param angle The base angle of the cone
  17477. * @returns the emitter
  17478. */
  17479. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17480. /**
  17481. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17484. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17485. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17486. * @returns the emitter
  17487. */
  17488. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17489. }
  17490. }
  17491. declare module "babylonjs/Particles/subEmitter" {
  17492. import { Scene } from "babylonjs/scene";
  17493. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17494. /**
  17495. * Type of sub emitter
  17496. */
  17497. export enum SubEmitterType {
  17498. /**
  17499. * Attached to the particle over it's lifetime
  17500. */
  17501. ATTACHED = 0,
  17502. /**
  17503. * Created when the particle dies
  17504. */
  17505. END = 1
  17506. }
  17507. /**
  17508. * Sub emitter class used to emit particles from an existing particle
  17509. */
  17510. export class SubEmitter {
  17511. /**
  17512. * the particle system to be used by the sub emitter
  17513. */
  17514. particleSystem: ParticleSystem;
  17515. /**
  17516. * Type of the submitter (Default: END)
  17517. */
  17518. type: SubEmitterType;
  17519. /**
  17520. * 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)
  17521. * Note: This only is supported when using an emitter of type Mesh
  17522. */
  17523. inheritDirection: boolean;
  17524. /**
  17525. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17526. */
  17527. inheritedVelocityAmount: number;
  17528. /**
  17529. * Creates a sub emitter
  17530. * @param particleSystem the particle system to be used by the sub emitter
  17531. */
  17532. constructor(
  17533. /**
  17534. * the particle system to be used by the sub emitter
  17535. */
  17536. particleSystem: ParticleSystem);
  17537. /**
  17538. * Clones the sub emitter
  17539. * @returns the cloned sub emitter
  17540. */
  17541. clone(): SubEmitter;
  17542. /**
  17543. * Serialize current object to a JSON object
  17544. * @returns the serialized object
  17545. */
  17546. serialize(): any;
  17547. /** @hidden */
  17548. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17549. /**
  17550. * Creates a new SubEmitter from a serialized JSON version
  17551. * @param serializationObject defines the JSON object to read from
  17552. * @param scene defines the hosting scene
  17553. * @param rootUrl defines the rootUrl for data loading
  17554. * @returns a new SubEmitter
  17555. */
  17556. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17557. /** Release associated resources */
  17558. dispose(): void;
  17559. }
  17560. }
  17561. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17562. /** @hidden */
  17563. export var clipPlaneFragmentDeclaration: {
  17564. name: string;
  17565. shader: string;
  17566. };
  17567. }
  17568. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17569. /** @hidden */
  17570. export var imageProcessingDeclaration: {
  17571. name: string;
  17572. shader: string;
  17573. };
  17574. }
  17575. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17576. /** @hidden */
  17577. export var imageProcessingFunctions: {
  17578. name: string;
  17579. shader: string;
  17580. };
  17581. }
  17582. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17583. /** @hidden */
  17584. export var clipPlaneFragment: {
  17585. name: string;
  17586. shader: string;
  17587. };
  17588. }
  17589. declare module "babylonjs/Shaders/particles.fragment" {
  17590. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17591. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17593. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17594. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17595. /** @hidden */
  17596. export var particlesPixelShader: {
  17597. name: string;
  17598. shader: string;
  17599. };
  17600. }
  17601. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17602. /** @hidden */
  17603. export var clipPlaneVertexDeclaration: {
  17604. name: string;
  17605. shader: string;
  17606. };
  17607. }
  17608. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17609. /** @hidden */
  17610. export var clipPlaneVertex: {
  17611. name: string;
  17612. shader: string;
  17613. };
  17614. }
  17615. declare module "babylonjs/Shaders/particles.vertex" {
  17616. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17618. /** @hidden */
  17619. export var particlesVertexShader: {
  17620. name: string;
  17621. shader: string;
  17622. };
  17623. }
  17624. declare module "babylonjs/Particles/particleSystem" {
  17625. import { Nullable } from "babylonjs/types";
  17626. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17627. import { Observable } from "babylonjs/Misc/observable";
  17628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17629. import { Effect } from "babylonjs/Materials/effect";
  17630. import { Scene, IDisposable } from "babylonjs/scene";
  17631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17632. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17633. import { Particle } from "babylonjs/Particles/particle";
  17634. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17636. import "babylonjs/Shaders/particles.fragment";
  17637. import "babylonjs/Shaders/particles.vertex";
  17638. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17639. /**
  17640. * This represents a particle system in Babylon.
  17641. * 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.
  17642. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17643. * @example https://doc.babylonjs.com/babylon101/particles
  17644. */
  17645. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17646. /**
  17647. * Billboard mode will only apply to Y axis
  17648. */
  17649. static readonly BILLBOARDMODE_Y: number;
  17650. /**
  17651. * Billboard mode will apply to all axes
  17652. */
  17653. static readonly BILLBOARDMODE_ALL: number;
  17654. /**
  17655. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17656. */
  17657. static readonly BILLBOARDMODE_STRETCHED: number;
  17658. /**
  17659. * This function can be defined to provide custom update for active particles.
  17660. * This function will be called instead of regular update (age, position, color, etc.).
  17661. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17662. */
  17663. updateFunction: (particles: Particle[]) => void;
  17664. private _emitterWorldMatrix;
  17665. /**
  17666. * This function can be defined to specify initial direction for every new particle.
  17667. * It by default use the emitterType defined function
  17668. */
  17669. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17670. /**
  17671. * This function can be defined to specify initial position for every new particle.
  17672. * It by default use the emitterType defined function
  17673. */
  17674. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17675. /**
  17676. * @hidden
  17677. */
  17678. _inheritedVelocityOffset: Vector3;
  17679. /**
  17680. * An event triggered when the system is disposed
  17681. */
  17682. onDisposeObservable: Observable<ParticleSystem>;
  17683. private _onDisposeObserver;
  17684. /**
  17685. * Sets a callback that will be triggered when the system is disposed
  17686. */
  17687. onDispose: () => void;
  17688. private _particles;
  17689. private _epsilon;
  17690. private _capacity;
  17691. private _stockParticles;
  17692. private _newPartsExcess;
  17693. private _vertexData;
  17694. private _vertexBuffer;
  17695. private _vertexBuffers;
  17696. private _spriteBuffer;
  17697. private _indexBuffer;
  17698. private _effect;
  17699. private _customEffect;
  17700. private _cachedDefines;
  17701. private _scaledColorStep;
  17702. private _colorDiff;
  17703. private _scaledDirection;
  17704. private _scaledGravity;
  17705. private _currentRenderId;
  17706. private _alive;
  17707. private _useInstancing;
  17708. private _started;
  17709. private _stopped;
  17710. private _actualFrame;
  17711. private _scaledUpdateSpeed;
  17712. private _vertexBufferSize;
  17713. /** @hidden */
  17714. _currentEmitRateGradient: Nullable<FactorGradient>;
  17715. /** @hidden */
  17716. _currentEmitRate1: number;
  17717. /** @hidden */
  17718. _currentEmitRate2: number;
  17719. /** @hidden */
  17720. _currentStartSizeGradient: Nullable<FactorGradient>;
  17721. /** @hidden */
  17722. _currentStartSize1: number;
  17723. /** @hidden */
  17724. _currentStartSize2: number;
  17725. private readonly _rawTextureWidth;
  17726. private _rampGradientsTexture;
  17727. private _useRampGradients;
  17728. /** Gets or sets a boolean indicating that ramp gradients must be used
  17729. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17730. */
  17731. useRampGradients: boolean;
  17732. /**
  17733. * 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.
  17734. * 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: [])
  17735. */
  17736. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17737. private _subEmitters;
  17738. /**
  17739. * @hidden
  17740. * If the particle systems emitter should be disposed when the particle system is disposed
  17741. */
  17742. _disposeEmitterOnDispose: boolean;
  17743. /**
  17744. * The current active Sub-systems, this property is used by the root particle system only.
  17745. */
  17746. activeSubSystems: Array<ParticleSystem>;
  17747. private _rootParticleSystem;
  17748. /**
  17749. * Gets the current list of active particles
  17750. */
  17751. readonly particles: Particle[];
  17752. /**
  17753. * Returns the string "ParticleSystem"
  17754. * @returns a string containing the class name
  17755. */
  17756. getClassName(): string;
  17757. /**
  17758. * Instantiates a particle system.
  17759. * 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.
  17760. * @param name The name of the particle system
  17761. * @param capacity The max number of particles alive at the same time
  17762. * @param scene The scene the particle system belongs to
  17763. * @param customEffect a custom effect used to change the way particles are rendered by default
  17764. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17765. * @param epsilon Offset used to render the particles
  17766. */
  17767. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17768. private _addFactorGradient;
  17769. private _removeFactorGradient;
  17770. /**
  17771. * Adds a new life time gradient
  17772. * @param gradient defines the gradient to use (between 0 and 1)
  17773. * @param factor defines the life time factor to affect to the specified gradient
  17774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17775. * @returns the current particle system
  17776. */
  17777. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17778. /**
  17779. * Remove a specific life time gradient
  17780. * @param gradient defines the gradient to remove
  17781. * @returns the current particle system
  17782. */
  17783. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17784. /**
  17785. * Adds a new size gradient
  17786. * @param gradient defines the gradient to use (between 0 and 1)
  17787. * @param factor defines the size factor to affect to the specified gradient
  17788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17789. * @returns the current particle system
  17790. */
  17791. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17792. /**
  17793. * Remove a specific size gradient
  17794. * @param gradient defines the gradient to remove
  17795. * @returns the current particle system
  17796. */
  17797. removeSizeGradient(gradient: number): IParticleSystem;
  17798. /**
  17799. * Adds a new color remap gradient
  17800. * @param gradient defines the gradient to use (between 0 and 1)
  17801. * @param min defines the color remap minimal range
  17802. * @param max defines the color remap maximal range
  17803. * @returns the current particle system
  17804. */
  17805. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17806. /**
  17807. * Remove a specific color remap gradient
  17808. * @param gradient defines the gradient to remove
  17809. * @returns the current particle system
  17810. */
  17811. removeColorRemapGradient(gradient: number): IParticleSystem;
  17812. /**
  17813. * Adds a new alpha remap gradient
  17814. * @param gradient defines the gradient to use (between 0 and 1)
  17815. * @param min defines the alpha remap minimal range
  17816. * @param max defines the alpha remap maximal range
  17817. * @returns the current particle system
  17818. */
  17819. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17820. /**
  17821. * Remove a specific alpha remap gradient
  17822. * @param gradient defines the gradient to remove
  17823. * @returns the current particle system
  17824. */
  17825. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17826. /**
  17827. * Adds a new angular speed gradient
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param factor defines the angular speed to affect to the specified gradient
  17830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17831. * @returns the current particle system
  17832. */
  17833. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17834. /**
  17835. * Remove a specific angular speed gradient
  17836. * @param gradient defines the gradient to remove
  17837. * @returns the current particle system
  17838. */
  17839. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17840. /**
  17841. * Adds a new velocity gradient
  17842. * @param gradient defines the gradient to use (between 0 and 1)
  17843. * @param factor defines the velocity to affect to the specified gradient
  17844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17845. * @returns the current particle system
  17846. */
  17847. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17848. /**
  17849. * Remove a specific velocity gradient
  17850. * @param gradient defines the gradient to remove
  17851. * @returns the current particle system
  17852. */
  17853. removeVelocityGradient(gradient: number): IParticleSystem;
  17854. /**
  17855. * Adds a new limit velocity gradient
  17856. * @param gradient defines the gradient to use (between 0 and 1)
  17857. * @param factor defines the limit velocity value to affect to the specified gradient
  17858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17859. * @returns the current particle system
  17860. */
  17861. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17862. /**
  17863. * Remove a specific limit velocity gradient
  17864. * @param gradient defines the gradient to remove
  17865. * @returns the current particle system
  17866. */
  17867. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17868. /**
  17869. * Adds a new drag gradient
  17870. * @param gradient defines the gradient to use (between 0 and 1)
  17871. * @param factor defines the drag value to affect to the specified gradient
  17872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17873. * @returns the current particle system
  17874. */
  17875. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17876. /**
  17877. * Remove a specific drag gradient
  17878. * @param gradient defines the gradient to remove
  17879. * @returns the current particle system
  17880. */
  17881. removeDragGradient(gradient: number): IParticleSystem;
  17882. /**
  17883. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17884. * @param gradient defines the gradient to use (between 0 and 1)
  17885. * @param factor defines the emit rate value to affect to the specified gradient
  17886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17887. * @returns the current particle system
  17888. */
  17889. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17890. /**
  17891. * Remove a specific emit rate gradient
  17892. * @param gradient defines the gradient to remove
  17893. * @returns the current particle system
  17894. */
  17895. removeEmitRateGradient(gradient: number): IParticleSystem;
  17896. /**
  17897. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17898. * @param gradient defines the gradient to use (between 0 and 1)
  17899. * @param factor defines the start size value to affect to the specified gradient
  17900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17901. * @returns the current particle system
  17902. */
  17903. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17904. /**
  17905. * Remove a specific start size gradient
  17906. * @param gradient defines the gradient to remove
  17907. * @returns the current particle system
  17908. */
  17909. removeStartSizeGradient(gradient: number): IParticleSystem;
  17910. private _createRampGradientTexture;
  17911. /**
  17912. * Gets the current list of ramp gradients.
  17913. * You must use addRampGradient and removeRampGradient to udpate this list
  17914. * @returns the list of ramp gradients
  17915. */
  17916. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17917. /**
  17918. * Adds a new ramp gradient used to remap particle colors
  17919. * @param gradient defines the gradient to use (between 0 and 1)
  17920. * @param color defines the color to affect to the specified gradient
  17921. * @returns the current particle system
  17922. */
  17923. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17924. /**
  17925. * Remove a specific ramp gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeRampGradient(gradient: number): ParticleSystem;
  17930. /**
  17931. * Adds a new color gradient
  17932. * @param gradient defines the gradient to use (between 0 and 1)
  17933. * @param color1 defines the color to affect to the specified gradient
  17934. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17935. * @returns this particle system
  17936. */
  17937. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17938. /**
  17939. * Remove a specific color gradient
  17940. * @param gradient defines the gradient to remove
  17941. * @returns this particle system
  17942. */
  17943. removeColorGradient(gradient: number): IParticleSystem;
  17944. private _fetchR;
  17945. protected _reset(): void;
  17946. private _resetEffect;
  17947. private _createVertexBuffers;
  17948. private _createIndexBuffer;
  17949. /**
  17950. * Gets the maximum number of particles active at the same time.
  17951. * @returns The max number of active particles.
  17952. */
  17953. getCapacity(): number;
  17954. /**
  17955. * Gets whether there are still active particles in the system.
  17956. * @returns True if it is alive, otherwise false.
  17957. */
  17958. isAlive(): boolean;
  17959. /**
  17960. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17961. * @returns True if it has been started, otherwise false.
  17962. */
  17963. isStarted(): boolean;
  17964. private _prepareSubEmitterInternalArray;
  17965. /**
  17966. * Starts the particle system and begins to emit
  17967. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17968. */
  17969. start(delay?: number): void;
  17970. /**
  17971. * Stops the particle system.
  17972. * @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.
  17973. */
  17974. stop(stopSubEmitters?: boolean): void;
  17975. /**
  17976. * Remove all active particles
  17977. */
  17978. reset(): void;
  17979. /**
  17980. * @hidden (for internal use only)
  17981. */
  17982. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17983. /**
  17984. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17985. * Its lifetime will start back at 0.
  17986. */
  17987. recycleParticle: (particle: Particle) => void;
  17988. private _stopSubEmitters;
  17989. private _createParticle;
  17990. private _removeFromRoot;
  17991. private _emitFromParticle;
  17992. private _update;
  17993. /** @hidden */
  17994. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17995. /** @hidden */
  17996. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17997. /** @hidden */
  17998. private _getEffect;
  17999. /**
  18000. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18001. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18002. */
  18003. animate(preWarmOnly?: boolean): void;
  18004. private _appendParticleVertices;
  18005. /**
  18006. * Rebuilds the particle system.
  18007. */
  18008. rebuild(): void;
  18009. /**
  18010. * Is this system ready to be used/rendered
  18011. * @return true if the system is ready
  18012. */
  18013. isReady(): boolean;
  18014. private _render;
  18015. /**
  18016. * Renders the particle system in its current state.
  18017. * @returns the current number of particles
  18018. */
  18019. render(): number;
  18020. /**
  18021. * Disposes the particle system and free the associated resources
  18022. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18023. */
  18024. dispose(disposeTexture?: boolean): void;
  18025. /**
  18026. * Clones the particle system.
  18027. * @param name The name of the cloned object
  18028. * @param newEmitter The new emitter to use
  18029. * @returns the cloned particle system
  18030. */
  18031. clone(name: string, newEmitter: any): ParticleSystem;
  18032. /**
  18033. * Serializes the particle system to a JSON object.
  18034. * @returns the JSON object
  18035. */
  18036. serialize(): any;
  18037. /** @hidden */
  18038. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18039. /** @hidden */
  18040. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18041. /**
  18042. * Parses a JSON object to create a particle system.
  18043. * @param parsedParticleSystem The JSON object to parse
  18044. * @param scene The scene to create the particle system in
  18045. * @param rootUrl The root url to use to load external dependencies like texture
  18046. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18047. * @returns the Parsed particle system
  18048. */
  18049. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18050. }
  18051. }
  18052. declare module "babylonjs/Particles/particle" {
  18053. import { Nullable } from "babylonjs/types";
  18054. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18055. import { Color4 } from "babylonjs/Maths/math.color";
  18056. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18057. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18058. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18059. /**
  18060. * A particle represents one of the element emitted by a particle system.
  18061. * This is mainly define by its coordinates, direction, velocity and age.
  18062. */
  18063. export class Particle {
  18064. /**
  18065. * The particle system the particle belongs to.
  18066. */
  18067. particleSystem: ParticleSystem;
  18068. private static _Count;
  18069. /**
  18070. * Unique ID of the particle
  18071. */
  18072. id: number;
  18073. /**
  18074. * The world position of the particle in the scene.
  18075. */
  18076. position: Vector3;
  18077. /**
  18078. * The world direction of the particle in the scene.
  18079. */
  18080. direction: Vector3;
  18081. /**
  18082. * The color of the particle.
  18083. */
  18084. color: Color4;
  18085. /**
  18086. * The color change of the particle per step.
  18087. */
  18088. colorStep: Color4;
  18089. /**
  18090. * Defines how long will the life of the particle be.
  18091. */
  18092. lifeTime: number;
  18093. /**
  18094. * The current age of the particle.
  18095. */
  18096. age: number;
  18097. /**
  18098. * The current size of the particle.
  18099. */
  18100. size: number;
  18101. /**
  18102. * The current scale of the particle.
  18103. */
  18104. scale: Vector2;
  18105. /**
  18106. * The current angle of the particle.
  18107. */
  18108. angle: number;
  18109. /**
  18110. * Defines how fast is the angle changing.
  18111. */
  18112. angularSpeed: number;
  18113. /**
  18114. * Defines the cell index used by the particle to be rendered from a sprite.
  18115. */
  18116. cellIndex: number;
  18117. /**
  18118. * The information required to support color remapping
  18119. */
  18120. remapData: Vector4;
  18121. /** @hidden */
  18122. _randomCellOffset?: number;
  18123. /** @hidden */
  18124. _initialDirection: Nullable<Vector3>;
  18125. /** @hidden */
  18126. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18127. /** @hidden */
  18128. _initialStartSpriteCellID: number;
  18129. /** @hidden */
  18130. _initialEndSpriteCellID: number;
  18131. /** @hidden */
  18132. _currentColorGradient: Nullable<ColorGradient>;
  18133. /** @hidden */
  18134. _currentColor1: Color4;
  18135. /** @hidden */
  18136. _currentColor2: Color4;
  18137. /** @hidden */
  18138. _currentSizeGradient: Nullable<FactorGradient>;
  18139. /** @hidden */
  18140. _currentSize1: number;
  18141. /** @hidden */
  18142. _currentSize2: number;
  18143. /** @hidden */
  18144. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18145. /** @hidden */
  18146. _currentAngularSpeed1: number;
  18147. /** @hidden */
  18148. _currentAngularSpeed2: number;
  18149. /** @hidden */
  18150. _currentVelocityGradient: Nullable<FactorGradient>;
  18151. /** @hidden */
  18152. _currentVelocity1: number;
  18153. /** @hidden */
  18154. _currentVelocity2: number;
  18155. /** @hidden */
  18156. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18157. /** @hidden */
  18158. _currentLimitVelocity1: number;
  18159. /** @hidden */
  18160. _currentLimitVelocity2: number;
  18161. /** @hidden */
  18162. _currentDragGradient: Nullable<FactorGradient>;
  18163. /** @hidden */
  18164. _currentDrag1: number;
  18165. /** @hidden */
  18166. _currentDrag2: number;
  18167. /** @hidden */
  18168. _randomNoiseCoordinates1: Vector3;
  18169. /** @hidden */
  18170. _randomNoiseCoordinates2: Vector3;
  18171. /**
  18172. * Creates a new instance Particle
  18173. * @param particleSystem the particle system the particle belongs to
  18174. */
  18175. constructor(
  18176. /**
  18177. * The particle system the particle belongs to.
  18178. */
  18179. particleSystem: ParticleSystem);
  18180. private updateCellInfoFromSystem;
  18181. /**
  18182. * Defines how the sprite cell index is updated for the particle
  18183. */
  18184. updateCellIndex(): void;
  18185. /** @hidden */
  18186. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18187. /** @hidden */
  18188. _inheritParticleInfoToSubEmitters(): void;
  18189. /** @hidden */
  18190. _reset(): void;
  18191. /**
  18192. * Copy the properties of particle to another one.
  18193. * @param other the particle to copy the information to.
  18194. */
  18195. copyTo(other: Particle): void;
  18196. }
  18197. }
  18198. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18199. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18200. import { Effect } from "babylonjs/Materials/effect";
  18201. import { Particle } from "babylonjs/Particles/particle";
  18202. /**
  18203. * Particle emitter represents a volume emitting particles.
  18204. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18205. */
  18206. export interface IParticleEmitterType {
  18207. /**
  18208. * Called by the particle System when the direction is computed for the created particle.
  18209. * @param worldMatrix is the world matrix of the particle system
  18210. * @param directionToUpdate is the direction vector to update with the result
  18211. * @param particle is the particle we are computed the direction for
  18212. */
  18213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18214. /**
  18215. * Called by the particle System when the position is computed for the created particle.
  18216. * @param worldMatrix is the world matrix of the particle system
  18217. * @param positionToUpdate is the position vector to update with the result
  18218. * @param particle is the particle we are computed the position for
  18219. */
  18220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18221. /**
  18222. * Clones the current emitter and returns a copy of it
  18223. * @returns the new emitter
  18224. */
  18225. clone(): IParticleEmitterType;
  18226. /**
  18227. * Called by the GPUParticleSystem to setup the update shader
  18228. * @param effect defines the update shader
  18229. */
  18230. applyToShader(effect: Effect): void;
  18231. /**
  18232. * Returns a string to use to update the GPU particles update shader
  18233. * @returns the effect defines string
  18234. */
  18235. getEffectDefines(): string;
  18236. /**
  18237. * Returns a string representing the class name
  18238. * @returns a string containing the class name
  18239. */
  18240. getClassName(): string;
  18241. /**
  18242. * Serializes the particle system to a JSON object.
  18243. * @returns the JSON object
  18244. */
  18245. serialize(): any;
  18246. /**
  18247. * Parse properties from a JSON object
  18248. * @param serializationObject defines the JSON object
  18249. */
  18250. parse(serializationObject: any): void;
  18251. }
  18252. }
  18253. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18254. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18255. import { Effect } from "babylonjs/Materials/effect";
  18256. import { Particle } from "babylonjs/Particles/particle";
  18257. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18258. /**
  18259. * Particle emitter emitting particles from the inside of a box.
  18260. * It emits the particles randomly between 2 given directions.
  18261. */
  18262. export class BoxParticleEmitter implements IParticleEmitterType {
  18263. /**
  18264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18265. */
  18266. direction1: Vector3;
  18267. /**
  18268. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18269. */
  18270. direction2: Vector3;
  18271. /**
  18272. * 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.
  18273. */
  18274. minEmitBox: Vector3;
  18275. /**
  18276. * 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.
  18277. */
  18278. maxEmitBox: Vector3;
  18279. /**
  18280. * Creates a new instance BoxParticleEmitter
  18281. */
  18282. constructor();
  18283. /**
  18284. * Called by the particle System when the direction is computed for the created particle.
  18285. * @param worldMatrix is the world matrix of the particle system
  18286. * @param directionToUpdate is the direction vector to update with the result
  18287. * @param particle is the particle we are computed the direction for
  18288. */
  18289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18290. /**
  18291. * Called by the particle System when the position is computed for the created particle.
  18292. * @param worldMatrix is the world matrix of the particle system
  18293. * @param positionToUpdate is the position vector to update with the result
  18294. * @param particle is the particle we are computed the position for
  18295. */
  18296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18297. /**
  18298. * Clones the current emitter and returns a copy of it
  18299. * @returns the new emitter
  18300. */
  18301. clone(): BoxParticleEmitter;
  18302. /**
  18303. * Called by the GPUParticleSystem to setup the update shader
  18304. * @param effect defines the update shader
  18305. */
  18306. applyToShader(effect: Effect): void;
  18307. /**
  18308. * Returns a string to use to update the GPU particles update shader
  18309. * @returns a string containng the defines string
  18310. */
  18311. getEffectDefines(): string;
  18312. /**
  18313. * Returns the string "BoxParticleEmitter"
  18314. * @returns a string containing the class name
  18315. */
  18316. getClassName(): string;
  18317. /**
  18318. * Serializes the particle system to a JSON object.
  18319. * @returns the JSON object
  18320. */
  18321. serialize(): any;
  18322. /**
  18323. * Parse properties from a JSON object
  18324. * @param serializationObject defines the JSON object
  18325. */
  18326. parse(serializationObject: any): void;
  18327. }
  18328. }
  18329. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18330. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18331. import { Effect } from "babylonjs/Materials/effect";
  18332. import { Particle } from "babylonjs/Particles/particle";
  18333. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18334. /**
  18335. * Particle emitter emitting particles from the inside of a cone.
  18336. * It emits the particles alongside the cone volume from the base to the particle.
  18337. * The emission direction might be randomized.
  18338. */
  18339. export class ConeParticleEmitter implements IParticleEmitterType {
  18340. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18341. directionRandomizer: number;
  18342. private _radius;
  18343. private _angle;
  18344. private _height;
  18345. /**
  18346. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18347. */
  18348. radiusRange: number;
  18349. /**
  18350. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18351. */
  18352. heightRange: number;
  18353. /**
  18354. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18355. */
  18356. emitFromSpawnPointOnly: boolean;
  18357. /**
  18358. * Gets or sets the radius of the emission cone
  18359. */
  18360. radius: number;
  18361. /**
  18362. * Gets or sets the angle of the emission cone
  18363. */
  18364. angle: number;
  18365. private _buildHeight;
  18366. /**
  18367. * Creates a new instance ConeParticleEmitter
  18368. * @param radius the radius of the emission cone (1 by default)
  18369. * @param angle the cone base angle (PI by default)
  18370. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18371. */
  18372. constructor(radius?: number, angle?: number,
  18373. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18374. directionRandomizer?: number);
  18375. /**
  18376. * Called by the particle System when the direction is computed for the created particle.
  18377. * @param worldMatrix is the world matrix of the particle system
  18378. * @param directionToUpdate is the direction vector to update with the result
  18379. * @param particle is the particle we are computed the direction for
  18380. */
  18381. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18382. /**
  18383. * Called by the particle System when the position is computed for the created particle.
  18384. * @param worldMatrix is the world matrix of the particle system
  18385. * @param positionToUpdate is the position vector to update with the result
  18386. * @param particle is the particle we are computed the position for
  18387. */
  18388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18389. /**
  18390. * Clones the current emitter and returns a copy of it
  18391. * @returns the new emitter
  18392. */
  18393. clone(): ConeParticleEmitter;
  18394. /**
  18395. * Called by the GPUParticleSystem to setup the update shader
  18396. * @param effect defines the update shader
  18397. */
  18398. applyToShader(effect: Effect): void;
  18399. /**
  18400. * Returns a string to use to update the GPU particles update shader
  18401. * @returns a string containng the defines string
  18402. */
  18403. getEffectDefines(): string;
  18404. /**
  18405. * Returns the string "ConeParticleEmitter"
  18406. * @returns a string containing the class name
  18407. */
  18408. getClassName(): string;
  18409. /**
  18410. * Serializes the particle system to a JSON object.
  18411. * @returns the JSON object
  18412. */
  18413. serialize(): any;
  18414. /**
  18415. * Parse properties from a JSON object
  18416. * @param serializationObject defines the JSON object
  18417. */
  18418. parse(serializationObject: any): void;
  18419. }
  18420. }
  18421. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18422. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18423. import { Effect } from "babylonjs/Materials/effect";
  18424. import { Particle } from "babylonjs/Particles/particle";
  18425. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18426. /**
  18427. * Particle emitter emitting particles from the inside of a cylinder.
  18428. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18429. */
  18430. export class CylinderParticleEmitter implements IParticleEmitterType {
  18431. /**
  18432. * The radius of the emission cylinder.
  18433. */
  18434. radius: number;
  18435. /**
  18436. * The height of the emission cylinder.
  18437. */
  18438. height: number;
  18439. /**
  18440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18441. */
  18442. radiusRange: number;
  18443. /**
  18444. * How much to randomize the particle direction [0-1].
  18445. */
  18446. directionRandomizer: number;
  18447. /**
  18448. * Creates a new instance CylinderParticleEmitter
  18449. * @param radius the radius of the emission cylinder (1 by default)
  18450. * @param height the height of the emission cylinder (1 by default)
  18451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18453. */
  18454. constructor(
  18455. /**
  18456. * The radius of the emission cylinder.
  18457. */
  18458. radius?: number,
  18459. /**
  18460. * The height of the emission cylinder.
  18461. */
  18462. height?: number,
  18463. /**
  18464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18465. */
  18466. radiusRange?: number,
  18467. /**
  18468. * How much to randomize the particle direction [0-1].
  18469. */
  18470. directionRandomizer?: number);
  18471. /**
  18472. * Called by the particle System when the direction is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param directionToUpdate is the direction vector to update with the result
  18475. * @param particle is the particle we are computed the direction for
  18476. */
  18477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Called by the particle System when the position is computed for the created particle.
  18480. * @param worldMatrix is the world matrix of the particle system
  18481. * @param positionToUpdate is the position vector to update with the result
  18482. * @param particle is the particle we are computed the position for
  18483. */
  18484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18485. /**
  18486. * Clones the current emitter and returns a copy of it
  18487. * @returns the new emitter
  18488. */
  18489. clone(): CylinderParticleEmitter;
  18490. /**
  18491. * Called by the GPUParticleSystem to setup the update shader
  18492. * @param effect defines the update shader
  18493. */
  18494. applyToShader(effect: Effect): void;
  18495. /**
  18496. * Returns a string to use to update the GPU particles update shader
  18497. * @returns a string containng the defines string
  18498. */
  18499. getEffectDefines(): string;
  18500. /**
  18501. * Returns the string "CylinderParticleEmitter"
  18502. * @returns a string containing the class name
  18503. */
  18504. getClassName(): string;
  18505. /**
  18506. * Serializes the particle system to a JSON object.
  18507. * @returns the JSON object
  18508. */
  18509. serialize(): any;
  18510. /**
  18511. * Parse properties from a JSON object
  18512. * @param serializationObject defines the JSON object
  18513. */
  18514. parse(serializationObject: any): void;
  18515. }
  18516. /**
  18517. * Particle emitter emitting particles from the inside of a cylinder.
  18518. * It emits the particles randomly between two vectors.
  18519. */
  18520. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18521. /**
  18522. * The min limit of the emission direction.
  18523. */
  18524. direction1: Vector3;
  18525. /**
  18526. * The max limit of the emission direction.
  18527. */
  18528. direction2: Vector3;
  18529. /**
  18530. * Creates a new instance CylinderDirectedParticleEmitter
  18531. * @param radius the radius of the emission cylinder (1 by default)
  18532. * @param height the height of the emission cylinder (1 by default)
  18533. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number, height?: number, radiusRange?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): CylinderDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "CylinderDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18586. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18587. import { Effect } from "babylonjs/Materials/effect";
  18588. import { Particle } from "babylonjs/Particles/particle";
  18589. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18590. /**
  18591. * Particle emitter emitting particles from the inside of a hemisphere.
  18592. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18593. */
  18594. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18595. /**
  18596. * The radius of the emission hemisphere.
  18597. */
  18598. radius: number;
  18599. /**
  18600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18601. */
  18602. radiusRange: number;
  18603. /**
  18604. * How much to randomize the particle direction [0-1].
  18605. */
  18606. directionRandomizer: number;
  18607. /**
  18608. * Creates a new instance HemisphericParticleEmitter
  18609. * @param radius the radius of the emission hemisphere (1 by default)
  18610. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18612. */
  18613. constructor(
  18614. /**
  18615. * The radius of the emission hemisphere.
  18616. */
  18617. radius?: number,
  18618. /**
  18619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18620. */
  18621. radiusRange?: number,
  18622. /**
  18623. * How much to randomize the particle direction [0-1].
  18624. */
  18625. directionRandomizer?: number);
  18626. /**
  18627. * Called by the particle System when the direction is computed for the created particle.
  18628. * @param worldMatrix is the world matrix of the particle system
  18629. * @param directionToUpdate is the direction vector to update with the result
  18630. * @param particle is the particle we are computed the direction for
  18631. */
  18632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18633. /**
  18634. * Called by the particle System when the position is computed for the created particle.
  18635. * @param worldMatrix is the world matrix of the particle system
  18636. * @param positionToUpdate is the position vector to update with the result
  18637. * @param particle is the particle we are computed the position for
  18638. */
  18639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18640. /**
  18641. * Clones the current emitter and returns a copy of it
  18642. * @returns the new emitter
  18643. */
  18644. clone(): HemisphericParticleEmitter;
  18645. /**
  18646. * Called by the GPUParticleSystem to setup the update shader
  18647. * @param effect defines the update shader
  18648. */
  18649. applyToShader(effect: Effect): void;
  18650. /**
  18651. * Returns a string to use to update the GPU particles update shader
  18652. * @returns a string containng the defines string
  18653. */
  18654. getEffectDefines(): string;
  18655. /**
  18656. * Returns the string "HemisphericParticleEmitter"
  18657. * @returns a string containing the class name
  18658. */
  18659. getClassName(): string;
  18660. /**
  18661. * Serializes the particle system to a JSON object.
  18662. * @returns the JSON object
  18663. */
  18664. serialize(): any;
  18665. /**
  18666. * Parse properties from a JSON object
  18667. * @param serializationObject defines the JSON object
  18668. */
  18669. parse(serializationObject: any): void;
  18670. }
  18671. }
  18672. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18673. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18674. import { Effect } from "babylonjs/Materials/effect";
  18675. import { Particle } from "babylonjs/Particles/particle";
  18676. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18677. /**
  18678. * Particle emitter emitting particles from a point.
  18679. * It emits the particles randomly between 2 given directions.
  18680. */
  18681. export class PointParticleEmitter implements IParticleEmitterType {
  18682. /**
  18683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18684. */
  18685. direction1: Vector3;
  18686. /**
  18687. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18688. */
  18689. direction2: Vector3;
  18690. /**
  18691. * Creates a new instance PointParticleEmitter
  18692. */
  18693. constructor();
  18694. /**
  18695. * Called by the particle System when the direction is computed for the created particle.
  18696. * @param worldMatrix is the world matrix of the particle system
  18697. * @param directionToUpdate is the direction vector to update with the result
  18698. * @param particle is the particle we are computed the direction for
  18699. */
  18700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18701. /**
  18702. * Called by the particle System when the position is computed for the created particle.
  18703. * @param worldMatrix is the world matrix of the particle system
  18704. * @param positionToUpdate is the position vector to update with the result
  18705. * @param particle is the particle we are computed the position for
  18706. */
  18707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18708. /**
  18709. * Clones the current emitter and returns a copy of it
  18710. * @returns the new emitter
  18711. */
  18712. clone(): PointParticleEmitter;
  18713. /**
  18714. * Called by the GPUParticleSystem to setup the update shader
  18715. * @param effect defines the update shader
  18716. */
  18717. applyToShader(effect: Effect): void;
  18718. /**
  18719. * Returns a string to use to update the GPU particles update shader
  18720. * @returns a string containng the defines string
  18721. */
  18722. getEffectDefines(): string;
  18723. /**
  18724. * Returns the string "PointParticleEmitter"
  18725. * @returns a string containing the class name
  18726. */
  18727. getClassName(): string;
  18728. /**
  18729. * Serializes the particle system to a JSON object.
  18730. * @returns the JSON object
  18731. */
  18732. serialize(): any;
  18733. /**
  18734. * Parse properties from a JSON object
  18735. * @param serializationObject defines the JSON object
  18736. */
  18737. parse(serializationObject: any): void;
  18738. }
  18739. }
  18740. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18741. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18742. import { Effect } from "babylonjs/Materials/effect";
  18743. import { Particle } from "babylonjs/Particles/particle";
  18744. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18745. /**
  18746. * Particle emitter emitting particles from the inside of a sphere.
  18747. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18748. */
  18749. export class SphereParticleEmitter implements IParticleEmitterType {
  18750. /**
  18751. * The radius of the emission sphere.
  18752. */
  18753. radius: number;
  18754. /**
  18755. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18756. */
  18757. radiusRange: number;
  18758. /**
  18759. * How much to randomize the particle direction [0-1].
  18760. */
  18761. directionRandomizer: number;
  18762. /**
  18763. * Creates a new instance SphereParticleEmitter
  18764. * @param radius the radius of the emission sphere (1 by default)
  18765. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18766. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18767. */
  18768. constructor(
  18769. /**
  18770. * The radius of the emission sphere.
  18771. */
  18772. radius?: number,
  18773. /**
  18774. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18775. */
  18776. radiusRange?: number,
  18777. /**
  18778. * How much to randomize the particle direction [0-1].
  18779. */
  18780. directionRandomizer?: number);
  18781. /**
  18782. * Called by the particle System when the direction is computed for the created particle.
  18783. * @param worldMatrix is the world matrix of the particle system
  18784. * @param directionToUpdate is the direction vector to update with the result
  18785. * @param particle is the particle we are computed the direction for
  18786. */
  18787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18788. /**
  18789. * Called by the particle System when the position is computed for the created particle.
  18790. * @param worldMatrix is the world matrix of the particle system
  18791. * @param positionToUpdate is the position vector to update with the result
  18792. * @param particle is the particle we are computed the position for
  18793. */
  18794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18795. /**
  18796. * Clones the current emitter and returns a copy of it
  18797. * @returns the new emitter
  18798. */
  18799. clone(): SphereParticleEmitter;
  18800. /**
  18801. * Called by the GPUParticleSystem to setup the update shader
  18802. * @param effect defines the update shader
  18803. */
  18804. applyToShader(effect: Effect): void;
  18805. /**
  18806. * Returns a string to use to update the GPU particles update shader
  18807. * @returns a string containng the defines string
  18808. */
  18809. getEffectDefines(): string;
  18810. /**
  18811. * Returns the string "SphereParticleEmitter"
  18812. * @returns a string containing the class name
  18813. */
  18814. getClassName(): string;
  18815. /**
  18816. * Serializes the particle system to a JSON object.
  18817. * @returns the JSON object
  18818. */
  18819. serialize(): any;
  18820. /**
  18821. * Parse properties from a JSON object
  18822. * @param serializationObject defines the JSON object
  18823. */
  18824. parse(serializationObject: any): void;
  18825. }
  18826. /**
  18827. * Particle emitter emitting particles from the inside of a sphere.
  18828. * It emits the particles randomly between two vectors.
  18829. */
  18830. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18831. /**
  18832. * The min limit of the emission direction.
  18833. */
  18834. direction1: Vector3;
  18835. /**
  18836. * The max limit of the emission direction.
  18837. */
  18838. direction2: Vector3;
  18839. /**
  18840. * Creates a new instance SphereDirectedParticleEmitter
  18841. * @param radius the radius of the emission sphere (1 by default)
  18842. * @param direction1 the min limit of the emission direction (up vector by default)
  18843. * @param direction2 the max limit of the emission direction (up vector by default)
  18844. */
  18845. constructor(radius?: number,
  18846. /**
  18847. * The min limit of the emission direction.
  18848. */
  18849. direction1?: Vector3,
  18850. /**
  18851. * The max limit of the emission direction.
  18852. */
  18853. direction2?: Vector3);
  18854. /**
  18855. * Called by the particle System when the direction is computed for the created particle.
  18856. * @param worldMatrix is the world matrix of the particle system
  18857. * @param directionToUpdate is the direction vector to update with the result
  18858. * @param particle is the particle we are computed the direction for
  18859. */
  18860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18861. /**
  18862. * Clones the current emitter and returns a copy of it
  18863. * @returns the new emitter
  18864. */
  18865. clone(): SphereDirectedParticleEmitter;
  18866. /**
  18867. * Called by the GPUParticleSystem to setup the update shader
  18868. * @param effect defines the update shader
  18869. */
  18870. applyToShader(effect: Effect): void;
  18871. /**
  18872. * Returns a string to use to update the GPU particles update shader
  18873. * @returns a string containng the defines string
  18874. */
  18875. getEffectDefines(): string;
  18876. /**
  18877. * Returns the string "SphereDirectedParticleEmitter"
  18878. * @returns a string containing the class name
  18879. */
  18880. getClassName(): string;
  18881. /**
  18882. * Serializes the particle system to a JSON object.
  18883. * @returns the JSON object
  18884. */
  18885. serialize(): any;
  18886. /**
  18887. * Parse properties from a JSON object
  18888. * @param serializationObject defines the JSON object
  18889. */
  18890. parse(serializationObject: any): void;
  18891. }
  18892. }
  18893. declare module "babylonjs/Particles/EmitterTypes/index" {
  18894. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18895. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18896. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18897. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18898. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18899. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18900. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18901. }
  18902. declare module "babylonjs/Particles/IParticleSystem" {
  18903. import { Nullable } from "babylonjs/types";
  18904. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18905. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18908. import { Texture } from "babylonjs/Materials/Textures/texture";
  18909. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18910. import { Scene } from "babylonjs/scene";
  18911. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18912. import { Animation } from "babylonjs/Animations/animation";
  18913. /**
  18914. * Interface representing a particle system in Babylon.js.
  18915. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18916. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18917. */
  18918. export interface IParticleSystem {
  18919. /**
  18920. * List of animations used by the particle system.
  18921. */
  18922. animations: Animation[];
  18923. /**
  18924. * The id of the Particle system.
  18925. */
  18926. id: string;
  18927. /**
  18928. * The name of the Particle system.
  18929. */
  18930. name: string;
  18931. /**
  18932. * The emitter represents the Mesh or position we are attaching the particle system to.
  18933. */
  18934. emitter: Nullable<AbstractMesh | Vector3>;
  18935. /**
  18936. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18937. */
  18938. isBillboardBased: boolean;
  18939. /**
  18940. * The rendering group used by the Particle system to chose when to render.
  18941. */
  18942. renderingGroupId: number;
  18943. /**
  18944. * The layer mask we are rendering the particles through.
  18945. */
  18946. layerMask: number;
  18947. /**
  18948. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18949. */
  18950. updateSpeed: number;
  18951. /**
  18952. * The amount of time the particle system is running (depends of the overall update speed).
  18953. */
  18954. targetStopDuration: number;
  18955. /**
  18956. * The texture used to render each particle. (this can be a spritesheet)
  18957. */
  18958. particleTexture: Nullable<Texture>;
  18959. /**
  18960. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18961. */
  18962. blendMode: number;
  18963. /**
  18964. * Minimum life time of emitting particles.
  18965. */
  18966. minLifeTime: number;
  18967. /**
  18968. * Maximum life time of emitting particles.
  18969. */
  18970. maxLifeTime: number;
  18971. /**
  18972. * Minimum Size of emitting particles.
  18973. */
  18974. minSize: number;
  18975. /**
  18976. * Maximum Size of emitting particles.
  18977. */
  18978. maxSize: number;
  18979. /**
  18980. * Minimum scale of emitting particles on X axis.
  18981. */
  18982. minScaleX: number;
  18983. /**
  18984. * Maximum scale of emitting particles on X axis.
  18985. */
  18986. maxScaleX: number;
  18987. /**
  18988. * Minimum scale of emitting particles on Y axis.
  18989. */
  18990. minScaleY: number;
  18991. /**
  18992. * Maximum scale of emitting particles on Y axis.
  18993. */
  18994. maxScaleY: number;
  18995. /**
  18996. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18997. */
  18998. color1: Color4;
  18999. /**
  19000. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19001. */
  19002. color2: Color4;
  19003. /**
  19004. * Color the particle will have at the end of its lifetime.
  19005. */
  19006. colorDead: Color4;
  19007. /**
  19008. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19009. */
  19010. emitRate: number;
  19011. /**
  19012. * You can use gravity if you want to give an orientation to your particles.
  19013. */
  19014. gravity: Vector3;
  19015. /**
  19016. * Minimum power of emitting particles.
  19017. */
  19018. minEmitPower: number;
  19019. /**
  19020. * Maximum power of emitting particles.
  19021. */
  19022. maxEmitPower: number;
  19023. /**
  19024. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19025. */
  19026. minAngularSpeed: number;
  19027. /**
  19028. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19029. */
  19030. maxAngularSpeed: number;
  19031. /**
  19032. * Gets or sets the minimal initial rotation in radians.
  19033. */
  19034. minInitialRotation: number;
  19035. /**
  19036. * Gets or sets the maximal initial rotation in radians.
  19037. */
  19038. maxInitialRotation: number;
  19039. /**
  19040. * The particle emitter type defines the emitter used by the particle system.
  19041. * It can be for example box, sphere, or cone...
  19042. */
  19043. particleEmitterType: Nullable<IParticleEmitterType>;
  19044. /**
  19045. * Defines the delay in milliseconds before starting the system (0 by default)
  19046. */
  19047. startDelay: number;
  19048. /**
  19049. * 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
  19050. */
  19051. preWarmCycles: number;
  19052. /**
  19053. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19054. */
  19055. preWarmStepOffset: number;
  19056. /**
  19057. * 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)
  19058. */
  19059. spriteCellChangeSpeed: number;
  19060. /**
  19061. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19062. */
  19063. startSpriteCellID: number;
  19064. /**
  19065. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19066. */
  19067. endSpriteCellID: number;
  19068. /**
  19069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19070. */
  19071. spriteCellWidth: number;
  19072. /**
  19073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19074. */
  19075. spriteCellHeight: number;
  19076. /**
  19077. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19078. */
  19079. spriteRandomStartCell: boolean;
  19080. /**
  19081. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19082. */
  19083. isAnimationSheetEnabled: boolean;
  19084. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19085. translationPivot: Vector2;
  19086. /**
  19087. * Gets or sets a texture used to add random noise to particle positions
  19088. */
  19089. noiseTexture: Nullable<BaseTexture>;
  19090. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19091. noiseStrength: Vector3;
  19092. /**
  19093. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19094. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19095. */
  19096. billboardMode: number;
  19097. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19098. limitVelocityDamping: number;
  19099. /**
  19100. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19101. */
  19102. beginAnimationOnStart: boolean;
  19103. /**
  19104. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19105. */
  19106. beginAnimationFrom: number;
  19107. /**
  19108. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19109. */
  19110. beginAnimationTo: number;
  19111. /**
  19112. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19113. */
  19114. beginAnimationLoop: boolean;
  19115. /**
  19116. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19117. */
  19118. disposeOnStop: boolean;
  19119. /**
  19120. * Gets the maximum number of particles active at the same time.
  19121. * @returns The max number of active particles.
  19122. */
  19123. getCapacity(): number;
  19124. /**
  19125. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19126. * @returns True if it has been started, otherwise false.
  19127. */
  19128. isStarted(): boolean;
  19129. /**
  19130. * Animates the particle system for this frame.
  19131. */
  19132. animate(): void;
  19133. /**
  19134. * Renders the particle system in its current state.
  19135. * @returns the current number of particles
  19136. */
  19137. render(): number;
  19138. /**
  19139. * Dispose the particle system and frees its associated resources.
  19140. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19141. */
  19142. dispose(disposeTexture?: boolean): void;
  19143. /**
  19144. * Clones the particle system.
  19145. * @param name The name of the cloned object
  19146. * @param newEmitter The new emitter to use
  19147. * @returns the cloned particle system
  19148. */
  19149. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19150. /**
  19151. * Serializes the particle system to a JSON object.
  19152. * @returns the JSON object
  19153. */
  19154. serialize(): any;
  19155. /**
  19156. * Rebuild the particle system
  19157. */
  19158. rebuild(): void;
  19159. /**
  19160. * Starts the particle system and begins to emit
  19161. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19162. */
  19163. start(delay?: number): void;
  19164. /**
  19165. * Stops the particle system.
  19166. */
  19167. stop(): void;
  19168. /**
  19169. * Remove all active particles
  19170. */
  19171. reset(): void;
  19172. /**
  19173. * Is this system ready to be used/rendered
  19174. * @return true if the system is ready
  19175. */
  19176. isReady(): boolean;
  19177. /**
  19178. * Adds a new color gradient
  19179. * @param gradient defines the gradient to use (between 0 and 1)
  19180. * @param color1 defines the color to affect to the specified gradient
  19181. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19182. * @returns the current particle system
  19183. */
  19184. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19185. /**
  19186. * Remove a specific color gradient
  19187. * @param gradient defines the gradient to remove
  19188. * @returns the current particle system
  19189. */
  19190. removeColorGradient(gradient: number): IParticleSystem;
  19191. /**
  19192. * Adds a new size gradient
  19193. * @param gradient defines the gradient to use (between 0 and 1)
  19194. * @param factor defines the size factor to affect to the specified gradient
  19195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19196. * @returns the current particle system
  19197. */
  19198. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19199. /**
  19200. * Remove a specific size gradient
  19201. * @param gradient defines the gradient to remove
  19202. * @returns the current particle system
  19203. */
  19204. removeSizeGradient(gradient: number): IParticleSystem;
  19205. /**
  19206. * Gets the current list of color gradients.
  19207. * You must use addColorGradient and removeColorGradient to udpate this list
  19208. * @returns the list of color gradients
  19209. */
  19210. getColorGradients(): Nullable<Array<ColorGradient>>;
  19211. /**
  19212. * Gets the current list of size gradients.
  19213. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19214. * @returns the list of size gradients
  19215. */
  19216. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19217. /**
  19218. * Gets the current list of angular speed gradients.
  19219. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19220. * @returns the list of angular speed gradients
  19221. */
  19222. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19223. /**
  19224. * Adds a new angular speed gradient
  19225. * @param gradient defines the gradient to use (between 0 and 1)
  19226. * @param factor defines the angular speed to affect to the specified gradient
  19227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19228. * @returns the current particle system
  19229. */
  19230. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19231. /**
  19232. * Remove a specific angular speed gradient
  19233. * @param gradient defines the gradient to remove
  19234. * @returns the current particle system
  19235. */
  19236. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19237. /**
  19238. * Gets the current list of velocity gradients.
  19239. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19240. * @returns the list of velocity gradients
  19241. */
  19242. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new velocity gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific velocity gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeVelocityGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of limit velocity gradients.
  19259. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19260. * @returns the list of limit velocity gradients
  19261. */
  19262. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new limit velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the limit 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific limit velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Adds a new drag gradient
  19279. * @param gradient defines the gradient to use (between 0 and 1)
  19280. * @param factor defines the drag to affect to the specified gradient
  19281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19282. * @returns the current particle system
  19283. */
  19284. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19285. /**
  19286. * Remove a specific drag gradient
  19287. * @param gradient defines the gradient to remove
  19288. * @returns the current particle system
  19289. */
  19290. removeDragGradient(gradient: number): IParticleSystem;
  19291. /**
  19292. * Gets the current list of drag gradients.
  19293. * You must use addDragGradient and removeDragGradient to udpate this list
  19294. * @returns the list of drag gradients
  19295. */
  19296. getDragGradients(): Nullable<Array<FactorGradient>>;
  19297. /**
  19298. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific emit rate gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeEmitRateGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of emit rate gradients.
  19313. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19314. * @returns the list of emit rate gradients
  19315. */
  19316. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new start size 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 start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific start size gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeStartSizeGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of start size gradients.
  19333. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19334. * @returns the list of start size gradients
  19335. */
  19336. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new life time gradient
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific life time gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of life time gradients.
  19353. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19354. * @returns the list of life time gradients
  19355. */
  19356. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Gets the current list of color gradients.
  19359. * You must use addColorGradient and removeColorGradient to udpate this list
  19360. * @returns the list of color gradients
  19361. */
  19362. getColorGradients(): Nullable<Array<ColorGradient>>;
  19363. /**
  19364. * Adds a new ramp gradient used to remap particle colors
  19365. * @param gradient defines the gradient to use (between 0 and 1)
  19366. * @param color defines the color to affect to the specified gradient
  19367. * @returns the current particle system
  19368. */
  19369. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19370. /**
  19371. * Gets the current list of ramp gradients.
  19372. * You must use addRampGradient and removeRampGradient to udpate this list
  19373. * @returns the list of ramp gradients
  19374. */
  19375. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19376. /** Gets or sets a boolean indicating that ramp gradients must be used
  19377. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19378. */
  19379. useRampGradients: boolean;
  19380. /**
  19381. * Adds a new color remap gradient
  19382. * @param gradient defines the gradient to use (between 0 and 1)
  19383. * @param min defines the color remap minimal range
  19384. * @param max defines the color remap maximal range
  19385. * @returns the current particle system
  19386. */
  19387. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of color remap gradients.
  19390. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19391. * @returns the list of color remap gradients
  19392. */
  19393. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Adds a new alpha remap gradient
  19396. * @param gradient defines the gradient to use (between 0 and 1)
  19397. * @param min defines the alpha remap minimal range
  19398. * @param max defines the alpha remap maximal range
  19399. * @returns the current particle system
  19400. */
  19401. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19402. /**
  19403. * Gets the current list of alpha remap gradients.
  19404. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19405. * @returns the list of alpha remap gradients
  19406. */
  19407. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19408. /**
  19409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19412. * @returns the emitter
  19413. */
  19414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19415. /**
  19416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19417. * @param radius The radius of the hemisphere to emit from
  19418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19419. * @returns the emitter
  19420. */
  19421. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19422. /**
  19423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19424. * @param radius The radius of the sphere to emit from
  19425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19426. * @returns the emitter
  19427. */
  19428. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19429. /**
  19430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19431. * @param radius The radius of the sphere to emit from
  19432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19434. * @returns the emitter
  19435. */
  19436. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19437. /**
  19438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19439. * @param radius The radius of the emission cylinder
  19440. * @param height The height of the emission cylinder
  19441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19443. * @returns the emitter
  19444. */
  19445. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19446. /**
  19447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19448. * @param radius The radius of the cylinder to emit from
  19449. * @param height The height of the emission cylinder
  19450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19453. * @returns the emitter
  19454. */
  19455. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19456. /**
  19457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19458. * @param radius The radius of the cone to emit from
  19459. * @param angle The base angle of the cone
  19460. * @returns the emitter
  19461. */
  19462. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19463. /**
  19464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19469. * @returns the emitter
  19470. */
  19471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19472. /**
  19473. * Get hosting scene
  19474. * @returns the scene
  19475. */
  19476. getScene(): Scene;
  19477. }
  19478. }
  19479. declare module "babylonjs/Meshes/instancedMesh" {
  19480. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19481. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19482. import { Camera } from "babylonjs/Cameras/camera";
  19483. import { Node } from "babylonjs/node";
  19484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19485. import { Mesh } from "babylonjs/Meshes/mesh";
  19486. import { Material } from "babylonjs/Materials/material";
  19487. import { Skeleton } from "babylonjs/Bones/skeleton";
  19488. import { Light } from "babylonjs/Lights/light";
  19489. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19490. /**
  19491. * Creates an instance based on a source mesh.
  19492. */
  19493. export class InstancedMesh extends AbstractMesh {
  19494. private _sourceMesh;
  19495. private _currentLOD;
  19496. /** @hidden */
  19497. _indexInSourceMeshInstanceArray: number;
  19498. constructor(name: string, source: Mesh);
  19499. /**
  19500. * Returns the string "InstancedMesh".
  19501. */
  19502. getClassName(): string;
  19503. /** Gets the list of lights affecting that mesh */
  19504. readonly lightSources: Light[];
  19505. _resyncLightSources(): void;
  19506. _resyncLighSource(light: Light): void;
  19507. _removeLightSource(light: Light, dispose: boolean): void;
  19508. /**
  19509. * If the source mesh receives shadows
  19510. */
  19511. readonly receiveShadows: boolean;
  19512. /**
  19513. * The material of the source mesh
  19514. */
  19515. readonly material: Nullable<Material>;
  19516. /**
  19517. * Visibility of the source mesh
  19518. */
  19519. readonly visibility: number;
  19520. /**
  19521. * Skeleton of the source mesh
  19522. */
  19523. readonly skeleton: Nullable<Skeleton>;
  19524. /**
  19525. * Rendering ground id of the source mesh
  19526. */
  19527. renderingGroupId: number;
  19528. /**
  19529. * Returns the total number of vertices (integer).
  19530. */
  19531. getTotalVertices(): number;
  19532. /**
  19533. * Returns a positive integer : the total number of indices in this mesh geometry.
  19534. * @returns the numner of indices or zero if the mesh has no geometry.
  19535. */
  19536. getTotalIndices(): number;
  19537. /**
  19538. * The source mesh of the instance
  19539. */
  19540. readonly sourceMesh: Mesh;
  19541. /**
  19542. * Is this node ready to be used/rendered
  19543. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19544. * @return {boolean} is it ready
  19545. */
  19546. isReady(completeCheck?: boolean): boolean;
  19547. /**
  19548. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19549. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19550. * @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.
  19551. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19552. */
  19553. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19554. /**
  19555. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19556. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19557. * The `data` are either a numeric array either a Float32Array.
  19558. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19559. * 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).
  19560. * Note that a new underlying VertexBuffer object is created each call.
  19561. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19562. *
  19563. * Possible `kind` values :
  19564. * - VertexBuffer.PositionKind
  19565. * - VertexBuffer.UVKind
  19566. * - VertexBuffer.UV2Kind
  19567. * - VertexBuffer.UV3Kind
  19568. * - VertexBuffer.UV4Kind
  19569. * - VertexBuffer.UV5Kind
  19570. * - VertexBuffer.UV6Kind
  19571. * - VertexBuffer.ColorKind
  19572. * - VertexBuffer.MatricesIndicesKind
  19573. * - VertexBuffer.MatricesIndicesExtraKind
  19574. * - VertexBuffer.MatricesWeightsKind
  19575. * - VertexBuffer.MatricesWeightsExtraKind
  19576. *
  19577. * Returns the Mesh.
  19578. */
  19579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19580. /**
  19581. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19582. * If the mesh has no geometry, it is simply returned as it is.
  19583. * The `data` are either a numeric array either a Float32Array.
  19584. * No new underlying VertexBuffer object is created.
  19585. * 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.
  19586. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19587. *
  19588. * Possible `kind` values :
  19589. * - VertexBuffer.PositionKind
  19590. * - VertexBuffer.UVKind
  19591. * - VertexBuffer.UV2Kind
  19592. * - VertexBuffer.UV3Kind
  19593. * - VertexBuffer.UV4Kind
  19594. * - VertexBuffer.UV5Kind
  19595. * - VertexBuffer.UV6Kind
  19596. * - VertexBuffer.ColorKind
  19597. * - VertexBuffer.MatricesIndicesKind
  19598. * - VertexBuffer.MatricesIndicesExtraKind
  19599. * - VertexBuffer.MatricesWeightsKind
  19600. * - VertexBuffer.MatricesWeightsExtraKind
  19601. *
  19602. * Returns the Mesh.
  19603. */
  19604. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19605. /**
  19606. * Sets the mesh indices.
  19607. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19608. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19609. * This method creates a new index buffer each call.
  19610. * Returns the Mesh.
  19611. */
  19612. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19613. /**
  19614. * Boolean : True if the mesh owns the requested kind of data.
  19615. */
  19616. isVerticesDataPresent(kind: string): boolean;
  19617. /**
  19618. * Returns an array of indices (IndicesArray).
  19619. */
  19620. getIndices(): Nullable<IndicesArray>;
  19621. readonly _positions: Nullable<Vector3[]>;
  19622. /**
  19623. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19624. * This means the mesh underlying bounding box and sphere are recomputed.
  19625. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19626. * @returns the current mesh
  19627. */
  19628. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19629. /** @hidden */
  19630. _preActivate(): InstancedMesh;
  19631. /** @hidden */
  19632. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19633. /** @hidden */
  19634. _postActivate(): void;
  19635. getWorldMatrix(): Matrix;
  19636. readonly isAnInstance: boolean;
  19637. /**
  19638. * Returns the current associated LOD AbstractMesh.
  19639. */
  19640. getLOD(camera: Camera): AbstractMesh;
  19641. /** @hidden */
  19642. _syncSubMeshes(): InstancedMesh;
  19643. /** @hidden */
  19644. _generatePointsArray(): boolean;
  19645. /**
  19646. * Creates a new InstancedMesh from the current mesh.
  19647. * - name (string) : the cloned mesh name
  19648. * - newParent (optional Node) : the optional Node to parent the clone to.
  19649. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19650. *
  19651. * Returns the clone.
  19652. */
  19653. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19654. /**
  19655. * Disposes the InstancedMesh.
  19656. * Returns nothing.
  19657. */
  19658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19659. }
  19660. module "babylonjs/Meshes/mesh" {
  19661. interface Mesh {
  19662. /**
  19663. * Register a custom buffer that will be instanced
  19664. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19665. * @param kind defines the buffer kind
  19666. * @param stride defines the stride in floats
  19667. */
  19668. registerInstancedBuffer(kind: string, stride: number): void;
  19669. /** @hidden */
  19670. _userInstancedBuffersStorage: {
  19671. data: {
  19672. [key: string]: Float32Array;
  19673. };
  19674. sizes: {
  19675. [key: string]: number;
  19676. };
  19677. vertexBuffers: {
  19678. [key: string]: Nullable<VertexBuffer>;
  19679. };
  19680. strides: {
  19681. [key: string]: number;
  19682. };
  19683. };
  19684. }
  19685. }
  19686. module "babylonjs/Meshes/abstractMesh" {
  19687. interface AbstractMesh {
  19688. /**
  19689. * Object used to store instanced buffers defined by user
  19690. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19691. */
  19692. instancedBuffers: {
  19693. [key: string]: any;
  19694. };
  19695. }
  19696. }
  19697. }
  19698. declare module "babylonjs/Materials/shaderMaterial" {
  19699. import { Scene } from "babylonjs/scene";
  19700. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19702. import { Mesh } from "babylonjs/Meshes/mesh";
  19703. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19705. import { Texture } from "babylonjs/Materials/Textures/texture";
  19706. import { Material } from "babylonjs/Materials/material";
  19707. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19708. /**
  19709. * Defines the options associated with the creation of a shader material.
  19710. */
  19711. export interface IShaderMaterialOptions {
  19712. /**
  19713. * Does the material work in alpha blend mode
  19714. */
  19715. needAlphaBlending: boolean;
  19716. /**
  19717. * Does the material work in alpha test mode
  19718. */
  19719. needAlphaTesting: boolean;
  19720. /**
  19721. * The list of attribute names used in the shader
  19722. */
  19723. attributes: string[];
  19724. /**
  19725. * The list of unifrom names used in the shader
  19726. */
  19727. uniforms: string[];
  19728. /**
  19729. * The list of UBO names used in the shader
  19730. */
  19731. uniformBuffers: string[];
  19732. /**
  19733. * The list of sampler names used in the shader
  19734. */
  19735. samplers: string[];
  19736. /**
  19737. * The list of defines used in the shader
  19738. */
  19739. defines: string[];
  19740. }
  19741. /**
  19742. * 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.
  19743. *
  19744. * This returned material effects how the mesh will look based on the code in the shaders.
  19745. *
  19746. * @see http://doc.babylonjs.com/how_to/shader_material
  19747. */
  19748. export class ShaderMaterial extends Material {
  19749. private _shaderPath;
  19750. private _options;
  19751. private _textures;
  19752. private _textureArrays;
  19753. private _floats;
  19754. private _ints;
  19755. private _floatsArrays;
  19756. private _colors3;
  19757. private _colors3Arrays;
  19758. private _colors4;
  19759. private _colors4Arrays;
  19760. private _vectors2;
  19761. private _vectors3;
  19762. private _vectors4;
  19763. private _matrices;
  19764. private _matrixArrays;
  19765. private _matrices3x3;
  19766. private _matrices2x2;
  19767. private _vectors2Arrays;
  19768. private _vectors3Arrays;
  19769. private _vectors4Arrays;
  19770. private _cachedWorldViewMatrix;
  19771. private _cachedWorldViewProjectionMatrix;
  19772. private _renderId;
  19773. private _multiview;
  19774. /**
  19775. * Instantiate a new shader material.
  19776. * 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.
  19777. * This returned material effects how the mesh will look based on the code in the shaders.
  19778. * @see http://doc.babylonjs.com/how_to/shader_material
  19779. * @param name Define the name of the material in the scene
  19780. * @param scene Define the scene the material belongs to
  19781. * @param shaderPath Defines the route to the shader code in one of three ways:
  19782. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19783. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19784. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19785. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19786. * @param options Define the options used to create the shader
  19787. */
  19788. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19789. /**
  19790. * Gets the shader path used to define the shader code
  19791. * It can be modified to trigger a new compilation
  19792. */
  19793. /**
  19794. * Sets the shader path used to define the shader code
  19795. * It can be modified to trigger a new compilation
  19796. */
  19797. shaderPath: any;
  19798. /**
  19799. * Gets the options used to compile the shader.
  19800. * They can be modified to trigger a new compilation
  19801. */
  19802. readonly options: IShaderMaterialOptions;
  19803. /**
  19804. * Gets the current class name of the material e.g. "ShaderMaterial"
  19805. * Mainly use in serialization.
  19806. * @returns the class name
  19807. */
  19808. getClassName(): string;
  19809. /**
  19810. * Specifies if the material will require alpha blending
  19811. * @returns a boolean specifying if alpha blending is needed
  19812. */
  19813. needAlphaBlending(): boolean;
  19814. /**
  19815. * Specifies if this material should be rendered in alpha test mode
  19816. * @returns a boolean specifying if an alpha test is needed.
  19817. */
  19818. needAlphaTesting(): boolean;
  19819. private _checkUniform;
  19820. /**
  19821. * Set a texture in the shader.
  19822. * @param name Define the name of the uniform samplers as defined in the shader
  19823. * @param texture Define the texture to bind to this sampler
  19824. * @return the material itself allowing "fluent" like uniform updates
  19825. */
  19826. setTexture(name: string, texture: Texture): ShaderMaterial;
  19827. /**
  19828. * Set a texture array in the shader.
  19829. * @param name Define the name of the uniform sampler array as defined in the shader
  19830. * @param textures Define the list of textures to bind to this sampler
  19831. * @return the material itself allowing "fluent" like uniform updates
  19832. */
  19833. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19834. /**
  19835. * Set a float in the shader.
  19836. * @param name Define the name of the uniform as defined in the shader
  19837. * @param value Define the value to give to the uniform
  19838. * @return the material itself allowing "fluent" like uniform updates
  19839. */
  19840. setFloat(name: string, value: number): ShaderMaterial;
  19841. /**
  19842. * Set a int in the shader.
  19843. * @param name Define the name of the uniform as defined in the shader
  19844. * @param value Define the value to give to the uniform
  19845. * @return the material itself allowing "fluent" like uniform updates
  19846. */
  19847. setInt(name: string, value: number): ShaderMaterial;
  19848. /**
  19849. * Set an array of floats in the shader.
  19850. * @param name Define the name of the uniform as defined in the shader
  19851. * @param value Define the value to give to the uniform
  19852. * @return the material itself allowing "fluent" like uniform updates
  19853. */
  19854. setFloats(name: string, value: number[]): ShaderMaterial;
  19855. /**
  19856. * Set a vec3 in the shader from a Color3.
  19857. * @param name Define the name of the uniform as defined in the shader
  19858. * @param value Define the value to give to the uniform
  19859. * @return the material itself allowing "fluent" like uniform updates
  19860. */
  19861. setColor3(name: string, value: Color3): ShaderMaterial;
  19862. /**
  19863. * Set a vec3 array in the shader from a Color3 array.
  19864. * @param name Define the name of the uniform as defined in the shader
  19865. * @param value Define the value to give to the uniform
  19866. * @return the material itself allowing "fluent" like uniform updates
  19867. */
  19868. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19869. /**
  19870. * Set a vec4 in the shader from a Color4.
  19871. * @param name Define the name of the uniform as defined in the shader
  19872. * @param value Define the value to give to the uniform
  19873. * @return the material itself allowing "fluent" like uniform updates
  19874. */
  19875. setColor4(name: string, value: Color4): ShaderMaterial;
  19876. /**
  19877. * Set a vec4 array in the shader from a Color4 array.
  19878. * @param name Define the name of the uniform as defined in the shader
  19879. * @param value Define the value to give to the uniform
  19880. * @return the material itself allowing "fluent" like uniform updates
  19881. */
  19882. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19883. /**
  19884. * Set a vec2 in the shader from a Vector2.
  19885. * @param name Define the name of the uniform as defined in the shader
  19886. * @param value Define the value to give to the uniform
  19887. * @return the material itself allowing "fluent" like uniform updates
  19888. */
  19889. setVector2(name: string, value: Vector2): ShaderMaterial;
  19890. /**
  19891. * Set a vec3 in the shader from a Vector3.
  19892. * @param name Define the name of the uniform as defined in the shader
  19893. * @param value Define the value to give to the uniform
  19894. * @return the material itself allowing "fluent" like uniform updates
  19895. */
  19896. setVector3(name: string, value: Vector3): ShaderMaterial;
  19897. /**
  19898. * Set a vec4 in the shader from a Vector4.
  19899. * @param name Define the name of the uniform as defined in the shader
  19900. * @param value Define the value to give to the uniform
  19901. * @return the material itself allowing "fluent" like uniform updates
  19902. */
  19903. setVector4(name: string, value: Vector4): ShaderMaterial;
  19904. /**
  19905. * Set a mat4 in the shader from a Matrix.
  19906. * @param name Define the name of the uniform as defined in the shader
  19907. * @param value Define the value to give to the uniform
  19908. * @return the material itself allowing "fluent" like uniform updates
  19909. */
  19910. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19911. /**
  19912. * Set a float32Array in the shader from a matrix array.
  19913. * @param name Define the name of the uniform as defined in the shader
  19914. * @param value Define the value to give to the uniform
  19915. * @return the material itself allowing "fluent" like uniform updates
  19916. */
  19917. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19918. /**
  19919. * Set a mat3 in the shader from a Float32Array.
  19920. * @param name Define the name of the uniform as defined in the shader
  19921. * @param value Define the value to give to the uniform
  19922. * @return the material itself allowing "fluent" like uniform updates
  19923. */
  19924. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19925. /**
  19926. * Set a mat2 in the shader from a Float32Array.
  19927. * @param name Define the name of the uniform as defined in the shader
  19928. * @param value Define the value to give to the uniform
  19929. * @return the material itself allowing "fluent" like uniform updates
  19930. */
  19931. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19932. /**
  19933. * Set a vec2 array in the shader from a number array.
  19934. * @param name Define the name of the uniform as defined in the shader
  19935. * @param value Define the value to give to the uniform
  19936. * @return the material itself allowing "fluent" like uniform updates
  19937. */
  19938. setArray2(name: string, value: number[]): ShaderMaterial;
  19939. /**
  19940. * Set a vec3 array in the shader from a number array.
  19941. * @param name Define the name of the uniform as defined in the shader
  19942. * @param value Define the value to give to the uniform
  19943. * @return the material itself allowing "fluent" like uniform updates
  19944. */
  19945. setArray3(name: string, value: number[]): ShaderMaterial;
  19946. /**
  19947. * Set a vec4 array in the shader from a number array.
  19948. * @param name Define the name of the uniform as defined in the shader
  19949. * @param value Define the value to give to the uniform
  19950. * @return the material itself allowing "fluent" like uniform updates
  19951. */
  19952. setArray4(name: string, value: number[]): ShaderMaterial;
  19953. private _checkCache;
  19954. /**
  19955. * Specifies that the submesh is ready to be used
  19956. * @param mesh defines the mesh to check
  19957. * @param subMesh defines which submesh to check
  19958. * @param useInstances specifies that instances should be used
  19959. * @returns a boolean indicating that the submesh is ready or not
  19960. */
  19961. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19962. /**
  19963. * Checks if the material is ready to render the requested mesh
  19964. * @param mesh Define the mesh to render
  19965. * @param useInstances Define whether or not the material is used with instances
  19966. * @returns true if ready, otherwise false
  19967. */
  19968. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19969. /**
  19970. * Binds the world matrix to the material
  19971. * @param world defines the world transformation matrix
  19972. */
  19973. bindOnlyWorldMatrix(world: Matrix): void;
  19974. /**
  19975. * Binds the material to the mesh
  19976. * @param world defines the world transformation matrix
  19977. * @param mesh defines the mesh to bind the material to
  19978. */
  19979. bind(world: Matrix, mesh?: Mesh): void;
  19980. /**
  19981. * Gets the active textures from the material
  19982. * @returns an array of textures
  19983. */
  19984. getActiveTextures(): BaseTexture[];
  19985. /**
  19986. * Specifies if the material uses a texture
  19987. * @param texture defines the texture to check against the material
  19988. * @returns a boolean specifying if the material uses the texture
  19989. */
  19990. hasTexture(texture: BaseTexture): boolean;
  19991. /**
  19992. * Makes a duplicate of the material, and gives it a new name
  19993. * @param name defines the new name for the duplicated material
  19994. * @returns the cloned material
  19995. */
  19996. clone(name: string): ShaderMaterial;
  19997. /**
  19998. * Disposes the material
  19999. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20000. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20001. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20002. */
  20003. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20004. /**
  20005. * Serializes this material in a JSON representation
  20006. * @returns the serialized material object
  20007. */
  20008. serialize(): any;
  20009. /**
  20010. * Creates a shader material from parsed shader material data
  20011. * @param source defines the JSON represnetation of the material
  20012. * @param scene defines the hosting scene
  20013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20014. * @returns a new material
  20015. */
  20016. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20017. }
  20018. }
  20019. declare module "babylonjs/Shaders/color.fragment" {
  20020. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20022. /** @hidden */
  20023. export var colorPixelShader: {
  20024. name: string;
  20025. shader: string;
  20026. };
  20027. }
  20028. declare module "babylonjs/Shaders/color.vertex" {
  20029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20031. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20034. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20035. /** @hidden */
  20036. export var colorVertexShader: {
  20037. name: string;
  20038. shader: string;
  20039. };
  20040. }
  20041. declare module "babylonjs/Meshes/linesMesh" {
  20042. import { Nullable } from "babylonjs/types";
  20043. import { Scene } from "babylonjs/scene";
  20044. import { Color3 } from "babylonjs/Maths/math.color";
  20045. import { Node } from "babylonjs/node";
  20046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20047. import { Mesh } from "babylonjs/Meshes/mesh";
  20048. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20049. import { Effect } from "babylonjs/Materials/effect";
  20050. import { Material } from "babylonjs/Materials/material";
  20051. import "babylonjs/Shaders/color.fragment";
  20052. import "babylonjs/Shaders/color.vertex";
  20053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20054. /**
  20055. * Line mesh
  20056. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20057. */
  20058. export class LinesMesh extends Mesh {
  20059. /**
  20060. * If vertex color should be applied to the mesh
  20061. */
  20062. readonly useVertexColor?: boolean | undefined;
  20063. /**
  20064. * If vertex alpha should be applied to the mesh
  20065. */
  20066. readonly useVertexAlpha?: boolean | undefined;
  20067. /**
  20068. * Color of the line (Default: White)
  20069. */
  20070. color: Color3;
  20071. /**
  20072. * Alpha of the line (Default: 1)
  20073. */
  20074. alpha: number;
  20075. /**
  20076. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20077. * This margin is expressed in world space coordinates, so its value may vary.
  20078. * Default value is 0.1
  20079. */
  20080. intersectionThreshold: number;
  20081. private _colorShader;
  20082. private color4;
  20083. /**
  20084. * Creates a new LinesMesh
  20085. * @param name defines the name
  20086. * @param scene defines the hosting scene
  20087. * @param parent defines the parent mesh if any
  20088. * @param source defines the optional source LinesMesh used to clone data from
  20089. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20090. * When false, achieved by calling a clone(), also passing False.
  20091. * This will make creation of children, recursive.
  20092. * @param useVertexColor defines if this LinesMesh supports vertex color
  20093. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20094. */
  20095. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. useVertexColor?: boolean | undefined,
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. useVertexAlpha?: boolean | undefined);
  20104. private _addClipPlaneDefine;
  20105. private _removeClipPlaneDefine;
  20106. isReady(): boolean;
  20107. /**
  20108. * Returns the string "LineMesh"
  20109. */
  20110. getClassName(): string;
  20111. /**
  20112. * @hidden
  20113. */
  20114. /**
  20115. * @hidden
  20116. */
  20117. material: Material;
  20118. /**
  20119. * @hidden
  20120. */
  20121. readonly checkCollisions: boolean;
  20122. /** @hidden */
  20123. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20124. /** @hidden */
  20125. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20126. /**
  20127. * Disposes of the line mesh
  20128. * @param doNotRecurse If children should be disposed
  20129. */
  20130. dispose(doNotRecurse?: boolean): void;
  20131. /**
  20132. * Returns a new LineMesh object cloned from the current one.
  20133. */
  20134. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20135. /**
  20136. * Creates a new InstancedLinesMesh object from the mesh model.
  20137. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20138. * @param name defines the name of the new instance
  20139. * @returns a new InstancedLinesMesh
  20140. */
  20141. createInstance(name: string): InstancedLinesMesh;
  20142. }
  20143. /**
  20144. * Creates an instance based on a source LinesMesh
  20145. */
  20146. export class InstancedLinesMesh extends InstancedMesh {
  20147. /**
  20148. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20149. * This margin is expressed in world space coordinates, so its value may vary.
  20150. * Initilized with the intersectionThreshold value of the source LinesMesh
  20151. */
  20152. intersectionThreshold: number;
  20153. constructor(name: string, source: LinesMesh);
  20154. /**
  20155. * Returns the string "InstancedLinesMesh".
  20156. */
  20157. getClassName(): string;
  20158. }
  20159. }
  20160. declare module "babylonjs/Shaders/line.fragment" {
  20161. /** @hidden */
  20162. export var linePixelShader: {
  20163. name: string;
  20164. shader: string;
  20165. };
  20166. }
  20167. declare module "babylonjs/Shaders/line.vertex" {
  20168. /** @hidden */
  20169. export var lineVertexShader: {
  20170. name: string;
  20171. shader: string;
  20172. };
  20173. }
  20174. declare module "babylonjs/Rendering/edgesRenderer" {
  20175. import { Nullable } from "babylonjs/types";
  20176. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20178. import { Vector3 } from "babylonjs/Maths/math.vector";
  20179. import { IDisposable } from "babylonjs/scene";
  20180. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20181. import "babylonjs/Shaders/line.fragment";
  20182. import "babylonjs/Shaders/line.vertex";
  20183. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20184. module "babylonjs/Meshes/abstractMesh" {
  20185. interface AbstractMesh {
  20186. /**
  20187. * Gets the edgesRenderer associated with the mesh
  20188. */
  20189. edgesRenderer: Nullable<EdgesRenderer>;
  20190. }
  20191. }
  20192. module "babylonjs/Meshes/linesMesh" {
  20193. interface LinesMesh {
  20194. /**
  20195. * Enables the edge rendering mode on the mesh.
  20196. * This mode makes the mesh edges visible
  20197. * @param epsilon defines the maximal distance between two angles to detect a face
  20198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20199. * @returns the currentAbstractMesh
  20200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20201. */
  20202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20203. }
  20204. }
  20205. module "babylonjs/Meshes/linesMesh" {
  20206. interface InstancedLinesMesh {
  20207. /**
  20208. * Enables the edge rendering mode on the mesh.
  20209. * This mode makes the mesh edges visible
  20210. * @param epsilon defines the maximal distance between two angles to detect a face
  20211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20212. * @returns the current InstancedLinesMesh
  20213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20214. */
  20215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20216. }
  20217. }
  20218. /**
  20219. * Defines the minimum contract an Edges renderer should follow.
  20220. */
  20221. export interface IEdgesRenderer extends IDisposable {
  20222. /**
  20223. * Gets or sets a boolean indicating if the edgesRenderer is active
  20224. */
  20225. isEnabled: boolean;
  20226. /**
  20227. * Renders the edges of the attached mesh,
  20228. */
  20229. render(): void;
  20230. /**
  20231. * Checks wether or not the edges renderer is ready to render.
  20232. * @return true if ready, otherwise false.
  20233. */
  20234. isReady(): boolean;
  20235. }
  20236. /**
  20237. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20238. */
  20239. export class EdgesRenderer implements IEdgesRenderer {
  20240. /**
  20241. * Define the size of the edges with an orthographic camera
  20242. */
  20243. edgesWidthScalerForOrthographic: number;
  20244. /**
  20245. * Define the size of the edges with a perspective camera
  20246. */
  20247. edgesWidthScalerForPerspective: number;
  20248. protected _source: AbstractMesh;
  20249. protected _linesPositions: number[];
  20250. protected _linesNormals: number[];
  20251. protected _linesIndices: number[];
  20252. protected _epsilon: number;
  20253. protected _indicesCount: number;
  20254. protected _lineShader: ShaderMaterial;
  20255. protected _ib: DataBuffer;
  20256. protected _buffers: {
  20257. [key: string]: Nullable<VertexBuffer>;
  20258. };
  20259. protected _checkVerticesInsteadOfIndices: boolean;
  20260. private _meshRebuildObserver;
  20261. private _meshDisposeObserver;
  20262. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20263. isEnabled: boolean;
  20264. /**
  20265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20267. * @param source Mesh used to create edges
  20268. * @param epsilon sum of angles in adjacency to check for edge
  20269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20271. */
  20272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20273. protected _prepareRessources(): void;
  20274. /** @hidden */
  20275. _rebuild(): void;
  20276. /**
  20277. * Releases the required resources for the edges renderer
  20278. */
  20279. dispose(): void;
  20280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20282. /**
  20283. * Checks if the pair of p0 and p1 is en edge
  20284. * @param faceIndex
  20285. * @param edge
  20286. * @param faceNormals
  20287. * @param p0
  20288. * @param p1
  20289. * @private
  20290. */
  20291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20292. /**
  20293. * push line into the position, normal and index buffer
  20294. * @protected
  20295. */
  20296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20297. /**
  20298. * Generates lines edges from adjacencjes
  20299. * @private
  20300. */
  20301. _generateEdgesLines(): void;
  20302. /**
  20303. * Checks wether or not the edges renderer is ready to render.
  20304. * @return true if ready, otherwise false.
  20305. */
  20306. isReady(): boolean;
  20307. /**
  20308. * Renders the edges of the attached mesh,
  20309. */
  20310. render(): void;
  20311. }
  20312. /**
  20313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20314. */
  20315. export class LineEdgesRenderer extends EdgesRenderer {
  20316. /**
  20317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20318. * @param source LineMesh used to generate edges
  20319. * @param epsilon not important (specified angle for edge detection)
  20320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20321. */
  20322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20323. /**
  20324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20325. */
  20326. _generateEdgesLines(): void;
  20327. }
  20328. }
  20329. declare module "babylonjs/Rendering/renderingGroup" {
  20330. import { SmartArray } from "babylonjs/Misc/smartArray";
  20331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20333. import { Nullable } from "babylonjs/types";
  20334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20335. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20336. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20337. import { Material } from "babylonjs/Materials/material";
  20338. import { Scene } from "babylonjs/scene";
  20339. /**
  20340. * This represents the object necessary to create a rendering group.
  20341. * This is exclusively used and created by the rendering manager.
  20342. * To modify the behavior, you use the available helpers in your scene or meshes.
  20343. * @hidden
  20344. */
  20345. export class RenderingGroup {
  20346. index: number;
  20347. private static _zeroVector;
  20348. private _scene;
  20349. private _opaqueSubMeshes;
  20350. private _transparentSubMeshes;
  20351. private _alphaTestSubMeshes;
  20352. private _depthOnlySubMeshes;
  20353. private _particleSystems;
  20354. private _spriteManagers;
  20355. private _opaqueSortCompareFn;
  20356. private _alphaTestSortCompareFn;
  20357. private _transparentSortCompareFn;
  20358. private _renderOpaque;
  20359. private _renderAlphaTest;
  20360. private _renderTransparent;
  20361. /** @hidden */
  20362. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20363. onBeforeTransparentRendering: () => void;
  20364. /**
  20365. * Set the opaque sort comparison function.
  20366. * If null the sub meshes will be render in the order they were created
  20367. */
  20368. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20369. /**
  20370. * Set the alpha test sort comparison function.
  20371. * If null the sub meshes will be render in the order they were created
  20372. */
  20373. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20374. /**
  20375. * Set the transparent sort comparison function.
  20376. * If null the sub meshes will be render in the order they were created
  20377. */
  20378. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20379. /**
  20380. * Creates a new rendering group.
  20381. * @param index The rendering group index
  20382. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20383. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20384. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20385. */
  20386. 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>);
  20387. /**
  20388. * Render all the sub meshes contained in the group.
  20389. * @param customRenderFunction Used to override the default render behaviour of the group.
  20390. * @returns true if rendered some submeshes.
  20391. */
  20392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20393. /**
  20394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20395. * @param subMeshes The submeshes to render
  20396. */
  20397. private renderOpaqueSorted;
  20398. /**
  20399. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20400. * @param subMeshes The submeshes to render
  20401. */
  20402. private renderAlphaTestSorted;
  20403. /**
  20404. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20405. * @param subMeshes The submeshes to render
  20406. */
  20407. private renderTransparentSorted;
  20408. /**
  20409. * Renders the submeshes in a specified order.
  20410. * @param subMeshes The submeshes to sort before render
  20411. * @param sortCompareFn The comparison function use to sort
  20412. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20413. * @param transparent Specifies to activate blending if true
  20414. */
  20415. private static renderSorted;
  20416. /**
  20417. * Renders the submeshes in the order they were dispatched (no sort applied).
  20418. * @param subMeshes The submeshes to render
  20419. */
  20420. private static renderUnsorted;
  20421. /**
  20422. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20423. * are rendered back to front if in the same alpha index.
  20424. *
  20425. * @param a The first submesh
  20426. * @param b The second submesh
  20427. * @returns The result of the comparison
  20428. */
  20429. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20430. /**
  20431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20432. * are rendered back to front.
  20433. *
  20434. * @param a The first submesh
  20435. * @param b The second submesh
  20436. * @returns The result of the comparison
  20437. */
  20438. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20439. /**
  20440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20441. * are rendered front to back (prevent overdraw).
  20442. *
  20443. * @param a The first submesh
  20444. * @param b The second submesh
  20445. * @returns The result of the comparison
  20446. */
  20447. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20448. /**
  20449. * Resets the different lists of submeshes to prepare a new frame.
  20450. */
  20451. prepare(): void;
  20452. dispose(): void;
  20453. /**
  20454. * Inserts the submesh in its correct queue depending on its material.
  20455. * @param subMesh The submesh to dispatch
  20456. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20457. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20458. */
  20459. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20460. dispatchSprites(spriteManager: ISpriteManager): void;
  20461. dispatchParticles(particleSystem: IParticleSystem): void;
  20462. private _renderParticles;
  20463. private _renderSprites;
  20464. }
  20465. }
  20466. declare module "babylonjs/Rendering/renderingManager" {
  20467. import { Nullable } from "babylonjs/types";
  20468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20470. import { SmartArray } from "babylonjs/Misc/smartArray";
  20471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20473. import { Material } from "babylonjs/Materials/material";
  20474. import { Scene } from "babylonjs/scene";
  20475. import { Camera } from "babylonjs/Cameras/camera";
  20476. /**
  20477. * Interface describing the different options available in the rendering manager
  20478. * regarding Auto Clear between groups.
  20479. */
  20480. export interface IRenderingManagerAutoClearSetup {
  20481. /**
  20482. * Defines whether or not autoclear is enable.
  20483. */
  20484. autoClear: boolean;
  20485. /**
  20486. * Defines whether or not to autoclear the depth buffer.
  20487. */
  20488. depth: boolean;
  20489. /**
  20490. * Defines whether or not to autoclear the stencil buffer.
  20491. */
  20492. stencil: boolean;
  20493. }
  20494. /**
  20495. * This class is used by the onRenderingGroupObservable
  20496. */
  20497. export class RenderingGroupInfo {
  20498. /**
  20499. * The Scene that being rendered
  20500. */
  20501. scene: Scene;
  20502. /**
  20503. * The camera currently used for the rendering pass
  20504. */
  20505. camera: Nullable<Camera>;
  20506. /**
  20507. * The ID of the renderingGroup being processed
  20508. */
  20509. renderingGroupId: number;
  20510. }
  20511. /**
  20512. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20513. * It is enable to manage the different groups as well as the different necessary sort functions.
  20514. * This should not be used directly aside of the few static configurations
  20515. */
  20516. export class RenderingManager {
  20517. /**
  20518. * The max id used for rendering groups (not included)
  20519. */
  20520. static MAX_RENDERINGGROUPS: number;
  20521. /**
  20522. * The min id used for rendering groups (included)
  20523. */
  20524. static MIN_RENDERINGGROUPS: number;
  20525. /**
  20526. * Used to globally prevent autoclearing scenes.
  20527. */
  20528. static AUTOCLEAR: boolean;
  20529. /**
  20530. * @hidden
  20531. */
  20532. _useSceneAutoClearSetup: boolean;
  20533. private _scene;
  20534. private _renderingGroups;
  20535. private _depthStencilBufferAlreadyCleaned;
  20536. private _autoClearDepthStencil;
  20537. private _customOpaqueSortCompareFn;
  20538. private _customAlphaTestSortCompareFn;
  20539. private _customTransparentSortCompareFn;
  20540. private _renderingGroupInfo;
  20541. /**
  20542. * Instantiates a new rendering group for a particular scene
  20543. * @param scene Defines the scene the groups belongs to
  20544. */
  20545. constructor(scene: Scene);
  20546. private _clearDepthStencilBuffer;
  20547. /**
  20548. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20549. * @hidden
  20550. */
  20551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20552. /**
  20553. * Resets the different information of the group to prepare a new frame
  20554. * @hidden
  20555. */
  20556. reset(): void;
  20557. /**
  20558. * Dispose and release the group and its associated resources.
  20559. * @hidden
  20560. */
  20561. dispose(): void;
  20562. /**
  20563. * Clear the info related to rendering groups preventing retention points during dispose.
  20564. */
  20565. freeRenderingGroups(): void;
  20566. private _prepareRenderingGroup;
  20567. /**
  20568. * Add a sprite manager to the rendering manager in order to render it this frame.
  20569. * @param spriteManager Define the sprite manager to render
  20570. */
  20571. dispatchSprites(spriteManager: ISpriteManager): void;
  20572. /**
  20573. * Add a particle system to the rendering manager in order to render it this frame.
  20574. * @param particleSystem Define the particle system to render
  20575. */
  20576. dispatchParticles(particleSystem: IParticleSystem): void;
  20577. /**
  20578. * Add a submesh to the manager in order to render it this frame
  20579. * @param subMesh The submesh to dispatch
  20580. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20581. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20582. */
  20583. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20584. /**
  20585. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20586. * This allowed control for front to back rendering or reversly depending of the special needs.
  20587. *
  20588. * @param renderingGroupId The rendering group id corresponding to its index
  20589. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20590. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20591. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20592. */
  20593. 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;
  20594. /**
  20595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20596. *
  20597. * @param renderingGroupId The rendering group id corresponding to its index
  20598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20599. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20600. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20601. */
  20602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20603. /**
  20604. * Gets the current auto clear configuration for one rendering group of the rendering
  20605. * manager.
  20606. * @param index the rendering group index to get the information for
  20607. * @returns The auto clear setup for the requested rendering group
  20608. */
  20609. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20610. }
  20611. }
  20612. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20613. import { Observable } from "babylonjs/Misc/observable";
  20614. import { SmartArray } from "babylonjs/Misc/smartArray";
  20615. import { Nullable } from "babylonjs/types";
  20616. import { Camera } from "babylonjs/Cameras/camera";
  20617. import { Scene } from "babylonjs/scene";
  20618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20619. import { Color4 } from "babylonjs/Maths/math.color";
  20620. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20622. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20624. import { Texture } from "babylonjs/Materials/Textures/texture";
  20625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20626. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20627. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20628. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20629. import { Engine } from "babylonjs/Engines/engine";
  20630. /**
  20631. * This Helps creating a texture that will be created from a camera in your scene.
  20632. * It is basically a dynamic texture that could be used to create special effects for instance.
  20633. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20634. */
  20635. export class RenderTargetTexture extends Texture {
  20636. isCube: boolean;
  20637. /**
  20638. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20639. */
  20640. static readonly REFRESHRATE_RENDER_ONCE: number;
  20641. /**
  20642. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20643. */
  20644. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20645. /**
  20646. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20647. * the central point of your effect and can save a lot of performances.
  20648. */
  20649. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20650. /**
  20651. * Use this predicate to dynamically define the list of mesh you want to render.
  20652. * If set, the renderList property will be overwritten.
  20653. */
  20654. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20655. private _renderList;
  20656. /**
  20657. * Use this list to define the list of mesh you want to render.
  20658. */
  20659. renderList: Nullable<Array<AbstractMesh>>;
  20660. private _hookArray;
  20661. /**
  20662. * Define if particles should be rendered in your texture.
  20663. */
  20664. renderParticles: boolean;
  20665. /**
  20666. * Define if sprites should be rendered in your texture.
  20667. */
  20668. renderSprites: boolean;
  20669. /**
  20670. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20671. */
  20672. coordinatesMode: number;
  20673. /**
  20674. * Define the camera used to render the texture.
  20675. */
  20676. activeCamera: Nullable<Camera>;
  20677. /**
  20678. * Override the render function of the texture with your own one.
  20679. */
  20680. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20681. /**
  20682. * Define if camera post processes should be use while rendering the texture.
  20683. */
  20684. useCameraPostProcesses: boolean;
  20685. /**
  20686. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20687. */
  20688. ignoreCameraViewport: boolean;
  20689. private _postProcessManager;
  20690. private _postProcesses;
  20691. private _resizeObserver;
  20692. /**
  20693. * An event triggered when the texture is unbind.
  20694. */
  20695. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20696. /**
  20697. * An event triggered when the texture is unbind.
  20698. */
  20699. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20700. private _onAfterUnbindObserver;
  20701. /**
  20702. * Set a after unbind callback in the texture.
  20703. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20704. */
  20705. onAfterUnbind: () => void;
  20706. /**
  20707. * An event triggered before rendering the texture
  20708. */
  20709. onBeforeRenderObservable: Observable<number>;
  20710. private _onBeforeRenderObserver;
  20711. /**
  20712. * Set a before render callback in the texture.
  20713. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20714. */
  20715. onBeforeRender: (faceIndex: number) => void;
  20716. /**
  20717. * An event triggered after rendering the texture
  20718. */
  20719. onAfterRenderObservable: Observable<number>;
  20720. private _onAfterRenderObserver;
  20721. /**
  20722. * Set a after render callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20724. */
  20725. onAfterRender: (faceIndex: number) => void;
  20726. /**
  20727. * An event triggered after the texture clear
  20728. */
  20729. onClearObservable: Observable<Engine>;
  20730. private _onClearObserver;
  20731. /**
  20732. * Set a clear callback in the texture.
  20733. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20734. */
  20735. onClear: (Engine: Engine) => void;
  20736. /**
  20737. * An event triggered when the texture is resized.
  20738. */
  20739. onResizeObservable: Observable<RenderTargetTexture>;
  20740. /**
  20741. * Define the clear color of the Render Target if it should be different from the scene.
  20742. */
  20743. clearColor: Color4;
  20744. protected _size: number | {
  20745. width: number;
  20746. height: number;
  20747. };
  20748. protected _initialSizeParameter: number | {
  20749. width: number;
  20750. height: number;
  20751. } | {
  20752. ratio: number;
  20753. };
  20754. protected _sizeRatio: Nullable<number>;
  20755. /** @hidden */
  20756. _generateMipMaps: boolean;
  20757. protected _renderingManager: RenderingManager;
  20758. /** @hidden */
  20759. _waitingRenderList: string[];
  20760. protected _doNotChangeAspectRatio: boolean;
  20761. protected _currentRefreshId: number;
  20762. protected _refreshRate: number;
  20763. protected _textureMatrix: Matrix;
  20764. protected _samples: number;
  20765. protected _renderTargetOptions: RenderTargetCreationOptions;
  20766. /**
  20767. * Gets render target creation options that were used.
  20768. */
  20769. readonly renderTargetOptions: RenderTargetCreationOptions;
  20770. protected _engine: Engine;
  20771. protected _onRatioRescale(): void;
  20772. /**
  20773. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20774. * It must define where the camera used to render the texture is set
  20775. */
  20776. boundingBoxPosition: Vector3;
  20777. private _boundingBoxSize;
  20778. /**
  20779. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20780. * When defined, the cubemap will switch to local mode
  20781. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20782. * @example https://www.babylonjs-playground.com/#RNASML
  20783. */
  20784. boundingBoxSize: Vector3;
  20785. /**
  20786. * In case the RTT has been created with a depth texture, get the associated
  20787. * depth texture.
  20788. * Otherwise, return null.
  20789. */
  20790. depthStencilTexture: Nullable<InternalTexture>;
  20791. /**
  20792. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20793. * or used a shadow, depth texture...
  20794. * @param name The friendly name of the texture
  20795. * @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)
  20796. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20797. * @param generateMipMaps True if mip maps need to be generated after render.
  20798. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20799. * @param type The type of the buffer in the RTT (int, half float, float...)
  20800. * @param isCube True if a cube texture needs to be created
  20801. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20802. * @param generateDepthBuffer True to generate a depth buffer
  20803. * @param generateStencilBuffer True to generate a stencil buffer
  20804. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20805. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20806. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20807. */
  20808. constructor(name: string, size: number | {
  20809. width: number;
  20810. height: number;
  20811. } | {
  20812. ratio: number;
  20813. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20814. /**
  20815. * Creates a depth stencil texture.
  20816. * This is only available in WebGL 2 or with the depth texture extension available.
  20817. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20818. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20819. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20820. */
  20821. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20822. private _processSizeParameter;
  20823. /**
  20824. * Define the number of samples to use in case of MSAA.
  20825. * It defaults to one meaning no MSAA has been enabled.
  20826. */
  20827. samples: number;
  20828. /**
  20829. * Resets the refresh counter of the texture and start bak from scratch.
  20830. * Could be useful to regenerate the texture if it is setup to render only once.
  20831. */
  20832. resetRefreshCounter(): void;
  20833. /**
  20834. * Define the refresh rate of the texture or the rendering frequency.
  20835. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20836. */
  20837. refreshRate: number;
  20838. /**
  20839. * Adds a post process to the render target rendering passes.
  20840. * @param postProcess define the post process to add
  20841. */
  20842. addPostProcess(postProcess: PostProcess): void;
  20843. /**
  20844. * Clear all the post processes attached to the render target
  20845. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20846. */
  20847. clearPostProcesses(dispose?: boolean): void;
  20848. /**
  20849. * Remove one of the post process from the list of attached post processes to the texture
  20850. * @param postProcess define the post process to remove from the list
  20851. */
  20852. removePostProcess(postProcess: PostProcess): void;
  20853. /** @hidden */
  20854. _shouldRender(): boolean;
  20855. /**
  20856. * Gets the actual render size of the texture.
  20857. * @returns the width of the render size
  20858. */
  20859. getRenderSize(): number;
  20860. /**
  20861. * Gets the actual render width of the texture.
  20862. * @returns the width of the render size
  20863. */
  20864. getRenderWidth(): number;
  20865. /**
  20866. * Gets the actual render height of the texture.
  20867. * @returns the height of the render size
  20868. */
  20869. getRenderHeight(): number;
  20870. /**
  20871. * Get if the texture can be rescaled or not.
  20872. */
  20873. readonly canRescale: boolean;
  20874. /**
  20875. * Resize the texture using a ratio.
  20876. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20877. */
  20878. scale(ratio: number): void;
  20879. /**
  20880. * Get the texture reflection matrix used to rotate/transform the reflection.
  20881. * @returns the reflection matrix
  20882. */
  20883. getReflectionTextureMatrix(): Matrix;
  20884. /**
  20885. * Resize the texture to a new desired size.
  20886. * Be carrefull as it will recreate all the data in the new texture.
  20887. * @param size Define the new size. It can be:
  20888. * - a number for squared texture,
  20889. * - an object containing { width: number, height: number }
  20890. * - or an object containing a ratio { ratio: number }
  20891. */
  20892. resize(size: number | {
  20893. width: number;
  20894. height: number;
  20895. } | {
  20896. ratio: number;
  20897. }): void;
  20898. /**
  20899. * Renders all the objects from the render list into the texture.
  20900. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20901. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20902. */
  20903. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20904. private _bestReflectionRenderTargetDimension;
  20905. /**
  20906. * @hidden
  20907. * @param faceIndex face index to bind to if this is a cubetexture
  20908. */
  20909. _bindFrameBuffer(faceIndex?: number): void;
  20910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20911. private renderToTarget;
  20912. /**
  20913. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20914. * This allowed control for front to back rendering or reversly depending of the special needs.
  20915. *
  20916. * @param renderingGroupId The rendering group id corresponding to its index
  20917. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20918. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20919. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20920. */
  20921. 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;
  20922. /**
  20923. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20924. *
  20925. * @param renderingGroupId The rendering group id corresponding to its index
  20926. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20927. */
  20928. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20929. /**
  20930. * Clones the texture.
  20931. * @returns the cloned texture
  20932. */
  20933. clone(): RenderTargetTexture;
  20934. /**
  20935. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20936. * @returns The JSON representation of the texture
  20937. */
  20938. serialize(): any;
  20939. /**
  20940. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20941. */
  20942. disposeFramebufferObjects(): void;
  20943. /**
  20944. * Dispose the texture and release its associated resources.
  20945. */
  20946. dispose(): void;
  20947. /** @hidden */
  20948. _rebuild(): void;
  20949. /**
  20950. * Clear the info related to rendering groups preventing retention point in material dispose.
  20951. */
  20952. freeRenderingGroups(): void;
  20953. /**
  20954. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20955. * @returns the view count
  20956. */
  20957. getViewCount(): number;
  20958. }
  20959. }
  20960. declare module "babylonjs/Materials/material" {
  20961. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20962. import { SmartArray } from "babylonjs/Misc/smartArray";
  20963. import { Observable } from "babylonjs/Misc/observable";
  20964. import { Nullable } from "babylonjs/types";
  20965. import { Scene } from "babylonjs/scene";
  20966. import { Matrix } from "babylonjs/Maths/math.vector";
  20967. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20969. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20970. import { Effect } from "babylonjs/Materials/effect";
  20971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20973. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20974. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20975. import { Mesh } from "babylonjs/Meshes/mesh";
  20976. import { Animation } from "babylonjs/Animations/animation";
  20977. /**
  20978. * Options for compiling materials.
  20979. */
  20980. export interface IMaterialCompilationOptions {
  20981. /**
  20982. * Defines whether clip planes are enabled.
  20983. */
  20984. clipPlane: boolean;
  20985. /**
  20986. * Defines whether instances are enabled.
  20987. */
  20988. useInstances: boolean;
  20989. }
  20990. /**
  20991. * Base class for the main features of a material in Babylon.js
  20992. */
  20993. export class Material implements IAnimatable {
  20994. /**
  20995. * Returns the triangle fill mode
  20996. */
  20997. static readonly TriangleFillMode: number;
  20998. /**
  20999. * Returns the wireframe mode
  21000. */
  21001. static readonly WireFrameFillMode: number;
  21002. /**
  21003. * Returns the point fill mode
  21004. */
  21005. static readonly PointFillMode: number;
  21006. /**
  21007. * Returns the point list draw mode
  21008. */
  21009. static readonly PointListDrawMode: number;
  21010. /**
  21011. * Returns the line list draw mode
  21012. */
  21013. static readonly LineListDrawMode: number;
  21014. /**
  21015. * Returns the line loop draw mode
  21016. */
  21017. static readonly LineLoopDrawMode: number;
  21018. /**
  21019. * Returns the line strip draw mode
  21020. */
  21021. static readonly LineStripDrawMode: number;
  21022. /**
  21023. * Returns the triangle strip draw mode
  21024. */
  21025. static readonly TriangleStripDrawMode: number;
  21026. /**
  21027. * Returns the triangle fan draw mode
  21028. */
  21029. static readonly TriangleFanDrawMode: number;
  21030. /**
  21031. * Stores the clock-wise side orientation
  21032. */
  21033. static readonly ClockWiseSideOrientation: number;
  21034. /**
  21035. * Stores the counter clock-wise side orientation
  21036. */
  21037. static readonly CounterClockWiseSideOrientation: number;
  21038. /**
  21039. * The dirty texture flag value
  21040. */
  21041. static readonly TextureDirtyFlag: number;
  21042. /**
  21043. * The dirty light flag value
  21044. */
  21045. static readonly LightDirtyFlag: number;
  21046. /**
  21047. * The dirty fresnel flag value
  21048. */
  21049. static readonly FresnelDirtyFlag: number;
  21050. /**
  21051. * The dirty attribute flag value
  21052. */
  21053. static readonly AttributesDirtyFlag: number;
  21054. /**
  21055. * The dirty misc flag value
  21056. */
  21057. static readonly MiscDirtyFlag: number;
  21058. /**
  21059. * The all dirty flag value
  21060. */
  21061. static readonly AllDirtyFlag: number;
  21062. /**
  21063. * The ID of the material
  21064. */
  21065. id: string;
  21066. /**
  21067. * Gets or sets the unique id of the material
  21068. */
  21069. uniqueId: number;
  21070. /**
  21071. * The name of the material
  21072. */
  21073. name: string;
  21074. /**
  21075. * Gets or sets user defined metadata
  21076. */
  21077. metadata: any;
  21078. /**
  21079. * For internal use only. Please do not use.
  21080. */
  21081. reservedDataStore: any;
  21082. /**
  21083. * Specifies if the ready state should be checked on each call
  21084. */
  21085. checkReadyOnEveryCall: boolean;
  21086. /**
  21087. * Specifies if the ready state should be checked once
  21088. */
  21089. checkReadyOnlyOnce: boolean;
  21090. /**
  21091. * The state of the material
  21092. */
  21093. state: string;
  21094. /**
  21095. * The alpha value of the material
  21096. */
  21097. protected _alpha: number;
  21098. /**
  21099. * List of inspectable custom properties (used by the Inspector)
  21100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21101. */
  21102. inspectableCustomProperties: IInspectable[];
  21103. /**
  21104. * Sets the alpha value of the material
  21105. */
  21106. /**
  21107. * Gets the alpha value of the material
  21108. */
  21109. alpha: number;
  21110. /**
  21111. * Specifies if back face culling is enabled
  21112. */
  21113. protected _backFaceCulling: boolean;
  21114. /**
  21115. * Sets the back-face culling state
  21116. */
  21117. /**
  21118. * Gets the back-face culling state
  21119. */
  21120. backFaceCulling: boolean;
  21121. /**
  21122. * Stores the value for side orientation
  21123. */
  21124. sideOrientation: number;
  21125. /**
  21126. * Callback triggered when the material is compiled
  21127. */
  21128. onCompiled: Nullable<(effect: Effect) => void>;
  21129. /**
  21130. * Callback triggered when an error occurs
  21131. */
  21132. onError: Nullable<(effect: Effect, errors: string) => void>;
  21133. /**
  21134. * Callback triggered to get the render target textures
  21135. */
  21136. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21137. /**
  21138. * Gets a boolean indicating that current material needs to register RTT
  21139. */
  21140. readonly hasRenderTargetTextures: boolean;
  21141. /**
  21142. * Specifies if the material should be serialized
  21143. */
  21144. doNotSerialize: boolean;
  21145. /**
  21146. * @hidden
  21147. */
  21148. _storeEffectOnSubMeshes: boolean;
  21149. /**
  21150. * Stores the animations for the material
  21151. */
  21152. animations: Nullable<Array<Animation>>;
  21153. /**
  21154. * An event triggered when the material is disposed
  21155. */
  21156. onDisposeObservable: Observable<Material>;
  21157. /**
  21158. * An observer which watches for dispose events
  21159. */
  21160. private _onDisposeObserver;
  21161. private _onUnBindObservable;
  21162. /**
  21163. * Called during a dispose event
  21164. */
  21165. onDispose: () => void;
  21166. private _onBindObservable;
  21167. /**
  21168. * An event triggered when the material is bound
  21169. */
  21170. readonly onBindObservable: Observable<AbstractMesh>;
  21171. /**
  21172. * An observer which watches for bind events
  21173. */
  21174. private _onBindObserver;
  21175. /**
  21176. * Called during a bind event
  21177. */
  21178. onBind: (Mesh: AbstractMesh) => void;
  21179. /**
  21180. * An event triggered when the material is unbound
  21181. */
  21182. readonly onUnBindObservable: Observable<Material>;
  21183. /**
  21184. * Stores the value of the alpha mode
  21185. */
  21186. private _alphaMode;
  21187. /**
  21188. * Sets the value of the alpha mode.
  21189. *
  21190. * | Value | Type | Description |
  21191. * | --- | --- | --- |
  21192. * | 0 | ALPHA_DISABLE | |
  21193. * | 1 | ALPHA_ADD | |
  21194. * | 2 | ALPHA_COMBINE | |
  21195. * | 3 | ALPHA_SUBTRACT | |
  21196. * | 4 | ALPHA_MULTIPLY | |
  21197. * | 5 | ALPHA_MAXIMIZED | |
  21198. * | 6 | ALPHA_ONEONE | |
  21199. * | 7 | ALPHA_PREMULTIPLIED | |
  21200. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21201. * | 9 | ALPHA_INTERPOLATE | |
  21202. * | 10 | ALPHA_SCREENMODE | |
  21203. *
  21204. */
  21205. /**
  21206. * Gets the value of the alpha mode
  21207. */
  21208. alphaMode: number;
  21209. /**
  21210. * Stores the state of the need depth pre-pass value
  21211. */
  21212. private _needDepthPrePass;
  21213. /**
  21214. * Sets the need depth pre-pass value
  21215. */
  21216. /**
  21217. * Gets the depth pre-pass value
  21218. */
  21219. needDepthPrePass: boolean;
  21220. /**
  21221. * Specifies if depth writing should be disabled
  21222. */
  21223. disableDepthWrite: boolean;
  21224. /**
  21225. * Specifies if depth writing should be forced
  21226. */
  21227. forceDepthWrite: boolean;
  21228. /**
  21229. * Specifies the depth function that should be used. 0 means the default engine function
  21230. */
  21231. depthFunction: number;
  21232. /**
  21233. * Specifies if there should be a separate pass for culling
  21234. */
  21235. separateCullingPass: boolean;
  21236. /**
  21237. * Stores the state specifing if fog should be enabled
  21238. */
  21239. private _fogEnabled;
  21240. /**
  21241. * Sets the state for enabling fog
  21242. */
  21243. /**
  21244. * Gets the value of the fog enabled state
  21245. */
  21246. fogEnabled: boolean;
  21247. /**
  21248. * Stores the size of points
  21249. */
  21250. pointSize: number;
  21251. /**
  21252. * Stores the z offset value
  21253. */
  21254. zOffset: number;
  21255. /**
  21256. * Gets a value specifying if wireframe mode is enabled
  21257. */
  21258. /**
  21259. * Sets the state of wireframe mode
  21260. */
  21261. wireframe: boolean;
  21262. /**
  21263. * Gets the value specifying if point clouds are enabled
  21264. */
  21265. /**
  21266. * Sets the state of point cloud mode
  21267. */
  21268. pointsCloud: boolean;
  21269. /**
  21270. * Gets the material fill mode
  21271. */
  21272. /**
  21273. * Sets the material fill mode
  21274. */
  21275. fillMode: number;
  21276. /**
  21277. * @hidden
  21278. * Stores the effects for the material
  21279. */
  21280. _effect: Nullable<Effect>;
  21281. /**
  21282. * @hidden
  21283. * Specifies if the material was previously ready
  21284. */
  21285. _wasPreviouslyReady: boolean;
  21286. /**
  21287. * Specifies if uniform buffers should be used
  21288. */
  21289. private _useUBO;
  21290. /**
  21291. * Stores a reference to the scene
  21292. */
  21293. private _scene;
  21294. /**
  21295. * Stores the fill mode state
  21296. */
  21297. private _fillMode;
  21298. /**
  21299. * Specifies if the depth write state should be cached
  21300. */
  21301. private _cachedDepthWriteState;
  21302. /**
  21303. * Specifies if the depth function state should be cached
  21304. */
  21305. private _cachedDepthFunctionState;
  21306. /**
  21307. * Stores the uniform buffer
  21308. */
  21309. protected _uniformBuffer: UniformBuffer;
  21310. /** @hidden */
  21311. _indexInSceneMaterialArray: number;
  21312. /** @hidden */
  21313. meshMap: Nullable<{
  21314. [id: string]: AbstractMesh | undefined;
  21315. }>;
  21316. /**
  21317. * Creates a material instance
  21318. * @param name defines the name of the material
  21319. * @param scene defines the scene to reference
  21320. * @param doNotAdd specifies if the material should be added to the scene
  21321. */
  21322. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21323. /**
  21324. * Returns a string representation of the current material
  21325. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21326. * @returns a string with material information
  21327. */
  21328. toString(fullDetails?: boolean): string;
  21329. /**
  21330. * Gets the class name of the material
  21331. * @returns a string with the class name of the material
  21332. */
  21333. getClassName(): string;
  21334. /**
  21335. * Specifies if updates for the material been locked
  21336. */
  21337. readonly isFrozen: boolean;
  21338. /**
  21339. * Locks updates for the material
  21340. */
  21341. freeze(): void;
  21342. /**
  21343. * Unlocks updates for the material
  21344. */
  21345. unfreeze(): void;
  21346. /**
  21347. * Specifies if the material is ready to be used
  21348. * @param mesh defines the mesh to check
  21349. * @param useInstances specifies if instances should be used
  21350. * @returns a boolean indicating if the material is ready to be used
  21351. */
  21352. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21353. /**
  21354. * Specifies that the submesh is ready to be used
  21355. * @param mesh defines the mesh to check
  21356. * @param subMesh defines which submesh to check
  21357. * @param useInstances specifies that instances should be used
  21358. * @returns a boolean indicating that the submesh is ready or not
  21359. */
  21360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21361. /**
  21362. * Returns the material effect
  21363. * @returns the effect associated with the material
  21364. */
  21365. getEffect(): Nullable<Effect>;
  21366. /**
  21367. * Returns the current scene
  21368. * @returns a Scene
  21369. */
  21370. getScene(): Scene;
  21371. /**
  21372. * Specifies if the material will require alpha blending
  21373. * @returns a boolean specifying if alpha blending is needed
  21374. */
  21375. needAlphaBlending(): boolean;
  21376. /**
  21377. * Specifies if the mesh will require alpha blending
  21378. * @param mesh defines the mesh to check
  21379. * @returns a boolean specifying if alpha blending is needed for the mesh
  21380. */
  21381. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21382. /**
  21383. * Specifies if this material should be rendered in alpha test mode
  21384. * @returns a boolean specifying if an alpha test is needed.
  21385. */
  21386. needAlphaTesting(): boolean;
  21387. /**
  21388. * Gets the texture used for the alpha test
  21389. * @returns the texture to use for alpha testing
  21390. */
  21391. getAlphaTestTexture(): Nullable<BaseTexture>;
  21392. /**
  21393. * Marks the material to indicate that it needs to be re-calculated
  21394. */
  21395. markDirty(): void;
  21396. /** @hidden */
  21397. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21398. /**
  21399. * Binds the material to the mesh
  21400. * @param world defines the world transformation matrix
  21401. * @param mesh defines the mesh to bind the material to
  21402. */
  21403. bind(world: Matrix, mesh?: Mesh): void;
  21404. /**
  21405. * Binds the submesh to the material
  21406. * @param world defines the world transformation matrix
  21407. * @param mesh defines the mesh containing the submesh
  21408. * @param subMesh defines the submesh to bind the material to
  21409. */
  21410. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21411. /**
  21412. * Binds the world matrix to the material
  21413. * @param world defines the world transformation matrix
  21414. */
  21415. bindOnlyWorldMatrix(world: Matrix): void;
  21416. /**
  21417. * Binds the scene's uniform buffer to the effect.
  21418. * @param effect defines the effect to bind to the scene uniform buffer
  21419. * @param sceneUbo defines the uniform buffer storing scene data
  21420. */
  21421. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21422. /**
  21423. * Binds the view matrix to the effect
  21424. * @param effect defines the effect to bind the view matrix to
  21425. */
  21426. bindView(effect: Effect): void;
  21427. /**
  21428. * Binds the view projection matrix to the effect
  21429. * @param effect defines the effect to bind the view projection matrix to
  21430. */
  21431. bindViewProjection(effect: Effect): void;
  21432. /**
  21433. * Specifies if material alpha testing should be turned on for the mesh
  21434. * @param mesh defines the mesh to check
  21435. */
  21436. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21437. /**
  21438. * Processes to execute after binding the material to a mesh
  21439. * @param mesh defines the rendered mesh
  21440. */
  21441. protected _afterBind(mesh?: Mesh): void;
  21442. /**
  21443. * Unbinds the material from the mesh
  21444. */
  21445. unbind(): void;
  21446. /**
  21447. * Gets the active textures from the material
  21448. * @returns an array of textures
  21449. */
  21450. getActiveTextures(): BaseTexture[];
  21451. /**
  21452. * Specifies if the material uses a texture
  21453. * @param texture defines the texture to check against the material
  21454. * @returns a boolean specifying if the material uses the texture
  21455. */
  21456. hasTexture(texture: BaseTexture): boolean;
  21457. /**
  21458. * Makes a duplicate of the material, and gives it a new name
  21459. * @param name defines the new name for the duplicated material
  21460. * @returns the cloned material
  21461. */
  21462. clone(name: string): Nullable<Material>;
  21463. /**
  21464. * Gets the meshes bound to the material
  21465. * @returns an array of meshes bound to the material
  21466. */
  21467. getBindedMeshes(): AbstractMesh[];
  21468. /**
  21469. * Force shader compilation
  21470. * @param mesh defines the mesh associated with this material
  21471. * @param onCompiled defines a function to execute once the material is compiled
  21472. * @param options defines the options to configure the compilation
  21473. * @param onError defines a function to execute if the material fails compiling
  21474. */
  21475. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21476. /**
  21477. * Force shader compilation
  21478. * @param mesh defines the mesh that will use this material
  21479. * @param options defines additional options for compiling the shaders
  21480. * @returns a promise that resolves when the compilation completes
  21481. */
  21482. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21483. private static readonly _AllDirtyCallBack;
  21484. private static readonly _ImageProcessingDirtyCallBack;
  21485. private static readonly _TextureDirtyCallBack;
  21486. private static readonly _FresnelDirtyCallBack;
  21487. private static readonly _MiscDirtyCallBack;
  21488. private static readonly _LightsDirtyCallBack;
  21489. private static readonly _AttributeDirtyCallBack;
  21490. private static _FresnelAndMiscDirtyCallBack;
  21491. private static _TextureAndMiscDirtyCallBack;
  21492. private static readonly _DirtyCallbackArray;
  21493. private static readonly _RunDirtyCallBacks;
  21494. /**
  21495. * Marks a define in the material to indicate that it needs to be re-computed
  21496. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21497. */
  21498. markAsDirty(flag: number): void;
  21499. /**
  21500. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21501. * @param func defines a function which checks material defines against the submeshes
  21502. */
  21503. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21504. /**
  21505. * Indicates that we need to re-calculated for all submeshes
  21506. */
  21507. protected _markAllSubMeshesAsAllDirty(): void;
  21508. /**
  21509. * Indicates that image processing needs to be re-calculated for all submeshes
  21510. */
  21511. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21512. /**
  21513. * Indicates that textures need to be re-calculated for all submeshes
  21514. */
  21515. protected _markAllSubMeshesAsTexturesDirty(): void;
  21516. /**
  21517. * Indicates that fresnel needs to be re-calculated for all submeshes
  21518. */
  21519. protected _markAllSubMeshesAsFresnelDirty(): void;
  21520. /**
  21521. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21522. */
  21523. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21524. /**
  21525. * Indicates that lights need to be re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsLightsDirty(): void;
  21528. /**
  21529. * Indicates that attributes need to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsAttributesDirty(): void;
  21532. /**
  21533. * Indicates that misc needs to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsMiscDirty(): void;
  21536. /**
  21537. * Indicates that textures and misc need to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21540. /**
  21541. * Disposes the material
  21542. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21543. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21544. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21545. */
  21546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21547. /** @hidden */
  21548. private releaseVertexArrayObject;
  21549. /**
  21550. * Serializes this material
  21551. * @returns the serialized material object
  21552. */
  21553. serialize(): any;
  21554. /**
  21555. * Creates a material from parsed material data
  21556. * @param parsedMaterial defines parsed material data
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root URL to use to load textures
  21559. * @returns a new material
  21560. */
  21561. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21562. }
  21563. }
  21564. declare module "babylonjs/Materials/multiMaterial" {
  21565. import { Nullable } from "babylonjs/types";
  21566. import { Scene } from "babylonjs/scene";
  21567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21568. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21570. import { Material } from "babylonjs/Materials/material";
  21571. /**
  21572. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21573. * separate meshes. This can be use to improve performances.
  21574. * @see http://doc.babylonjs.com/how_to/multi_materials
  21575. */
  21576. export class MultiMaterial extends Material {
  21577. private _subMaterials;
  21578. /**
  21579. * Gets or Sets the list of Materials used within the multi material.
  21580. * They need to be ordered according to the submeshes order in the associated mesh
  21581. */
  21582. subMaterials: Nullable<Material>[];
  21583. /**
  21584. * Function used to align with Node.getChildren()
  21585. * @returns the list of Materials used within the multi material
  21586. */
  21587. getChildren(): Nullable<Material>[];
  21588. /**
  21589. * Instantiates a new Multi Material
  21590. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21591. * separate meshes. This can be use to improve performances.
  21592. * @see http://doc.babylonjs.com/how_to/multi_materials
  21593. * @param name Define the name in the scene
  21594. * @param scene Define the scene the material belongs to
  21595. */
  21596. constructor(name: string, scene: Scene);
  21597. private _hookArray;
  21598. /**
  21599. * Get one of the submaterial by its index in the submaterials array
  21600. * @param index The index to look the sub material at
  21601. * @returns The Material if the index has been defined
  21602. */
  21603. getSubMaterial(index: number): Nullable<Material>;
  21604. /**
  21605. * Get the list of active textures for the whole sub materials list.
  21606. * @returns All the textures that will be used during the rendering
  21607. */
  21608. getActiveTextures(): BaseTexture[];
  21609. /**
  21610. * Gets the current class name of the material e.g. "MultiMaterial"
  21611. * Mainly use in serialization.
  21612. * @returns the class name
  21613. */
  21614. getClassName(): string;
  21615. /**
  21616. * Checks if the material is ready to render the requested sub mesh
  21617. * @param mesh Define the mesh the submesh belongs to
  21618. * @param subMesh Define the sub mesh to look readyness for
  21619. * @param useInstances Define whether or not the material is used with instances
  21620. * @returns true if ready, otherwise false
  21621. */
  21622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21623. /**
  21624. * Clones the current material and its related sub materials
  21625. * @param name Define the name of the newly cloned material
  21626. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21627. * @returns the cloned material
  21628. */
  21629. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21630. /**
  21631. * Serializes the materials into a JSON representation.
  21632. * @returns the JSON representation
  21633. */
  21634. serialize(): any;
  21635. /**
  21636. * Dispose the material and release its associated resources
  21637. * @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)
  21638. * @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)
  21639. * @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)
  21640. */
  21641. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21642. /**
  21643. * Creates a MultiMaterial from parsed MultiMaterial data.
  21644. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21645. * @param scene defines the hosting scene
  21646. * @returns a new MultiMaterial
  21647. */
  21648. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21649. }
  21650. }
  21651. declare module "babylonjs/Meshes/subMesh" {
  21652. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21653. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21654. import { Engine } from "babylonjs/Engines/engine";
  21655. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21656. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21657. import { Effect } from "babylonjs/Materials/effect";
  21658. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21659. import { Plane } from "babylonjs/Maths/math.plane";
  21660. import { Collider } from "babylonjs/Collisions/collider";
  21661. import { Material } from "babylonjs/Materials/material";
  21662. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21664. import { Mesh } from "babylonjs/Meshes/mesh";
  21665. import { Ray } from "babylonjs/Culling/ray";
  21666. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21667. /**
  21668. * Base class for submeshes
  21669. */
  21670. export class BaseSubMesh {
  21671. /** @hidden */
  21672. _materialDefines: Nullable<MaterialDefines>;
  21673. /** @hidden */
  21674. _materialEffect: Nullable<Effect>;
  21675. /**
  21676. * Gets associated effect
  21677. */
  21678. readonly effect: Nullable<Effect>;
  21679. /**
  21680. * Sets associated effect (effect used to render this submesh)
  21681. * @param effect defines the effect to associate with
  21682. * @param defines defines the set of defines used to compile this effect
  21683. */
  21684. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21685. }
  21686. /**
  21687. * Defines a subdivision inside a mesh
  21688. */
  21689. export class SubMesh extends BaseSubMesh implements ICullable {
  21690. /** the material index to use */
  21691. materialIndex: number;
  21692. /** vertex index start */
  21693. verticesStart: number;
  21694. /** vertices count */
  21695. verticesCount: number;
  21696. /** index start */
  21697. indexStart: number;
  21698. /** indices count */
  21699. indexCount: number;
  21700. /** @hidden */
  21701. _linesIndexCount: number;
  21702. private _mesh;
  21703. private _renderingMesh;
  21704. private _boundingInfo;
  21705. private _linesIndexBuffer;
  21706. /** @hidden */
  21707. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21708. /** @hidden */
  21709. _trianglePlanes: Plane[];
  21710. /** @hidden */
  21711. _lastColliderTransformMatrix: Nullable<Matrix>;
  21712. /** @hidden */
  21713. _renderId: number;
  21714. /** @hidden */
  21715. _alphaIndex: number;
  21716. /** @hidden */
  21717. _distanceToCamera: number;
  21718. /** @hidden */
  21719. _id: number;
  21720. private _currentMaterial;
  21721. /**
  21722. * Add a new submesh to a mesh
  21723. * @param materialIndex defines the material index to use
  21724. * @param verticesStart defines vertex index start
  21725. * @param verticesCount defines vertices count
  21726. * @param indexStart defines index start
  21727. * @param indexCount defines indices count
  21728. * @param mesh defines the parent mesh
  21729. * @param renderingMesh defines an optional rendering mesh
  21730. * @param createBoundingBox defines if bounding box should be created for this submesh
  21731. * @returns the new submesh
  21732. */
  21733. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21734. /**
  21735. * Creates a new submesh
  21736. * @param materialIndex defines the material index to use
  21737. * @param verticesStart defines vertex index start
  21738. * @param verticesCount defines vertices count
  21739. * @param indexStart defines index start
  21740. * @param indexCount defines indices count
  21741. * @param mesh defines the parent mesh
  21742. * @param renderingMesh defines an optional rendering mesh
  21743. * @param createBoundingBox defines if bounding box should be created for this submesh
  21744. */
  21745. constructor(
  21746. /** the material index to use */
  21747. materialIndex: number,
  21748. /** vertex index start */
  21749. verticesStart: number,
  21750. /** vertices count */
  21751. verticesCount: number,
  21752. /** index start */
  21753. indexStart: number,
  21754. /** indices count */
  21755. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21756. /**
  21757. * Returns true if this submesh covers the entire parent mesh
  21758. * @ignorenaming
  21759. */
  21760. readonly IsGlobal: boolean;
  21761. /**
  21762. * Returns the submesh BoudingInfo object
  21763. * @returns current bounding info (or mesh's one if the submesh is global)
  21764. */
  21765. getBoundingInfo(): BoundingInfo;
  21766. /**
  21767. * Sets the submesh BoundingInfo
  21768. * @param boundingInfo defines the new bounding info to use
  21769. * @returns the SubMesh
  21770. */
  21771. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21772. /**
  21773. * Returns the mesh of the current submesh
  21774. * @return the parent mesh
  21775. */
  21776. getMesh(): AbstractMesh;
  21777. /**
  21778. * Returns the rendering mesh of the submesh
  21779. * @returns the rendering mesh (could be different from parent mesh)
  21780. */
  21781. getRenderingMesh(): Mesh;
  21782. /**
  21783. * Returns the submesh material
  21784. * @returns null or the current material
  21785. */
  21786. getMaterial(): Nullable<Material>;
  21787. /**
  21788. * Sets a new updated BoundingInfo object to the submesh
  21789. * @param data defines an optional position array to use to determine the bounding info
  21790. * @returns the SubMesh
  21791. */
  21792. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21793. /** @hidden */
  21794. _checkCollision(collider: Collider): boolean;
  21795. /**
  21796. * Updates the submesh BoundingInfo
  21797. * @param world defines the world matrix to use to update the bounding info
  21798. * @returns the submesh
  21799. */
  21800. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21801. /**
  21802. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21803. * @param frustumPlanes defines the frustum planes
  21804. * @returns true if the submesh is intersecting with the frustum
  21805. */
  21806. isInFrustum(frustumPlanes: Plane[]): boolean;
  21807. /**
  21808. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21809. * @param frustumPlanes defines the frustum planes
  21810. * @returns true if the submesh is inside the frustum
  21811. */
  21812. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21813. /**
  21814. * Renders the submesh
  21815. * @param enableAlphaMode defines if alpha needs to be used
  21816. * @returns the submesh
  21817. */
  21818. render(enableAlphaMode: boolean): SubMesh;
  21819. /**
  21820. * @hidden
  21821. */
  21822. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21823. /**
  21824. * Checks if the submesh intersects with a ray
  21825. * @param ray defines the ray to test
  21826. * @returns true is the passed ray intersects the submesh bounding box
  21827. */
  21828. canIntersects(ray: Ray): boolean;
  21829. /**
  21830. * Intersects current submesh with a ray
  21831. * @param ray defines the ray to test
  21832. * @param positions defines mesh's positions array
  21833. * @param indices defines mesh's indices array
  21834. * @param fastCheck defines if only bounding info should be used
  21835. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21836. * @returns intersection info or null if no intersection
  21837. */
  21838. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21839. /** @hidden */
  21840. private _intersectLines;
  21841. /** @hidden */
  21842. private _intersectUnIndexedLines;
  21843. /** @hidden */
  21844. private _intersectTriangles;
  21845. /** @hidden */
  21846. private _intersectUnIndexedTriangles;
  21847. /** @hidden */
  21848. _rebuild(): void;
  21849. /**
  21850. * Creates a new submesh from the passed mesh
  21851. * @param newMesh defines the new hosting mesh
  21852. * @param newRenderingMesh defines an optional rendering mesh
  21853. * @returns the new submesh
  21854. */
  21855. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21856. /**
  21857. * Release associated resources
  21858. */
  21859. dispose(): void;
  21860. /**
  21861. * Gets the class name
  21862. * @returns the string "SubMesh".
  21863. */
  21864. getClassName(): string;
  21865. /**
  21866. * Creates a new submesh from indices data
  21867. * @param materialIndex the index of the main mesh material
  21868. * @param startIndex the index where to start the copy in the mesh indices array
  21869. * @param indexCount the number of indices to copy then from the startIndex
  21870. * @param mesh the main mesh to create the submesh from
  21871. * @param renderingMesh the optional rendering mesh
  21872. * @returns a new submesh
  21873. */
  21874. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21875. }
  21876. }
  21877. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21878. /**
  21879. * Class used to represent data loading progression
  21880. */
  21881. export class SceneLoaderFlags {
  21882. private static _ForceFullSceneLoadingForIncremental;
  21883. private static _ShowLoadingScreen;
  21884. private static _CleanBoneMatrixWeights;
  21885. private static _loggingLevel;
  21886. /**
  21887. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21888. */
  21889. static ForceFullSceneLoadingForIncremental: boolean;
  21890. /**
  21891. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21892. */
  21893. static ShowLoadingScreen: boolean;
  21894. /**
  21895. * Defines the current logging level (while loading the scene)
  21896. * @ignorenaming
  21897. */
  21898. static loggingLevel: number;
  21899. /**
  21900. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21901. */
  21902. static CleanBoneMatrixWeights: boolean;
  21903. }
  21904. }
  21905. declare module "babylonjs/Meshes/geometry" {
  21906. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21907. import { Scene } from "babylonjs/scene";
  21908. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21909. import { Engine } from "babylonjs/Engines/engine";
  21910. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21911. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21912. import { Effect } from "babylonjs/Materials/effect";
  21913. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21914. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21915. import { Mesh } from "babylonjs/Meshes/mesh";
  21916. /**
  21917. * Class used to store geometry data (vertex buffers + index buffer)
  21918. */
  21919. export class Geometry implements IGetSetVerticesData {
  21920. /**
  21921. * Gets or sets the ID of the geometry
  21922. */
  21923. id: string;
  21924. /**
  21925. * Gets or sets the unique ID of the geometry
  21926. */
  21927. uniqueId: number;
  21928. /**
  21929. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21930. */
  21931. delayLoadState: number;
  21932. /**
  21933. * Gets the file containing the data to load when running in delay load state
  21934. */
  21935. delayLoadingFile: Nullable<string>;
  21936. /**
  21937. * Callback called when the geometry is updated
  21938. */
  21939. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21940. private _scene;
  21941. private _engine;
  21942. private _meshes;
  21943. private _totalVertices;
  21944. /** @hidden */
  21945. _indices: IndicesArray;
  21946. /** @hidden */
  21947. _vertexBuffers: {
  21948. [key: string]: VertexBuffer;
  21949. };
  21950. private _isDisposed;
  21951. private _extend;
  21952. private _boundingBias;
  21953. /** @hidden */
  21954. _delayInfo: Array<string>;
  21955. private _indexBuffer;
  21956. private _indexBufferIsUpdatable;
  21957. /** @hidden */
  21958. _boundingInfo: Nullable<BoundingInfo>;
  21959. /** @hidden */
  21960. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21961. /** @hidden */
  21962. _softwareSkinningFrameId: number;
  21963. private _vertexArrayObjects;
  21964. private _updatable;
  21965. /** @hidden */
  21966. _positions: Nullable<Vector3[]>;
  21967. /**
  21968. * 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
  21969. */
  21970. /**
  21971. * 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
  21972. */
  21973. boundingBias: Vector2;
  21974. /**
  21975. * Static function used to attach a new empty geometry to a mesh
  21976. * @param mesh defines the mesh to attach the geometry to
  21977. * @returns the new Geometry
  21978. */
  21979. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21980. /**
  21981. * Creates a new geometry
  21982. * @param id defines the unique ID
  21983. * @param scene defines the hosting scene
  21984. * @param vertexData defines the VertexData used to get geometry data
  21985. * @param updatable defines if geometry must be updatable (false by default)
  21986. * @param mesh defines the mesh that will be associated with the geometry
  21987. */
  21988. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21989. /**
  21990. * Gets the current extend of the geometry
  21991. */
  21992. readonly extend: {
  21993. minimum: Vector3;
  21994. maximum: Vector3;
  21995. };
  21996. /**
  21997. * Gets the hosting scene
  21998. * @returns the hosting Scene
  21999. */
  22000. getScene(): Scene;
  22001. /**
  22002. * Gets the hosting engine
  22003. * @returns the hosting Engine
  22004. */
  22005. getEngine(): Engine;
  22006. /**
  22007. * Defines if the geometry is ready to use
  22008. * @returns true if the geometry is ready to be used
  22009. */
  22010. isReady(): boolean;
  22011. /**
  22012. * Gets a value indicating that the geometry should not be serialized
  22013. */
  22014. readonly doNotSerialize: boolean;
  22015. /** @hidden */
  22016. _rebuild(): void;
  22017. /**
  22018. * Affects all geometry data in one call
  22019. * @param vertexData defines the geometry data
  22020. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22021. */
  22022. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22023. /**
  22024. * Set specific vertex data
  22025. * @param kind defines the data kind (Position, normal, etc...)
  22026. * @param data defines the vertex data to use
  22027. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22028. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22029. */
  22030. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22031. /**
  22032. * Removes a specific vertex data
  22033. * @param kind defines the data kind (Position, normal, etc...)
  22034. */
  22035. removeVerticesData(kind: string): void;
  22036. /**
  22037. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22038. * @param buffer defines the vertex buffer to use
  22039. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22040. */
  22041. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22042. /**
  22043. * Update a specific vertex buffer
  22044. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22045. * It will do nothing if the buffer is not updatable
  22046. * @param kind defines the data kind (Position, normal, etc...)
  22047. * @param data defines the data to use
  22048. * @param offset defines the offset in the target buffer where to store the data
  22049. * @param useBytes set to true if the offset is in bytes
  22050. */
  22051. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22052. /**
  22053. * Update a specific vertex buffer
  22054. * This function will create a new buffer if the current one is not updatable
  22055. * @param kind defines the data kind (Position, normal, etc...)
  22056. * @param data defines the data to use
  22057. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22058. */
  22059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22060. private _updateBoundingInfo;
  22061. /** @hidden */
  22062. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22063. /**
  22064. * Gets total number of vertices
  22065. * @returns the total number of vertices
  22066. */
  22067. getTotalVertices(): number;
  22068. /**
  22069. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22070. * @param kind defines the data kind (Position, normal, etc...)
  22071. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22073. * @returns a float array containing vertex data
  22074. */
  22075. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22076. /**
  22077. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22078. * @param kind defines the data kind (Position, normal, etc...)
  22079. * @returns true if the vertex buffer with the specified kind is updatable
  22080. */
  22081. isVertexBufferUpdatable(kind: string): boolean;
  22082. /**
  22083. * Gets a specific vertex buffer
  22084. * @param kind defines the data kind (Position, normal, etc...)
  22085. * @returns a VertexBuffer
  22086. */
  22087. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22088. /**
  22089. * Returns all vertex buffers
  22090. * @return an object holding all vertex buffers indexed by kind
  22091. */
  22092. getVertexBuffers(): Nullable<{
  22093. [key: string]: VertexBuffer;
  22094. }>;
  22095. /**
  22096. * Gets a boolean indicating if specific vertex buffer is present
  22097. * @param kind defines the data kind (Position, normal, etc...)
  22098. * @returns true if data is present
  22099. */
  22100. isVerticesDataPresent(kind: string): boolean;
  22101. /**
  22102. * Gets a list of all attached data kinds (Position, normal, etc...)
  22103. * @returns a list of string containing all kinds
  22104. */
  22105. getVerticesDataKinds(): string[];
  22106. /**
  22107. * Update index buffer
  22108. * @param indices defines the indices to store in the index buffer
  22109. * @param offset defines the offset in the target buffer where to store the data
  22110. * @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)
  22111. */
  22112. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22113. /**
  22114. * Creates a new index buffer
  22115. * @param indices defines the indices to store in the index buffer
  22116. * @param totalVertices defines the total number of vertices (could be null)
  22117. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22118. */
  22119. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22120. /**
  22121. * Return the total number of indices
  22122. * @returns the total number of indices
  22123. */
  22124. getTotalIndices(): number;
  22125. /**
  22126. * Gets the index buffer array
  22127. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22128. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22129. * @returns the index buffer array
  22130. */
  22131. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22132. /**
  22133. * Gets the index buffer
  22134. * @return the index buffer
  22135. */
  22136. getIndexBuffer(): Nullable<DataBuffer>;
  22137. /** @hidden */
  22138. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22139. /**
  22140. * Release the associated resources for a specific mesh
  22141. * @param mesh defines the source mesh
  22142. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22143. */
  22144. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22145. /**
  22146. * Apply current geometry to a given mesh
  22147. * @param mesh defines the mesh to apply geometry to
  22148. */
  22149. applyToMesh(mesh: Mesh): void;
  22150. private _updateExtend;
  22151. private _applyToMesh;
  22152. private notifyUpdate;
  22153. /**
  22154. * Load the geometry if it was flagged as delay loaded
  22155. * @param scene defines the hosting scene
  22156. * @param onLoaded defines a callback called when the geometry is loaded
  22157. */
  22158. load(scene: Scene, onLoaded?: () => void): void;
  22159. private _queueLoad;
  22160. /**
  22161. * Invert the geometry to move from a right handed system to a left handed one.
  22162. */
  22163. toLeftHanded(): void;
  22164. /** @hidden */
  22165. _resetPointsArrayCache(): void;
  22166. /** @hidden */
  22167. _generatePointsArray(): boolean;
  22168. /**
  22169. * Gets a value indicating if the geometry is disposed
  22170. * @returns true if the geometry was disposed
  22171. */
  22172. isDisposed(): boolean;
  22173. private _disposeVertexArrayObjects;
  22174. /**
  22175. * Free all associated resources
  22176. */
  22177. dispose(): void;
  22178. /**
  22179. * Clone the current geometry into a new geometry
  22180. * @param id defines the unique ID of the new geometry
  22181. * @returns a new geometry object
  22182. */
  22183. copy(id: string): Geometry;
  22184. /**
  22185. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22186. * @return a JSON representation of the current geometry data (without the vertices data)
  22187. */
  22188. serialize(): any;
  22189. private toNumberArray;
  22190. /**
  22191. * Serialize all vertices data into a JSON oject
  22192. * @returns a JSON representation of the current geometry data
  22193. */
  22194. serializeVerticeData(): any;
  22195. /**
  22196. * Extracts a clone of a mesh geometry
  22197. * @param mesh defines the source mesh
  22198. * @param id defines the unique ID of the new geometry object
  22199. * @returns the new geometry object
  22200. */
  22201. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22202. /**
  22203. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22204. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22205. * Be aware Math.random() could cause collisions, but:
  22206. * "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"
  22207. * @returns a string containing a new GUID
  22208. */
  22209. static RandomId(): string;
  22210. /** @hidden */
  22211. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22212. private static _CleanMatricesWeights;
  22213. /**
  22214. * Create a new geometry from persisted data (Using .babylon file format)
  22215. * @param parsedVertexData defines the persisted data
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22218. * @returns the new geometry object
  22219. */
  22220. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22221. }
  22222. }
  22223. declare module "babylonjs/Meshes/mesh.vertexData" {
  22224. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22225. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22226. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22227. import { Geometry } from "babylonjs/Meshes/geometry";
  22228. import { Mesh } from "babylonjs/Meshes/mesh";
  22229. /**
  22230. * Define an interface for all classes that will get and set the data on vertices
  22231. */
  22232. export interface IGetSetVerticesData {
  22233. /**
  22234. * Gets a boolean indicating if specific vertex data is present
  22235. * @param kind defines the vertex data kind to use
  22236. * @returns true is data kind is present
  22237. */
  22238. isVerticesDataPresent(kind: string): boolean;
  22239. /**
  22240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22241. * @param kind defines the data kind (Position, normal, etc...)
  22242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22244. * @returns a float array containing vertex data
  22245. */
  22246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22247. /**
  22248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22249. * @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.
  22250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22251. * @returns the indices array or an empty array if the mesh has no geometry
  22252. */
  22253. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22254. /**
  22255. * Set specific vertex data
  22256. * @param kind defines the data kind (Position, normal, etc...)
  22257. * @param data defines the vertex data to use
  22258. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22259. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22260. */
  22261. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22262. /**
  22263. * Update a specific associated vertex buffer
  22264. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22265. * - VertexBuffer.PositionKind
  22266. * - VertexBuffer.UVKind
  22267. * - VertexBuffer.UV2Kind
  22268. * - VertexBuffer.UV3Kind
  22269. * - VertexBuffer.UV4Kind
  22270. * - VertexBuffer.UV5Kind
  22271. * - VertexBuffer.UV6Kind
  22272. * - VertexBuffer.ColorKind
  22273. * - VertexBuffer.MatricesIndicesKind
  22274. * - VertexBuffer.MatricesIndicesExtraKind
  22275. * - VertexBuffer.MatricesWeightsKind
  22276. * - VertexBuffer.MatricesWeightsExtraKind
  22277. * @param data defines the data source
  22278. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22279. * @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)
  22280. */
  22281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22282. /**
  22283. * Creates a new index buffer
  22284. * @param indices defines the indices to store in the index buffer
  22285. * @param totalVertices defines the total number of vertices (could be null)
  22286. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22287. */
  22288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22289. }
  22290. /**
  22291. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22292. */
  22293. export class VertexData {
  22294. /**
  22295. * Mesh side orientation : usually the external or front surface
  22296. */
  22297. static readonly FRONTSIDE: number;
  22298. /**
  22299. * Mesh side orientation : usually the internal or back surface
  22300. */
  22301. static readonly BACKSIDE: number;
  22302. /**
  22303. * Mesh side orientation : both internal and external or front and back surfaces
  22304. */
  22305. static readonly DOUBLESIDE: number;
  22306. /**
  22307. * Mesh side orientation : by default, `FRONTSIDE`
  22308. */
  22309. static readonly DEFAULTSIDE: number;
  22310. /**
  22311. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22312. */
  22313. positions: Nullable<FloatArray>;
  22314. /**
  22315. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22316. */
  22317. normals: Nullable<FloatArray>;
  22318. /**
  22319. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22320. */
  22321. tangents: Nullable<FloatArray>;
  22322. /**
  22323. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22324. */
  22325. uvs: Nullable<FloatArray>;
  22326. /**
  22327. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22328. */
  22329. uvs2: Nullable<FloatArray>;
  22330. /**
  22331. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22332. */
  22333. uvs3: Nullable<FloatArray>;
  22334. /**
  22335. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22336. */
  22337. uvs4: Nullable<FloatArray>;
  22338. /**
  22339. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22340. */
  22341. uvs5: Nullable<FloatArray>;
  22342. /**
  22343. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22344. */
  22345. uvs6: Nullable<FloatArray>;
  22346. /**
  22347. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22348. */
  22349. colors: Nullable<FloatArray>;
  22350. /**
  22351. * 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).
  22352. */
  22353. matricesIndices: Nullable<FloatArray>;
  22354. /**
  22355. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22356. */
  22357. matricesWeights: Nullable<FloatArray>;
  22358. /**
  22359. * An array extending the number of possible indices
  22360. */
  22361. matricesIndicesExtra: Nullable<FloatArray>;
  22362. /**
  22363. * An array extending the number of possible weights when the number of indices is extended
  22364. */
  22365. matricesWeightsExtra: Nullable<FloatArray>;
  22366. /**
  22367. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22368. */
  22369. indices: Nullable<IndicesArray>;
  22370. /**
  22371. * Uses the passed data array to set the set the values for the specified kind of data
  22372. * @param data a linear array of floating numbers
  22373. * @param kind the type of data that is being set, eg positions, colors etc
  22374. */
  22375. set(data: FloatArray, kind: string): void;
  22376. /**
  22377. * Associates the vertexData to the passed Mesh.
  22378. * Sets it as updatable or not (default `false`)
  22379. * @param mesh the mesh the vertexData is applied to
  22380. * @param updatable when used and having the value true allows new data to update the vertexData
  22381. * @returns the VertexData
  22382. */
  22383. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22384. /**
  22385. * Associates the vertexData to the passed Geometry.
  22386. * Sets it as updatable or not (default `false`)
  22387. * @param geometry the geometry the vertexData is applied to
  22388. * @param updatable when used and having the value true allows new data to update the vertexData
  22389. * @returns VertexData
  22390. */
  22391. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22392. /**
  22393. * Updates the associated mesh
  22394. * @param mesh the mesh to be updated
  22395. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22396. * @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
  22397. * @returns VertexData
  22398. */
  22399. updateMesh(mesh: Mesh): VertexData;
  22400. /**
  22401. * Updates the associated geometry
  22402. * @param geometry the geometry to be updated
  22403. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22404. * @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
  22405. * @returns VertexData.
  22406. */
  22407. updateGeometry(geometry: Geometry): VertexData;
  22408. private _applyTo;
  22409. private _update;
  22410. /**
  22411. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22412. * @param matrix the transforming matrix
  22413. * @returns the VertexData
  22414. */
  22415. transform(matrix: Matrix): VertexData;
  22416. /**
  22417. * Merges the passed VertexData into the current one
  22418. * @param other the VertexData to be merged into the current one
  22419. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22420. * @returns the modified VertexData
  22421. */
  22422. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22423. private _mergeElement;
  22424. private _validate;
  22425. /**
  22426. * Serializes the VertexData
  22427. * @returns a serialized object
  22428. */
  22429. serialize(): any;
  22430. /**
  22431. * Extracts the vertexData from a mesh
  22432. * @param mesh the mesh from which to extract the VertexData
  22433. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22434. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22435. * @returns the object VertexData associated to the passed mesh
  22436. */
  22437. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22438. /**
  22439. * Extracts the vertexData from the geometry
  22440. * @param geometry the geometry from which to extract the VertexData
  22441. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22442. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22443. * @returns the object VertexData associated to the passed mesh
  22444. */
  22445. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22446. private static _ExtractFrom;
  22447. /**
  22448. * Creates the VertexData for a Ribbon
  22449. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22450. * * pathArray array of paths, each of which an array of successive Vector3
  22451. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22452. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22453. * * 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
  22454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22455. * * 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)
  22456. * * 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)
  22457. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22458. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22459. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22460. * @returns the VertexData of the ribbon
  22461. */
  22462. static CreateRibbon(options: {
  22463. pathArray: Vector3[][];
  22464. closeArray?: boolean;
  22465. closePath?: boolean;
  22466. offset?: number;
  22467. sideOrientation?: number;
  22468. frontUVs?: Vector4;
  22469. backUVs?: Vector4;
  22470. invertUV?: boolean;
  22471. uvs?: Vector2[];
  22472. colors?: Color4[];
  22473. }): VertexData;
  22474. /**
  22475. * Creates the VertexData for a box
  22476. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22477. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22478. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22479. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22480. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22481. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22482. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22484. * * 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)
  22485. * * 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)
  22486. * @returns the VertexData of the box
  22487. */
  22488. static CreateBox(options: {
  22489. size?: number;
  22490. width?: number;
  22491. height?: number;
  22492. depth?: number;
  22493. faceUV?: Vector4[];
  22494. faceColors?: Color4[];
  22495. sideOrientation?: number;
  22496. frontUVs?: Vector4;
  22497. backUVs?: Vector4;
  22498. }): VertexData;
  22499. /**
  22500. * Creates the VertexData for a tiled box
  22501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22502. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22503. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22504. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22506. * @returns the VertexData of the box
  22507. */
  22508. static CreateTiledBox(options: {
  22509. pattern?: number;
  22510. width?: number;
  22511. height?: number;
  22512. depth?: number;
  22513. tileSize?: number;
  22514. tileWidth?: number;
  22515. tileHeight?: number;
  22516. alignHorizontal?: number;
  22517. alignVertical?: number;
  22518. faceUV?: Vector4[];
  22519. faceColors?: Color4[];
  22520. sideOrientation?: number;
  22521. }): VertexData;
  22522. /**
  22523. * Creates the VertexData for a tiled plane
  22524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22525. * * pattern a limited pattern arrangement depending on the number
  22526. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22527. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22528. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22531. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22532. * @returns the VertexData of the tiled plane
  22533. */
  22534. static CreateTiledPlane(options: {
  22535. pattern?: number;
  22536. tileSize?: number;
  22537. tileWidth?: number;
  22538. tileHeight?: number;
  22539. size?: number;
  22540. width?: number;
  22541. height?: number;
  22542. alignHorizontal?: number;
  22543. alignVertical?: number;
  22544. sideOrientation?: number;
  22545. frontUVs?: Vector4;
  22546. backUVs?: Vector4;
  22547. }): VertexData;
  22548. /**
  22549. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22551. * * segments sets the number of horizontal strips optional, default 32
  22552. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22553. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22554. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22555. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22556. * * 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
  22557. * * 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
  22558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22559. * * 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)
  22560. * * 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)
  22561. * @returns the VertexData of the ellipsoid
  22562. */
  22563. static CreateSphere(options: {
  22564. segments?: number;
  22565. diameter?: number;
  22566. diameterX?: number;
  22567. diameterY?: number;
  22568. diameterZ?: number;
  22569. arc?: number;
  22570. slice?: number;
  22571. sideOrientation?: number;
  22572. frontUVs?: Vector4;
  22573. backUVs?: Vector4;
  22574. }): VertexData;
  22575. /**
  22576. * Creates the VertexData for a cylinder, cone or prism
  22577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22578. * * height sets the height (y direction) of the cylinder, optional, default 2
  22579. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22580. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22581. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22583. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22584. * * 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
  22585. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22586. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22587. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22588. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22590. * * 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)
  22591. * * 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)
  22592. * @returns the VertexData of the cylinder, cone or prism
  22593. */
  22594. static CreateCylinder(options: {
  22595. height?: number;
  22596. diameterTop?: number;
  22597. diameterBottom?: number;
  22598. diameter?: number;
  22599. tessellation?: number;
  22600. subdivisions?: number;
  22601. arc?: number;
  22602. faceColors?: Color4[];
  22603. faceUV?: Vector4[];
  22604. hasRings?: boolean;
  22605. enclose?: boolean;
  22606. sideOrientation?: number;
  22607. frontUVs?: Vector4;
  22608. backUVs?: Vector4;
  22609. }): VertexData;
  22610. /**
  22611. * Creates the VertexData for a torus
  22612. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22613. * * diameter the diameter of the torus, optional default 1
  22614. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22615. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  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 torus
  22620. */
  22621. static CreateTorus(options: {
  22622. diameter?: number;
  22623. thickness?: number;
  22624. tessellation?: number;
  22625. sideOrientation?: number;
  22626. frontUVs?: Vector4;
  22627. backUVs?: Vector4;
  22628. }): VertexData;
  22629. /**
  22630. * Creates the VertexData of the LineSystem
  22631. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22632. * - lines an array of lines, each line being an array of successive Vector3
  22633. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22634. * @returns the VertexData of the LineSystem
  22635. */
  22636. static CreateLineSystem(options: {
  22637. lines: Vector3[][];
  22638. colors?: Nullable<Color4[][]>;
  22639. }): VertexData;
  22640. /**
  22641. * Create the VertexData for a DashedLines
  22642. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22643. * - points an array successive Vector3
  22644. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22645. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22646. * - dashNb the intended total number of dashes, optional, default 200
  22647. * @returns the VertexData for the DashedLines
  22648. */
  22649. static CreateDashedLines(options: {
  22650. points: Vector3[];
  22651. dashSize?: number;
  22652. gapSize?: number;
  22653. dashNb?: number;
  22654. }): VertexData;
  22655. /**
  22656. * Creates the VertexData for a Ground
  22657. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22658. * - width the width (x direction) of the ground, optional, default 1
  22659. * - height the height (z direction) of the ground, optional, default 1
  22660. * - subdivisions the number of subdivisions per side, optional, default 1
  22661. * @returns the VertexData of the Ground
  22662. */
  22663. static CreateGround(options: {
  22664. width?: number;
  22665. height?: number;
  22666. subdivisions?: number;
  22667. subdivisionsX?: number;
  22668. subdivisionsY?: number;
  22669. }): VertexData;
  22670. /**
  22671. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22673. * * xmin the ground minimum X coordinate, optional, default -1
  22674. * * zmin the ground minimum Z coordinate, optional, default -1
  22675. * * xmax the ground maximum X coordinate, optional, default 1
  22676. * * zmax the ground maximum Z coordinate, optional, default 1
  22677. * * 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}
  22678. * * 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}
  22679. * @returns the VertexData of the TiledGround
  22680. */
  22681. static CreateTiledGround(options: {
  22682. xmin: number;
  22683. zmin: number;
  22684. xmax: number;
  22685. zmax: number;
  22686. subdivisions?: {
  22687. w: number;
  22688. h: number;
  22689. };
  22690. precision?: {
  22691. w: number;
  22692. h: number;
  22693. };
  22694. }): VertexData;
  22695. /**
  22696. * Creates the VertexData of the Ground designed from a heightmap
  22697. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22698. * * width the width (x direction) of the ground
  22699. * * height the height (z direction) of the ground
  22700. * * subdivisions the number of subdivisions per side
  22701. * * minHeight the minimum altitude on the ground, optional, default 0
  22702. * * maxHeight the maximum altitude on the ground, optional default 1
  22703. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22704. * * buffer the array holding the image color data
  22705. * * bufferWidth the width of image
  22706. * * bufferHeight the height of image
  22707. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22708. * @returns the VertexData of the Ground designed from a heightmap
  22709. */
  22710. static CreateGroundFromHeightMap(options: {
  22711. width: number;
  22712. height: number;
  22713. subdivisions: number;
  22714. minHeight: number;
  22715. maxHeight: number;
  22716. colorFilter: Color3;
  22717. buffer: Uint8Array;
  22718. bufferWidth: number;
  22719. bufferHeight: number;
  22720. alphaFilter: number;
  22721. }): VertexData;
  22722. /**
  22723. * Creates the VertexData for a Plane
  22724. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22725. * * size sets the width and height of the plane to the value of size, optional default 1
  22726. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22727. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22729. * * 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)
  22730. * * 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)
  22731. * @returns the VertexData of the box
  22732. */
  22733. static CreatePlane(options: {
  22734. size?: number;
  22735. width?: number;
  22736. height?: number;
  22737. sideOrientation?: number;
  22738. frontUVs?: Vector4;
  22739. backUVs?: Vector4;
  22740. }): VertexData;
  22741. /**
  22742. * Creates the VertexData of the Disc or regular Polygon
  22743. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22744. * * radius the radius of the disc, optional default 0.5
  22745. * * tessellation the number of polygon sides, optional, default 64
  22746. * * 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
  22747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22748. * * 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)
  22749. * * 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)
  22750. * @returns the VertexData of the box
  22751. */
  22752. static CreateDisc(options: {
  22753. radius?: number;
  22754. tessellation?: number;
  22755. arc?: number;
  22756. sideOrientation?: number;
  22757. frontUVs?: Vector4;
  22758. backUVs?: Vector4;
  22759. }): VertexData;
  22760. /**
  22761. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22762. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22763. * @param polygon a mesh built from polygonTriangulation.build()
  22764. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22765. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22766. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22767. * @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)
  22768. * @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)
  22769. * @returns the VertexData of the Polygon
  22770. */
  22771. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22772. /**
  22773. * Creates the VertexData of the IcoSphere
  22774. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22775. * * radius the radius of the IcoSphere, optional default 1
  22776. * * radiusX allows stretching in the x direction, optional, default radius
  22777. * * radiusY allows stretching in the y direction, optional, default radius
  22778. * * radiusZ allows stretching in the z direction, optional, default radius
  22779. * * flat when true creates a flat shaded mesh, optional, default true
  22780. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22782. * * 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)
  22783. * * 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)
  22784. * @returns the VertexData of the IcoSphere
  22785. */
  22786. static CreateIcoSphere(options: {
  22787. radius?: number;
  22788. radiusX?: number;
  22789. radiusY?: number;
  22790. radiusZ?: number;
  22791. flat?: boolean;
  22792. subdivisions?: number;
  22793. sideOrientation?: number;
  22794. frontUVs?: Vector4;
  22795. backUVs?: Vector4;
  22796. }): VertexData;
  22797. /**
  22798. * Creates the VertexData for a Polyhedron
  22799. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22800. * * type provided types are:
  22801. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22802. * * 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)
  22803. * * size the size of the IcoSphere, optional default 1
  22804. * * sizeX allows stretching in the x direction, optional, default size
  22805. * * sizeY allows stretching in the y direction, optional, default size
  22806. * * sizeZ allows stretching in the z direction, optional, default size
  22807. * * 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
  22808. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22809. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22810. * * flat when true creates a flat shaded mesh, optional, default true
  22811. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * 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)
  22814. * * 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)
  22815. * @returns the VertexData of the Polyhedron
  22816. */
  22817. static CreatePolyhedron(options: {
  22818. type?: number;
  22819. size?: number;
  22820. sizeX?: number;
  22821. sizeY?: number;
  22822. sizeZ?: number;
  22823. custom?: any;
  22824. faceUV?: Vector4[];
  22825. faceColors?: Color4[];
  22826. flat?: boolean;
  22827. sideOrientation?: number;
  22828. frontUVs?: Vector4;
  22829. backUVs?: Vector4;
  22830. }): VertexData;
  22831. /**
  22832. * Creates the VertexData for a TorusKnot
  22833. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22834. * * radius the radius of the torus knot, optional, default 2
  22835. * * tube the thickness of the tube, optional, default 0.5
  22836. * * radialSegments the number of sides on each tube segments, optional, default 32
  22837. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22838. * * p the number of windings around the z axis, optional, default 2
  22839. * * q the number of windings around the x axis, optional, default 3
  22840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22841. * * 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)
  22842. * * 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)
  22843. * @returns the VertexData of the Torus Knot
  22844. */
  22845. static CreateTorusKnot(options: {
  22846. radius?: number;
  22847. tube?: number;
  22848. radialSegments?: number;
  22849. tubularSegments?: number;
  22850. p?: number;
  22851. q?: number;
  22852. sideOrientation?: number;
  22853. frontUVs?: Vector4;
  22854. backUVs?: Vector4;
  22855. }): VertexData;
  22856. /**
  22857. * Compute normals for given positions and indices
  22858. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22859. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22860. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22861. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22862. * * facetNormals : optional array of facet normals (vector3)
  22863. * * facetPositions : optional array of facet positions (vector3)
  22864. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22865. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22866. * * bInfo : optional bounding info, required for facetPartitioning computation
  22867. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22868. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22869. * * useRightHandedSystem: optional boolean to for right handed system computation
  22870. * * depthSort : optional boolean to enable the facet depth sort computation
  22871. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22872. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22873. */
  22874. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22875. facetNormals?: any;
  22876. facetPositions?: any;
  22877. facetPartitioning?: any;
  22878. ratio?: number;
  22879. bInfo?: any;
  22880. bbSize?: Vector3;
  22881. subDiv?: any;
  22882. useRightHandedSystem?: boolean;
  22883. depthSort?: boolean;
  22884. distanceTo?: Vector3;
  22885. depthSortedFacets?: any;
  22886. }): void;
  22887. /** @hidden */
  22888. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22889. /**
  22890. * Applies VertexData created from the imported parameters to the geometry
  22891. * @param parsedVertexData the parsed data from an imported file
  22892. * @param geometry the geometry to apply the VertexData to
  22893. */
  22894. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22895. }
  22896. }
  22897. declare module "babylonjs/Morph/morphTarget" {
  22898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22899. import { Observable } from "babylonjs/Misc/observable";
  22900. import { Nullable, FloatArray } from "babylonjs/types";
  22901. import { Scene } from "babylonjs/scene";
  22902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22903. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22904. /**
  22905. * Defines a target to use with MorphTargetManager
  22906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22907. */
  22908. export class MorphTarget implements IAnimatable {
  22909. /** defines the name of the target */
  22910. name: string;
  22911. /**
  22912. * Gets or sets the list of animations
  22913. */
  22914. animations: import("babylonjs/Animations/animation").Animation[];
  22915. private _scene;
  22916. private _positions;
  22917. private _normals;
  22918. private _tangents;
  22919. private _uvs;
  22920. private _influence;
  22921. private _uniqueId;
  22922. /**
  22923. * Observable raised when the influence changes
  22924. */
  22925. onInfluenceChanged: Observable<boolean>;
  22926. /** @hidden */
  22927. _onDataLayoutChanged: Observable<void>;
  22928. /**
  22929. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22930. */
  22931. influence: number;
  22932. /**
  22933. * Gets or sets the id of the morph Target
  22934. */
  22935. id: string;
  22936. private _animationPropertiesOverride;
  22937. /**
  22938. * Gets or sets the animation properties override
  22939. */
  22940. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22941. /**
  22942. * Creates a new MorphTarget
  22943. * @param name defines the name of the target
  22944. * @param influence defines the influence to use
  22945. * @param scene defines the scene the morphtarget belongs to
  22946. */
  22947. constructor(
  22948. /** defines the name of the target */
  22949. name: string, influence?: number, scene?: Nullable<Scene>);
  22950. /**
  22951. * Gets the unique ID of this manager
  22952. */
  22953. readonly uniqueId: number;
  22954. /**
  22955. * Gets a boolean defining if the target contains position data
  22956. */
  22957. readonly hasPositions: boolean;
  22958. /**
  22959. * Gets a boolean defining if the target contains normal data
  22960. */
  22961. readonly hasNormals: boolean;
  22962. /**
  22963. * Gets a boolean defining if the target contains tangent data
  22964. */
  22965. readonly hasTangents: boolean;
  22966. /**
  22967. * Gets a boolean defining if the target contains texture coordinates data
  22968. */
  22969. readonly hasUVs: boolean;
  22970. /**
  22971. * Affects position data to this target
  22972. * @param data defines the position data to use
  22973. */
  22974. setPositions(data: Nullable<FloatArray>): void;
  22975. /**
  22976. * Gets the position data stored in this target
  22977. * @returns a FloatArray containing the position data (or null if not present)
  22978. */
  22979. getPositions(): Nullable<FloatArray>;
  22980. /**
  22981. * Affects normal data to this target
  22982. * @param data defines the normal data to use
  22983. */
  22984. setNormals(data: Nullable<FloatArray>): void;
  22985. /**
  22986. * Gets the normal data stored in this target
  22987. * @returns a FloatArray containing the normal data (or null if not present)
  22988. */
  22989. getNormals(): Nullable<FloatArray>;
  22990. /**
  22991. * Affects tangent data to this target
  22992. * @param data defines the tangent data to use
  22993. */
  22994. setTangents(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the tangent data stored in this target
  22997. * @returns a FloatArray containing the tangent data (or null if not present)
  22998. */
  22999. getTangents(): Nullable<FloatArray>;
  23000. /**
  23001. * Affects texture coordinates data to this target
  23002. * @param data defines the texture coordinates data to use
  23003. */
  23004. setUVs(data: Nullable<FloatArray>): void;
  23005. /**
  23006. * Gets the texture coordinates data stored in this target
  23007. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23008. */
  23009. getUVs(): Nullable<FloatArray>;
  23010. /**
  23011. * Clone the current target
  23012. * @returns a new MorphTarget
  23013. */
  23014. clone(): MorphTarget;
  23015. /**
  23016. * Serializes the current target into a Serialization object
  23017. * @returns the serialized object
  23018. */
  23019. serialize(): any;
  23020. /**
  23021. * Returns the string "MorphTarget"
  23022. * @returns "MorphTarget"
  23023. */
  23024. getClassName(): string;
  23025. /**
  23026. * Creates a new target from serialized data
  23027. * @param serializationObject defines the serialized data to use
  23028. * @returns a new MorphTarget
  23029. */
  23030. static Parse(serializationObject: any): MorphTarget;
  23031. /**
  23032. * Creates a MorphTarget from mesh data
  23033. * @param mesh defines the source mesh
  23034. * @param name defines the name to use for the new target
  23035. * @param influence defines the influence to attach to the target
  23036. * @returns a new MorphTarget
  23037. */
  23038. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23039. }
  23040. }
  23041. declare module "babylonjs/Morph/morphTargetManager" {
  23042. import { Nullable } from "babylonjs/types";
  23043. import { Scene } from "babylonjs/scene";
  23044. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23045. /**
  23046. * This class is used to deform meshes using morphing between different targets
  23047. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23048. */
  23049. export class MorphTargetManager {
  23050. private _targets;
  23051. private _targetInfluenceChangedObservers;
  23052. private _targetDataLayoutChangedObservers;
  23053. private _activeTargets;
  23054. private _scene;
  23055. private _influences;
  23056. private _supportsNormals;
  23057. private _supportsTangents;
  23058. private _supportsUVs;
  23059. private _vertexCount;
  23060. private _uniqueId;
  23061. private _tempInfluences;
  23062. /**
  23063. * Gets or sets a boolean indicating if normals must be morphed
  23064. */
  23065. enableNormalMorphing: boolean;
  23066. /**
  23067. * Gets or sets a boolean indicating if tangents must be morphed
  23068. */
  23069. enableTangentMorphing: boolean;
  23070. /**
  23071. * Gets or sets a boolean indicating if UV must be morphed
  23072. */
  23073. enableUVMorphing: boolean;
  23074. /**
  23075. * Creates a new MorphTargetManager
  23076. * @param scene defines the current scene
  23077. */
  23078. constructor(scene?: Nullable<Scene>);
  23079. /**
  23080. * Gets the unique ID of this manager
  23081. */
  23082. readonly uniqueId: number;
  23083. /**
  23084. * Gets the number of vertices handled by this manager
  23085. */
  23086. readonly vertexCount: number;
  23087. /**
  23088. * Gets a boolean indicating if this manager supports morphing of normals
  23089. */
  23090. readonly supportsNormals: boolean;
  23091. /**
  23092. * Gets a boolean indicating if this manager supports morphing of tangents
  23093. */
  23094. readonly supportsTangents: boolean;
  23095. /**
  23096. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23097. */
  23098. readonly supportsUVs: boolean;
  23099. /**
  23100. * Gets the number of targets stored in this manager
  23101. */
  23102. readonly numTargets: number;
  23103. /**
  23104. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23105. */
  23106. readonly numInfluencers: number;
  23107. /**
  23108. * Gets the list of influences (one per target)
  23109. */
  23110. readonly influences: Float32Array;
  23111. /**
  23112. * Gets the active target at specified index. An active target is a target with an influence > 0
  23113. * @param index defines the index to check
  23114. * @returns the requested target
  23115. */
  23116. getActiveTarget(index: number): MorphTarget;
  23117. /**
  23118. * Gets the target at specified index
  23119. * @param index defines the index to check
  23120. * @returns the requested target
  23121. */
  23122. getTarget(index: number): MorphTarget;
  23123. /**
  23124. * Add a new target to this manager
  23125. * @param target defines the target to add
  23126. */
  23127. addTarget(target: MorphTarget): void;
  23128. /**
  23129. * Removes a target from the manager
  23130. * @param target defines the target to remove
  23131. */
  23132. removeTarget(target: MorphTarget): void;
  23133. /**
  23134. * Clone the current manager
  23135. * @returns a new MorphTargetManager
  23136. */
  23137. clone(): MorphTargetManager;
  23138. /**
  23139. * Serializes the current manager into a Serialization object
  23140. * @returns the serialized object
  23141. */
  23142. serialize(): any;
  23143. private _syncActiveTargets;
  23144. /**
  23145. * Syncrhonize the targets with all the meshes using this morph target manager
  23146. */
  23147. synchronize(): void;
  23148. /**
  23149. * Creates a new MorphTargetManager from serialized data
  23150. * @param serializationObject defines the serialized data
  23151. * @param scene defines the hosting scene
  23152. * @returns the new MorphTargetManager
  23153. */
  23154. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23155. }
  23156. }
  23157. declare module "babylonjs/Meshes/meshLODLevel" {
  23158. import { Mesh } from "babylonjs/Meshes/mesh";
  23159. import { Nullable } from "babylonjs/types";
  23160. /**
  23161. * Class used to represent a specific level of detail of a mesh
  23162. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23163. */
  23164. export class MeshLODLevel {
  23165. /** Defines the distance where this level should start being displayed */
  23166. distance: number;
  23167. /** Defines the mesh to use to render this level */
  23168. mesh: Nullable<Mesh>;
  23169. /**
  23170. * Creates a new LOD level
  23171. * @param distance defines the distance where this level should star being displayed
  23172. * @param mesh defines the mesh to use to render this level
  23173. */
  23174. constructor(
  23175. /** Defines the distance where this level should start being displayed */
  23176. distance: number,
  23177. /** Defines the mesh to use to render this level */
  23178. mesh: Nullable<Mesh>);
  23179. }
  23180. }
  23181. declare module "babylonjs/Meshes/groundMesh" {
  23182. import { Scene } from "babylonjs/scene";
  23183. import { Vector3 } from "babylonjs/Maths/math.vector";
  23184. import { Mesh } from "babylonjs/Meshes/mesh";
  23185. /**
  23186. * Mesh representing the gorund
  23187. */
  23188. export class GroundMesh extends Mesh {
  23189. /** If octree should be generated */
  23190. generateOctree: boolean;
  23191. private _heightQuads;
  23192. /** @hidden */
  23193. _subdivisionsX: number;
  23194. /** @hidden */
  23195. _subdivisionsY: number;
  23196. /** @hidden */
  23197. _width: number;
  23198. /** @hidden */
  23199. _height: number;
  23200. /** @hidden */
  23201. _minX: number;
  23202. /** @hidden */
  23203. _maxX: number;
  23204. /** @hidden */
  23205. _minZ: number;
  23206. /** @hidden */
  23207. _maxZ: number;
  23208. constructor(name: string, scene: Scene);
  23209. /**
  23210. * "GroundMesh"
  23211. * @returns "GroundMesh"
  23212. */
  23213. getClassName(): string;
  23214. /**
  23215. * The minimum of x and y subdivisions
  23216. */
  23217. readonly subdivisions: number;
  23218. /**
  23219. * X subdivisions
  23220. */
  23221. readonly subdivisionsX: number;
  23222. /**
  23223. * Y subdivisions
  23224. */
  23225. readonly subdivisionsY: number;
  23226. /**
  23227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23229. * @param chunksCount the number of subdivisions for x and y
  23230. * @param octreeBlocksSize (Default: 32)
  23231. */
  23232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23233. /**
  23234. * Returns a height (y) value in the Worl system :
  23235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23236. * @param x x coordinate
  23237. * @param z z coordinate
  23238. * @returns the ground y position if (x, z) are outside the ground surface.
  23239. */
  23240. getHeightAtCoordinates(x: number, z: number): number;
  23241. /**
  23242. * Returns a normalized vector (Vector3) orthogonal to the ground
  23243. * at the ground coordinates (x, z) expressed in the World system.
  23244. * @param x x coordinate
  23245. * @param z z coordinate
  23246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23247. */
  23248. getNormalAtCoordinates(x: number, z: number): Vector3;
  23249. /**
  23250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23251. * at the ground coordinates (x, z) expressed in the World system.
  23252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23253. * @param x x coordinate
  23254. * @param z z coordinate
  23255. * @param ref vector to store the result
  23256. * @returns the GroundMesh.
  23257. */
  23258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23259. /**
  23260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23261. * if the ground has been updated.
  23262. * This can be used in the render loop.
  23263. * @returns the GroundMesh.
  23264. */
  23265. updateCoordinateHeights(): GroundMesh;
  23266. private _getFacetAt;
  23267. private _initHeightQuads;
  23268. private _computeHeightQuads;
  23269. /**
  23270. * Serializes this ground mesh
  23271. * @param serializationObject object to write serialization to
  23272. */
  23273. serialize(serializationObject: any): void;
  23274. /**
  23275. * Parses a serialized ground mesh
  23276. * @param parsedMesh the serialized mesh
  23277. * @param scene the scene to create the ground mesh in
  23278. * @returns the created ground mesh
  23279. */
  23280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23281. }
  23282. }
  23283. declare module "babylonjs/Physics/physicsJoint" {
  23284. import { Vector3 } from "babylonjs/Maths/math.vector";
  23285. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23286. /**
  23287. * Interface for Physics-Joint data
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export interface PhysicsJointData {
  23291. /**
  23292. * The main pivot of the joint
  23293. */
  23294. mainPivot?: Vector3;
  23295. /**
  23296. * The connected pivot of the joint
  23297. */
  23298. connectedPivot?: Vector3;
  23299. /**
  23300. * The main axis of the joint
  23301. */
  23302. mainAxis?: Vector3;
  23303. /**
  23304. * The connected axis of the joint
  23305. */
  23306. connectedAxis?: Vector3;
  23307. /**
  23308. * The collision of the joint
  23309. */
  23310. collision?: boolean;
  23311. /**
  23312. * Native Oimo/Cannon/Energy data
  23313. */
  23314. nativeParams?: any;
  23315. }
  23316. /**
  23317. * This is a holder class for the physics joint created by the physics plugin
  23318. * It holds a set of functions to control the underlying joint
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export class PhysicsJoint {
  23322. /**
  23323. * The type of the physics joint
  23324. */
  23325. type: number;
  23326. /**
  23327. * The data for the physics joint
  23328. */
  23329. jointData: PhysicsJointData;
  23330. private _physicsJoint;
  23331. protected _physicsPlugin: IPhysicsEnginePlugin;
  23332. /**
  23333. * Initializes the physics joint
  23334. * @param type The type of the physics joint
  23335. * @param jointData The data for the physics joint
  23336. */
  23337. constructor(
  23338. /**
  23339. * The type of the physics joint
  23340. */
  23341. type: number,
  23342. /**
  23343. * The data for the physics joint
  23344. */
  23345. jointData: PhysicsJointData);
  23346. /**
  23347. * Gets the physics joint
  23348. */
  23349. /**
  23350. * Sets the physics joint
  23351. */
  23352. physicsJoint: any;
  23353. /**
  23354. * Sets the physics plugin
  23355. */
  23356. physicsPlugin: IPhysicsEnginePlugin;
  23357. /**
  23358. * Execute a function that is physics-plugin specific.
  23359. * @param {Function} func the function that will be executed.
  23360. * It accepts two parameters: the physics world and the physics joint
  23361. */
  23362. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23363. /**
  23364. * Distance-Joint type
  23365. */
  23366. static DistanceJoint: number;
  23367. /**
  23368. * Hinge-Joint type
  23369. */
  23370. static HingeJoint: number;
  23371. /**
  23372. * Ball-and-Socket joint type
  23373. */
  23374. static BallAndSocketJoint: number;
  23375. /**
  23376. * Wheel-Joint type
  23377. */
  23378. static WheelJoint: number;
  23379. /**
  23380. * Slider-Joint type
  23381. */
  23382. static SliderJoint: number;
  23383. /**
  23384. * Prismatic-Joint type
  23385. */
  23386. static PrismaticJoint: number;
  23387. /**
  23388. * Universal-Joint type
  23389. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23390. */
  23391. static UniversalJoint: number;
  23392. /**
  23393. * Hinge-Joint 2 type
  23394. */
  23395. static Hinge2Joint: number;
  23396. /**
  23397. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23398. */
  23399. static PointToPointJoint: number;
  23400. /**
  23401. * Spring-Joint type
  23402. */
  23403. static SpringJoint: number;
  23404. /**
  23405. * Lock-Joint type
  23406. */
  23407. static LockJoint: number;
  23408. }
  23409. /**
  23410. * A class representing a physics distance joint
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export class DistanceJoint extends PhysicsJoint {
  23414. /**
  23415. *
  23416. * @param jointData The data for the Distance-Joint
  23417. */
  23418. constructor(jointData: DistanceJointData);
  23419. /**
  23420. * Update the predefined distance.
  23421. * @param maxDistance The maximum preferred distance
  23422. * @param minDistance The minimum preferred distance
  23423. */
  23424. updateDistance(maxDistance: number, minDistance?: number): void;
  23425. }
  23426. /**
  23427. * Represents a Motor-Enabled Joint
  23428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23429. */
  23430. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23431. /**
  23432. * Initializes the Motor-Enabled Joint
  23433. * @param type The type of the joint
  23434. * @param jointData The physica joint data for the joint
  23435. */
  23436. constructor(type: number, jointData: PhysicsJointData);
  23437. /**
  23438. * Set the motor values.
  23439. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23440. * @param force the force to apply
  23441. * @param maxForce max force for this motor.
  23442. */
  23443. setMotor(force?: number, maxForce?: number): void;
  23444. /**
  23445. * Set the motor's limits.
  23446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23447. * @param upperLimit The upper limit of the motor
  23448. * @param lowerLimit The lower limit of the motor
  23449. */
  23450. setLimit(upperLimit: number, lowerLimit?: number): void;
  23451. }
  23452. /**
  23453. * This class represents a single physics Hinge-Joint
  23454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23455. */
  23456. export class HingeJoint extends MotorEnabledJoint {
  23457. /**
  23458. * Initializes the Hinge-Joint
  23459. * @param jointData The joint data for the Hinge-Joint
  23460. */
  23461. constructor(jointData: PhysicsJointData);
  23462. /**
  23463. * Set the motor values.
  23464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23465. * @param {number} force the force to apply
  23466. * @param {number} maxForce max force for this motor.
  23467. */
  23468. setMotor(force?: number, maxForce?: number): void;
  23469. /**
  23470. * Set the motor's limits.
  23471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23472. * @param upperLimit The upper limit of the motor
  23473. * @param lowerLimit The lower limit of the motor
  23474. */
  23475. setLimit(upperLimit: number, lowerLimit?: number): void;
  23476. }
  23477. /**
  23478. * This class represents a dual hinge physics joint (same as wheel joint)
  23479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23480. */
  23481. export class Hinge2Joint extends MotorEnabledJoint {
  23482. /**
  23483. * Initializes the Hinge2-Joint
  23484. * @param jointData The joint data for the Hinge2-Joint
  23485. */
  23486. constructor(jointData: PhysicsJointData);
  23487. /**
  23488. * Set the motor values.
  23489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23490. * @param {number} targetSpeed the speed the motor is to reach
  23491. * @param {number} maxForce max force for this motor.
  23492. * @param {motorIndex} the motor's index, 0 or 1.
  23493. */
  23494. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23495. /**
  23496. * Set the motor limits.
  23497. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23498. * @param {number} upperLimit the upper limit
  23499. * @param {number} lowerLimit lower limit
  23500. * @param {motorIndex} the motor's index, 0 or 1.
  23501. */
  23502. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23503. }
  23504. /**
  23505. * Interface for a motor enabled joint
  23506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23507. */
  23508. export interface IMotorEnabledJoint {
  23509. /**
  23510. * Physics joint
  23511. */
  23512. physicsJoint: any;
  23513. /**
  23514. * Sets the motor of the motor-enabled joint
  23515. * @param force The force of the motor
  23516. * @param maxForce The maximum force of the motor
  23517. * @param motorIndex The index of the motor
  23518. */
  23519. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23520. /**
  23521. * Sets the limit of the motor
  23522. * @param upperLimit The upper limit of the motor
  23523. * @param lowerLimit The lower limit of the motor
  23524. * @param motorIndex The index of the motor
  23525. */
  23526. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23527. }
  23528. /**
  23529. * Joint data for a Distance-Joint
  23530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23531. */
  23532. export interface DistanceJointData extends PhysicsJointData {
  23533. /**
  23534. * Max distance the 2 joint objects can be apart
  23535. */
  23536. maxDistance: number;
  23537. }
  23538. /**
  23539. * Joint data from a spring joint
  23540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23541. */
  23542. export interface SpringJointData extends PhysicsJointData {
  23543. /**
  23544. * Length of the spring
  23545. */
  23546. length: number;
  23547. /**
  23548. * Stiffness of the spring
  23549. */
  23550. stiffness: number;
  23551. /**
  23552. * Damping of the spring
  23553. */
  23554. damping: number;
  23555. /** this callback will be called when applying the force to the impostors. */
  23556. forceApplicationCallback: () => void;
  23557. }
  23558. }
  23559. declare module "babylonjs/Physics/physicsRaycastResult" {
  23560. import { Vector3 } from "babylonjs/Maths/math.vector";
  23561. /**
  23562. * Holds the data for the raycast result
  23563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23564. */
  23565. export class PhysicsRaycastResult {
  23566. private _hasHit;
  23567. private _hitDistance;
  23568. private _hitNormalWorld;
  23569. private _hitPointWorld;
  23570. private _rayFromWorld;
  23571. private _rayToWorld;
  23572. /**
  23573. * Gets if there was a hit
  23574. */
  23575. readonly hasHit: boolean;
  23576. /**
  23577. * Gets the distance from the hit
  23578. */
  23579. readonly hitDistance: number;
  23580. /**
  23581. * Gets the hit normal/direction in the world
  23582. */
  23583. readonly hitNormalWorld: Vector3;
  23584. /**
  23585. * Gets the hit point in the world
  23586. */
  23587. readonly hitPointWorld: Vector3;
  23588. /**
  23589. * Gets the ray "start point" of the ray in the world
  23590. */
  23591. readonly rayFromWorld: Vector3;
  23592. /**
  23593. * Gets the ray "end point" of the ray in the world
  23594. */
  23595. readonly rayToWorld: Vector3;
  23596. /**
  23597. * Sets the hit data (normal & point in world space)
  23598. * @param hitNormalWorld defines the normal in world space
  23599. * @param hitPointWorld defines the point in world space
  23600. */
  23601. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23602. /**
  23603. * Sets the distance from the start point to the hit point
  23604. * @param distance
  23605. */
  23606. setHitDistance(distance: number): void;
  23607. /**
  23608. * Calculates the distance manually
  23609. */
  23610. calculateHitDistance(): void;
  23611. /**
  23612. * Resets all the values to default
  23613. * @param from The from point on world space
  23614. * @param to The to point on world space
  23615. */
  23616. reset(from?: Vector3, to?: Vector3): void;
  23617. }
  23618. /**
  23619. * Interface for the size containing width and height
  23620. */
  23621. interface IXYZ {
  23622. /**
  23623. * X
  23624. */
  23625. x: number;
  23626. /**
  23627. * Y
  23628. */
  23629. y: number;
  23630. /**
  23631. * Z
  23632. */
  23633. z: number;
  23634. }
  23635. }
  23636. declare module "babylonjs/Physics/IPhysicsEngine" {
  23637. import { Nullable } from "babylonjs/types";
  23638. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23640. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23641. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23642. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23643. /**
  23644. * Interface used to describe a physics joint
  23645. */
  23646. export interface PhysicsImpostorJoint {
  23647. /** Defines the main impostor to which the joint is linked */
  23648. mainImpostor: PhysicsImpostor;
  23649. /** Defines the impostor that is connected to the main impostor using this joint */
  23650. connectedImpostor: PhysicsImpostor;
  23651. /** Defines the joint itself */
  23652. joint: PhysicsJoint;
  23653. }
  23654. /** @hidden */
  23655. export interface IPhysicsEnginePlugin {
  23656. world: any;
  23657. name: string;
  23658. setGravity(gravity: Vector3): void;
  23659. setTimeStep(timeStep: number): void;
  23660. getTimeStep(): number;
  23661. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23662. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23663. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23664. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23665. removePhysicsBody(impostor: PhysicsImpostor): void;
  23666. generateJoint(joint: PhysicsImpostorJoint): void;
  23667. removeJoint(joint: PhysicsImpostorJoint): void;
  23668. isSupported(): boolean;
  23669. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23670. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23671. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23672. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23673. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23674. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23675. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23676. getBodyMass(impostor: PhysicsImpostor): number;
  23677. getBodyFriction(impostor: PhysicsImpostor): number;
  23678. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23679. getBodyRestitution(impostor: PhysicsImpostor): number;
  23680. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23681. getBodyPressure?(impostor: PhysicsImpostor): number;
  23682. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23683. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23684. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23685. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23686. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23687. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23688. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23689. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23690. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23691. sleepBody(impostor: PhysicsImpostor): void;
  23692. wakeUpBody(impostor: PhysicsImpostor): void;
  23693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23694. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23695. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23696. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23697. getRadius(impostor: PhysicsImpostor): number;
  23698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23699. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23700. dispose(): void;
  23701. }
  23702. /**
  23703. * Interface used to define a physics engine
  23704. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23705. */
  23706. export interface IPhysicsEngine {
  23707. /**
  23708. * Gets the gravity vector used by the simulation
  23709. */
  23710. gravity: Vector3;
  23711. /**
  23712. * Sets the gravity vector used by the simulation
  23713. * @param gravity defines the gravity vector to use
  23714. */
  23715. setGravity(gravity: Vector3): void;
  23716. /**
  23717. * Set the time step of the physics engine.
  23718. * Default is 1/60.
  23719. * To slow it down, enter 1/600 for example.
  23720. * To speed it up, 1/30
  23721. * @param newTimeStep the new timestep to apply to this world.
  23722. */
  23723. setTimeStep(newTimeStep: number): void;
  23724. /**
  23725. * Get the time step of the physics engine.
  23726. * @returns the current time step
  23727. */
  23728. getTimeStep(): number;
  23729. /**
  23730. * Release all resources
  23731. */
  23732. dispose(): void;
  23733. /**
  23734. * Gets the name of the current physics plugin
  23735. * @returns the name of the plugin
  23736. */
  23737. getPhysicsPluginName(): string;
  23738. /**
  23739. * Adding a new impostor for the impostor tracking.
  23740. * This will be done by the impostor itself.
  23741. * @param impostor the impostor to add
  23742. */
  23743. addImpostor(impostor: PhysicsImpostor): void;
  23744. /**
  23745. * Remove an impostor from the engine.
  23746. * This impostor and its mesh will not longer be updated by the physics engine.
  23747. * @param impostor the impostor to remove
  23748. */
  23749. removeImpostor(impostor: PhysicsImpostor): void;
  23750. /**
  23751. * Add a joint to the physics engine
  23752. * @param mainImpostor defines the main impostor to which the joint is added.
  23753. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23754. * @param joint defines the joint that will connect both impostors.
  23755. */
  23756. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23757. /**
  23758. * Removes a joint from the simulation
  23759. * @param mainImpostor defines the impostor used with the joint
  23760. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23761. * @param joint defines the joint to remove
  23762. */
  23763. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23764. /**
  23765. * Gets the current plugin used to run the simulation
  23766. * @returns current plugin
  23767. */
  23768. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23769. /**
  23770. * Gets the list of physic impostors
  23771. * @returns an array of PhysicsImpostor
  23772. */
  23773. getImpostors(): Array<PhysicsImpostor>;
  23774. /**
  23775. * Gets the impostor for a physics enabled object
  23776. * @param object defines the object impersonated by the impostor
  23777. * @returns the PhysicsImpostor or null if not found
  23778. */
  23779. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23780. /**
  23781. * Gets the impostor for a physics body object
  23782. * @param body defines physics body used by the impostor
  23783. * @returns the PhysicsImpostor or null if not found
  23784. */
  23785. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23786. /**
  23787. * Does a raycast in the physics world
  23788. * @param from when should the ray start?
  23789. * @param to when should the ray end?
  23790. * @returns PhysicsRaycastResult
  23791. */
  23792. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23793. /**
  23794. * Called by the scene. No need to call it.
  23795. * @param delta defines the timespam between frames
  23796. */
  23797. _step(delta: number): void;
  23798. }
  23799. }
  23800. declare module "babylonjs/Physics/physicsImpostor" {
  23801. import { Nullable, IndicesArray } from "babylonjs/types";
  23802. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23803. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23805. import { Scene } from "babylonjs/scene";
  23806. import { Bone } from "babylonjs/Bones/bone";
  23807. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23808. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23809. import { Space } from "babylonjs/Maths/math.axis";
  23810. /**
  23811. * The interface for the physics imposter parameters
  23812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23813. */
  23814. export interface PhysicsImpostorParameters {
  23815. /**
  23816. * The mass of the physics imposter
  23817. */
  23818. mass: number;
  23819. /**
  23820. * The friction of the physics imposter
  23821. */
  23822. friction?: number;
  23823. /**
  23824. * The coefficient of restitution of the physics imposter
  23825. */
  23826. restitution?: number;
  23827. /**
  23828. * The native options of the physics imposter
  23829. */
  23830. nativeOptions?: any;
  23831. /**
  23832. * Specifies if the parent should be ignored
  23833. */
  23834. ignoreParent?: boolean;
  23835. /**
  23836. * Specifies if bi-directional transformations should be disabled
  23837. */
  23838. disableBidirectionalTransformation?: boolean;
  23839. /**
  23840. * The pressure inside the physics imposter, soft object only
  23841. */
  23842. pressure?: number;
  23843. /**
  23844. * The stiffness the physics imposter, soft object only
  23845. */
  23846. stiffness?: number;
  23847. /**
  23848. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23849. */
  23850. velocityIterations?: number;
  23851. /**
  23852. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23853. */
  23854. positionIterations?: number;
  23855. /**
  23856. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23857. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23858. * Add to fix multiple points
  23859. */
  23860. fixedPoints?: number;
  23861. /**
  23862. * The collision margin around a soft object
  23863. */
  23864. margin?: number;
  23865. /**
  23866. * The collision margin around a soft object
  23867. */
  23868. damping?: number;
  23869. /**
  23870. * The path for a rope based on an extrusion
  23871. */
  23872. path?: any;
  23873. /**
  23874. * The shape of an extrusion used for a rope based on an extrusion
  23875. */
  23876. shape?: any;
  23877. }
  23878. /**
  23879. * Interface for a physics-enabled object
  23880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23881. */
  23882. export interface IPhysicsEnabledObject {
  23883. /**
  23884. * The position of the physics-enabled object
  23885. */
  23886. position: Vector3;
  23887. /**
  23888. * The rotation of the physics-enabled object
  23889. */
  23890. rotationQuaternion: Nullable<Quaternion>;
  23891. /**
  23892. * The scale of the physics-enabled object
  23893. */
  23894. scaling: Vector3;
  23895. /**
  23896. * The rotation of the physics-enabled object
  23897. */
  23898. rotation?: Vector3;
  23899. /**
  23900. * The parent of the physics-enabled object
  23901. */
  23902. parent?: any;
  23903. /**
  23904. * The bounding info of the physics-enabled object
  23905. * @returns The bounding info of the physics-enabled object
  23906. */
  23907. getBoundingInfo(): BoundingInfo;
  23908. /**
  23909. * Computes the world matrix
  23910. * @param force Specifies if the world matrix should be computed by force
  23911. * @returns A world matrix
  23912. */
  23913. computeWorldMatrix(force: boolean): Matrix;
  23914. /**
  23915. * Gets the world matrix
  23916. * @returns A world matrix
  23917. */
  23918. getWorldMatrix?(): Matrix;
  23919. /**
  23920. * Gets the child meshes
  23921. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23922. * @returns An array of abstract meshes
  23923. */
  23924. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23925. /**
  23926. * Gets the vertex data
  23927. * @param kind The type of vertex data
  23928. * @returns A nullable array of numbers, or a float32 array
  23929. */
  23930. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23931. /**
  23932. * Gets the indices from the mesh
  23933. * @returns A nullable array of index arrays
  23934. */
  23935. getIndices?(): Nullable<IndicesArray>;
  23936. /**
  23937. * Gets the scene from the mesh
  23938. * @returns the indices array or null
  23939. */
  23940. getScene?(): Scene;
  23941. /**
  23942. * Gets the absolute position from the mesh
  23943. * @returns the absolute position
  23944. */
  23945. getAbsolutePosition(): Vector3;
  23946. /**
  23947. * Gets the absolute pivot point from the mesh
  23948. * @returns the absolute pivot point
  23949. */
  23950. getAbsolutePivotPoint(): Vector3;
  23951. /**
  23952. * Rotates the mesh
  23953. * @param axis The axis of rotation
  23954. * @param amount The amount of rotation
  23955. * @param space The space of the rotation
  23956. * @returns The rotation transform node
  23957. */
  23958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23959. /**
  23960. * Translates the mesh
  23961. * @param axis The axis of translation
  23962. * @param distance The distance of translation
  23963. * @param space The space of the translation
  23964. * @returns The transform node
  23965. */
  23966. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23967. /**
  23968. * Sets the absolute position of the mesh
  23969. * @param absolutePosition The absolute position of the mesh
  23970. * @returns The transform node
  23971. */
  23972. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23973. /**
  23974. * Gets the class name of the mesh
  23975. * @returns The class name
  23976. */
  23977. getClassName(): string;
  23978. }
  23979. /**
  23980. * Represents a physics imposter
  23981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23982. */
  23983. export class PhysicsImpostor {
  23984. /**
  23985. * The physics-enabled object used as the physics imposter
  23986. */
  23987. object: IPhysicsEnabledObject;
  23988. /**
  23989. * The type of the physics imposter
  23990. */
  23991. type: number;
  23992. private _options;
  23993. private _scene?;
  23994. /**
  23995. * The default object size of the imposter
  23996. */
  23997. static DEFAULT_OBJECT_SIZE: Vector3;
  23998. /**
  23999. * The identity quaternion of the imposter
  24000. */
  24001. static IDENTITY_QUATERNION: Quaternion;
  24002. /** @hidden */
  24003. _pluginData: any;
  24004. private _physicsEngine;
  24005. private _physicsBody;
  24006. private _bodyUpdateRequired;
  24007. private _onBeforePhysicsStepCallbacks;
  24008. private _onAfterPhysicsStepCallbacks;
  24009. /** @hidden */
  24010. _onPhysicsCollideCallbacks: Array<{
  24011. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24012. otherImpostors: Array<PhysicsImpostor>;
  24013. }>;
  24014. private _deltaPosition;
  24015. private _deltaRotation;
  24016. private _deltaRotationConjugated;
  24017. /** @hidden */
  24018. _isFromLine: boolean;
  24019. private _parent;
  24020. private _isDisposed;
  24021. private static _tmpVecs;
  24022. private static _tmpQuat;
  24023. /**
  24024. * Specifies if the physics imposter is disposed
  24025. */
  24026. readonly isDisposed: boolean;
  24027. /**
  24028. * Gets the mass of the physics imposter
  24029. */
  24030. mass: number;
  24031. /**
  24032. * Gets the coefficient of friction
  24033. */
  24034. /**
  24035. * Sets the coefficient of friction
  24036. */
  24037. friction: number;
  24038. /**
  24039. * Gets the coefficient of restitution
  24040. */
  24041. /**
  24042. * Sets the coefficient of restitution
  24043. */
  24044. restitution: number;
  24045. /**
  24046. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24047. */
  24048. /**
  24049. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24050. */
  24051. pressure: number;
  24052. /**
  24053. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24054. */
  24055. /**
  24056. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24057. */
  24058. stiffness: number;
  24059. /**
  24060. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24061. */
  24062. /**
  24063. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24064. */
  24065. velocityIterations: number;
  24066. /**
  24067. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24068. */
  24069. /**
  24070. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24071. */
  24072. positionIterations: number;
  24073. /**
  24074. * The unique id of the physics imposter
  24075. * set by the physics engine when adding this impostor to the array
  24076. */
  24077. uniqueId: number;
  24078. /**
  24079. * @hidden
  24080. */
  24081. soft: boolean;
  24082. /**
  24083. * @hidden
  24084. */
  24085. segments: number;
  24086. private _joints;
  24087. /**
  24088. * Initializes the physics imposter
  24089. * @param object The physics-enabled object used as the physics imposter
  24090. * @param type The type of the physics imposter
  24091. * @param _options The options for the physics imposter
  24092. * @param _scene The Babylon scene
  24093. */
  24094. constructor(
  24095. /**
  24096. * The physics-enabled object used as the physics imposter
  24097. */
  24098. object: IPhysicsEnabledObject,
  24099. /**
  24100. * The type of the physics imposter
  24101. */
  24102. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24103. /**
  24104. * This function will completly initialize this impostor.
  24105. * It will create a new body - but only if this mesh has no parent.
  24106. * If it has, this impostor will not be used other than to define the impostor
  24107. * of the child mesh.
  24108. * @hidden
  24109. */
  24110. _init(): void;
  24111. private _getPhysicsParent;
  24112. /**
  24113. * Should a new body be generated.
  24114. * @returns boolean specifying if body initialization is required
  24115. */
  24116. isBodyInitRequired(): boolean;
  24117. /**
  24118. * Sets the updated scaling
  24119. * @param updated Specifies if the scaling is updated
  24120. */
  24121. setScalingUpdated(): void;
  24122. /**
  24123. * Force a regeneration of this or the parent's impostor's body.
  24124. * Use under cautious - This will remove all joints already implemented.
  24125. */
  24126. forceUpdate(): void;
  24127. /**
  24128. * Gets the body that holds this impostor. Either its own, or its parent.
  24129. */
  24130. /**
  24131. * Set the physics body. Used mainly by the physics engine/plugin
  24132. */
  24133. physicsBody: any;
  24134. /**
  24135. * Get the parent of the physics imposter
  24136. * @returns Physics imposter or null
  24137. */
  24138. /**
  24139. * Sets the parent of the physics imposter
  24140. */
  24141. parent: Nullable<PhysicsImpostor>;
  24142. /**
  24143. * Resets the update flags
  24144. */
  24145. resetUpdateFlags(): void;
  24146. /**
  24147. * Gets the object extend size
  24148. * @returns the object extend size
  24149. */
  24150. getObjectExtendSize(): Vector3;
  24151. /**
  24152. * Gets the object center
  24153. * @returns The object center
  24154. */
  24155. getObjectCenter(): Vector3;
  24156. /**
  24157. * Get a specific parametes from the options parameter
  24158. * @param paramName The object parameter name
  24159. * @returns The object parameter
  24160. */
  24161. getParam(paramName: string): any;
  24162. /**
  24163. * Sets a specific parameter in the options given to the physics plugin
  24164. * @param paramName The parameter name
  24165. * @param value The value of the parameter
  24166. */
  24167. setParam(paramName: string, value: number): void;
  24168. /**
  24169. * Specifically change the body's mass option. Won't recreate the physics body object
  24170. * @param mass The mass of the physics imposter
  24171. */
  24172. setMass(mass: number): void;
  24173. /**
  24174. * Gets the linear velocity
  24175. * @returns linear velocity or null
  24176. */
  24177. getLinearVelocity(): Nullable<Vector3>;
  24178. /**
  24179. * Sets the linear velocity
  24180. * @param velocity linear velocity or null
  24181. */
  24182. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24183. /**
  24184. * Gets the angular velocity
  24185. * @returns angular velocity or null
  24186. */
  24187. getAngularVelocity(): Nullable<Vector3>;
  24188. /**
  24189. * Sets the angular velocity
  24190. * @param velocity The velocity or null
  24191. */
  24192. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24193. /**
  24194. * Execute a function with the physics plugin native code
  24195. * Provide a function the will have two variables - the world object and the physics body object
  24196. * @param func The function to execute with the physics plugin native code
  24197. */
  24198. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24199. /**
  24200. * Register a function that will be executed before the physics world is stepping forward
  24201. * @param func The function to execute before the physics world is stepped forward
  24202. */
  24203. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24204. /**
  24205. * Unregister a function that will be executed before the physics world is stepping forward
  24206. * @param func The function to execute before the physics world is stepped forward
  24207. */
  24208. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24209. /**
  24210. * Register a function that will be executed after the physics step
  24211. * @param func The function to execute after physics step
  24212. */
  24213. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24214. /**
  24215. * Unregisters a function that will be executed after the physics step
  24216. * @param func The function to execute after physics step
  24217. */
  24218. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24219. /**
  24220. * register a function that will be executed when this impostor collides against a different body
  24221. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24222. * @param func Callback that is executed on collision
  24223. */
  24224. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24225. /**
  24226. * Unregisters the physics imposter on contact
  24227. * @param collideAgainst The physics object to collide against
  24228. * @param func Callback to execute on collision
  24229. */
  24230. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24231. private _tmpQuat;
  24232. private _tmpQuat2;
  24233. /**
  24234. * Get the parent rotation
  24235. * @returns The parent rotation
  24236. */
  24237. getParentsRotation(): Quaternion;
  24238. /**
  24239. * this function is executed by the physics engine.
  24240. */
  24241. beforeStep: () => void;
  24242. /**
  24243. * this function is executed by the physics engine
  24244. */
  24245. afterStep: () => void;
  24246. /**
  24247. * Legacy collision detection event support
  24248. */
  24249. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24250. /**
  24251. * event and body object due to cannon's event-based architecture.
  24252. */
  24253. onCollide: (e: {
  24254. body: any;
  24255. }) => void;
  24256. /**
  24257. * Apply a force
  24258. * @param force The force to apply
  24259. * @param contactPoint The contact point for the force
  24260. * @returns The physics imposter
  24261. */
  24262. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24263. /**
  24264. * Apply an impulse
  24265. * @param force The impulse force
  24266. * @param contactPoint The contact point for the impulse force
  24267. * @returns The physics imposter
  24268. */
  24269. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24270. /**
  24271. * A help function to create a joint
  24272. * @param otherImpostor A physics imposter used to create a joint
  24273. * @param jointType The type of joint
  24274. * @param jointData The data for the joint
  24275. * @returns The physics imposter
  24276. */
  24277. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24278. /**
  24279. * Add a joint to this impostor with a different impostor
  24280. * @param otherImpostor A physics imposter used to add a joint
  24281. * @param joint The joint to add
  24282. * @returns The physics imposter
  24283. */
  24284. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24285. /**
  24286. * Add an anchor to a cloth impostor
  24287. * @param otherImpostor rigid impostor to anchor to
  24288. * @param width ratio across width from 0 to 1
  24289. * @param height ratio up height from 0 to 1
  24290. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24291. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24292. * @returns impostor the soft imposter
  24293. */
  24294. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24295. /**
  24296. * Add a hook to a rope impostor
  24297. * @param otherImpostor rigid impostor to anchor to
  24298. * @param length ratio across rope from 0 to 1
  24299. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24300. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24301. * @returns impostor the rope imposter
  24302. */
  24303. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24304. /**
  24305. * Will keep this body still, in a sleep mode.
  24306. * @returns the physics imposter
  24307. */
  24308. sleep(): PhysicsImpostor;
  24309. /**
  24310. * Wake the body up.
  24311. * @returns The physics imposter
  24312. */
  24313. wakeUp(): PhysicsImpostor;
  24314. /**
  24315. * Clones the physics imposter
  24316. * @param newObject The physics imposter clones to this physics-enabled object
  24317. * @returns A nullable physics imposter
  24318. */
  24319. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24320. /**
  24321. * Disposes the physics imposter
  24322. */
  24323. dispose(): void;
  24324. /**
  24325. * Sets the delta position
  24326. * @param position The delta position amount
  24327. */
  24328. setDeltaPosition(position: Vector3): void;
  24329. /**
  24330. * Sets the delta rotation
  24331. * @param rotation The delta rotation amount
  24332. */
  24333. setDeltaRotation(rotation: Quaternion): void;
  24334. /**
  24335. * Gets the box size of the physics imposter and stores the result in the input parameter
  24336. * @param result Stores the box size
  24337. * @returns The physics imposter
  24338. */
  24339. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24340. /**
  24341. * Gets the radius of the physics imposter
  24342. * @returns Radius of the physics imposter
  24343. */
  24344. getRadius(): number;
  24345. /**
  24346. * Sync a bone with this impostor
  24347. * @param bone The bone to sync to the impostor.
  24348. * @param boneMesh The mesh that the bone is influencing.
  24349. * @param jointPivot The pivot of the joint / bone in local space.
  24350. * @param distToJoint Optional distance from the impostor to the joint.
  24351. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24352. */
  24353. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24354. /**
  24355. * Sync impostor to a bone
  24356. * @param bone The bone that the impostor will be synced to.
  24357. * @param boneMesh The mesh that the bone is influencing.
  24358. * @param jointPivot The pivot of the joint / bone in local space.
  24359. * @param distToJoint Optional distance from the impostor to the joint.
  24360. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24361. * @param boneAxis Optional vector3 axis the bone is aligned with
  24362. */
  24363. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24364. /**
  24365. * No-Imposter type
  24366. */
  24367. static NoImpostor: number;
  24368. /**
  24369. * Sphere-Imposter type
  24370. */
  24371. static SphereImpostor: number;
  24372. /**
  24373. * Box-Imposter type
  24374. */
  24375. static BoxImpostor: number;
  24376. /**
  24377. * Plane-Imposter type
  24378. */
  24379. static PlaneImpostor: number;
  24380. /**
  24381. * Mesh-imposter type
  24382. */
  24383. static MeshImpostor: number;
  24384. /**
  24385. * Capsule-Impostor type (Ammo.js plugin only)
  24386. */
  24387. static CapsuleImpostor: number;
  24388. /**
  24389. * Cylinder-Imposter type
  24390. */
  24391. static CylinderImpostor: number;
  24392. /**
  24393. * Particle-Imposter type
  24394. */
  24395. static ParticleImpostor: number;
  24396. /**
  24397. * Heightmap-Imposter type
  24398. */
  24399. static HeightmapImpostor: number;
  24400. /**
  24401. * ConvexHull-Impostor type (Ammo.js plugin only)
  24402. */
  24403. static ConvexHullImpostor: number;
  24404. /**
  24405. * Rope-Imposter type
  24406. */
  24407. static RopeImpostor: number;
  24408. /**
  24409. * Cloth-Imposter type
  24410. */
  24411. static ClothImpostor: number;
  24412. /**
  24413. * Softbody-Imposter type
  24414. */
  24415. static SoftbodyImpostor: number;
  24416. }
  24417. }
  24418. declare module "babylonjs/Meshes/mesh" {
  24419. import { Observable } from "babylonjs/Misc/observable";
  24420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24421. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24422. import { Camera } from "babylonjs/Cameras/camera";
  24423. import { Scene } from "babylonjs/scene";
  24424. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24425. import { Color4 } from "babylonjs/Maths/math.color";
  24426. import { Engine } from "babylonjs/Engines/engine";
  24427. import { Node } from "babylonjs/node";
  24428. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24429. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24430. import { Buffer } from "babylonjs/Meshes/buffer";
  24431. import { Geometry } from "babylonjs/Meshes/geometry";
  24432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24434. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24435. import { Effect } from "babylonjs/Materials/effect";
  24436. import { Material } from "babylonjs/Materials/material";
  24437. import { Skeleton } from "babylonjs/Bones/skeleton";
  24438. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24439. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24440. import { Path3D } from "babylonjs/Maths/math.path";
  24441. import { Plane } from "babylonjs/Maths/math.plane";
  24442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24443. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24444. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24445. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24446. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24447. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24448. /**
  24449. * @hidden
  24450. **/
  24451. export class _CreationDataStorage {
  24452. closePath?: boolean;
  24453. closeArray?: boolean;
  24454. idx: number[];
  24455. dashSize: number;
  24456. gapSize: number;
  24457. path3D: Path3D;
  24458. pathArray: Vector3[][];
  24459. arc: number;
  24460. radius: number;
  24461. cap: number;
  24462. tessellation: number;
  24463. }
  24464. /**
  24465. * @hidden
  24466. **/
  24467. class _InstanceDataStorage {
  24468. visibleInstances: any;
  24469. batchCache: _InstancesBatch;
  24470. instancesBufferSize: number;
  24471. instancesBuffer: Nullable<Buffer>;
  24472. instancesData: Float32Array;
  24473. overridenInstanceCount: number;
  24474. isFrozen: boolean;
  24475. previousBatch: Nullable<_InstancesBatch>;
  24476. hardwareInstancedRendering: boolean;
  24477. sideOrientation: number;
  24478. manualUpdate: boolean;
  24479. }
  24480. /**
  24481. * @hidden
  24482. **/
  24483. export class _InstancesBatch {
  24484. mustReturn: boolean;
  24485. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24486. renderSelf: boolean[];
  24487. hardwareInstancedRendering: boolean[];
  24488. }
  24489. /**
  24490. * Class used to represent renderable models
  24491. */
  24492. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24493. /**
  24494. * Mesh side orientation : usually the external or front surface
  24495. */
  24496. static readonly FRONTSIDE: number;
  24497. /**
  24498. * Mesh side orientation : usually the internal or back surface
  24499. */
  24500. static readonly BACKSIDE: number;
  24501. /**
  24502. * Mesh side orientation : both internal and external or front and back surfaces
  24503. */
  24504. static readonly DOUBLESIDE: number;
  24505. /**
  24506. * Mesh side orientation : by default, `FRONTSIDE`
  24507. */
  24508. static readonly DEFAULTSIDE: number;
  24509. /**
  24510. * Mesh cap setting : no cap
  24511. */
  24512. static readonly NO_CAP: number;
  24513. /**
  24514. * Mesh cap setting : one cap at the beginning of the mesh
  24515. */
  24516. static readonly CAP_START: number;
  24517. /**
  24518. * Mesh cap setting : one cap at the end of the mesh
  24519. */
  24520. static readonly CAP_END: number;
  24521. /**
  24522. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24523. */
  24524. static readonly CAP_ALL: number;
  24525. /**
  24526. * Mesh pattern setting : no flip or rotate
  24527. */
  24528. static readonly NO_FLIP: number;
  24529. /**
  24530. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24531. */
  24532. static readonly FLIP_TILE: number;
  24533. /**
  24534. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24535. */
  24536. static readonly ROTATE_TILE: number;
  24537. /**
  24538. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24539. */
  24540. static readonly FLIP_ROW: number;
  24541. /**
  24542. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24543. */
  24544. static readonly ROTATE_ROW: number;
  24545. /**
  24546. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24547. */
  24548. static readonly FLIP_N_ROTATE_TILE: number;
  24549. /**
  24550. * Mesh pattern setting : rotate pattern and rotate
  24551. */
  24552. static readonly FLIP_N_ROTATE_ROW: number;
  24553. /**
  24554. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24555. */
  24556. static readonly CENTER: number;
  24557. /**
  24558. * Mesh tile positioning : part tiles on left
  24559. */
  24560. static readonly LEFT: number;
  24561. /**
  24562. * Mesh tile positioning : part tiles on right
  24563. */
  24564. static readonly RIGHT: number;
  24565. /**
  24566. * Mesh tile positioning : part tiles on top
  24567. */
  24568. static readonly TOP: number;
  24569. /**
  24570. * Mesh tile positioning : part tiles on bottom
  24571. */
  24572. static readonly BOTTOM: number;
  24573. /**
  24574. * Gets the default side orientation.
  24575. * @param orientation the orientation to value to attempt to get
  24576. * @returns the default orientation
  24577. * @hidden
  24578. */
  24579. static _GetDefaultSideOrientation(orientation?: number): number;
  24580. private _internalMeshDataInfo;
  24581. /**
  24582. * An event triggered before rendering the mesh
  24583. */
  24584. readonly onBeforeRenderObservable: Observable<Mesh>;
  24585. /**
  24586. * An event triggered before binding the mesh
  24587. */
  24588. readonly onBeforeBindObservable: Observable<Mesh>;
  24589. /**
  24590. * An event triggered after rendering the mesh
  24591. */
  24592. readonly onAfterRenderObservable: Observable<Mesh>;
  24593. /**
  24594. * An event triggered before drawing the mesh
  24595. */
  24596. readonly onBeforeDrawObservable: Observable<Mesh>;
  24597. private _onBeforeDrawObserver;
  24598. /**
  24599. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24600. */
  24601. onBeforeDraw: () => void;
  24602. readonly hasInstances: boolean;
  24603. /**
  24604. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24605. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24606. */
  24607. delayLoadState: number;
  24608. /**
  24609. * Gets the list of instances created from this mesh
  24610. * it is not supposed to be modified manually.
  24611. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24613. */
  24614. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24615. /**
  24616. * Gets the file containing delay loading data for this mesh
  24617. */
  24618. delayLoadingFile: string;
  24619. /** @hidden */
  24620. _binaryInfo: any;
  24621. /**
  24622. * User defined function used to change how LOD level selection is done
  24623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24624. */
  24625. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24626. /**
  24627. * Gets or sets the morph target manager
  24628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24629. */
  24630. morphTargetManager: Nullable<MorphTargetManager>;
  24631. /** @hidden */
  24632. _creationDataStorage: Nullable<_CreationDataStorage>;
  24633. /** @hidden */
  24634. _geometry: Nullable<Geometry>;
  24635. /** @hidden */
  24636. _delayInfo: Array<string>;
  24637. /** @hidden */
  24638. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24639. /** @hidden */
  24640. _instanceDataStorage: _InstanceDataStorage;
  24641. private _effectiveMaterial;
  24642. /** @hidden */
  24643. _shouldGenerateFlatShading: boolean;
  24644. /** @hidden */
  24645. _originalBuilderSideOrientation: number;
  24646. /**
  24647. * Use this property to change the original side orientation defined at construction time
  24648. */
  24649. overrideMaterialSideOrientation: Nullable<number>;
  24650. /**
  24651. * Gets the source mesh (the one used to clone this one from)
  24652. */
  24653. readonly source: Nullable<Mesh>;
  24654. /**
  24655. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24656. */
  24657. isUnIndexed: boolean;
  24658. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24659. readonly worldMatrixInstancedBuffer: Float32Array;
  24660. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24661. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24662. /**
  24663. * @constructor
  24664. * @param name The value used by scene.getMeshByName() to do a lookup.
  24665. * @param scene The scene to add this mesh to.
  24666. * @param parent The parent of this mesh, if it has one
  24667. * @param source An optional Mesh from which geometry is shared, cloned.
  24668. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24669. * When false, achieved by calling a clone(), also passing False.
  24670. * This will make creation of children, recursive.
  24671. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24672. */
  24673. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24674. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24675. doNotInstantiate: boolean;
  24676. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24677. /**
  24678. * Gets the class name
  24679. * @returns the string "Mesh".
  24680. */
  24681. getClassName(): string;
  24682. /** @hidden */
  24683. readonly _isMesh: boolean;
  24684. /**
  24685. * Returns a description of this mesh
  24686. * @param fullDetails define if full details about this mesh must be used
  24687. * @returns a descriptive string representing this mesh
  24688. */
  24689. toString(fullDetails?: boolean): string;
  24690. /** @hidden */
  24691. _unBindEffect(): void;
  24692. /**
  24693. * Gets a boolean indicating if this mesh has LOD
  24694. */
  24695. readonly hasLODLevels: boolean;
  24696. /**
  24697. * Gets the list of MeshLODLevel associated with the current mesh
  24698. * @returns an array of MeshLODLevel
  24699. */
  24700. getLODLevels(): MeshLODLevel[];
  24701. private _sortLODLevels;
  24702. /**
  24703. * Add a mesh as LOD level triggered at the given distance.
  24704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24705. * @param distance The distance from the center of the object to show this level
  24706. * @param mesh The mesh to be added as LOD level (can be null)
  24707. * @return This mesh (for chaining)
  24708. */
  24709. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24710. /**
  24711. * Returns the LOD level mesh at the passed distance or null if not found.
  24712. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24713. * @param distance The distance from the center of the object to show this level
  24714. * @returns a Mesh or `null`
  24715. */
  24716. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24717. /**
  24718. * Remove a mesh from the LOD array
  24719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24720. * @param mesh defines the mesh to be removed
  24721. * @return This mesh (for chaining)
  24722. */
  24723. removeLODLevel(mesh: Mesh): Mesh;
  24724. /**
  24725. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24727. * @param camera defines the camera to use to compute distance
  24728. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24729. * @return This mesh (for chaining)
  24730. */
  24731. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24732. /**
  24733. * Gets the mesh internal Geometry object
  24734. */
  24735. readonly geometry: Nullable<Geometry>;
  24736. /**
  24737. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24738. * @returns the total number of vertices
  24739. */
  24740. getTotalVertices(): number;
  24741. /**
  24742. * Returns the content of an associated vertex buffer
  24743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24744. * - VertexBuffer.PositionKind
  24745. * - VertexBuffer.UVKind
  24746. * - VertexBuffer.UV2Kind
  24747. * - VertexBuffer.UV3Kind
  24748. * - VertexBuffer.UV4Kind
  24749. * - VertexBuffer.UV5Kind
  24750. * - VertexBuffer.UV6Kind
  24751. * - VertexBuffer.ColorKind
  24752. * - VertexBuffer.MatricesIndicesKind
  24753. * - VertexBuffer.MatricesIndicesExtraKind
  24754. * - VertexBuffer.MatricesWeightsKind
  24755. * - VertexBuffer.MatricesWeightsExtraKind
  24756. * @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
  24757. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24758. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24759. */
  24760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24761. /**
  24762. * Returns the mesh VertexBuffer object from the requested `kind`
  24763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24764. * - VertexBuffer.PositionKind
  24765. * - VertexBuffer.NormalKind
  24766. * - VertexBuffer.UVKind
  24767. * - VertexBuffer.UV2Kind
  24768. * - VertexBuffer.UV3Kind
  24769. * - VertexBuffer.UV4Kind
  24770. * - VertexBuffer.UV5Kind
  24771. * - VertexBuffer.UV6Kind
  24772. * - VertexBuffer.ColorKind
  24773. * - VertexBuffer.MatricesIndicesKind
  24774. * - VertexBuffer.MatricesIndicesExtraKind
  24775. * - VertexBuffer.MatricesWeightsKind
  24776. * - VertexBuffer.MatricesWeightsExtraKind
  24777. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24778. */
  24779. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24780. /**
  24781. * Tests if a specific vertex buffer is associated with this mesh
  24782. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24783. * - VertexBuffer.PositionKind
  24784. * - VertexBuffer.NormalKind
  24785. * - VertexBuffer.UVKind
  24786. * - VertexBuffer.UV2Kind
  24787. * - VertexBuffer.UV3Kind
  24788. * - VertexBuffer.UV4Kind
  24789. * - VertexBuffer.UV5Kind
  24790. * - VertexBuffer.UV6Kind
  24791. * - VertexBuffer.ColorKind
  24792. * - VertexBuffer.MatricesIndicesKind
  24793. * - VertexBuffer.MatricesIndicesExtraKind
  24794. * - VertexBuffer.MatricesWeightsKind
  24795. * - VertexBuffer.MatricesWeightsExtraKind
  24796. * @returns a boolean
  24797. */
  24798. isVerticesDataPresent(kind: string): boolean;
  24799. /**
  24800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24801. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24802. * - VertexBuffer.PositionKind
  24803. * - VertexBuffer.UVKind
  24804. * - VertexBuffer.UV2Kind
  24805. * - VertexBuffer.UV3Kind
  24806. * - VertexBuffer.UV4Kind
  24807. * - VertexBuffer.UV5Kind
  24808. * - VertexBuffer.UV6Kind
  24809. * - VertexBuffer.ColorKind
  24810. * - VertexBuffer.MatricesIndicesKind
  24811. * - VertexBuffer.MatricesIndicesExtraKind
  24812. * - VertexBuffer.MatricesWeightsKind
  24813. * - VertexBuffer.MatricesWeightsExtraKind
  24814. * @returns a boolean
  24815. */
  24816. isVertexBufferUpdatable(kind: string): boolean;
  24817. /**
  24818. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24819. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24820. * - VertexBuffer.PositionKind
  24821. * - VertexBuffer.NormalKind
  24822. * - VertexBuffer.UVKind
  24823. * - VertexBuffer.UV2Kind
  24824. * - VertexBuffer.UV3Kind
  24825. * - VertexBuffer.UV4Kind
  24826. * - VertexBuffer.UV5Kind
  24827. * - VertexBuffer.UV6Kind
  24828. * - VertexBuffer.ColorKind
  24829. * - VertexBuffer.MatricesIndicesKind
  24830. * - VertexBuffer.MatricesIndicesExtraKind
  24831. * - VertexBuffer.MatricesWeightsKind
  24832. * - VertexBuffer.MatricesWeightsExtraKind
  24833. * @returns an array of strings
  24834. */
  24835. getVerticesDataKinds(): string[];
  24836. /**
  24837. * Returns a positive integer : the total number of indices in this mesh geometry.
  24838. * @returns the numner of indices or zero if the mesh has no geometry.
  24839. */
  24840. getTotalIndices(): number;
  24841. /**
  24842. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24843. * @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.
  24844. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24845. * @returns the indices array or an empty array if the mesh has no geometry
  24846. */
  24847. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24848. readonly isBlocked: boolean;
  24849. /**
  24850. * Determine if the current mesh is ready to be rendered
  24851. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24852. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24853. * @returns true if all associated assets are ready (material, textures, shaders)
  24854. */
  24855. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24856. /**
  24857. * 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.
  24858. */
  24859. readonly areNormalsFrozen: boolean;
  24860. /**
  24861. * 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.
  24862. * @returns the current mesh
  24863. */
  24864. freezeNormals(): Mesh;
  24865. /**
  24866. * 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
  24867. * @returns the current mesh
  24868. */
  24869. unfreezeNormals(): Mesh;
  24870. /**
  24871. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24872. */
  24873. overridenInstanceCount: number;
  24874. /** @hidden */
  24875. _preActivate(): Mesh;
  24876. /** @hidden */
  24877. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24878. /** @hidden */
  24879. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24880. /**
  24881. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24882. * This means the mesh underlying bounding box and sphere are recomputed.
  24883. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24884. * @returns the current mesh
  24885. */
  24886. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24887. /** @hidden */
  24888. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24889. /**
  24890. * This function will subdivide the mesh into multiple submeshes
  24891. * @param count defines the expected number of submeshes
  24892. */
  24893. subdivide(count: number): void;
  24894. /**
  24895. * Copy a FloatArray into a specific associated vertex buffer
  24896. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24897. * - VertexBuffer.PositionKind
  24898. * - VertexBuffer.UVKind
  24899. * - VertexBuffer.UV2Kind
  24900. * - VertexBuffer.UV3Kind
  24901. * - VertexBuffer.UV4Kind
  24902. * - VertexBuffer.UV5Kind
  24903. * - VertexBuffer.UV6Kind
  24904. * - VertexBuffer.ColorKind
  24905. * - VertexBuffer.MatricesIndicesKind
  24906. * - VertexBuffer.MatricesIndicesExtraKind
  24907. * - VertexBuffer.MatricesWeightsKind
  24908. * - VertexBuffer.MatricesWeightsExtraKind
  24909. * @param data defines the data source
  24910. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24911. * @param stride defines the data stride size (can be null)
  24912. * @returns the current mesh
  24913. */
  24914. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24915. /**
  24916. * Delete a vertex buffer associated with this mesh
  24917. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24918. * - VertexBuffer.PositionKind
  24919. * - VertexBuffer.UVKind
  24920. * - VertexBuffer.UV2Kind
  24921. * - VertexBuffer.UV3Kind
  24922. * - VertexBuffer.UV4Kind
  24923. * - VertexBuffer.UV5Kind
  24924. * - VertexBuffer.UV6Kind
  24925. * - VertexBuffer.ColorKind
  24926. * - VertexBuffer.MatricesIndicesKind
  24927. * - VertexBuffer.MatricesIndicesExtraKind
  24928. * - VertexBuffer.MatricesWeightsKind
  24929. * - VertexBuffer.MatricesWeightsExtraKind
  24930. */
  24931. removeVerticesData(kind: string): void;
  24932. /**
  24933. * Flags an associated vertex buffer as updatable
  24934. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24935. * - VertexBuffer.PositionKind
  24936. * - VertexBuffer.UVKind
  24937. * - VertexBuffer.UV2Kind
  24938. * - VertexBuffer.UV3Kind
  24939. * - VertexBuffer.UV4Kind
  24940. * - VertexBuffer.UV5Kind
  24941. * - VertexBuffer.UV6Kind
  24942. * - VertexBuffer.ColorKind
  24943. * - VertexBuffer.MatricesIndicesKind
  24944. * - VertexBuffer.MatricesIndicesExtraKind
  24945. * - VertexBuffer.MatricesWeightsKind
  24946. * - VertexBuffer.MatricesWeightsExtraKind
  24947. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24948. */
  24949. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24950. /**
  24951. * Sets the mesh global Vertex Buffer
  24952. * @param buffer defines the buffer to use
  24953. * @returns the current mesh
  24954. */
  24955. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24956. /**
  24957. * Update a specific associated vertex buffer
  24958. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24959. * - VertexBuffer.PositionKind
  24960. * - VertexBuffer.UVKind
  24961. * - VertexBuffer.UV2Kind
  24962. * - VertexBuffer.UV3Kind
  24963. * - VertexBuffer.UV4Kind
  24964. * - VertexBuffer.UV5Kind
  24965. * - VertexBuffer.UV6Kind
  24966. * - VertexBuffer.ColorKind
  24967. * - VertexBuffer.MatricesIndicesKind
  24968. * - VertexBuffer.MatricesIndicesExtraKind
  24969. * - VertexBuffer.MatricesWeightsKind
  24970. * - VertexBuffer.MatricesWeightsExtraKind
  24971. * @param data defines the data source
  24972. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24973. * @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)
  24974. * @returns the current mesh
  24975. */
  24976. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24977. /**
  24978. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24979. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24980. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24981. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24982. * @returns the current mesh
  24983. */
  24984. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24985. /**
  24986. * Creates a un-shared specific occurence of the geometry for the mesh.
  24987. * @returns the current mesh
  24988. */
  24989. makeGeometryUnique(): Mesh;
  24990. /**
  24991. * Set the index buffer of this mesh
  24992. * @param indices defines the source data
  24993. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24994. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24995. * @returns the current mesh
  24996. */
  24997. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24998. /**
  24999. * Update the current index buffer
  25000. * @param indices defines the source data
  25001. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25002. * @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)
  25003. * @returns the current mesh
  25004. */
  25005. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25006. /**
  25007. * Invert the geometry to move from a right handed system to a left handed one.
  25008. * @returns the current mesh
  25009. */
  25010. toLeftHanded(): Mesh;
  25011. /** @hidden */
  25012. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25013. /** @hidden */
  25014. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25015. /**
  25016. * Registers for this mesh a javascript function called just before the rendering process
  25017. * @param func defines the function to call before rendering this mesh
  25018. * @returns the current mesh
  25019. */
  25020. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25021. /**
  25022. * Disposes a previously registered javascript function called before the rendering
  25023. * @param func defines the function to remove
  25024. * @returns the current mesh
  25025. */
  25026. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25027. /**
  25028. * Registers for this mesh a javascript function called just after the rendering is complete
  25029. * @param func defines the function to call after rendering this mesh
  25030. * @returns the current mesh
  25031. */
  25032. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25033. /**
  25034. * Disposes a previously registered javascript function called after the rendering.
  25035. * @param func defines the function to remove
  25036. * @returns the current mesh
  25037. */
  25038. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25039. /** @hidden */
  25040. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25041. /** @hidden */
  25042. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25043. /** @hidden */
  25044. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25045. /** @hidden */
  25046. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25047. /** @hidden */
  25048. _rebuild(): void;
  25049. /** @hidden */
  25050. _freeze(): void;
  25051. /** @hidden */
  25052. _unFreeze(): void;
  25053. /**
  25054. * 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
  25055. * @param subMesh defines the subMesh to render
  25056. * @param enableAlphaMode defines if alpha mode can be changed
  25057. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25058. * @returns the current mesh
  25059. */
  25060. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25061. private _onBeforeDraw;
  25062. /**
  25063. * Renormalize the mesh and patch it up if there are no weights
  25064. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25065. * However in the case of zero weights then we set just a single influence to 1.
  25066. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25067. */
  25068. cleanMatrixWeights(): void;
  25069. private normalizeSkinFourWeights;
  25070. private normalizeSkinWeightsAndExtra;
  25071. /**
  25072. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25073. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25074. * the user know there was an issue with importing the mesh
  25075. * @returns a validation object with skinned, valid and report string
  25076. */
  25077. validateSkinning(): {
  25078. skinned: boolean;
  25079. valid: boolean;
  25080. report: string;
  25081. };
  25082. /** @hidden */
  25083. _checkDelayState(): Mesh;
  25084. private _queueLoad;
  25085. /**
  25086. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25087. * A mesh is in the frustum if its bounding box intersects the frustum
  25088. * @param frustumPlanes defines the frustum to test
  25089. * @returns true if the mesh is in the frustum planes
  25090. */
  25091. isInFrustum(frustumPlanes: Plane[]): boolean;
  25092. /**
  25093. * Sets the mesh material by the material or multiMaterial `id` property
  25094. * @param id is a string identifying the material or the multiMaterial
  25095. * @returns the current mesh
  25096. */
  25097. setMaterialByID(id: string): Mesh;
  25098. /**
  25099. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25100. * @returns an array of IAnimatable
  25101. */
  25102. getAnimatables(): IAnimatable[];
  25103. /**
  25104. * Modifies the mesh geometry according to the passed transformation matrix.
  25105. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25106. * The mesh normals are modified using the same transformation.
  25107. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25108. * @param transform defines the transform matrix to use
  25109. * @see http://doc.babylonjs.com/resources/baking_transformations
  25110. * @returns the current mesh
  25111. */
  25112. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25113. /**
  25114. * Modifies the mesh geometry according to its own current World Matrix.
  25115. * The mesh World Matrix is then reset.
  25116. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25117. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25118. * @see http://doc.babylonjs.com/resources/baking_transformations
  25119. * @returns the current mesh
  25120. */
  25121. bakeCurrentTransformIntoVertices(): Mesh;
  25122. /** @hidden */
  25123. readonly _positions: Nullable<Vector3[]>;
  25124. /** @hidden */
  25125. _resetPointsArrayCache(): Mesh;
  25126. /** @hidden */
  25127. _generatePointsArray(): boolean;
  25128. /**
  25129. * Returns a new Mesh object generated from the current mesh properties.
  25130. * This method must not get confused with createInstance()
  25131. * @param name is a string, the name given to the new mesh
  25132. * @param newParent can be any Node object (default `null`)
  25133. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25134. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25135. * @returns a new mesh
  25136. */
  25137. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25138. /**
  25139. * Releases resources associated with this mesh.
  25140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25142. */
  25143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25144. /** @hidden */
  25145. _disposeInstanceSpecificData(): void;
  25146. /**
  25147. * Modifies the mesh geometry according to a displacement map.
  25148. * 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.
  25149. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25150. * @param url is a string, the URL from the image file is to be downloaded.
  25151. * @param minHeight is the lower limit of the displacement.
  25152. * @param maxHeight is the upper limit of the displacement.
  25153. * @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.
  25154. * @param uvOffset is an optional vector2 used to offset UV.
  25155. * @param uvScale is an optional vector2 used to scale UV.
  25156. * @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.
  25157. * @returns the Mesh.
  25158. */
  25159. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25160. /**
  25161. * Modifies the mesh geometry according to a displacementMap buffer.
  25162. * 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.
  25163. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25164. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25165. * @param heightMapWidth is the width of the buffer image.
  25166. * @param heightMapHeight is the height of the buffer image.
  25167. * @param minHeight is the lower limit of the displacement.
  25168. * @param maxHeight is the upper limit of the displacement.
  25169. * @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.
  25170. * @param uvOffset is an optional vector2 used to offset UV.
  25171. * @param uvScale is an optional vector2 used to scale UV.
  25172. * @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.
  25173. * @returns the Mesh.
  25174. */
  25175. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25176. /**
  25177. * Modify the mesh to get a flat shading rendering.
  25178. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25179. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25180. * @returns current mesh
  25181. */
  25182. convertToFlatShadedMesh(): Mesh;
  25183. /**
  25184. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25185. * In other words, more vertices, no more indices and a single bigger VBO.
  25186. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25187. * @returns current mesh
  25188. */
  25189. convertToUnIndexedMesh(): Mesh;
  25190. /**
  25191. * Inverses facet orientations.
  25192. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25193. * @param flipNormals will also inverts the normals
  25194. * @returns current mesh
  25195. */
  25196. flipFaces(flipNormals?: boolean): Mesh;
  25197. /**
  25198. * Increase the number of facets and hence vertices in a mesh
  25199. * Vertex normals are interpolated from existing vertex normals
  25200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25201. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25202. */
  25203. increaseVertices(numberPerEdge: number): void;
  25204. /**
  25205. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25206. * This will undo any application of covertToFlatShadedMesh
  25207. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25208. */
  25209. forceSharedVertices(): void;
  25210. /** @hidden */
  25211. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25212. /** @hidden */
  25213. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25214. /**
  25215. * Creates a new InstancedMesh object from the mesh model.
  25216. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25217. * @param name defines the name of the new instance
  25218. * @returns a new InstancedMesh
  25219. */
  25220. createInstance(name: string): InstancedMesh;
  25221. /**
  25222. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25223. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25224. * @returns the current mesh
  25225. */
  25226. synchronizeInstances(): Mesh;
  25227. /**
  25228. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25229. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25230. * This should be used together with the simplification to avoid disappearing triangles.
  25231. * @param successCallback an optional success callback to be called after the optimization finished.
  25232. * @returns the current mesh
  25233. */
  25234. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25235. /**
  25236. * Serialize current mesh
  25237. * @param serializationObject defines the object which will receive the serialization data
  25238. */
  25239. serialize(serializationObject: any): void;
  25240. /** @hidden */
  25241. _syncGeometryWithMorphTargetManager(): void;
  25242. /** @hidden */
  25243. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25244. /**
  25245. * Returns a new Mesh object parsed from the source provided.
  25246. * @param parsedMesh is the source
  25247. * @param scene defines the hosting scene
  25248. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25249. * @returns a new Mesh
  25250. */
  25251. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25252. /**
  25253. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25254. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25255. * @param name defines the name of the mesh to create
  25256. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25257. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25258. * @param closePath creates a seam between the first and the last points of each path of the path array
  25259. * @param offset is taken in account only if the `pathArray` is containing a single path
  25260. * @param scene defines the hosting scene
  25261. * @param updatable defines if the mesh must be flagged as updatable
  25262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25263. * @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)
  25264. * @returns a new Mesh
  25265. */
  25266. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25267. /**
  25268. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25269. * @param name defines the name of the mesh to create
  25270. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25271. * @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
  25272. * @param scene defines the hosting scene
  25273. * @param updatable defines if the mesh must be flagged as updatable
  25274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25275. * @returns a new Mesh
  25276. */
  25277. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25278. /**
  25279. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25280. * @param name defines the name of the mesh to create
  25281. * @param size sets the size (float) of each box side (default 1)
  25282. * @param scene defines the hosting scene
  25283. * @param updatable defines if the mesh must be flagged as updatable
  25284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25285. * @returns a new Mesh
  25286. */
  25287. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25288. /**
  25289. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25290. * @param name defines the name of the mesh to create
  25291. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25292. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25299. /**
  25300. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25301. * @param name defines the name of the mesh to create
  25302. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25303. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25304. * @param scene defines the hosting scene
  25305. * @returns a new Mesh
  25306. */
  25307. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25308. /**
  25309. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25310. * @param name defines the name of the mesh to create
  25311. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25312. * @param diameterTop set the top cap diameter (floats, default 1)
  25313. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25314. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25315. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25316. * @param scene defines the hosting scene
  25317. * @param updatable defines if the mesh must be flagged as updatable
  25318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25319. * @returns a new Mesh
  25320. */
  25321. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25322. /**
  25323. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25324. * @param name defines the name of the mesh to create
  25325. * @param diameter sets the diameter size (float) of the torus (default 1)
  25326. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25327. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25328. * @param scene defines the hosting scene
  25329. * @param updatable defines if the mesh must be flagged as updatable
  25330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25331. * @returns a new Mesh
  25332. */
  25333. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25334. /**
  25335. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25336. * @param name defines the name of the mesh to create
  25337. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25338. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25339. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25340. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25341. * @param p the number of windings on X axis (positive integers, default 2)
  25342. * @param q the number of windings on Y axis (positive integers, default 3)
  25343. * @param scene defines the hosting scene
  25344. * @param updatable defines if the mesh must be flagged as updatable
  25345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25346. * @returns a new Mesh
  25347. */
  25348. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25349. /**
  25350. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25351. * @param name defines the name of the mesh to create
  25352. * @param points is an array successive Vector3
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @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).
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25359. /**
  25360. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param points is an array successive Vector3
  25363. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25364. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25365. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25366. * @param scene defines the hosting scene
  25367. * @param updatable defines if the mesh must be flagged as updatable
  25368. * @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)
  25369. * @returns a new Mesh
  25370. */
  25371. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25372. /**
  25373. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25374. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25375. * 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.
  25376. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25377. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25378. * Remember you can only change the shape positions, not their number when updating a polygon.
  25379. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25380. * @param name defines the name of the mesh to create
  25381. * @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
  25382. * @param scene defines the hosting scene
  25383. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25384. * @param updatable defines if the mesh must be flagged as updatable
  25385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25386. * @param earcutInjection can be used to inject your own earcut reference
  25387. * @returns a new Mesh
  25388. */
  25389. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25390. /**
  25391. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25393. * @param name defines the name of the mesh to create
  25394. * @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
  25395. * @param depth defines the height of extrusion
  25396. * @param scene defines the hosting scene
  25397. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25398. * @param updatable defines if the mesh must be flagged as updatable
  25399. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25400. * @param earcutInjection can be used to inject your own earcut reference
  25401. * @returns a new Mesh
  25402. */
  25403. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25404. /**
  25405. * Creates an extruded shape mesh.
  25406. * 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
  25407. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25408. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25409. * @param name defines the name of the mesh to create
  25410. * @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
  25411. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25412. * @param scale is the value to scale the shape
  25413. * @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
  25414. * @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
  25415. * @param scene defines the hosting scene
  25416. * @param updatable defines if the mesh must be flagged as updatable
  25417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25418. * @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)
  25419. * @returns a new Mesh
  25420. */
  25421. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25422. /**
  25423. * Creates an custom extruded shape mesh.
  25424. * The custom extrusion is a parametric shape.
  25425. * It has no predefined shape. Its final shape will depend on the input parameters.
  25426. * Please consider using the same method from the MeshBuilder class instead
  25427. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25428. * @param name defines the name of the mesh to create
  25429. * @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
  25430. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25431. * @param scaleFunction is a custom Javascript function called on each path point
  25432. * @param rotationFunction is a custom Javascript function called on each path point
  25433. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25434. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25435. * @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
  25436. * @param scene defines the hosting scene
  25437. * @param updatable defines if the mesh must be flagged as updatable
  25438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25439. * @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)
  25440. * @returns a new Mesh
  25441. */
  25442. 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;
  25443. /**
  25444. * Creates lathe mesh.
  25445. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @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
  25449. * @param radius is the radius value of the lathe
  25450. * @param tessellation is the side number of the lathe.
  25451. * @param scene defines the hosting scene
  25452. * @param updatable defines if the mesh must be flagged as updatable
  25453. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25454. * @returns a new Mesh
  25455. */
  25456. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25457. /**
  25458. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25461. * @param scene defines the hosting scene
  25462. * @param updatable defines if the mesh must be flagged as updatable
  25463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25464. * @returns a new Mesh
  25465. */
  25466. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25467. /**
  25468. * Creates a ground mesh.
  25469. * Please consider using the same method from the MeshBuilder class instead
  25470. * @param name defines the name of the mesh to create
  25471. * @param width set the width of the ground
  25472. * @param height set the height of the ground
  25473. * @param subdivisions sets the number of subdivisions per side
  25474. * @param scene defines the hosting scene
  25475. * @param updatable defines if the mesh must be flagged as updatable
  25476. * @returns a new Mesh
  25477. */
  25478. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25479. /**
  25480. * Creates a tiled ground mesh.
  25481. * Please consider using the same method from the MeshBuilder class instead
  25482. * @param name defines the name of the mesh to create
  25483. * @param xmin set the ground minimum X coordinate
  25484. * @param zmin set the ground minimum Y coordinate
  25485. * @param xmax set the ground maximum X coordinate
  25486. * @param zmax set the ground maximum Z coordinate
  25487. * @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
  25488. * @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
  25489. * @param scene defines the hosting scene
  25490. * @param updatable defines if the mesh must be flagged as updatable
  25491. * @returns a new Mesh
  25492. */
  25493. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25494. w: number;
  25495. h: number;
  25496. }, precision: {
  25497. w: number;
  25498. h: number;
  25499. }, scene: Scene, updatable?: boolean): Mesh;
  25500. /**
  25501. * Creates a ground mesh from a height map.
  25502. * Please consider using the same method from the MeshBuilder class instead
  25503. * @see http://doc.babylonjs.com/babylon101/height_map
  25504. * @param name defines the name of the mesh to create
  25505. * @param url sets the URL of the height map image resource
  25506. * @param width set the ground width size
  25507. * @param height set the ground height size
  25508. * @param subdivisions sets the number of subdivision per side
  25509. * @param minHeight is the minimum altitude on the ground
  25510. * @param maxHeight is the maximum altitude on the ground
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25514. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25515. * @returns a new Mesh
  25516. */
  25517. 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;
  25518. /**
  25519. * Creates a tube mesh.
  25520. * The tube is a parametric shape.
  25521. * It has no predefined shape. Its final shape will depend on the input parameters.
  25522. * Please consider using the same method from the MeshBuilder class instead
  25523. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25524. * @param name defines the name of the mesh to create
  25525. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25526. * @param radius sets the tube radius size
  25527. * @param tessellation is the number of sides on the tubular surface
  25528. * @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
  25529. * @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
  25530. * @param scene defines the hosting scene
  25531. * @param updatable defines if the mesh must be flagged as updatable
  25532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25533. * @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)
  25534. * @returns a new Mesh
  25535. */
  25536. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25537. (i: number, distance: number): number;
  25538. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25539. /**
  25540. * Creates a polyhedron mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead.
  25542. * * 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
  25543. * * The parameter `size` (positive float, default 1) sets the polygon size
  25544. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25545. * * 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`
  25546. * * 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
  25547. * * 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)`)
  25548. * * 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
  25549. * * 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
  25550. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25551. * * If you create a double-sided mesh, you can choose what parts of 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
  25552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25553. * @param name defines the name of the mesh to create
  25554. * @param options defines the options used to create the mesh
  25555. * @param scene defines the hosting scene
  25556. * @returns a new Mesh
  25557. */
  25558. static CreatePolyhedron(name: string, options: {
  25559. type?: number;
  25560. size?: number;
  25561. sizeX?: number;
  25562. sizeY?: number;
  25563. sizeZ?: number;
  25564. custom?: any;
  25565. faceUV?: Vector4[];
  25566. faceColors?: Color4[];
  25567. updatable?: boolean;
  25568. sideOrientation?: number;
  25569. }, scene: Scene): Mesh;
  25570. /**
  25571. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25572. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25573. * * 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`)
  25574. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25575. * * 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
  25576. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25577. * * If you create a double-sided mesh, you can choose what parts of 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
  25578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25579. * @param name defines the name of the mesh
  25580. * @param options defines the options used to create the mesh
  25581. * @param scene defines the hosting scene
  25582. * @returns a new Mesh
  25583. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25584. */
  25585. static CreateIcoSphere(name: string, options: {
  25586. radius?: number;
  25587. flat?: boolean;
  25588. subdivisions?: number;
  25589. sideOrientation?: number;
  25590. updatable?: boolean;
  25591. }, scene: Scene): Mesh;
  25592. /**
  25593. * Creates a decal mesh.
  25594. * Please consider using the same method from the MeshBuilder class instead.
  25595. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25596. * @param name defines the name of the mesh
  25597. * @param sourceMesh defines the mesh receiving the decal
  25598. * @param position sets the position of the decal in world coordinates
  25599. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25600. * @param size sets the decal scaling
  25601. * @param angle sets the angle to rotate the decal
  25602. * @returns a new Mesh
  25603. */
  25604. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25605. /**
  25606. * Prepare internal position array for software CPU skinning
  25607. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25608. */
  25609. setPositionsForCPUSkinning(): Float32Array;
  25610. /**
  25611. * Prepare internal normal array for software CPU skinning
  25612. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25613. */
  25614. setNormalsForCPUSkinning(): Float32Array;
  25615. /**
  25616. * Updates the vertex buffer by applying transformation from the bones
  25617. * @param skeleton defines the skeleton to apply to current mesh
  25618. * @returns the current mesh
  25619. */
  25620. applySkeleton(skeleton: Skeleton): Mesh;
  25621. /**
  25622. * 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
  25623. * @param meshes defines the list of meshes to scan
  25624. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25625. */
  25626. static MinMax(meshes: AbstractMesh[]): {
  25627. min: Vector3;
  25628. max: Vector3;
  25629. };
  25630. /**
  25631. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25632. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25633. * @returns a vector3
  25634. */
  25635. static Center(meshesOrMinMaxVector: {
  25636. min: Vector3;
  25637. max: Vector3;
  25638. } | AbstractMesh[]): Vector3;
  25639. /**
  25640. * Merge the array of meshes into a single mesh for performance reasons.
  25641. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25642. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25643. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25644. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25645. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25646. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25647. * @returns a new mesh
  25648. */
  25649. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25650. /** @hidden */
  25651. addInstance(instance: InstancedMesh): void;
  25652. /** @hidden */
  25653. removeInstance(instance: InstancedMesh): void;
  25654. }
  25655. }
  25656. declare module "babylonjs/Cameras/camera" {
  25657. import { SmartArray } from "babylonjs/Misc/smartArray";
  25658. import { Observable } from "babylonjs/Misc/observable";
  25659. import { Nullable } from "babylonjs/types";
  25660. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25661. import { Scene } from "babylonjs/scene";
  25662. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25663. import { Node } from "babylonjs/node";
  25664. import { Mesh } from "babylonjs/Meshes/mesh";
  25665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25666. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25667. import { Viewport } from "babylonjs/Maths/math.viewport";
  25668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25669. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25670. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25671. import { Ray } from "babylonjs/Culling/ray";
  25672. /**
  25673. * This is the base class of all the camera used in the application.
  25674. * @see http://doc.babylonjs.com/features/cameras
  25675. */
  25676. export class Camera extends Node {
  25677. /** @hidden */
  25678. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25679. /**
  25680. * This is the default projection mode used by the cameras.
  25681. * It helps recreating a feeling of perspective and better appreciate depth.
  25682. * This is the best way to simulate real life cameras.
  25683. */
  25684. static readonly PERSPECTIVE_CAMERA: number;
  25685. /**
  25686. * This helps creating camera with an orthographic mode.
  25687. * 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.
  25688. */
  25689. static readonly ORTHOGRAPHIC_CAMERA: number;
  25690. /**
  25691. * This is the default FOV mode for perspective cameras.
  25692. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25693. */
  25694. static readonly FOVMODE_VERTICAL_FIXED: number;
  25695. /**
  25696. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25697. */
  25698. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25699. /**
  25700. * This specifies ther is no need for a camera rig.
  25701. * Basically only one eye is rendered corresponding to the camera.
  25702. */
  25703. static readonly RIG_MODE_NONE: number;
  25704. /**
  25705. * Simulates a camera Rig with one blue eye and one red eye.
  25706. * This can be use with 3d blue and red glasses.
  25707. */
  25708. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25709. /**
  25710. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25711. */
  25712. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25713. /**
  25714. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25715. */
  25716. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25717. /**
  25718. * Defines that both eyes of the camera will be rendered over under each other.
  25719. */
  25720. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25721. /**
  25722. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25723. */
  25724. static readonly RIG_MODE_VR: number;
  25725. /**
  25726. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25727. */
  25728. static readonly RIG_MODE_WEBVR: number;
  25729. /**
  25730. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25731. */
  25732. static readonly RIG_MODE_CUSTOM: number;
  25733. /**
  25734. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25735. */
  25736. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25737. /**
  25738. * Define the input manager associated with the camera.
  25739. */
  25740. inputs: CameraInputsManager<Camera>;
  25741. /** @hidden */
  25742. _position: Vector3;
  25743. /**
  25744. * Define the current local position of the camera in the scene
  25745. */
  25746. position: Vector3;
  25747. /**
  25748. * The vector the camera should consider as up.
  25749. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25750. */
  25751. upVector: Vector3;
  25752. /**
  25753. * Define the current limit on the left side for an orthographic camera
  25754. * In scene unit
  25755. */
  25756. orthoLeft: Nullable<number>;
  25757. /**
  25758. * Define the current limit on the right side for an orthographic camera
  25759. * In scene unit
  25760. */
  25761. orthoRight: Nullable<number>;
  25762. /**
  25763. * Define the current limit on the bottom side for an orthographic camera
  25764. * In scene unit
  25765. */
  25766. orthoBottom: Nullable<number>;
  25767. /**
  25768. * Define the current limit on the top side for an orthographic camera
  25769. * In scene unit
  25770. */
  25771. orthoTop: Nullable<number>;
  25772. /**
  25773. * Field Of View is set in Radians. (default is 0.8)
  25774. */
  25775. fov: number;
  25776. /**
  25777. * Define the minimum distance the camera can see from.
  25778. * This is important to note that the depth buffer are not infinite and the closer it starts
  25779. * the more your scene might encounter depth fighting issue.
  25780. */
  25781. minZ: number;
  25782. /**
  25783. * Define the maximum distance the camera can see to.
  25784. * This is important to note that the depth buffer are not infinite and the further it end
  25785. * the more your scene might encounter depth fighting issue.
  25786. */
  25787. maxZ: number;
  25788. /**
  25789. * Define the default inertia of the camera.
  25790. * This helps giving a smooth feeling to the camera movement.
  25791. */
  25792. inertia: number;
  25793. /**
  25794. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25795. */
  25796. mode: number;
  25797. /**
  25798. * Define wether the camera is intermediate.
  25799. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25800. */
  25801. isIntermediate: boolean;
  25802. /**
  25803. * Define the viewport of the camera.
  25804. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25805. */
  25806. viewport: Viewport;
  25807. /**
  25808. * Restricts the camera to viewing objects with the same layerMask.
  25809. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25810. */
  25811. layerMask: number;
  25812. /**
  25813. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25814. */
  25815. fovMode: number;
  25816. /**
  25817. * Rig mode of the camera.
  25818. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25819. * This is normally controlled byt the camera themselves as internal use.
  25820. */
  25821. cameraRigMode: number;
  25822. /**
  25823. * Defines the distance between both "eyes" in case of a RIG
  25824. */
  25825. interaxialDistance: number;
  25826. /**
  25827. * Defines if stereoscopic rendering is done side by side or over under.
  25828. */
  25829. isStereoscopicSideBySide: boolean;
  25830. /**
  25831. * 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
  25832. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25833. * else in the scene. (Eg. security camera)
  25834. *
  25835. * 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)
  25836. */
  25837. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25838. /**
  25839. * When set, the camera will render to this render target instead of the default canvas
  25840. *
  25841. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25842. */
  25843. outputRenderTarget: Nullable<RenderTargetTexture>;
  25844. /**
  25845. * Observable triggered when the camera view matrix has changed.
  25846. */
  25847. onViewMatrixChangedObservable: Observable<Camera>;
  25848. /**
  25849. * Observable triggered when the camera Projection matrix has changed.
  25850. */
  25851. onProjectionMatrixChangedObservable: Observable<Camera>;
  25852. /**
  25853. * Observable triggered when the inputs have been processed.
  25854. */
  25855. onAfterCheckInputsObservable: Observable<Camera>;
  25856. /**
  25857. * Observable triggered when reset has been called and applied to the camera.
  25858. */
  25859. onRestoreStateObservable: Observable<Camera>;
  25860. /** @hidden */
  25861. _cameraRigParams: any;
  25862. /** @hidden */
  25863. _rigCameras: Camera[];
  25864. /** @hidden */
  25865. _rigPostProcess: Nullable<PostProcess>;
  25866. protected _webvrViewMatrix: Matrix;
  25867. /** @hidden */
  25868. _skipRendering: boolean;
  25869. /** @hidden */
  25870. _projectionMatrix: Matrix;
  25871. /** @hidden */
  25872. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25873. /** @hidden */
  25874. _activeMeshes: SmartArray<AbstractMesh>;
  25875. protected _globalPosition: Vector3;
  25876. /** @hidden */
  25877. _computedViewMatrix: Matrix;
  25878. private _doNotComputeProjectionMatrix;
  25879. private _transformMatrix;
  25880. private _frustumPlanes;
  25881. private _refreshFrustumPlanes;
  25882. private _storedFov;
  25883. private _stateStored;
  25884. /**
  25885. * Instantiates a new camera object.
  25886. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25887. * @see http://doc.babylonjs.com/features/cameras
  25888. * @param name Defines the name of the camera in the scene
  25889. * @param position Defines the position of the camera
  25890. * @param scene Defines the scene the camera belongs too
  25891. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25892. */
  25893. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25894. /**
  25895. * Store current camera state (fov, position, etc..)
  25896. * @returns the camera
  25897. */
  25898. storeState(): Camera;
  25899. /**
  25900. * Restores the camera state values if it has been stored. You must call storeState() first
  25901. */
  25902. protected _restoreStateValues(): boolean;
  25903. /**
  25904. * Restored camera state. You must call storeState() first.
  25905. * @returns true if restored and false otherwise
  25906. */
  25907. restoreState(): boolean;
  25908. /**
  25909. * Gets the class name of the camera.
  25910. * @returns the class name
  25911. */
  25912. getClassName(): string;
  25913. /** @hidden */
  25914. readonly _isCamera: boolean;
  25915. /**
  25916. * Gets a string representation of the camera useful for debug purpose.
  25917. * @param fullDetails Defines that a more verboe level of logging is required
  25918. * @returns the string representation
  25919. */
  25920. toString(fullDetails?: boolean): string;
  25921. /**
  25922. * Gets the current world space position of the camera.
  25923. */
  25924. readonly globalPosition: Vector3;
  25925. /**
  25926. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25927. * @returns the active meshe list
  25928. */
  25929. getActiveMeshes(): SmartArray<AbstractMesh>;
  25930. /**
  25931. * Check wether a mesh is part of the current active mesh list of the camera
  25932. * @param mesh Defines the mesh to check
  25933. * @returns true if active, false otherwise
  25934. */
  25935. isActiveMesh(mesh: Mesh): boolean;
  25936. /**
  25937. * Is this camera ready to be used/rendered
  25938. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25939. * @return true if the camera is ready
  25940. */
  25941. isReady(completeCheck?: boolean): boolean;
  25942. /** @hidden */
  25943. _initCache(): void;
  25944. /** @hidden */
  25945. _updateCache(ignoreParentClass?: boolean): void;
  25946. /** @hidden */
  25947. _isSynchronized(): boolean;
  25948. /** @hidden */
  25949. _isSynchronizedViewMatrix(): boolean;
  25950. /** @hidden */
  25951. _isSynchronizedProjectionMatrix(): boolean;
  25952. /**
  25953. * Attach the input controls to a specific dom element to get the input from.
  25954. * @param element Defines the element the controls should be listened from
  25955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25956. */
  25957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25958. /**
  25959. * Detach the current controls from the specified dom element.
  25960. * @param element Defines the element to stop listening the inputs from
  25961. */
  25962. detachControl(element: HTMLElement): void;
  25963. /**
  25964. * Update the camera state according to the different inputs gathered during the frame.
  25965. */
  25966. update(): void;
  25967. /** @hidden */
  25968. _checkInputs(): void;
  25969. /** @hidden */
  25970. readonly rigCameras: Camera[];
  25971. /**
  25972. * Gets the post process used by the rig cameras
  25973. */
  25974. readonly rigPostProcess: Nullable<PostProcess>;
  25975. /**
  25976. * Internal, gets the first post proces.
  25977. * @returns the first post process to be run on this camera.
  25978. */
  25979. _getFirstPostProcess(): Nullable<PostProcess>;
  25980. private _cascadePostProcessesToRigCams;
  25981. /**
  25982. * Attach a post process to the camera.
  25983. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25984. * @param postProcess The post process to attach to the camera
  25985. * @param insertAt The position of the post process in case several of them are in use in the scene
  25986. * @returns the position the post process has been inserted at
  25987. */
  25988. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25989. /**
  25990. * Detach a post process to the camera.
  25991. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25992. * @param postProcess The post process to detach from the camera
  25993. */
  25994. detachPostProcess(postProcess: PostProcess): void;
  25995. /**
  25996. * Gets the current world matrix of the camera
  25997. */
  25998. getWorldMatrix(): Matrix;
  25999. /** @hidden */
  26000. _getViewMatrix(): Matrix;
  26001. /**
  26002. * Gets the current view matrix of the camera.
  26003. * @param force forces the camera to recompute the matrix without looking at the cached state
  26004. * @returns the view matrix
  26005. */
  26006. getViewMatrix(force?: boolean): Matrix;
  26007. /**
  26008. * Freeze the projection matrix.
  26009. * It will prevent the cache check of the camera projection compute and can speed up perf
  26010. * if no parameter of the camera are meant to change
  26011. * @param projection Defines manually a projection if necessary
  26012. */
  26013. freezeProjectionMatrix(projection?: Matrix): void;
  26014. /**
  26015. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26016. */
  26017. unfreezeProjectionMatrix(): void;
  26018. /**
  26019. * Gets the current projection matrix of the camera.
  26020. * @param force forces the camera to recompute the matrix without looking at the cached state
  26021. * @returns the projection matrix
  26022. */
  26023. getProjectionMatrix(force?: boolean): Matrix;
  26024. /**
  26025. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26026. * @returns a Matrix
  26027. */
  26028. getTransformationMatrix(): Matrix;
  26029. private _updateFrustumPlanes;
  26030. /**
  26031. * Checks if a cullable object (mesh...) is in the camera frustum
  26032. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26033. * @param target The object to check
  26034. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26035. * @returns true if the object is in frustum otherwise false
  26036. */
  26037. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26038. /**
  26039. * Checks if a cullable object (mesh...) is in the camera frustum
  26040. * Unlike isInFrustum this cheks the full bounding box
  26041. * @param target The object to check
  26042. * @returns true if the object is in frustum otherwise false
  26043. */
  26044. isCompletelyInFrustum(target: ICullable): boolean;
  26045. /**
  26046. * Gets a ray in the forward direction from the camera.
  26047. * @param length Defines the length of the ray to create
  26048. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26049. * @param origin Defines the start point of the ray which defaults to the camera position
  26050. * @returns the forward ray
  26051. */
  26052. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26053. /**
  26054. * Releases resources associated with this node.
  26055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26057. */
  26058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26059. /** @hidden */
  26060. _isLeftCamera: boolean;
  26061. /**
  26062. * Gets the left camera of a rig setup in case of Rigged Camera
  26063. */
  26064. readonly isLeftCamera: boolean;
  26065. /** @hidden */
  26066. _isRightCamera: boolean;
  26067. /**
  26068. * Gets the right camera of a rig setup in case of Rigged Camera
  26069. */
  26070. readonly isRightCamera: boolean;
  26071. /**
  26072. * Gets the left camera of a rig setup in case of Rigged Camera
  26073. */
  26074. readonly leftCamera: Nullable<FreeCamera>;
  26075. /**
  26076. * Gets the right camera of a rig setup in case of Rigged Camera
  26077. */
  26078. readonly rightCamera: Nullable<FreeCamera>;
  26079. /**
  26080. * Gets the left camera target of a rig setup in case of Rigged Camera
  26081. * @returns the target position
  26082. */
  26083. getLeftTarget(): Nullable<Vector3>;
  26084. /**
  26085. * Gets the right camera target of a rig setup in case of Rigged Camera
  26086. * @returns the target position
  26087. */
  26088. getRightTarget(): Nullable<Vector3>;
  26089. /**
  26090. * @hidden
  26091. */
  26092. setCameraRigMode(mode: number, rigParams: any): void;
  26093. /** @hidden */
  26094. static _setStereoscopicRigMode(camera: Camera): void;
  26095. /** @hidden */
  26096. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26097. /** @hidden */
  26098. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26099. /** @hidden */
  26100. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26101. /** @hidden */
  26102. _getVRProjectionMatrix(): Matrix;
  26103. protected _updateCameraRotationMatrix(): void;
  26104. protected _updateWebVRCameraRotationMatrix(): void;
  26105. /**
  26106. * This function MUST be overwritten by the different WebVR cameras available.
  26107. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26108. * @hidden
  26109. */
  26110. _getWebVRProjectionMatrix(): Matrix;
  26111. /**
  26112. * This function MUST be overwritten by the different WebVR cameras available.
  26113. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26114. * @hidden
  26115. */
  26116. _getWebVRViewMatrix(): Matrix;
  26117. /** @hidden */
  26118. setCameraRigParameter(name: string, value: any): void;
  26119. /**
  26120. * needs to be overridden by children so sub has required properties to be copied
  26121. * @hidden
  26122. */
  26123. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26124. /**
  26125. * May need to be overridden by children
  26126. * @hidden
  26127. */
  26128. _updateRigCameras(): void;
  26129. /** @hidden */
  26130. _setupInputs(): void;
  26131. /**
  26132. * Serialiaze the camera setup to a json represention
  26133. * @returns the JSON representation
  26134. */
  26135. serialize(): any;
  26136. /**
  26137. * Clones the current camera.
  26138. * @param name The cloned camera name
  26139. * @returns the cloned camera
  26140. */
  26141. clone(name: string): Camera;
  26142. /**
  26143. * Gets the direction of the camera relative to a given local axis.
  26144. * @param localAxis Defines the reference axis to provide a relative direction.
  26145. * @return the direction
  26146. */
  26147. getDirection(localAxis: Vector3): Vector3;
  26148. /**
  26149. * Returns the current camera absolute rotation
  26150. */
  26151. readonly absoluteRotation: Quaternion;
  26152. /**
  26153. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26154. * @param localAxis Defines the reference axis to provide a relative direction.
  26155. * @param result Defines the vector to store the result in
  26156. */
  26157. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26158. /**
  26159. * Gets a camera constructor for a given camera type
  26160. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26161. * @param name The name of the camera the result will be able to instantiate
  26162. * @param scene The scene the result will construct the camera in
  26163. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26164. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26165. * @returns a factory method to construc the camera
  26166. */
  26167. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26168. /**
  26169. * Compute the world matrix of the camera.
  26170. * @returns the camera world matrix
  26171. */
  26172. computeWorldMatrix(): Matrix;
  26173. /**
  26174. * Parse a JSON and creates the camera from the parsed information
  26175. * @param parsedCamera The JSON to parse
  26176. * @param scene The scene to instantiate the camera in
  26177. * @returns the newly constructed camera
  26178. */
  26179. static Parse(parsedCamera: any, scene: Scene): Camera;
  26180. }
  26181. }
  26182. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26183. import { Nullable } from "babylonjs/types";
  26184. import { Scene } from "babylonjs/scene";
  26185. import { Vector4 } from "babylonjs/Maths/math.vector";
  26186. import { Mesh } from "babylonjs/Meshes/mesh";
  26187. /**
  26188. * Class containing static functions to help procedurally build meshes
  26189. */
  26190. export class DiscBuilder {
  26191. /**
  26192. * Creates a plane polygonal mesh. By default, this is a disc
  26193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26194. * * 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
  26195. * * 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
  26196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26199. * @param name defines the name of the mesh
  26200. * @param options defines the options used to create the mesh
  26201. * @param scene defines the hosting scene
  26202. * @returns the plane polygonal mesh
  26203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26204. */
  26205. static CreateDisc(name: string, options: {
  26206. radius?: number;
  26207. tessellation?: number;
  26208. arc?: number;
  26209. updatable?: boolean;
  26210. sideOrientation?: number;
  26211. frontUVs?: Vector4;
  26212. backUVs?: Vector4;
  26213. }, scene?: Nullable<Scene>): Mesh;
  26214. }
  26215. }
  26216. declare module "babylonjs/Particles/solidParticleSystem" {
  26217. import { Nullable } from "babylonjs/types";
  26218. import { Vector3 } from "babylonjs/Maths/math.vector";
  26219. import { Mesh } from "babylonjs/Meshes/mesh";
  26220. import { Scene, IDisposable } from "babylonjs/scene";
  26221. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26222. /**
  26223. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26224. *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.
  26225. * The SPS is also a particle system. It provides some methods to manage the particles.
  26226. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26227. *
  26228. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26229. */
  26230. export class SolidParticleSystem implements IDisposable {
  26231. /**
  26232. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26233. * Example : var p = SPS.particles[i];
  26234. */
  26235. particles: SolidParticle[];
  26236. /**
  26237. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26238. */
  26239. nbParticles: number;
  26240. /**
  26241. * If the particles must ever face the camera (default false). Useful for planar particles.
  26242. */
  26243. billboard: boolean;
  26244. /**
  26245. * Recompute normals when adding a shape
  26246. */
  26247. recomputeNormals: boolean;
  26248. /**
  26249. * This a counter ofr your own usage. It's not set by any SPS functions.
  26250. */
  26251. counter: number;
  26252. /**
  26253. * The SPS name. This name is also given to the underlying mesh.
  26254. */
  26255. name: string;
  26256. /**
  26257. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26258. */
  26259. mesh: Mesh;
  26260. /**
  26261. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26262. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26263. */
  26264. vars: any;
  26265. /**
  26266. * This array is populated when the SPS is set as 'pickable'.
  26267. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26268. * Each element of this array is an object `{idx: int, faceId: int}`.
  26269. * `idx` is the picked particle index in the `SPS.particles` array
  26270. * `faceId` is the picked face index counted within this particle.
  26271. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26272. */
  26273. pickedParticles: {
  26274. idx: number;
  26275. faceId: number;
  26276. }[];
  26277. /**
  26278. * This array is populated when `enableDepthSort` is set to true.
  26279. * Each element of this array is an instance of the class DepthSortedParticle.
  26280. */
  26281. depthSortedParticles: DepthSortedParticle[];
  26282. /**
  26283. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26284. * @hidden
  26285. */
  26286. _bSphereOnly: boolean;
  26287. /**
  26288. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26289. * @hidden
  26290. */
  26291. _bSphereRadiusFactor: number;
  26292. private _scene;
  26293. private _positions;
  26294. private _indices;
  26295. private _normals;
  26296. private _colors;
  26297. private _uvs;
  26298. private _indices32;
  26299. private _positions32;
  26300. private _normals32;
  26301. private _fixedNormal32;
  26302. private _colors32;
  26303. private _uvs32;
  26304. private _index;
  26305. private _updatable;
  26306. private _pickable;
  26307. private _isVisibilityBoxLocked;
  26308. private _alwaysVisible;
  26309. private _depthSort;
  26310. private _expandable;
  26311. private _shapeCounter;
  26312. private _copy;
  26313. private _color;
  26314. private _computeParticleColor;
  26315. private _computeParticleTexture;
  26316. private _computeParticleRotation;
  26317. private _computeParticleVertex;
  26318. private _computeBoundingBox;
  26319. private _depthSortParticles;
  26320. private _camera;
  26321. private _mustUnrotateFixedNormals;
  26322. private _particlesIntersect;
  26323. private _needs32Bits;
  26324. private _isNotBuilt;
  26325. private _lastParticleId;
  26326. private _idxOfId;
  26327. /**
  26328. * Creates a SPS (Solid Particle System) object.
  26329. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26330. * @param scene (Scene) is the scene in which the SPS is added.
  26331. * @param options defines the options of the sps e.g.
  26332. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26333. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26334. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26335. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26336. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26337. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26338. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26339. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26340. */
  26341. constructor(name: string, scene: Scene, options?: {
  26342. updatable?: boolean;
  26343. isPickable?: boolean;
  26344. enableDepthSort?: boolean;
  26345. particleIntersection?: boolean;
  26346. boundingSphereOnly?: boolean;
  26347. bSphereRadiusFactor?: number;
  26348. expandable?: boolean;
  26349. });
  26350. /**
  26351. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26352. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26353. * @returns the created mesh
  26354. */
  26355. buildMesh(): Mesh;
  26356. /**
  26357. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26358. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26359. * Thus the particles generated from `digest()` have their property `position` set yet.
  26360. * @param mesh ( Mesh ) is the mesh to be digested
  26361. * @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
  26362. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26363. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26364. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26365. * @returns the current SPS
  26366. */
  26367. digest(mesh: Mesh, options?: {
  26368. facetNb?: number;
  26369. number?: number;
  26370. delta?: number;
  26371. storage?: [];
  26372. }): SolidParticleSystem;
  26373. /**
  26374. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26375. * @hidden
  26376. */
  26377. private _unrotateFixedNormals;
  26378. /**
  26379. * Resets the temporary working copy particle
  26380. * @hidden
  26381. */
  26382. private _resetCopy;
  26383. /**
  26384. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26385. * @param p the current index in the positions array to be updated
  26386. * @param shape a Vector3 array, the shape geometry
  26387. * @param positions the positions array to be updated
  26388. * @param meshInd the shape indices array
  26389. * @param indices the indices array to be updated
  26390. * @param meshUV the shape uv array
  26391. * @param uvs the uv array to be updated
  26392. * @param meshCol the shape color array
  26393. * @param colors the color array to be updated
  26394. * @param meshNor the shape normals array
  26395. * @param normals the normals array to be updated
  26396. * @param idx the particle index
  26397. * @param idxInShape the particle index in its shape
  26398. * @param options the addShape() method passed options
  26399. * @hidden
  26400. */
  26401. private _meshBuilder;
  26402. /**
  26403. * Returns a shape Vector3 array from positions float array
  26404. * @param positions float array
  26405. * @returns a vector3 array
  26406. * @hidden
  26407. */
  26408. private _posToShape;
  26409. /**
  26410. * Returns a shapeUV array from a float uvs (array deep copy)
  26411. * @param uvs as a float array
  26412. * @returns a shapeUV array
  26413. * @hidden
  26414. */
  26415. private _uvsToShapeUV;
  26416. /**
  26417. * Adds a new particle object in the particles array
  26418. * @param idx particle index in particles array
  26419. * @param id particle id
  26420. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26421. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26422. * @param model particle ModelShape object
  26423. * @param shapeId model shape identifier
  26424. * @param idxInShape index of the particle in the current model
  26425. * @param bInfo model bounding info object
  26426. * @param storage target storage array, if any
  26427. * @hidden
  26428. */
  26429. private _addParticle;
  26430. /**
  26431. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26432. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26433. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26434. * @param nb (positive integer) the number of particles to be created from this model
  26435. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26436. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26437. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26438. * @returns the number of shapes in the system
  26439. */
  26440. addShape(mesh: Mesh, nb: number, options?: {
  26441. positionFunction?: any;
  26442. vertexFunction?: any;
  26443. storage?: [];
  26444. }): number;
  26445. /**
  26446. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26447. * @hidden
  26448. */
  26449. private _rebuildParticle;
  26450. /**
  26451. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26452. * @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.
  26453. * @returns the SPS.
  26454. */
  26455. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26456. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26457. * Returns an array with the removed particles.
  26458. * 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.
  26459. * The SPS can't be empty so at least one particle needs to remain in place.
  26460. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26461. * @param start index of the first particle to remove
  26462. * @param end index of the last particle to remove (included)
  26463. * @returns an array populated with the removed particles
  26464. */
  26465. removeParticles(start: number, end: number): SolidParticle[];
  26466. /**
  26467. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26468. * @param solidParticleArray an array populated with Solid Particles objects
  26469. * @returns the SPS
  26470. */
  26471. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26472. /**
  26473. * Creates a new particle and modifies the SPS mesh geometry :
  26474. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26475. * - calls _addParticle() to populate the particle array
  26476. * factorized code from addShape() and insertParticlesFromArray()
  26477. * @param idx particle index in the particles array
  26478. * @param i particle index in its shape
  26479. * @param modelShape particle ModelShape object
  26480. * @param shape shape vertex array
  26481. * @param meshInd shape indices array
  26482. * @param meshUV shape uv array
  26483. * @param meshCol shape color array
  26484. * @param meshNor shape normals array
  26485. * @param bbInfo shape bounding info
  26486. * @param storage target particle storage
  26487. * @options addShape() passed options
  26488. * @hidden
  26489. */
  26490. private _insertNewParticle;
  26491. /**
  26492. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26493. * This method calls `updateParticle()` for each particle of the SPS.
  26494. * For an animated SPS, it is usually called within the render loop.
  26495. * 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.
  26496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26499. * @returns the SPS.
  26500. */
  26501. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26502. /**
  26503. * Disposes the SPS.
  26504. */
  26505. dispose(): void;
  26506. /**
  26507. * Returns a SolidParticle object from its identifier : particle.id
  26508. * @param id (integer) the particle Id
  26509. * @returns the searched particle or null if not found in the SPS.
  26510. */
  26511. getParticleById(id: number): Nullable<SolidParticle>;
  26512. /**
  26513. * Returns a new array populated with the particles having the passed shapeId.
  26514. * @param shapeId (integer) the shape identifier
  26515. * @returns a new solid particle array
  26516. */
  26517. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26518. /**
  26519. * Populates the passed array "ref" with the particles having the passed shapeId.
  26520. * @param shapeId the shape identifier
  26521. * @returns the SPS
  26522. * @param ref
  26523. */
  26524. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26525. /**
  26526. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26528. * @returns the SPS.
  26529. */
  26530. refreshVisibleSize(): SolidParticleSystem;
  26531. /**
  26532. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26533. * @param size the size (float) of the visibility box
  26534. * note : this doesn't lock the SPS mesh bounding box.
  26535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26536. */
  26537. setVisibilityBox(size: number): void;
  26538. /**
  26539. * Gets whether the SPS as always visible or not
  26540. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26541. */
  26542. /**
  26543. * Sets the SPS as always visible or not
  26544. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26545. */
  26546. isAlwaysVisible: boolean;
  26547. /**
  26548. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26550. */
  26551. /**
  26552. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26553. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26554. */
  26555. isVisibilityBoxLocked: boolean;
  26556. /**
  26557. * Tells to `setParticles()` to compute the particle rotations or not.
  26558. * Default value : true. The SPS is faster when it's set to false.
  26559. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26560. */
  26561. /**
  26562. * Gets if `setParticles()` computes the particle rotations or not.
  26563. * Default value : true. The SPS is faster when it's set to false.
  26564. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26565. */
  26566. computeParticleRotation: boolean;
  26567. /**
  26568. * Tells to `setParticles()` to compute the particle colors or not.
  26569. * Default value : true. The SPS is faster when it's set to false.
  26570. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26571. */
  26572. /**
  26573. * Gets if `setParticles()` computes the particle colors or not.
  26574. * Default value : true. The SPS is faster when it's set to false.
  26575. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26576. */
  26577. computeParticleColor: boolean;
  26578. /**
  26579. * Gets if `setParticles()` computes the particle textures or not.
  26580. * Default value : true. The SPS is faster when it's set to false.
  26581. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26582. */
  26583. computeParticleTexture: boolean;
  26584. /**
  26585. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26586. * Default value : false. The SPS is faster when it's set to false.
  26587. * Note : the particle custom vertex positions aren't stored values.
  26588. */
  26589. /**
  26590. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26591. * Default value : false. The SPS is faster when it's set to false.
  26592. * Note : the particle custom vertex positions aren't stored values.
  26593. */
  26594. computeParticleVertex: boolean;
  26595. /**
  26596. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26597. */
  26598. /**
  26599. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26600. */
  26601. computeBoundingBox: boolean;
  26602. /**
  26603. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26604. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26605. * Default : `true`
  26606. */
  26607. /**
  26608. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26609. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26610. * Default : `true`
  26611. */
  26612. depthSortParticles: boolean;
  26613. /**
  26614. * Gets if the SPS is created as expandable at construction time.
  26615. * Default : `false`
  26616. */
  26617. readonly expandable: boolean;
  26618. /**
  26619. * This function does nothing. It may be overwritten to set all the particle first values.
  26620. * The SPS doesn't call this function, you may have to call it by your own.
  26621. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26622. */
  26623. initParticles(): void;
  26624. /**
  26625. * This function does nothing. It may be overwritten to recycle a particle.
  26626. * The SPS doesn't call this function, you may have to call it by your own.
  26627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26628. * @param particle The particle to recycle
  26629. * @returns the recycled particle
  26630. */
  26631. recycleParticle(particle: SolidParticle): SolidParticle;
  26632. /**
  26633. * Updates a particle : this function should be overwritten by the user.
  26634. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26636. * @example : just set a particle position or velocity and recycle conditions
  26637. * @param particle The particle to update
  26638. * @returns the updated particle
  26639. */
  26640. updateParticle(particle: SolidParticle): SolidParticle;
  26641. /**
  26642. * Updates a vertex of a particle : it can be overwritten by the user.
  26643. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26644. * @param particle the current particle
  26645. * @param vertex the current index of the current particle
  26646. * @param pt the index of the current vertex in the particle shape
  26647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26648. * @example : just set a vertex particle position
  26649. * @returns the updated vertex
  26650. */
  26651. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26652. /**
  26653. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26654. * This does nothing and may be overwritten by the user.
  26655. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26656. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26657. * @param update the boolean update value actually passed to setParticles()
  26658. */
  26659. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26660. /**
  26661. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26662. * This will be passed three parameters.
  26663. * This does nothing and may be overwritten by the user.
  26664. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26665. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26666. * @param update the boolean update value actually passed to setParticles()
  26667. */
  26668. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26669. }
  26670. }
  26671. declare module "babylonjs/Particles/solidParticle" {
  26672. import { Nullable } from "babylonjs/types";
  26673. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26674. import { Color4 } from "babylonjs/Maths/math.color";
  26675. import { Mesh } from "babylonjs/Meshes/mesh";
  26676. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26677. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26678. import { Plane } from "babylonjs/Maths/math.plane";
  26679. /**
  26680. * Represents one particle of a solid particle system.
  26681. */
  26682. export class SolidParticle {
  26683. /**
  26684. * particle global index
  26685. */
  26686. idx: number;
  26687. /**
  26688. * particle identifier
  26689. */
  26690. id: number;
  26691. /**
  26692. * The color of the particle
  26693. */
  26694. color: Nullable<Color4>;
  26695. /**
  26696. * The world space position of the particle.
  26697. */
  26698. position: Vector3;
  26699. /**
  26700. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26701. */
  26702. rotation: Vector3;
  26703. /**
  26704. * The world space rotation quaternion of the particle.
  26705. */
  26706. rotationQuaternion: Nullable<Quaternion>;
  26707. /**
  26708. * The scaling of the particle.
  26709. */
  26710. scaling: Vector3;
  26711. /**
  26712. * The uvs of the particle.
  26713. */
  26714. uvs: Vector4;
  26715. /**
  26716. * The current speed of the particle.
  26717. */
  26718. velocity: Vector3;
  26719. /**
  26720. * The pivot point in the particle local space.
  26721. */
  26722. pivot: Vector3;
  26723. /**
  26724. * Must the particle be translated from its pivot point in its local space ?
  26725. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26726. * Default : false
  26727. */
  26728. translateFromPivot: boolean;
  26729. /**
  26730. * Is the particle active or not ?
  26731. */
  26732. alive: boolean;
  26733. /**
  26734. * Is the particle visible or not ?
  26735. */
  26736. isVisible: boolean;
  26737. /**
  26738. * Index of this particle in the global "positions" array (Internal use)
  26739. * @hidden
  26740. */
  26741. _pos: number;
  26742. /**
  26743. * @hidden Index of this particle in the global "indices" array (Internal use)
  26744. */
  26745. _ind: number;
  26746. /**
  26747. * @hidden ModelShape of this particle (Internal use)
  26748. */
  26749. _model: ModelShape;
  26750. /**
  26751. * ModelShape id of this particle
  26752. */
  26753. shapeId: number;
  26754. /**
  26755. * Index of the particle in its shape id
  26756. */
  26757. idxInShape: number;
  26758. /**
  26759. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26760. */
  26761. _modelBoundingInfo: BoundingInfo;
  26762. /**
  26763. * @hidden Particle BoundingInfo object (Internal use)
  26764. */
  26765. _boundingInfo: BoundingInfo;
  26766. /**
  26767. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26768. */
  26769. _sps: SolidParticleSystem;
  26770. /**
  26771. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26772. */
  26773. _stillInvisible: boolean;
  26774. /**
  26775. * @hidden Last computed particle rotation matrix
  26776. */
  26777. _rotationMatrix: number[];
  26778. /**
  26779. * Parent particle Id, if any.
  26780. * Default null.
  26781. */
  26782. parentId: Nullable<number>;
  26783. /**
  26784. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26785. * The possible values are :
  26786. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26787. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26788. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26790. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26791. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26792. * */
  26793. cullingStrategy: number;
  26794. /**
  26795. * @hidden Internal global position in the SPS.
  26796. */
  26797. _globalPosition: Vector3;
  26798. /**
  26799. * Creates a Solid Particle object.
  26800. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26801. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26802. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26803. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26804. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26805. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26806. * @param shapeId (integer) is the model shape identifier in the SPS.
  26807. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26808. * @param sps defines the sps it is associated to
  26809. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26810. */
  26811. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26812. /**
  26813. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26814. * @param target the particle target
  26815. * @returns the current particle
  26816. */
  26817. copyToRef(target: SolidParticle): SolidParticle;
  26818. /**
  26819. * Legacy support, changed scale to scaling
  26820. */
  26821. /**
  26822. * Legacy support, changed scale to scaling
  26823. */
  26824. scale: Vector3;
  26825. /**
  26826. * Legacy support, changed quaternion to rotationQuaternion
  26827. */
  26828. /**
  26829. * Legacy support, changed quaternion to rotationQuaternion
  26830. */
  26831. quaternion: Nullable<Quaternion>;
  26832. /**
  26833. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26834. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26835. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26836. * @returns true if it intersects
  26837. */
  26838. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26839. /**
  26840. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26841. * A particle is in the frustum if its bounding box intersects the frustum
  26842. * @param frustumPlanes defines the frustum to test
  26843. * @returns true if the particle is in the frustum planes
  26844. */
  26845. isInFrustum(frustumPlanes: Plane[]): boolean;
  26846. /**
  26847. * get the rotation matrix of the particle
  26848. * @hidden
  26849. */
  26850. getRotationMatrix(m: Matrix): void;
  26851. }
  26852. /**
  26853. * Represents the shape of the model used by one particle of a solid particle system.
  26854. * SPS internal tool, don't use it manually.
  26855. */
  26856. export class ModelShape {
  26857. /**
  26858. * The shape id
  26859. * @hidden
  26860. */
  26861. shapeID: number;
  26862. /**
  26863. * flat array of model positions (internal use)
  26864. * @hidden
  26865. */
  26866. _shape: Vector3[];
  26867. /**
  26868. * flat array of model UVs (internal use)
  26869. * @hidden
  26870. */
  26871. _shapeUV: number[];
  26872. /**
  26873. * color array of the model
  26874. * @hidden
  26875. */
  26876. _shapeColors: number[];
  26877. /**
  26878. * indices array of the model
  26879. * @hidden
  26880. */
  26881. _indices: number[];
  26882. /**
  26883. * normals array of the model
  26884. * @hidden
  26885. */
  26886. _normals: number[];
  26887. /**
  26888. * length of the shape in the model indices array (internal use)
  26889. * @hidden
  26890. */
  26891. _indicesLength: number;
  26892. /**
  26893. * Custom position function (internal use)
  26894. * @hidden
  26895. */
  26896. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26897. /**
  26898. * Custom vertex function (internal use)
  26899. * @hidden
  26900. */
  26901. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26902. /**
  26903. * 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.
  26904. * SPS internal tool, don't use it manually.
  26905. * @hidden
  26906. */
  26907. 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>);
  26908. }
  26909. /**
  26910. * Represents a Depth Sorted Particle in the solid particle system.
  26911. */
  26912. export class DepthSortedParticle {
  26913. /**
  26914. * Index of the particle in the "indices" array
  26915. */
  26916. ind: number;
  26917. /**
  26918. * Length of the particle shape in the "indices" array
  26919. */
  26920. indicesLength: number;
  26921. /**
  26922. * Squared distance from the particle to the camera
  26923. */
  26924. sqDistance: number;
  26925. }
  26926. }
  26927. declare module "babylonjs/Collisions/meshCollisionData" {
  26928. import { Collider } from "babylonjs/Collisions/collider";
  26929. import { Vector3 } from "babylonjs/Maths/math.vector";
  26930. import { Nullable } from "babylonjs/types";
  26931. import { Observer } from "babylonjs/Misc/observable";
  26932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26933. /**
  26934. * @hidden
  26935. */
  26936. export class _MeshCollisionData {
  26937. _checkCollisions: boolean;
  26938. _collisionMask: number;
  26939. _collisionGroup: number;
  26940. _collider: Nullable<Collider>;
  26941. _oldPositionForCollisions: Vector3;
  26942. _diffPositionForCollisions: Vector3;
  26943. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26944. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26945. }
  26946. }
  26947. declare module "babylonjs/Meshes/abstractMesh" {
  26948. import { Observable } from "babylonjs/Misc/observable";
  26949. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26950. import { Camera } from "babylonjs/Cameras/camera";
  26951. import { Scene, IDisposable } from "babylonjs/scene";
  26952. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26953. import { Node } from "babylonjs/node";
  26954. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26956. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26957. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26958. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26959. import { Material } from "babylonjs/Materials/material";
  26960. import { Light } from "babylonjs/Lights/light";
  26961. import { Skeleton } from "babylonjs/Bones/skeleton";
  26962. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26963. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26964. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26965. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26966. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26967. import { Plane } from "babylonjs/Maths/math.plane";
  26968. import { Ray } from "babylonjs/Culling/ray";
  26969. import { Collider } from "babylonjs/Collisions/collider";
  26970. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26971. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26972. /** @hidden */
  26973. class _FacetDataStorage {
  26974. facetPositions: Vector3[];
  26975. facetNormals: Vector3[];
  26976. facetPartitioning: number[][];
  26977. facetNb: number;
  26978. partitioningSubdivisions: number;
  26979. partitioningBBoxRatio: number;
  26980. facetDataEnabled: boolean;
  26981. facetParameters: any;
  26982. bbSize: Vector3;
  26983. subDiv: {
  26984. max: number;
  26985. X: number;
  26986. Y: number;
  26987. Z: number;
  26988. };
  26989. facetDepthSort: boolean;
  26990. facetDepthSortEnabled: boolean;
  26991. depthSortedIndices: IndicesArray;
  26992. depthSortedFacets: {
  26993. ind: number;
  26994. sqDistance: number;
  26995. }[];
  26996. facetDepthSortFunction: (f1: {
  26997. ind: number;
  26998. sqDistance: number;
  26999. }, f2: {
  27000. ind: number;
  27001. sqDistance: number;
  27002. }) => number;
  27003. facetDepthSortFrom: Vector3;
  27004. facetDepthSortOrigin: Vector3;
  27005. invertedMatrix: Matrix;
  27006. }
  27007. /**
  27008. * @hidden
  27009. **/
  27010. class _InternalAbstractMeshDataInfo {
  27011. _hasVertexAlpha: boolean;
  27012. _useVertexColors: boolean;
  27013. _numBoneInfluencers: number;
  27014. _applyFog: boolean;
  27015. _receiveShadows: boolean;
  27016. _facetData: _FacetDataStorage;
  27017. _visibility: number;
  27018. _skeleton: Nullable<Skeleton>;
  27019. _layerMask: number;
  27020. _computeBonesUsingShaders: boolean;
  27021. _isActive: boolean;
  27022. _onlyForInstances: boolean;
  27023. _isActiveIntermediate: boolean;
  27024. _onlyForInstancesIntermediate: boolean;
  27025. _actAsRegularMesh: boolean;
  27026. }
  27027. /**
  27028. * Class used to store all common mesh properties
  27029. */
  27030. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27031. /** No occlusion */
  27032. static OCCLUSION_TYPE_NONE: number;
  27033. /** Occlusion set to optimisitic */
  27034. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27035. /** Occlusion set to strict */
  27036. static OCCLUSION_TYPE_STRICT: number;
  27037. /** Use an accurante occlusion algorithm */
  27038. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27039. /** Use a conservative occlusion algorithm */
  27040. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27041. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27042. * Test order :
  27043. * Is the bounding sphere outside the frustum ?
  27044. * If not, are the bounding box vertices outside the frustum ?
  27045. * It not, then the cullable object is in the frustum.
  27046. */
  27047. static readonly CULLINGSTRATEGY_STANDARD: number;
  27048. /** Culling strategy : Bounding Sphere Only.
  27049. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27050. * It's also less accurate than the standard because some not visible objects can still be selected.
  27051. * Test : is the bounding sphere outside the frustum ?
  27052. * If not, then the cullable object is in the frustum.
  27053. */
  27054. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27055. /** Culling strategy : Optimistic Inclusion.
  27056. * This in an inclusion test first, then the standard exclusion test.
  27057. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27058. * 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.
  27059. * Anyway, it's as accurate as the standard strategy.
  27060. * Test :
  27061. * Is the cullable object bounding sphere center in the frustum ?
  27062. * If not, apply the default culling strategy.
  27063. */
  27064. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27065. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27066. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27067. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27068. * 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.
  27069. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27070. * Test :
  27071. * Is the cullable object bounding sphere center in the frustum ?
  27072. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27073. */
  27074. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27075. /**
  27076. * No billboard
  27077. */
  27078. static readonly BILLBOARDMODE_NONE: number;
  27079. /** Billboard on X axis */
  27080. static readonly BILLBOARDMODE_X: number;
  27081. /** Billboard on Y axis */
  27082. static readonly BILLBOARDMODE_Y: number;
  27083. /** Billboard on Z axis */
  27084. static readonly BILLBOARDMODE_Z: number;
  27085. /** Billboard on all axes */
  27086. static readonly BILLBOARDMODE_ALL: number;
  27087. /** Billboard on using position instead of orientation */
  27088. static readonly BILLBOARDMODE_USE_POSITION: number;
  27089. /** @hidden */
  27090. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27091. /**
  27092. * The culling strategy to use to check whether the mesh must be rendered or not.
  27093. * This value can be changed at any time and will be used on the next render mesh selection.
  27094. * The possible values are :
  27095. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27096. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27097. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27098. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27099. * Please read each static variable documentation to get details about the culling process.
  27100. * */
  27101. cullingStrategy: number;
  27102. /**
  27103. * Gets the number of facets in the mesh
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27105. */
  27106. readonly facetNb: number;
  27107. /**
  27108. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27110. */
  27111. partitioningSubdivisions: number;
  27112. /**
  27113. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27114. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27116. */
  27117. partitioningBBoxRatio: number;
  27118. /**
  27119. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27120. * Works only for updatable meshes.
  27121. * Doesn't work with multi-materials
  27122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27123. */
  27124. mustDepthSortFacets: boolean;
  27125. /**
  27126. * The location (Vector3) where the facet depth sort must be computed from.
  27127. * By default, the active camera position.
  27128. * Used only when facet depth sort is enabled
  27129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27130. */
  27131. facetDepthSortFrom: Vector3;
  27132. /**
  27133. * gets a boolean indicating if facetData is enabled
  27134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27135. */
  27136. readonly isFacetDataEnabled: boolean;
  27137. /** @hidden */
  27138. _updateNonUniformScalingState(value: boolean): boolean;
  27139. /**
  27140. * An event triggered when this mesh collides with another one
  27141. */
  27142. onCollideObservable: Observable<AbstractMesh>;
  27143. /** Set a function to call when this mesh collides with another one */
  27144. onCollide: () => void;
  27145. /**
  27146. * An event triggered when the collision's position changes
  27147. */
  27148. onCollisionPositionChangeObservable: Observable<Vector3>;
  27149. /** Set a function to call when the collision's position changes */
  27150. onCollisionPositionChange: () => void;
  27151. /**
  27152. * An event triggered when material is changed
  27153. */
  27154. onMaterialChangedObservable: Observable<AbstractMesh>;
  27155. /**
  27156. * Gets or sets the orientation for POV movement & rotation
  27157. */
  27158. definedFacingForward: boolean;
  27159. /** @hidden */
  27160. _occlusionQuery: Nullable<WebGLQuery>;
  27161. /** @hidden */
  27162. _renderingGroup: Nullable<RenderingGroup>;
  27163. /**
  27164. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27165. */
  27166. /**
  27167. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27168. */
  27169. visibility: number;
  27170. /** Gets or sets the alpha index used to sort transparent meshes
  27171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27172. */
  27173. alphaIndex: number;
  27174. /**
  27175. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27176. */
  27177. isVisible: boolean;
  27178. /**
  27179. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27180. */
  27181. isPickable: boolean;
  27182. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27183. showSubMeshesBoundingBox: boolean;
  27184. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27185. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27186. */
  27187. isBlocker: boolean;
  27188. /**
  27189. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27190. */
  27191. enablePointerMoveEvents: boolean;
  27192. /**
  27193. * Specifies the rendering group id for this mesh (0 by default)
  27194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27195. */
  27196. renderingGroupId: number;
  27197. private _material;
  27198. /** Gets or sets current material */
  27199. material: Nullable<Material>;
  27200. /**
  27201. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27202. * @see http://doc.babylonjs.com/babylon101/shadows
  27203. */
  27204. receiveShadows: boolean;
  27205. /** Defines color to use when rendering outline */
  27206. outlineColor: Color3;
  27207. /** Define width to use when rendering outline */
  27208. outlineWidth: number;
  27209. /** Defines color to use when rendering overlay */
  27210. overlayColor: Color3;
  27211. /** Defines alpha to use when rendering overlay */
  27212. overlayAlpha: number;
  27213. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27214. hasVertexAlpha: boolean;
  27215. /** 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) */
  27216. useVertexColors: boolean;
  27217. /**
  27218. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27219. */
  27220. computeBonesUsingShaders: boolean;
  27221. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27222. numBoneInfluencers: number;
  27223. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27224. applyFog: boolean;
  27225. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27226. useOctreeForRenderingSelection: boolean;
  27227. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27228. useOctreeForPicking: boolean;
  27229. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27230. useOctreeForCollisions: boolean;
  27231. /**
  27232. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27233. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27234. */
  27235. layerMask: number;
  27236. /**
  27237. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27238. */
  27239. alwaysSelectAsActiveMesh: boolean;
  27240. /**
  27241. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27242. */
  27243. doNotSyncBoundingInfo: boolean;
  27244. /**
  27245. * Gets or sets the current action manager
  27246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27247. */
  27248. actionManager: Nullable<AbstractActionManager>;
  27249. private _meshCollisionData;
  27250. /**
  27251. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27253. */
  27254. ellipsoid: Vector3;
  27255. /**
  27256. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27257. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27258. */
  27259. ellipsoidOffset: Vector3;
  27260. /**
  27261. * Gets or sets a collision mask used to mask collisions (default is -1).
  27262. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27263. */
  27264. collisionMask: number;
  27265. /**
  27266. * Gets or sets the current collision group mask (-1 by default).
  27267. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27268. */
  27269. collisionGroup: number;
  27270. /**
  27271. * Defines edge width used when edgesRenderer is enabled
  27272. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27273. */
  27274. edgesWidth: number;
  27275. /**
  27276. * Defines edge color used when edgesRenderer is enabled
  27277. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27278. */
  27279. edgesColor: Color4;
  27280. /** @hidden */
  27281. _edgesRenderer: Nullable<IEdgesRenderer>;
  27282. /** @hidden */
  27283. _masterMesh: Nullable<AbstractMesh>;
  27284. /** @hidden */
  27285. _boundingInfo: Nullable<BoundingInfo>;
  27286. /** @hidden */
  27287. _renderId: number;
  27288. /**
  27289. * Gets or sets the list of subMeshes
  27290. * @see http://doc.babylonjs.com/how_to/multi_materials
  27291. */
  27292. subMeshes: SubMesh[];
  27293. /** @hidden */
  27294. _intersectionsInProgress: AbstractMesh[];
  27295. /** @hidden */
  27296. _unIndexed: boolean;
  27297. /** @hidden */
  27298. _lightSources: Light[];
  27299. /** Gets the list of lights affecting that mesh */
  27300. readonly lightSources: Light[];
  27301. /** @hidden */
  27302. readonly _positions: Nullable<Vector3[]>;
  27303. /** @hidden */
  27304. _waitingData: {
  27305. lods: Nullable<any>;
  27306. actions: Nullable<any>;
  27307. freezeWorldMatrix: Nullable<boolean>;
  27308. };
  27309. /** @hidden */
  27310. _bonesTransformMatrices: Nullable<Float32Array>;
  27311. /** @hidden */
  27312. _transformMatrixTexture: Nullable<RawTexture>;
  27313. /**
  27314. * Gets or sets a skeleton to apply skining transformations
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27316. */
  27317. skeleton: Nullable<Skeleton>;
  27318. /**
  27319. * An event triggered when the mesh is rebuilt.
  27320. */
  27321. onRebuildObservable: Observable<AbstractMesh>;
  27322. /**
  27323. * Creates a new AbstractMesh
  27324. * @param name defines the name of the mesh
  27325. * @param scene defines the hosting scene
  27326. */
  27327. constructor(name: string, scene?: Nullable<Scene>);
  27328. /**
  27329. * Returns the string "AbstractMesh"
  27330. * @returns "AbstractMesh"
  27331. */
  27332. getClassName(): string;
  27333. /**
  27334. * Gets a string representation of the current mesh
  27335. * @param fullDetails defines a boolean indicating if full details must be included
  27336. * @returns a string representation of the current mesh
  27337. */
  27338. toString(fullDetails?: boolean): string;
  27339. /**
  27340. * @hidden
  27341. */
  27342. protected _getEffectiveParent(): Nullable<Node>;
  27343. /** @hidden */
  27344. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27345. /** @hidden */
  27346. _rebuild(): void;
  27347. /** @hidden */
  27348. _resyncLightSources(): void;
  27349. /** @hidden */
  27350. _resyncLighSource(light: Light): void;
  27351. /** @hidden */
  27352. _unBindEffect(): void;
  27353. /** @hidden */
  27354. _removeLightSource(light: Light, dispose: boolean): void;
  27355. private _markSubMeshesAsDirty;
  27356. /** @hidden */
  27357. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27358. /** @hidden */
  27359. _markSubMeshesAsAttributesDirty(): void;
  27360. /** @hidden */
  27361. _markSubMeshesAsMiscDirty(): void;
  27362. /**
  27363. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27364. */
  27365. scaling: Vector3;
  27366. /**
  27367. * Returns true if the mesh is blocked. Implemented by child classes
  27368. */
  27369. readonly isBlocked: boolean;
  27370. /**
  27371. * Returns the mesh itself by default. Implemented by child classes
  27372. * @param camera defines the camera to use to pick the right LOD level
  27373. * @returns the currentAbstractMesh
  27374. */
  27375. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27376. /**
  27377. * Returns 0 by default. Implemented by child classes
  27378. * @returns an integer
  27379. */
  27380. getTotalVertices(): number;
  27381. /**
  27382. * Returns a positive integer : the total number of indices in this mesh geometry.
  27383. * @returns the numner of indices or zero if the mesh has no geometry.
  27384. */
  27385. getTotalIndices(): number;
  27386. /**
  27387. * Returns null by default. Implemented by child classes
  27388. * @returns null
  27389. */
  27390. getIndices(): Nullable<IndicesArray>;
  27391. /**
  27392. * Returns the array of the requested vertex data kind. Implemented by child classes
  27393. * @param kind defines the vertex data kind to use
  27394. * @returns null
  27395. */
  27396. getVerticesData(kind: string): Nullable<FloatArray>;
  27397. /**
  27398. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27399. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27400. * Note that a new underlying VertexBuffer object is created each call.
  27401. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27402. * @param kind defines vertex data kind:
  27403. * * VertexBuffer.PositionKind
  27404. * * VertexBuffer.UVKind
  27405. * * VertexBuffer.UV2Kind
  27406. * * VertexBuffer.UV3Kind
  27407. * * VertexBuffer.UV4Kind
  27408. * * VertexBuffer.UV5Kind
  27409. * * VertexBuffer.UV6Kind
  27410. * * VertexBuffer.ColorKind
  27411. * * VertexBuffer.MatricesIndicesKind
  27412. * * VertexBuffer.MatricesIndicesExtraKind
  27413. * * VertexBuffer.MatricesWeightsKind
  27414. * * VertexBuffer.MatricesWeightsExtraKind
  27415. * @param data defines the data source
  27416. * @param updatable defines if the data must be flagged as updatable (or static)
  27417. * @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
  27418. * @returns the current mesh
  27419. */
  27420. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27421. /**
  27422. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27423. * If the mesh has no geometry, it is simply returned as it is.
  27424. * @param kind defines vertex data kind:
  27425. * * VertexBuffer.PositionKind
  27426. * * VertexBuffer.UVKind
  27427. * * VertexBuffer.UV2Kind
  27428. * * VertexBuffer.UV3Kind
  27429. * * VertexBuffer.UV4Kind
  27430. * * VertexBuffer.UV5Kind
  27431. * * VertexBuffer.UV6Kind
  27432. * * VertexBuffer.ColorKind
  27433. * * VertexBuffer.MatricesIndicesKind
  27434. * * VertexBuffer.MatricesIndicesExtraKind
  27435. * * VertexBuffer.MatricesWeightsKind
  27436. * * VertexBuffer.MatricesWeightsExtraKind
  27437. * @param data defines the data source
  27438. * @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
  27439. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27440. * @returns the current mesh
  27441. */
  27442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27443. /**
  27444. * Sets the mesh indices,
  27445. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27446. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27447. * @param totalVertices Defines the total number of vertices
  27448. * @returns the current mesh
  27449. */
  27450. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27451. /**
  27452. * Gets a boolean indicating if specific vertex data is present
  27453. * @param kind defines the vertex data kind to use
  27454. * @returns true is data kind is present
  27455. */
  27456. isVerticesDataPresent(kind: string): boolean;
  27457. /**
  27458. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27459. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27460. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27461. * @returns a BoundingInfo
  27462. */
  27463. getBoundingInfo(): BoundingInfo;
  27464. /**
  27465. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27466. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27467. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27468. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27469. * @returns the current mesh
  27470. */
  27471. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27472. /**
  27473. * Overwrite the current bounding info
  27474. * @param boundingInfo defines the new bounding info
  27475. * @returns the current mesh
  27476. */
  27477. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27478. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27479. readonly useBones: boolean;
  27480. /** @hidden */
  27481. _preActivate(): void;
  27482. /** @hidden */
  27483. _preActivateForIntermediateRendering(renderId: number): void;
  27484. /** @hidden */
  27485. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27486. /** @hidden */
  27487. _postActivate(): void;
  27488. /** @hidden */
  27489. _freeze(): void;
  27490. /** @hidden */
  27491. _unFreeze(): void;
  27492. /**
  27493. * Gets the current world matrix
  27494. * @returns a Matrix
  27495. */
  27496. getWorldMatrix(): Matrix;
  27497. /** @hidden */
  27498. _getWorldMatrixDeterminant(): number;
  27499. /**
  27500. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27501. */
  27502. readonly isAnInstance: boolean;
  27503. /**
  27504. * Gets a boolean indicating if this mesh has instances
  27505. */
  27506. readonly hasInstances: boolean;
  27507. /**
  27508. * Perform relative position change from the point of view of behind the front of the mesh.
  27509. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27510. * Supports definition of mesh facing forward or backward
  27511. * @param amountRight defines the distance on the right axis
  27512. * @param amountUp defines the distance on the up axis
  27513. * @param amountForward defines the distance on the forward axis
  27514. * @returns the current mesh
  27515. */
  27516. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27517. /**
  27518. * Calculate relative position change from the point of view of behind the front of the mesh.
  27519. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27520. * Supports definition of mesh facing forward or backward
  27521. * @param amountRight defines the distance on the right axis
  27522. * @param amountUp defines the distance on the up axis
  27523. * @param amountForward defines the distance on the forward axis
  27524. * @returns the new displacement vector
  27525. */
  27526. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27527. /**
  27528. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27529. * Supports definition of mesh facing forward or backward
  27530. * @param flipBack defines the flip
  27531. * @param twirlClockwise defines the twirl
  27532. * @param tiltRight defines the tilt
  27533. * @returns the current mesh
  27534. */
  27535. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27536. /**
  27537. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27538. * Supports definition of mesh facing forward or backward.
  27539. * @param flipBack defines the flip
  27540. * @param twirlClockwise defines the twirl
  27541. * @param tiltRight defines the tilt
  27542. * @returns the new rotation vector
  27543. */
  27544. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27545. /**
  27546. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27547. * This means the mesh underlying bounding box and sphere are recomputed.
  27548. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27549. * @returns the current mesh
  27550. */
  27551. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27552. /** @hidden */
  27553. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27554. /** @hidden */
  27555. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27556. /** @hidden */
  27557. _updateBoundingInfo(): AbstractMesh;
  27558. /** @hidden */
  27559. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27560. /** @hidden */
  27561. protected _afterComputeWorldMatrix(): void;
  27562. /** @hidden */
  27563. readonly _effectiveMesh: AbstractMesh;
  27564. /**
  27565. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27566. * A mesh is in the frustum if its bounding box intersects the frustum
  27567. * @param frustumPlanes defines the frustum to test
  27568. * @returns true if the mesh is in the frustum planes
  27569. */
  27570. isInFrustum(frustumPlanes: Plane[]): boolean;
  27571. /**
  27572. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27573. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27574. * @param frustumPlanes defines the frustum to test
  27575. * @returns true if the mesh is completely in the frustum planes
  27576. */
  27577. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27578. /**
  27579. * True if the mesh intersects another mesh or a SolidParticle object
  27580. * @param mesh defines a target mesh or SolidParticle to test
  27581. * @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)
  27582. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27583. * @returns true if there is an intersection
  27584. */
  27585. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27586. /**
  27587. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27588. * @param point defines the point to test
  27589. * @returns true if there is an intersection
  27590. */
  27591. intersectsPoint(point: Vector3): boolean;
  27592. /**
  27593. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27595. */
  27596. checkCollisions: boolean;
  27597. /**
  27598. * Gets Collider object used to compute collisions (not physics)
  27599. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27600. */
  27601. readonly collider: Nullable<Collider>;
  27602. /**
  27603. * Move the mesh using collision engine
  27604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27605. * @param displacement defines the requested displacement vector
  27606. * @returns the current mesh
  27607. */
  27608. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27609. private _onCollisionPositionChange;
  27610. /** @hidden */
  27611. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27612. /** @hidden */
  27613. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27614. /** @hidden */
  27615. _checkCollision(collider: Collider): AbstractMesh;
  27616. /** @hidden */
  27617. _generatePointsArray(): boolean;
  27618. /**
  27619. * Checks if the passed Ray intersects with the mesh
  27620. * @param ray defines the ray to use
  27621. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27622. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27623. * @returns the picking info
  27624. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27625. */
  27626. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27627. /**
  27628. * Clones the current mesh
  27629. * @param name defines the mesh name
  27630. * @param newParent defines the new mesh parent
  27631. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27632. * @returns the new mesh
  27633. */
  27634. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27635. /**
  27636. * Disposes all the submeshes of the current meshnp
  27637. * @returns the current mesh
  27638. */
  27639. releaseSubMeshes(): AbstractMesh;
  27640. /**
  27641. * Releases resources associated with this abstract mesh.
  27642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27644. */
  27645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27646. /**
  27647. * Adds the passed mesh as a child to the current mesh
  27648. * @param mesh defines the child mesh
  27649. * @returns the current mesh
  27650. */
  27651. addChild(mesh: AbstractMesh): AbstractMesh;
  27652. /**
  27653. * Removes the passed mesh from the current mesh children list
  27654. * @param mesh defines the child mesh
  27655. * @returns the current mesh
  27656. */
  27657. removeChild(mesh: AbstractMesh): AbstractMesh;
  27658. /** @hidden */
  27659. private _initFacetData;
  27660. /**
  27661. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27662. * This method can be called within the render loop.
  27663. * 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
  27664. * @returns the current mesh
  27665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27666. */
  27667. updateFacetData(): AbstractMesh;
  27668. /**
  27669. * Returns the facetLocalNormals array.
  27670. * The normals are expressed in the mesh local spac
  27671. * @returns an array of Vector3
  27672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27673. */
  27674. getFacetLocalNormals(): Vector3[];
  27675. /**
  27676. * Returns the facetLocalPositions array.
  27677. * The facet positions are expressed in the mesh local space
  27678. * @returns an array of Vector3
  27679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27680. */
  27681. getFacetLocalPositions(): Vector3[];
  27682. /**
  27683. * Returns the facetLocalPartioning array
  27684. * @returns an array of array of numbers
  27685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27686. */
  27687. getFacetLocalPartitioning(): number[][];
  27688. /**
  27689. * Returns the i-th facet position in the world system.
  27690. * This method allocates a new Vector3 per call
  27691. * @param i defines the facet index
  27692. * @returns a new Vector3
  27693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27694. */
  27695. getFacetPosition(i: number): Vector3;
  27696. /**
  27697. * Sets the reference Vector3 with the i-th facet position in the world system
  27698. * @param i defines the facet index
  27699. * @param ref defines the target vector
  27700. * @returns the current mesh
  27701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27702. */
  27703. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27704. /**
  27705. * Returns the i-th facet normal in the world system.
  27706. * This method allocates a new Vector3 per call
  27707. * @param i defines the facet index
  27708. * @returns a new Vector3
  27709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27710. */
  27711. getFacetNormal(i: number): Vector3;
  27712. /**
  27713. * Sets the reference Vector3 with the i-th facet normal in the world system
  27714. * @param i defines the facet index
  27715. * @param ref defines the target vector
  27716. * @returns the current mesh
  27717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27718. */
  27719. getFacetNormalToRef(i: number, ref: Vector3): this;
  27720. /**
  27721. * 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)
  27722. * @param x defines x coordinate
  27723. * @param y defines y coordinate
  27724. * @param z defines z coordinate
  27725. * @returns the array of facet indexes
  27726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27727. */
  27728. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27729. /**
  27730. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27731. * @param projected sets as the (x,y,z) world projection on the facet
  27732. * @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
  27733. * @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
  27734. * @param x defines x coordinate
  27735. * @param y defines y coordinate
  27736. * @param z defines z coordinate
  27737. * @returns the face index if found (or null instead)
  27738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27739. */
  27740. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27741. /**
  27742. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27743. * @param projected sets as the (x,y,z) local projection on the facet
  27744. * @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
  27745. * @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
  27746. * @param x defines x coordinate
  27747. * @param y defines y coordinate
  27748. * @param z defines z coordinate
  27749. * @returns the face index if found (or null instead)
  27750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27751. */
  27752. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27753. /**
  27754. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27755. * @returns the parameters
  27756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27757. */
  27758. getFacetDataParameters(): any;
  27759. /**
  27760. * Disables the feature FacetData and frees the related memory
  27761. * @returns the current mesh
  27762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27763. */
  27764. disableFacetData(): AbstractMesh;
  27765. /**
  27766. * Updates the AbstractMesh indices array
  27767. * @param indices defines the data source
  27768. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27769. * @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)
  27770. * @returns the current mesh
  27771. */
  27772. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27773. /**
  27774. * Creates new normals data for the mesh
  27775. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27776. * @returns the current mesh
  27777. */
  27778. createNormals(updatable: boolean): AbstractMesh;
  27779. /**
  27780. * Align the mesh with a normal
  27781. * @param normal defines the normal to use
  27782. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27783. * @returns the current mesh
  27784. */
  27785. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27786. /** @hidden */
  27787. _checkOcclusionQuery(): boolean;
  27788. /**
  27789. * Disables the mesh edge rendering mode
  27790. * @returns the currentAbstractMesh
  27791. */
  27792. disableEdgesRendering(): AbstractMesh;
  27793. /**
  27794. * Enables the edge rendering mode on the mesh.
  27795. * This mode makes the mesh edges visible
  27796. * @param epsilon defines the maximal distance between two angles to detect a face
  27797. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27798. * @returns the currentAbstractMesh
  27799. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27800. */
  27801. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27802. }
  27803. }
  27804. declare module "babylonjs/Actions/actionEvent" {
  27805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27806. import { Nullable } from "babylonjs/types";
  27807. import { Sprite } from "babylonjs/Sprites/sprite";
  27808. import { Scene } from "babylonjs/scene";
  27809. import { Vector2 } from "babylonjs/Maths/math.vector";
  27810. /**
  27811. * Interface used to define ActionEvent
  27812. */
  27813. export interface IActionEvent {
  27814. /** The mesh or sprite that triggered the action */
  27815. source: any;
  27816. /** The X mouse cursor position at the time of the event */
  27817. pointerX: number;
  27818. /** The Y mouse cursor position at the time of the event */
  27819. pointerY: number;
  27820. /** The mesh that is currently pointed at (can be null) */
  27821. meshUnderPointer: Nullable<AbstractMesh>;
  27822. /** the original (browser) event that triggered the ActionEvent */
  27823. sourceEvent?: any;
  27824. /** additional data for the event */
  27825. additionalData?: any;
  27826. }
  27827. /**
  27828. * ActionEvent is the event being sent when an action is triggered.
  27829. */
  27830. export class ActionEvent implements IActionEvent {
  27831. /** The mesh or sprite that triggered the action */
  27832. source: any;
  27833. /** The X mouse cursor position at the time of the event */
  27834. pointerX: number;
  27835. /** The Y mouse cursor position at the time of the event */
  27836. pointerY: number;
  27837. /** The mesh that is currently pointed at (can be null) */
  27838. meshUnderPointer: Nullable<AbstractMesh>;
  27839. /** the original (browser) event that triggered the ActionEvent */
  27840. sourceEvent?: any;
  27841. /** additional data for the event */
  27842. additionalData?: any;
  27843. /**
  27844. * Creates a new ActionEvent
  27845. * @param source The mesh or sprite that triggered the action
  27846. * @param pointerX The X mouse cursor position at the time of the event
  27847. * @param pointerY The Y mouse cursor position at the time of the event
  27848. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27849. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27850. * @param additionalData additional data for the event
  27851. */
  27852. constructor(
  27853. /** The mesh or sprite that triggered the action */
  27854. source: any,
  27855. /** The X mouse cursor position at the time of the event */
  27856. pointerX: number,
  27857. /** The Y mouse cursor position at the time of the event */
  27858. pointerY: number,
  27859. /** The mesh that is currently pointed at (can be null) */
  27860. meshUnderPointer: Nullable<AbstractMesh>,
  27861. /** the original (browser) event that triggered the ActionEvent */
  27862. sourceEvent?: any,
  27863. /** additional data for the event */
  27864. additionalData?: any);
  27865. /**
  27866. * Helper function to auto-create an ActionEvent from a source mesh.
  27867. * @param source The source mesh that triggered the event
  27868. * @param evt The original (browser) event
  27869. * @param additionalData additional data for the event
  27870. * @returns the new ActionEvent
  27871. */
  27872. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27873. /**
  27874. * Helper function to auto-create an ActionEvent from a source sprite
  27875. * @param source The source sprite that triggered the event
  27876. * @param scene Scene associated with the sprite
  27877. * @param evt The original (browser) event
  27878. * @param additionalData additional data for the event
  27879. * @returns the new ActionEvent
  27880. */
  27881. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27882. /**
  27883. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27884. * @param scene the scene where the event occurred
  27885. * @param evt The original (browser) event
  27886. * @returns the new ActionEvent
  27887. */
  27888. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27889. /**
  27890. * Helper function to auto-create an ActionEvent from a primitive
  27891. * @param prim defines the target primitive
  27892. * @param pointerPos defines the pointer position
  27893. * @param evt The original (browser) event
  27894. * @param additionalData additional data for the event
  27895. * @returns the new ActionEvent
  27896. */
  27897. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27898. }
  27899. }
  27900. declare module "babylonjs/Actions/abstractActionManager" {
  27901. import { IDisposable } from "babylonjs/scene";
  27902. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27903. import { IAction } from "babylonjs/Actions/action";
  27904. import { Nullable } from "babylonjs/types";
  27905. /**
  27906. * Abstract class used to decouple action Manager from scene and meshes.
  27907. * Do not instantiate.
  27908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27909. */
  27910. export abstract class AbstractActionManager implements IDisposable {
  27911. /** Gets the list of active triggers */
  27912. static Triggers: {
  27913. [key: string]: number;
  27914. };
  27915. /** Gets the cursor to use when hovering items */
  27916. hoverCursor: string;
  27917. /** Gets the list of actions */
  27918. actions: IAction[];
  27919. /**
  27920. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27921. */
  27922. isRecursive: boolean;
  27923. /**
  27924. * Releases all associated resources
  27925. */
  27926. abstract dispose(): void;
  27927. /**
  27928. * Does this action manager has pointer triggers
  27929. */
  27930. abstract readonly hasPointerTriggers: boolean;
  27931. /**
  27932. * Does this action manager has pick triggers
  27933. */
  27934. abstract readonly hasPickTriggers: boolean;
  27935. /**
  27936. * Process a specific trigger
  27937. * @param trigger defines the trigger to process
  27938. * @param evt defines the event details to be processed
  27939. */
  27940. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27941. /**
  27942. * Does this action manager handles actions of any of the given triggers
  27943. * @param triggers defines the triggers to be tested
  27944. * @return a boolean indicating whether one (or more) of the triggers is handled
  27945. */
  27946. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27947. /**
  27948. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27949. * speed.
  27950. * @param triggerA defines the trigger to be tested
  27951. * @param triggerB defines the trigger to be tested
  27952. * @return a boolean indicating whether one (or more) of the triggers is handled
  27953. */
  27954. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27955. /**
  27956. * Does this action manager handles actions of a given trigger
  27957. * @param trigger defines the trigger to be tested
  27958. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27959. * @return whether the trigger is handled
  27960. */
  27961. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27962. /**
  27963. * Serialize this manager to a JSON object
  27964. * @param name defines the property name to store this manager
  27965. * @returns a JSON representation of this manager
  27966. */
  27967. abstract serialize(name: string): any;
  27968. /**
  27969. * Registers an action to this action manager
  27970. * @param action defines the action to be registered
  27971. * @return the action amended (prepared) after registration
  27972. */
  27973. abstract registerAction(action: IAction): Nullable<IAction>;
  27974. /**
  27975. * Unregisters an action to this action manager
  27976. * @param action defines the action to be unregistered
  27977. * @return a boolean indicating whether the action has been unregistered
  27978. */
  27979. abstract unregisterAction(action: IAction): Boolean;
  27980. /**
  27981. * Does exist one action manager with at least one trigger
  27982. **/
  27983. static readonly HasTriggers: boolean;
  27984. /**
  27985. * Does exist one action manager with at least one pick trigger
  27986. **/
  27987. static readonly HasPickTriggers: boolean;
  27988. /**
  27989. * Does exist one action manager that handles actions of a given trigger
  27990. * @param trigger defines the trigger to be tested
  27991. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27992. **/
  27993. static HasSpecificTrigger(trigger: number): boolean;
  27994. }
  27995. }
  27996. declare module "babylonjs/node" {
  27997. import { Scene } from "babylonjs/scene";
  27998. import { Nullable } from "babylonjs/types";
  27999. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28000. import { Engine } from "babylonjs/Engines/engine";
  28001. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28002. import { Observable } from "babylonjs/Misc/observable";
  28003. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28004. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28005. import { Animatable } from "babylonjs/Animations/animatable";
  28006. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28007. import { Animation } from "babylonjs/Animations/animation";
  28008. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28010. /**
  28011. * Defines how a node can be built from a string name.
  28012. */
  28013. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28014. /**
  28015. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28016. */
  28017. export class Node implements IBehaviorAware<Node> {
  28018. /** @hidden */
  28019. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28020. private static _NodeConstructors;
  28021. /**
  28022. * Add a new node constructor
  28023. * @param type defines the type name of the node to construct
  28024. * @param constructorFunc defines the constructor function
  28025. */
  28026. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28027. /**
  28028. * Returns a node constructor based on type name
  28029. * @param type defines the type name
  28030. * @param name defines the new node name
  28031. * @param scene defines the hosting scene
  28032. * @param options defines optional options to transmit to constructors
  28033. * @returns the new constructor or null
  28034. */
  28035. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28036. /**
  28037. * Gets or sets the name of the node
  28038. */
  28039. name: string;
  28040. /**
  28041. * Gets or sets the id of the node
  28042. */
  28043. id: string;
  28044. /**
  28045. * Gets or sets the unique id of the node
  28046. */
  28047. uniqueId: number;
  28048. /**
  28049. * Gets or sets a string used to store user defined state for the node
  28050. */
  28051. state: string;
  28052. /**
  28053. * Gets or sets an object used to store user defined information for the node
  28054. */
  28055. metadata: any;
  28056. /**
  28057. * For internal use only. Please do not use.
  28058. */
  28059. reservedDataStore: any;
  28060. /**
  28061. * List of inspectable custom properties (used by the Inspector)
  28062. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28063. */
  28064. inspectableCustomProperties: IInspectable[];
  28065. private _doNotSerialize;
  28066. /**
  28067. * Gets or sets a boolean used to define if the node must be serialized
  28068. */
  28069. doNotSerialize: boolean;
  28070. /** @hidden */
  28071. _isDisposed: boolean;
  28072. /**
  28073. * Gets a list of Animations associated with the node
  28074. */
  28075. animations: import("babylonjs/Animations/animation").Animation[];
  28076. protected _ranges: {
  28077. [name: string]: Nullable<AnimationRange>;
  28078. };
  28079. /**
  28080. * Callback raised when the node is ready to be used
  28081. */
  28082. onReady: Nullable<(node: Node) => void>;
  28083. private _isEnabled;
  28084. private _isParentEnabled;
  28085. private _isReady;
  28086. /** @hidden */
  28087. _currentRenderId: number;
  28088. private _parentUpdateId;
  28089. /** @hidden */
  28090. _childUpdateId: number;
  28091. /** @hidden */
  28092. _waitingParentId: Nullable<string>;
  28093. /** @hidden */
  28094. _scene: Scene;
  28095. /** @hidden */
  28096. _cache: any;
  28097. private _parentNode;
  28098. private _children;
  28099. /** @hidden */
  28100. _worldMatrix: Matrix;
  28101. /** @hidden */
  28102. _worldMatrixDeterminant: number;
  28103. /** @hidden */
  28104. _worldMatrixDeterminantIsDirty: boolean;
  28105. /** @hidden */
  28106. private _sceneRootNodesIndex;
  28107. /**
  28108. * Gets a boolean indicating if the node has been disposed
  28109. * @returns true if the node was disposed
  28110. */
  28111. isDisposed(): boolean;
  28112. /**
  28113. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28114. * @see https://doc.babylonjs.com/how_to/parenting
  28115. */
  28116. parent: Nullable<Node>;
  28117. /** @hidden */
  28118. _addToSceneRootNodes(): void;
  28119. /** @hidden */
  28120. _removeFromSceneRootNodes(): void;
  28121. private _animationPropertiesOverride;
  28122. /**
  28123. * Gets or sets the animation properties override
  28124. */
  28125. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28126. /**
  28127. * Gets a string idenfifying the name of the class
  28128. * @returns "Node" string
  28129. */
  28130. getClassName(): string;
  28131. /** @hidden */
  28132. readonly _isNode: boolean;
  28133. /**
  28134. * An event triggered when the mesh is disposed
  28135. */
  28136. onDisposeObservable: Observable<Node>;
  28137. private _onDisposeObserver;
  28138. /**
  28139. * Sets a callback that will be raised when the node will be disposed
  28140. */
  28141. onDispose: () => void;
  28142. /**
  28143. * Creates a new Node
  28144. * @param name the name and id to be given to this node
  28145. * @param scene the scene this node will be added to
  28146. */
  28147. constructor(name: string, scene?: Nullable<Scene>);
  28148. /**
  28149. * Gets the scene of the node
  28150. * @returns a scene
  28151. */
  28152. getScene(): Scene;
  28153. /**
  28154. * Gets the engine of the node
  28155. * @returns a Engine
  28156. */
  28157. getEngine(): Engine;
  28158. private _behaviors;
  28159. /**
  28160. * Attach a behavior to the node
  28161. * @see http://doc.babylonjs.com/features/behaviour
  28162. * @param behavior defines the behavior to attach
  28163. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28164. * @returns the current Node
  28165. */
  28166. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28167. /**
  28168. * Remove an attached behavior
  28169. * @see http://doc.babylonjs.com/features/behaviour
  28170. * @param behavior defines the behavior to attach
  28171. * @returns the current Node
  28172. */
  28173. removeBehavior(behavior: Behavior<Node>): Node;
  28174. /**
  28175. * Gets the list of attached behaviors
  28176. * @see http://doc.babylonjs.com/features/behaviour
  28177. */
  28178. readonly behaviors: Behavior<Node>[];
  28179. /**
  28180. * Gets an attached behavior by name
  28181. * @param name defines the name of the behavior to look for
  28182. * @see http://doc.babylonjs.com/features/behaviour
  28183. * @returns null if behavior was not found else the requested behavior
  28184. */
  28185. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28186. /**
  28187. * Returns the latest update of the World matrix
  28188. * @returns a Matrix
  28189. */
  28190. getWorldMatrix(): Matrix;
  28191. /** @hidden */
  28192. _getWorldMatrixDeterminant(): number;
  28193. /**
  28194. * Returns directly the latest state of the mesh World matrix.
  28195. * A Matrix is returned.
  28196. */
  28197. readonly worldMatrixFromCache: Matrix;
  28198. /** @hidden */
  28199. _initCache(): void;
  28200. /** @hidden */
  28201. updateCache(force?: boolean): void;
  28202. /** @hidden */
  28203. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28204. /** @hidden */
  28205. _updateCache(ignoreParentClass?: boolean): void;
  28206. /** @hidden */
  28207. _isSynchronized(): boolean;
  28208. /** @hidden */
  28209. _markSyncedWithParent(): void;
  28210. /** @hidden */
  28211. isSynchronizedWithParent(): boolean;
  28212. /** @hidden */
  28213. isSynchronized(): boolean;
  28214. /**
  28215. * Is this node ready to be used/rendered
  28216. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28217. * @return true if the node is ready
  28218. */
  28219. isReady(completeCheck?: boolean): boolean;
  28220. /**
  28221. * Is this node enabled?
  28222. * 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
  28223. * @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
  28224. * @return whether this node (and its parent) is enabled
  28225. */
  28226. isEnabled(checkAncestors?: boolean): boolean;
  28227. /** @hidden */
  28228. protected _syncParentEnabledState(): void;
  28229. /**
  28230. * Set the enabled state of this node
  28231. * @param value defines the new enabled state
  28232. */
  28233. setEnabled(value: boolean): void;
  28234. /**
  28235. * Is this node a descendant of the given node?
  28236. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28237. * @param ancestor defines the parent node to inspect
  28238. * @returns a boolean indicating if this node is a descendant of the given node
  28239. */
  28240. isDescendantOf(ancestor: Node): boolean;
  28241. /** @hidden */
  28242. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28243. /**
  28244. * Will return all nodes that have this node as ascendant
  28245. * @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
  28246. * @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
  28247. * @return all children nodes of all types
  28248. */
  28249. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28250. /**
  28251. * Get all child-meshes of this node
  28252. * @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)
  28253. * @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
  28254. * @returns an array of AbstractMesh
  28255. */
  28256. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28257. /**
  28258. * Get all direct children of this node
  28259. * @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
  28260. * @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)
  28261. * @returns an array of Node
  28262. */
  28263. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28264. /** @hidden */
  28265. _setReady(state: boolean): void;
  28266. /**
  28267. * Get an animation by name
  28268. * @param name defines the name of the animation to look for
  28269. * @returns null if not found else the requested animation
  28270. */
  28271. getAnimationByName(name: string): Nullable<Animation>;
  28272. /**
  28273. * Creates an animation range for this node
  28274. * @param name defines the name of the range
  28275. * @param from defines the starting key
  28276. * @param to defines the end key
  28277. */
  28278. createAnimationRange(name: string, from: number, to: number): void;
  28279. /**
  28280. * Delete a specific animation range
  28281. * @param name defines the name of the range to delete
  28282. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28283. */
  28284. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28285. /**
  28286. * Get an animation range by name
  28287. * @param name defines the name of the animation range to look for
  28288. * @returns null if not found else the requested animation range
  28289. */
  28290. getAnimationRange(name: string): Nullable<AnimationRange>;
  28291. /**
  28292. * Gets the list of all animation ranges defined on this node
  28293. * @returns an array
  28294. */
  28295. getAnimationRanges(): Nullable<AnimationRange>[];
  28296. /**
  28297. * Will start the animation sequence
  28298. * @param name defines the range frames for animation sequence
  28299. * @param loop defines if the animation should loop (false by default)
  28300. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28301. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28302. * @returns the object created for this animation. If range does not exist, it will return null
  28303. */
  28304. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28305. /**
  28306. * Serialize animation ranges into a JSON compatible object
  28307. * @returns serialization object
  28308. */
  28309. serializeAnimationRanges(): any;
  28310. /**
  28311. * Computes the world matrix of the node
  28312. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28313. * @returns the world matrix
  28314. */
  28315. computeWorldMatrix(force?: boolean): Matrix;
  28316. /**
  28317. * Releases resources associated with this node.
  28318. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28319. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28320. */
  28321. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28322. /**
  28323. * Parse animation range data from a serialization object and store them into a given node
  28324. * @param node defines where to store the animation ranges
  28325. * @param parsedNode defines the serialization object to read data from
  28326. * @param scene defines the hosting scene
  28327. */
  28328. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28329. /**
  28330. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28331. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28332. * @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
  28333. * @returns the new bounding vectors
  28334. */
  28335. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28336. min: Vector3;
  28337. max: Vector3;
  28338. };
  28339. }
  28340. }
  28341. declare module "babylonjs/Animations/animation" {
  28342. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28343. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28344. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28345. import { Nullable } from "babylonjs/types";
  28346. import { Scene } from "babylonjs/scene";
  28347. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28348. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28349. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28350. import { Node } from "babylonjs/node";
  28351. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28352. import { Size } from "babylonjs/Maths/math.size";
  28353. import { Animatable } from "babylonjs/Animations/animatable";
  28354. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28355. /**
  28356. * @hidden
  28357. */
  28358. export class _IAnimationState {
  28359. key: number;
  28360. repeatCount: number;
  28361. workValue?: any;
  28362. loopMode?: number;
  28363. offsetValue?: any;
  28364. highLimitValue?: any;
  28365. }
  28366. /**
  28367. * Class used to store any kind of animation
  28368. */
  28369. export class Animation {
  28370. /**Name of the animation */
  28371. name: string;
  28372. /**Property to animate */
  28373. targetProperty: string;
  28374. /**The frames per second of the animation */
  28375. framePerSecond: number;
  28376. /**The data type of the animation */
  28377. dataType: number;
  28378. /**The loop mode of the animation */
  28379. loopMode?: number | undefined;
  28380. /**Specifies if blending should be enabled */
  28381. enableBlending?: boolean | undefined;
  28382. /**
  28383. * Use matrix interpolation instead of using direct key value when animating matrices
  28384. */
  28385. static AllowMatricesInterpolation: boolean;
  28386. /**
  28387. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28388. */
  28389. static AllowMatrixDecomposeForInterpolation: boolean;
  28390. /**
  28391. * Stores the key frames of the animation
  28392. */
  28393. private _keys;
  28394. /**
  28395. * Stores the easing function of the animation
  28396. */
  28397. private _easingFunction;
  28398. /**
  28399. * @hidden Internal use only
  28400. */
  28401. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28402. /**
  28403. * The set of event that will be linked to this animation
  28404. */
  28405. private _events;
  28406. /**
  28407. * Stores an array of target property paths
  28408. */
  28409. targetPropertyPath: string[];
  28410. /**
  28411. * Stores the blending speed of the animation
  28412. */
  28413. blendingSpeed: number;
  28414. /**
  28415. * Stores the animation ranges for the animation
  28416. */
  28417. private _ranges;
  28418. /**
  28419. * @hidden Internal use
  28420. */
  28421. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28422. /**
  28423. * Sets up an animation
  28424. * @param property The property to animate
  28425. * @param animationType The animation type to apply
  28426. * @param framePerSecond The frames per second of the animation
  28427. * @param easingFunction The easing function used in the animation
  28428. * @returns The created animation
  28429. */
  28430. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28431. /**
  28432. * Create and start an animation on a node
  28433. * @param name defines the name of the global animation that will be run on all nodes
  28434. * @param node defines the root node where the animation will take place
  28435. * @param targetProperty defines property to animate
  28436. * @param framePerSecond defines the number of frame per second yo use
  28437. * @param totalFrame defines the number of frames in total
  28438. * @param from defines the initial value
  28439. * @param to defines the final value
  28440. * @param loopMode defines which loop mode you want to use (off by default)
  28441. * @param easingFunction defines the easing function to use (linear by default)
  28442. * @param onAnimationEnd defines the callback to call when animation end
  28443. * @returns the animatable created for this animation
  28444. */
  28445. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28446. /**
  28447. * Create and start an animation on a node and its descendants
  28448. * @param name defines the name of the global animation that will be run on all nodes
  28449. * @param node defines the root node where the animation will take place
  28450. * @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
  28451. * @param targetProperty defines property to animate
  28452. * @param framePerSecond defines the number of frame per second to use
  28453. * @param totalFrame defines the number of frames in total
  28454. * @param from defines the initial value
  28455. * @param to defines the final value
  28456. * @param loopMode defines which loop mode you want to use (off by default)
  28457. * @param easingFunction defines the easing function to use (linear by default)
  28458. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28459. * @returns the list of animatables created for all nodes
  28460. * @example https://www.babylonjs-playground.com/#MH0VLI
  28461. */
  28462. 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[]>;
  28463. /**
  28464. * Creates a new animation, merges it with the existing animations and starts it
  28465. * @param name Name of the animation
  28466. * @param node Node which contains the scene that begins the animations
  28467. * @param targetProperty Specifies which property to animate
  28468. * @param framePerSecond The frames per second of the animation
  28469. * @param totalFrame The total number of frames
  28470. * @param from The frame at the beginning of the animation
  28471. * @param to The frame at the end of the animation
  28472. * @param loopMode Specifies the loop mode of the animation
  28473. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28474. * @param onAnimationEnd Callback to run once the animation is complete
  28475. * @returns Nullable animation
  28476. */
  28477. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28478. /**
  28479. * Transition property of an host to the target Value
  28480. * @param property The property to transition
  28481. * @param targetValue The target Value of the property
  28482. * @param host The object where the property to animate belongs
  28483. * @param scene Scene used to run the animation
  28484. * @param frameRate Framerate (in frame/s) to use
  28485. * @param transition The transition type we want to use
  28486. * @param duration The duration of the animation, in milliseconds
  28487. * @param onAnimationEnd Callback trigger at the end of the animation
  28488. * @returns Nullable animation
  28489. */
  28490. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28491. /**
  28492. * Return the array of runtime animations currently using this animation
  28493. */
  28494. readonly runtimeAnimations: RuntimeAnimation[];
  28495. /**
  28496. * Specifies if any of the runtime animations are currently running
  28497. */
  28498. readonly hasRunningRuntimeAnimations: boolean;
  28499. /**
  28500. * Initializes the animation
  28501. * @param name Name of the animation
  28502. * @param targetProperty Property to animate
  28503. * @param framePerSecond The frames per second of the animation
  28504. * @param dataType The data type of the animation
  28505. * @param loopMode The loop mode of the animation
  28506. * @param enableBlending Specifies if blending should be enabled
  28507. */
  28508. constructor(
  28509. /**Name of the animation */
  28510. name: string,
  28511. /**Property to animate */
  28512. targetProperty: string,
  28513. /**The frames per second of the animation */
  28514. framePerSecond: number,
  28515. /**The data type of the animation */
  28516. dataType: number,
  28517. /**The loop mode of the animation */
  28518. loopMode?: number | undefined,
  28519. /**Specifies if blending should be enabled */
  28520. enableBlending?: boolean | undefined);
  28521. /**
  28522. * Converts the animation to a string
  28523. * @param fullDetails support for multiple levels of logging within scene loading
  28524. * @returns String form of the animation
  28525. */
  28526. toString(fullDetails?: boolean): string;
  28527. /**
  28528. * Add an event to this animation
  28529. * @param event Event to add
  28530. */
  28531. addEvent(event: AnimationEvent): void;
  28532. /**
  28533. * Remove all events found at the given frame
  28534. * @param frame The frame to remove events from
  28535. */
  28536. removeEvents(frame: number): void;
  28537. /**
  28538. * Retrieves all the events from the animation
  28539. * @returns Events from the animation
  28540. */
  28541. getEvents(): AnimationEvent[];
  28542. /**
  28543. * Creates an animation range
  28544. * @param name Name of the animation range
  28545. * @param from Starting frame of the animation range
  28546. * @param to Ending frame of the animation
  28547. */
  28548. createRange(name: string, from: number, to: number): void;
  28549. /**
  28550. * Deletes an animation range by name
  28551. * @param name Name of the animation range to delete
  28552. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28553. */
  28554. deleteRange(name: string, deleteFrames?: boolean): void;
  28555. /**
  28556. * Gets the animation range by name, or null if not defined
  28557. * @param name Name of the animation range
  28558. * @returns Nullable animation range
  28559. */
  28560. getRange(name: string): Nullable<AnimationRange>;
  28561. /**
  28562. * Gets the key frames from the animation
  28563. * @returns The key frames of the animation
  28564. */
  28565. getKeys(): Array<IAnimationKey>;
  28566. /**
  28567. * Gets the highest frame rate of the animation
  28568. * @returns Highest frame rate of the animation
  28569. */
  28570. getHighestFrame(): number;
  28571. /**
  28572. * Gets the easing function of the animation
  28573. * @returns Easing function of the animation
  28574. */
  28575. getEasingFunction(): IEasingFunction;
  28576. /**
  28577. * Sets the easing function of the animation
  28578. * @param easingFunction A custom mathematical formula for animation
  28579. */
  28580. setEasingFunction(easingFunction: EasingFunction): void;
  28581. /**
  28582. * Interpolates a scalar linearly
  28583. * @param startValue Start value of the animation curve
  28584. * @param endValue End value of the animation curve
  28585. * @param gradient Scalar amount to interpolate
  28586. * @returns Interpolated scalar value
  28587. */
  28588. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28589. /**
  28590. * Interpolates a scalar cubically
  28591. * @param startValue Start value of the animation curve
  28592. * @param outTangent End tangent of the animation
  28593. * @param endValue End value of the animation curve
  28594. * @param inTangent Start tangent of the animation curve
  28595. * @param gradient Scalar amount to interpolate
  28596. * @returns Interpolated scalar value
  28597. */
  28598. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28599. /**
  28600. * Interpolates a quaternion using a spherical linear interpolation
  28601. * @param startValue Start value of the animation curve
  28602. * @param endValue End value of the animation curve
  28603. * @param gradient Scalar amount to interpolate
  28604. * @returns Interpolated quaternion value
  28605. */
  28606. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28607. /**
  28608. * Interpolates a quaternion cubically
  28609. * @param startValue Start value of the animation curve
  28610. * @param outTangent End tangent of the animation curve
  28611. * @param endValue End value of the animation curve
  28612. * @param inTangent Start tangent of the animation curve
  28613. * @param gradient Scalar amount to interpolate
  28614. * @returns Interpolated quaternion value
  28615. */
  28616. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28617. /**
  28618. * Interpolates a Vector3 linearl
  28619. * @param startValue Start value of the animation curve
  28620. * @param endValue End value of the animation curve
  28621. * @param gradient Scalar amount to interpolate
  28622. * @returns Interpolated scalar value
  28623. */
  28624. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28625. /**
  28626. * Interpolates a Vector3 cubically
  28627. * @param startValue Start value of the animation curve
  28628. * @param outTangent End tangent of the animation
  28629. * @param endValue End value of the animation curve
  28630. * @param inTangent Start tangent of the animation curve
  28631. * @param gradient Scalar amount to interpolate
  28632. * @returns InterpolatedVector3 value
  28633. */
  28634. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28635. /**
  28636. * Interpolates a Vector2 linearly
  28637. * @param startValue Start value of the animation curve
  28638. * @param endValue End value of the animation curve
  28639. * @param gradient Scalar amount to interpolate
  28640. * @returns Interpolated Vector2 value
  28641. */
  28642. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28643. /**
  28644. * Interpolates a Vector2 cubically
  28645. * @param startValue Start value of the animation curve
  28646. * @param outTangent End tangent of the animation
  28647. * @param endValue End value of the animation curve
  28648. * @param inTangent Start tangent of the animation curve
  28649. * @param gradient Scalar amount to interpolate
  28650. * @returns Interpolated Vector2 value
  28651. */
  28652. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28653. /**
  28654. * Interpolates a size linearly
  28655. * @param startValue Start value of the animation curve
  28656. * @param endValue End value of the animation curve
  28657. * @param gradient Scalar amount to interpolate
  28658. * @returns Interpolated Size value
  28659. */
  28660. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28661. /**
  28662. * Interpolates a Color3 linearly
  28663. * @param startValue Start value of the animation curve
  28664. * @param endValue End value of the animation curve
  28665. * @param gradient Scalar amount to interpolate
  28666. * @returns Interpolated Color3 value
  28667. */
  28668. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28669. /**
  28670. * Interpolates a Color4 linearly
  28671. * @param startValue Start value of the animation curve
  28672. * @param endValue End value of the animation curve
  28673. * @param gradient Scalar amount to interpolate
  28674. * @returns Interpolated Color3 value
  28675. */
  28676. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28677. /**
  28678. * @hidden Internal use only
  28679. */
  28680. _getKeyValue(value: any): any;
  28681. /**
  28682. * @hidden Internal use only
  28683. */
  28684. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28685. /**
  28686. * Defines the function to use to interpolate matrices
  28687. * @param startValue defines the start matrix
  28688. * @param endValue defines the end matrix
  28689. * @param gradient defines the gradient between both matrices
  28690. * @param result defines an optional target matrix where to store the interpolation
  28691. * @returns the interpolated matrix
  28692. */
  28693. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28694. /**
  28695. * Makes a copy of the animation
  28696. * @returns Cloned animation
  28697. */
  28698. clone(): Animation;
  28699. /**
  28700. * Sets the key frames of the animation
  28701. * @param values The animation key frames to set
  28702. */
  28703. setKeys(values: Array<IAnimationKey>): void;
  28704. /**
  28705. * Serializes the animation to an object
  28706. * @returns Serialized object
  28707. */
  28708. serialize(): any;
  28709. /**
  28710. * Float animation type
  28711. */
  28712. static readonly ANIMATIONTYPE_FLOAT: number;
  28713. /**
  28714. * Vector3 animation type
  28715. */
  28716. static readonly ANIMATIONTYPE_VECTOR3: number;
  28717. /**
  28718. * Quaternion animation type
  28719. */
  28720. static readonly ANIMATIONTYPE_QUATERNION: number;
  28721. /**
  28722. * Matrix animation type
  28723. */
  28724. static readonly ANIMATIONTYPE_MATRIX: number;
  28725. /**
  28726. * Color3 animation type
  28727. */
  28728. static readonly ANIMATIONTYPE_COLOR3: number;
  28729. /**
  28730. * Color3 animation type
  28731. */
  28732. static readonly ANIMATIONTYPE_COLOR4: number;
  28733. /**
  28734. * Vector2 animation type
  28735. */
  28736. static readonly ANIMATIONTYPE_VECTOR2: number;
  28737. /**
  28738. * Size animation type
  28739. */
  28740. static readonly ANIMATIONTYPE_SIZE: number;
  28741. /**
  28742. * Relative Loop Mode
  28743. */
  28744. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28745. /**
  28746. * Cycle Loop Mode
  28747. */
  28748. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28749. /**
  28750. * Constant Loop Mode
  28751. */
  28752. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28753. /** @hidden */
  28754. static _UniversalLerp(left: any, right: any, amount: number): any;
  28755. /**
  28756. * Parses an animation object and creates an animation
  28757. * @param parsedAnimation Parsed animation object
  28758. * @returns Animation object
  28759. */
  28760. static Parse(parsedAnimation: any): Animation;
  28761. /**
  28762. * Appends the serialized animations from the source animations
  28763. * @param source Source containing the animations
  28764. * @param destination Target to store the animations
  28765. */
  28766. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28767. }
  28768. }
  28769. declare module "babylonjs/Animations/animatable.interface" {
  28770. import { Nullable } from "babylonjs/types";
  28771. import { Animation } from "babylonjs/Animations/animation";
  28772. /**
  28773. * Interface containing an array of animations
  28774. */
  28775. export interface IAnimatable {
  28776. /**
  28777. * Array of animations
  28778. */
  28779. animations: Nullable<Array<Animation>>;
  28780. }
  28781. }
  28782. declare module "babylonjs/Materials/fresnelParameters" {
  28783. import { Color3 } from "babylonjs/Maths/math.color";
  28784. /**
  28785. * This represents all the required information to add a fresnel effect on a material:
  28786. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28787. */
  28788. export class FresnelParameters {
  28789. private _isEnabled;
  28790. /**
  28791. * Define if the fresnel effect is enable or not.
  28792. */
  28793. isEnabled: boolean;
  28794. /**
  28795. * Define the color used on edges (grazing angle)
  28796. */
  28797. leftColor: Color3;
  28798. /**
  28799. * Define the color used on center
  28800. */
  28801. rightColor: Color3;
  28802. /**
  28803. * Define bias applied to computed fresnel term
  28804. */
  28805. bias: number;
  28806. /**
  28807. * Defined the power exponent applied to fresnel term
  28808. */
  28809. power: number;
  28810. /**
  28811. * Clones the current fresnel and its valuues
  28812. * @returns a clone fresnel configuration
  28813. */
  28814. clone(): FresnelParameters;
  28815. /**
  28816. * Serializes the current fresnel parameters to a JSON representation.
  28817. * @return the JSON serialization
  28818. */
  28819. serialize(): any;
  28820. /**
  28821. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28822. * @param parsedFresnelParameters Define the JSON representation
  28823. * @returns the parsed parameters
  28824. */
  28825. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28826. }
  28827. }
  28828. declare module "babylonjs/Misc/decorators" {
  28829. import { Nullable } from "babylonjs/types";
  28830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28831. import { Scene } from "babylonjs/scene";
  28832. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28833. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28834. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28835. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28836. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28837. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28838. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28839. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28840. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28841. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28842. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28843. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28844. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28845. /**
  28846. * Decorator used to define property that can be serialized as reference to a camera
  28847. * @param sourceName defines the name of the property to decorate
  28848. */
  28849. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28850. /**
  28851. * Class used to help serialization objects
  28852. */
  28853. export class SerializationHelper {
  28854. /** @hidden */
  28855. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28856. /** @hidden */
  28857. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28858. /** @hidden */
  28859. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28860. /** @hidden */
  28861. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28862. /**
  28863. * Appends the serialized animations from the source animations
  28864. * @param source Source containing the animations
  28865. * @param destination Target to store the animations
  28866. */
  28867. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28868. /**
  28869. * Static function used to serialized a specific entity
  28870. * @param entity defines the entity to serialize
  28871. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28872. * @returns a JSON compatible object representing the serialization of the entity
  28873. */
  28874. static Serialize<T>(entity: T, serializationObject?: any): any;
  28875. /**
  28876. * Creates a new entity from a serialization data object
  28877. * @param creationFunction defines a function used to instanciated the new entity
  28878. * @param source defines the source serialization data
  28879. * @param scene defines the hosting scene
  28880. * @param rootUrl defines the root url for resources
  28881. * @returns a new entity
  28882. */
  28883. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28884. /**
  28885. * Clones an object
  28886. * @param creationFunction defines the function used to instanciate the new object
  28887. * @param source defines the source object
  28888. * @returns the cloned object
  28889. */
  28890. static Clone<T>(creationFunction: () => T, source: T): T;
  28891. /**
  28892. * Instanciates a new object based on a source one (some data will be shared between both object)
  28893. * @param creationFunction defines the function used to instanciate the new object
  28894. * @param source defines the source object
  28895. * @returns the new object
  28896. */
  28897. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28898. }
  28899. }
  28900. declare module "babylonjs/Misc/guid" {
  28901. /**
  28902. * Class used to manipulate GUIDs
  28903. */
  28904. export class GUID {
  28905. /**
  28906. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28907. * Be aware Math.random() could cause collisions, but:
  28908. * "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"
  28909. * @returns a pseudo random id
  28910. */
  28911. static RandomId(): string;
  28912. }
  28913. }
  28914. declare module "babylonjs/Materials/Textures/baseTexture" {
  28915. import { Observable } from "babylonjs/Misc/observable";
  28916. import { Nullable } from "babylonjs/types";
  28917. import { Scene } from "babylonjs/scene";
  28918. import { Matrix } from "babylonjs/Maths/math.vector";
  28919. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28920. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28921. import { ISize } from "babylonjs/Maths/math.size";
  28922. /**
  28923. * Base class of all the textures in babylon.
  28924. * It groups all the common properties the materials, post process, lights... might need
  28925. * in order to make a correct use of the texture.
  28926. */
  28927. export class BaseTexture implements IAnimatable {
  28928. /**
  28929. * Default anisotropic filtering level for the application.
  28930. * It is set to 4 as a good tradeoff between perf and quality.
  28931. */
  28932. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28933. /**
  28934. * Gets or sets the unique id of the texture
  28935. */
  28936. uniqueId: number;
  28937. /**
  28938. * Define the name of the texture.
  28939. */
  28940. name: string;
  28941. /**
  28942. * Gets or sets an object used to store user defined information.
  28943. */
  28944. metadata: any;
  28945. /**
  28946. * For internal use only. Please do not use.
  28947. */
  28948. reservedDataStore: any;
  28949. private _hasAlpha;
  28950. /**
  28951. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28952. */
  28953. hasAlpha: boolean;
  28954. /**
  28955. * Defines if the alpha value should be determined via the rgb values.
  28956. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28957. */
  28958. getAlphaFromRGB: boolean;
  28959. /**
  28960. * Intensity or strength of the texture.
  28961. * It is commonly used by materials to fine tune the intensity of the texture
  28962. */
  28963. level: number;
  28964. /**
  28965. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28966. * This is part of the texture as textures usually maps to one uv set.
  28967. */
  28968. coordinatesIndex: number;
  28969. private _coordinatesMode;
  28970. /**
  28971. * How a texture is mapped.
  28972. *
  28973. * | Value | Type | Description |
  28974. * | ----- | ----------------------------------- | ----------- |
  28975. * | 0 | EXPLICIT_MODE | |
  28976. * | 1 | SPHERICAL_MODE | |
  28977. * | 2 | PLANAR_MODE | |
  28978. * | 3 | CUBIC_MODE | |
  28979. * | 4 | PROJECTION_MODE | |
  28980. * | 5 | SKYBOX_MODE | |
  28981. * | 6 | INVCUBIC_MODE | |
  28982. * | 7 | EQUIRECTANGULAR_MODE | |
  28983. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28984. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28985. */
  28986. coordinatesMode: number;
  28987. /**
  28988. * | Value | Type | Description |
  28989. * | ----- | ------------------ | ----------- |
  28990. * | 0 | CLAMP_ADDRESSMODE | |
  28991. * | 1 | WRAP_ADDRESSMODE | |
  28992. * | 2 | MIRROR_ADDRESSMODE | |
  28993. */
  28994. wrapU: number;
  28995. /**
  28996. * | Value | Type | Description |
  28997. * | ----- | ------------------ | ----------- |
  28998. * | 0 | CLAMP_ADDRESSMODE | |
  28999. * | 1 | WRAP_ADDRESSMODE | |
  29000. * | 2 | MIRROR_ADDRESSMODE | |
  29001. */
  29002. wrapV: number;
  29003. /**
  29004. * | Value | Type | Description |
  29005. * | ----- | ------------------ | ----------- |
  29006. * | 0 | CLAMP_ADDRESSMODE | |
  29007. * | 1 | WRAP_ADDRESSMODE | |
  29008. * | 2 | MIRROR_ADDRESSMODE | |
  29009. */
  29010. wrapR: number;
  29011. /**
  29012. * With compliant hardware and browser (supporting anisotropic filtering)
  29013. * this defines the level of anisotropic filtering in the texture.
  29014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29015. */
  29016. anisotropicFilteringLevel: number;
  29017. /**
  29018. * Define if the texture is a cube texture or if false a 2d texture.
  29019. */
  29020. isCube: boolean;
  29021. /**
  29022. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29023. */
  29024. is3D: boolean;
  29025. /**
  29026. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29027. */
  29028. is2DArray: boolean;
  29029. /**
  29030. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29031. * HDR texture are usually stored in linear space.
  29032. * This only impacts the PBR and Background materials
  29033. */
  29034. gammaSpace: boolean;
  29035. /**
  29036. * Gets or sets whether or not the texture contains RGBD data.
  29037. */
  29038. isRGBD: boolean;
  29039. /**
  29040. * Is Z inverted in the texture (useful in a cube texture).
  29041. */
  29042. invertZ: boolean;
  29043. /**
  29044. * Are mip maps generated for this texture or not.
  29045. */
  29046. readonly noMipmap: boolean;
  29047. /**
  29048. * @hidden
  29049. */
  29050. lodLevelInAlpha: boolean;
  29051. /**
  29052. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29053. */
  29054. lodGenerationOffset: number;
  29055. /**
  29056. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29057. */
  29058. lodGenerationScale: number;
  29059. /**
  29060. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29061. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29062. * average roughness values.
  29063. */
  29064. linearSpecularLOD: boolean;
  29065. /**
  29066. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29067. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29068. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29069. */
  29070. irradianceTexture: Nullable<BaseTexture>;
  29071. /**
  29072. * Define if the texture is a render target.
  29073. */
  29074. isRenderTarget: boolean;
  29075. /**
  29076. * Define the unique id of the texture in the scene.
  29077. */
  29078. readonly uid: string;
  29079. /**
  29080. * Return a string representation of the texture.
  29081. * @returns the texture as a string
  29082. */
  29083. toString(): string;
  29084. /**
  29085. * Get the class name of the texture.
  29086. * @returns "BaseTexture"
  29087. */
  29088. getClassName(): string;
  29089. /**
  29090. * Define the list of animation attached to the texture.
  29091. */
  29092. animations: import("babylonjs/Animations/animation").Animation[];
  29093. /**
  29094. * An event triggered when the texture is disposed.
  29095. */
  29096. onDisposeObservable: Observable<BaseTexture>;
  29097. private _onDisposeObserver;
  29098. /**
  29099. * Callback triggered when the texture has been disposed.
  29100. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29101. */
  29102. onDispose: () => void;
  29103. /**
  29104. * Define the current state of the loading sequence when in delayed load mode.
  29105. */
  29106. delayLoadState: number;
  29107. private _scene;
  29108. /** @hidden */
  29109. _texture: Nullable<InternalTexture>;
  29110. private _uid;
  29111. /**
  29112. * Define if the texture is preventinga material to render or not.
  29113. * If not and the texture is not ready, the engine will use a default black texture instead.
  29114. */
  29115. readonly isBlocking: boolean;
  29116. /**
  29117. * Instantiates a new BaseTexture.
  29118. * Base class of all the textures in babylon.
  29119. * It groups all the common properties the materials, post process, lights... might need
  29120. * in order to make a correct use of the texture.
  29121. * @param scene Define the scene the texture blongs to
  29122. */
  29123. constructor(scene: Nullable<Scene>);
  29124. /**
  29125. * Get the scene the texture belongs to.
  29126. * @returns the scene or null if undefined
  29127. */
  29128. getScene(): Nullable<Scene>;
  29129. /**
  29130. * Get the texture transform matrix used to offset tile the texture for istance.
  29131. * @returns the transformation matrix
  29132. */
  29133. getTextureMatrix(): Matrix;
  29134. /**
  29135. * Get the texture reflection matrix used to rotate/transform the reflection.
  29136. * @returns the reflection matrix
  29137. */
  29138. getReflectionTextureMatrix(): Matrix;
  29139. /**
  29140. * Get the underlying lower level texture from Babylon.
  29141. * @returns the insternal texture
  29142. */
  29143. getInternalTexture(): Nullable<InternalTexture>;
  29144. /**
  29145. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29146. * @returns true if ready or not blocking
  29147. */
  29148. isReadyOrNotBlocking(): boolean;
  29149. /**
  29150. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29151. * @returns true if fully ready
  29152. */
  29153. isReady(): boolean;
  29154. private _cachedSize;
  29155. /**
  29156. * Get the size of the texture.
  29157. * @returns the texture size.
  29158. */
  29159. getSize(): ISize;
  29160. /**
  29161. * Get the base size of the texture.
  29162. * It can be different from the size if the texture has been resized for POT for instance
  29163. * @returns the base size
  29164. */
  29165. getBaseSize(): ISize;
  29166. /**
  29167. * Update the sampling mode of the texture.
  29168. * Default is Trilinear mode.
  29169. *
  29170. * | Value | Type | Description |
  29171. * | ----- | ------------------ | ----------- |
  29172. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29173. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29174. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29175. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29176. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29177. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29178. * | 7 | NEAREST_LINEAR | |
  29179. * | 8 | NEAREST_NEAREST | |
  29180. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29181. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29182. * | 11 | LINEAR_LINEAR | |
  29183. * | 12 | LINEAR_NEAREST | |
  29184. *
  29185. * > _mag_: magnification filter (close to the viewer)
  29186. * > _min_: minification filter (far from the viewer)
  29187. * > _mip_: filter used between mip map levels
  29188. *@param samplingMode Define the new sampling mode of the texture
  29189. */
  29190. updateSamplingMode(samplingMode: number): void;
  29191. /**
  29192. * Scales the texture if is `canRescale()`
  29193. * @param ratio the resize factor we want to use to rescale
  29194. */
  29195. scale(ratio: number): void;
  29196. /**
  29197. * Get if the texture can rescale.
  29198. */
  29199. readonly canRescale: boolean;
  29200. /** @hidden */
  29201. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29202. /** @hidden */
  29203. _rebuild(): void;
  29204. /**
  29205. * Triggers the load sequence in delayed load mode.
  29206. */
  29207. delayLoad(): void;
  29208. /**
  29209. * Clones the texture.
  29210. * @returns the cloned texture
  29211. */
  29212. clone(): Nullable<BaseTexture>;
  29213. /**
  29214. * Get the texture underlying type (INT, FLOAT...)
  29215. */
  29216. readonly textureType: number;
  29217. /**
  29218. * Get the texture underlying format (RGB, RGBA...)
  29219. */
  29220. readonly textureFormat: number;
  29221. /**
  29222. * Indicates that textures need to be re-calculated for all materials
  29223. */
  29224. protected _markAllSubMeshesAsTexturesDirty(): void;
  29225. /**
  29226. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29227. * This will returns an RGBA array buffer containing either in values (0-255) or
  29228. * float values (0-1) depending of the underlying buffer type.
  29229. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29230. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29231. * @param buffer defines a user defined buffer to fill with data (can be null)
  29232. * @returns The Array buffer containing the pixels data.
  29233. */
  29234. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29235. /**
  29236. * Release and destroy the underlying lower level texture aka internalTexture.
  29237. */
  29238. releaseInternalTexture(): void;
  29239. /** @hidden */
  29240. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29241. /** @hidden */
  29242. readonly _lodTextureMid: Nullable<BaseTexture>;
  29243. /** @hidden */
  29244. readonly _lodTextureLow: Nullable<BaseTexture>;
  29245. /**
  29246. * Dispose the texture and release its associated resources.
  29247. */
  29248. dispose(): void;
  29249. /**
  29250. * Serialize the texture into a JSON representation that can be parsed later on.
  29251. * @returns the JSON representation of the texture
  29252. */
  29253. serialize(): any;
  29254. /**
  29255. * Helper function to be called back once a list of texture contains only ready textures.
  29256. * @param textures Define the list of textures to wait for
  29257. * @param callback Define the callback triggered once the entire list will be ready
  29258. */
  29259. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29260. }
  29261. }
  29262. declare module "babylonjs/Materials/effect" {
  29263. import { Observable } from "babylonjs/Misc/observable";
  29264. import { Nullable } from "babylonjs/types";
  29265. import { IDisposable } from "babylonjs/scene";
  29266. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29267. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29268. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29269. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29270. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29271. import { Engine } from "babylonjs/Engines/engine";
  29272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29274. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29275. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29276. /**
  29277. * Options to be used when creating an effect.
  29278. */
  29279. export interface IEffectCreationOptions {
  29280. /**
  29281. * Atrributes that will be used in the shader.
  29282. */
  29283. attributes: string[];
  29284. /**
  29285. * Uniform varible names that will be set in the shader.
  29286. */
  29287. uniformsNames: string[];
  29288. /**
  29289. * Uniform buffer variable names that will be set in the shader.
  29290. */
  29291. uniformBuffersNames: string[];
  29292. /**
  29293. * Sampler texture variable names that will be set in the shader.
  29294. */
  29295. samplers: string[];
  29296. /**
  29297. * Define statements that will be set in the shader.
  29298. */
  29299. defines: any;
  29300. /**
  29301. * Possible fallbacks for this effect to improve performance when needed.
  29302. */
  29303. fallbacks: Nullable<IEffectFallbacks>;
  29304. /**
  29305. * Callback that will be called when the shader is compiled.
  29306. */
  29307. onCompiled: Nullable<(effect: Effect) => void>;
  29308. /**
  29309. * Callback that will be called if an error occurs during shader compilation.
  29310. */
  29311. onError: Nullable<(effect: Effect, errors: string) => void>;
  29312. /**
  29313. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29314. */
  29315. indexParameters?: any;
  29316. /**
  29317. * Max number of lights that can be used in the shader.
  29318. */
  29319. maxSimultaneousLights?: number;
  29320. /**
  29321. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29322. */
  29323. transformFeedbackVaryings?: Nullable<string[]>;
  29324. }
  29325. /**
  29326. * Effect containing vertex and fragment shader that can be executed on an object.
  29327. */
  29328. export class Effect implements IDisposable {
  29329. /**
  29330. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29331. */
  29332. static ShadersRepository: string;
  29333. /**
  29334. * Name of the effect.
  29335. */
  29336. name: any;
  29337. /**
  29338. * String container all the define statements that should be set on the shader.
  29339. */
  29340. defines: string;
  29341. /**
  29342. * Callback that will be called when the shader is compiled.
  29343. */
  29344. onCompiled: Nullable<(effect: Effect) => void>;
  29345. /**
  29346. * Callback that will be called if an error occurs during shader compilation.
  29347. */
  29348. onError: Nullable<(effect: Effect, errors: string) => void>;
  29349. /**
  29350. * Callback that will be called when effect is bound.
  29351. */
  29352. onBind: Nullable<(effect: Effect) => void>;
  29353. /**
  29354. * Unique ID of the effect.
  29355. */
  29356. uniqueId: number;
  29357. /**
  29358. * Observable that will be called when the shader is compiled.
  29359. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29360. */
  29361. onCompileObservable: Observable<Effect>;
  29362. /**
  29363. * Observable that will be called if an error occurs during shader compilation.
  29364. */
  29365. onErrorObservable: Observable<Effect>;
  29366. /** @hidden */
  29367. _onBindObservable: Nullable<Observable<Effect>>;
  29368. /**
  29369. * Observable that will be called when effect is bound.
  29370. */
  29371. readonly onBindObservable: Observable<Effect>;
  29372. /** @hidden */
  29373. _bonesComputationForcedToCPU: boolean;
  29374. private static _uniqueIdSeed;
  29375. private _engine;
  29376. private _uniformBuffersNames;
  29377. private _uniformsNames;
  29378. private _samplerList;
  29379. private _samplers;
  29380. private _isReady;
  29381. private _compilationError;
  29382. private _allFallbacksProcessed;
  29383. private _attributesNames;
  29384. private _attributes;
  29385. private _uniforms;
  29386. /**
  29387. * Key for the effect.
  29388. * @hidden
  29389. */
  29390. _key: string;
  29391. private _indexParameters;
  29392. private _fallbacks;
  29393. private _vertexSourceCode;
  29394. private _fragmentSourceCode;
  29395. private _vertexSourceCodeOverride;
  29396. private _fragmentSourceCodeOverride;
  29397. private _transformFeedbackVaryings;
  29398. /**
  29399. * Compiled shader to webGL program.
  29400. * @hidden
  29401. */
  29402. _pipelineContext: Nullable<IPipelineContext>;
  29403. private _valueCache;
  29404. private static _baseCache;
  29405. /**
  29406. * Instantiates an effect.
  29407. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29408. * @param baseName Name of the effect.
  29409. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29410. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29411. * @param samplers List of sampler variables that will be passed to the shader.
  29412. * @param engine Engine to be used to render the effect
  29413. * @param defines Define statements to be added to the shader.
  29414. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29415. * @param onCompiled Callback that will be called when the shader is compiled.
  29416. * @param onError Callback that will be called if an error occurs during shader compilation.
  29417. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29418. */
  29419. 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);
  29420. private _useFinalCode;
  29421. /**
  29422. * Unique key for this effect
  29423. */
  29424. readonly key: string;
  29425. /**
  29426. * If the effect has been compiled and prepared.
  29427. * @returns if the effect is compiled and prepared.
  29428. */
  29429. isReady(): boolean;
  29430. private _isReadyInternal;
  29431. /**
  29432. * The engine the effect was initialized with.
  29433. * @returns the engine.
  29434. */
  29435. getEngine(): Engine;
  29436. /**
  29437. * The pipeline context for this effect
  29438. * @returns the associated pipeline context
  29439. */
  29440. getPipelineContext(): Nullable<IPipelineContext>;
  29441. /**
  29442. * The set of names of attribute variables for the shader.
  29443. * @returns An array of attribute names.
  29444. */
  29445. getAttributesNames(): string[];
  29446. /**
  29447. * Returns the attribute at the given index.
  29448. * @param index The index of the attribute.
  29449. * @returns The location of the attribute.
  29450. */
  29451. getAttributeLocation(index: number): number;
  29452. /**
  29453. * Returns the attribute based on the name of the variable.
  29454. * @param name of the attribute to look up.
  29455. * @returns the attribute location.
  29456. */
  29457. getAttributeLocationByName(name: string): number;
  29458. /**
  29459. * The number of attributes.
  29460. * @returns the numnber of attributes.
  29461. */
  29462. getAttributesCount(): number;
  29463. /**
  29464. * Gets the index of a uniform variable.
  29465. * @param uniformName of the uniform to look up.
  29466. * @returns the index.
  29467. */
  29468. getUniformIndex(uniformName: string): number;
  29469. /**
  29470. * Returns the attribute based on the name of the variable.
  29471. * @param uniformName of the uniform to look up.
  29472. * @returns the location of the uniform.
  29473. */
  29474. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29475. /**
  29476. * Returns an array of sampler variable names
  29477. * @returns The array of sampler variable neames.
  29478. */
  29479. getSamplers(): string[];
  29480. /**
  29481. * The error from the last compilation.
  29482. * @returns the error string.
  29483. */
  29484. getCompilationError(): string;
  29485. /**
  29486. * Gets a boolean indicating that all fallbacks were used during compilation
  29487. * @returns true if all fallbacks were used
  29488. */
  29489. allFallbacksProcessed(): boolean;
  29490. /**
  29491. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29492. * @param func The callback to be used.
  29493. */
  29494. executeWhenCompiled(func: (effect: Effect) => void): void;
  29495. private _checkIsReady;
  29496. private _loadShader;
  29497. /**
  29498. * Recompiles the webGL program
  29499. * @param vertexSourceCode The source code for the vertex shader.
  29500. * @param fragmentSourceCode The source code for the fragment shader.
  29501. * @param onCompiled Callback called when completed.
  29502. * @param onError Callback called on error.
  29503. * @hidden
  29504. */
  29505. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29506. /**
  29507. * Prepares the effect
  29508. * @hidden
  29509. */
  29510. _prepareEffect(): void;
  29511. private _processCompilationErrors;
  29512. /**
  29513. * Checks if the effect is supported. (Must be called after compilation)
  29514. */
  29515. readonly isSupported: boolean;
  29516. /**
  29517. * Binds a texture to the engine to be used as output of the shader.
  29518. * @param channel Name of the output variable.
  29519. * @param texture Texture to bind.
  29520. * @hidden
  29521. */
  29522. _bindTexture(channel: string, texture: InternalTexture): void;
  29523. /**
  29524. * Sets a texture on the engine to be used in the shader.
  29525. * @param channel Name of the sampler variable.
  29526. * @param texture Texture to set.
  29527. */
  29528. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29529. /**
  29530. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29531. * @param channel Name of the sampler variable.
  29532. * @param texture Texture to set.
  29533. */
  29534. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29535. /**
  29536. * Sets an array of textures on the engine to be used in the shader.
  29537. * @param channel Name of the variable.
  29538. * @param textures Textures to set.
  29539. */
  29540. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29541. /**
  29542. * 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)
  29543. * @param channel Name of the sampler variable.
  29544. * @param postProcess Post process to get the input texture from.
  29545. */
  29546. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29547. /**
  29548. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29549. * 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)
  29550. * @param channel Name of the sampler variable.
  29551. * @param postProcess Post process to get the output texture from.
  29552. */
  29553. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29554. /** @hidden */
  29555. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29556. /** @hidden */
  29557. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29558. /** @hidden */
  29559. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29560. /** @hidden */
  29561. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29562. /**
  29563. * Binds a buffer to a uniform.
  29564. * @param buffer Buffer to bind.
  29565. * @param name Name of the uniform variable to bind to.
  29566. */
  29567. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29568. /**
  29569. * Binds block to a uniform.
  29570. * @param blockName Name of the block to bind.
  29571. * @param index Index to bind.
  29572. */
  29573. bindUniformBlock(blockName: string, index: number): void;
  29574. /**
  29575. * Sets an interger value on a uniform variable.
  29576. * @param uniformName Name of the variable.
  29577. * @param value Value to be set.
  29578. * @returns this effect.
  29579. */
  29580. setInt(uniformName: string, value: number): Effect;
  29581. /**
  29582. * Sets an int array on a uniform variable.
  29583. * @param uniformName Name of the variable.
  29584. * @param array array to be set.
  29585. * @returns this effect.
  29586. */
  29587. setIntArray(uniformName: string, array: Int32Array): Effect;
  29588. /**
  29589. * 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)
  29590. * @param uniformName Name of the variable.
  29591. * @param array array to be set.
  29592. * @returns this effect.
  29593. */
  29594. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29595. /**
  29596. * 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)
  29597. * @param uniformName Name of the variable.
  29598. * @param array array to be set.
  29599. * @returns this effect.
  29600. */
  29601. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29602. /**
  29603. * 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)
  29604. * @param uniformName Name of the variable.
  29605. * @param array array to be set.
  29606. * @returns this effect.
  29607. */
  29608. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29609. /**
  29610. * Sets an float array on a uniform variable.
  29611. * @param uniformName Name of the variable.
  29612. * @param array array to be set.
  29613. * @returns this effect.
  29614. */
  29615. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29616. /**
  29617. * 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)
  29618. * @param uniformName Name of the variable.
  29619. * @param array array to be set.
  29620. * @returns this effect.
  29621. */
  29622. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29623. /**
  29624. * 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)
  29625. * @param uniformName Name of the variable.
  29626. * @param array array to be set.
  29627. * @returns this effect.
  29628. */
  29629. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29630. /**
  29631. * 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)
  29632. * @param uniformName Name of the variable.
  29633. * @param array array to be set.
  29634. * @returns this effect.
  29635. */
  29636. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29637. /**
  29638. * Sets an array on a uniform variable.
  29639. * @param uniformName Name of the variable.
  29640. * @param array array to be set.
  29641. * @returns this effect.
  29642. */
  29643. setArray(uniformName: string, array: number[]): Effect;
  29644. /**
  29645. * 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)
  29646. * @param uniformName Name of the variable.
  29647. * @param array array to be set.
  29648. * @returns this effect.
  29649. */
  29650. setArray2(uniformName: string, array: number[]): Effect;
  29651. /**
  29652. * 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)
  29653. * @param uniformName Name of the variable.
  29654. * @param array array to be set.
  29655. * @returns this effect.
  29656. */
  29657. setArray3(uniformName: string, array: number[]): Effect;
  29658. /**
  29659. * 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)
  29660. * @param uniformName Name of the variable.
  29661. * @param array array to be set.
  29662. * @returns this effect.
  29663. */
  29664. setArray4(uniformName: string, array: number[]): Effect;
  29665. /**
  29666. * Sets matrices on a uniform variable.
  29667. * @param uniformName Name of the variable.
  29668. * @param matrices matrices to be set.
  29669. * @returns this effect.
  29670. */
  29671. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29672. /**
  29673. * Sets matrix on a uniform variable.
  29674. * @param uniformName Name of the variable.
  29675. * @param matrix matrix to be set.
  29676. * @returns this effect.
  29677. */
  29678. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29679. /**
  29680. * 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)
  29681. * @param uniformName Name of the variable.
  29682. * @param matrix matrix to be set.
  29683. * @returns this effect.
  29684. */
  29685. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29686. /**
  29687. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29688. * @param uniformName Name of the variable.
  29689. * @param matrix matrix to be set.
  29690. * @returns this effect.
  29691. */
  29692. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29693. /**
  29694. * Sets a float on a uniform variable.
  29695. * @param uniformName Name of the variable.
  29696. * @param value value to be set.
  29697. * @returns this effect.
  29698. */
  29699. setFloat(uniformName: string, value: number): Effect;
  29700. /**
  29701. * Sets a boolean on a uniform variable.
  29702. * @param uniformName Name of the variable.
  29703. * @param bool value to be set.
  29704. * @returns this effect.
  29705. */
  29706. setBool(uniformName: string, bool: boolean): Effect;
  29707. /**
  29708. * Sets a Vector2 on a uniform variable.
  29709. * @param uniformName Name of the variable.
  29710. * @param vector2 vector2 to be set.
  29711. * @returns this effect.
  29712. */
  29713. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29714. /**
  29715. * Sets a float2 on a uniform variable.
  29716. * @param uniformName Name of the variable.
  29717. * @param x First float in float2.
  29718. * @param y Second float in float2.
  29719. * @returns this effect.
  29720. */
  29721. setFloat2(uniformName: string, x: number, y: number): Effect;
  29722. /**
  29723. * Sets a Vector3 on a uniform variable.
  29724. * @param uniformName Name of the variable.
  29725. * @param vector3 Value to be set.
  29726. * @returns this effect.
  29727. */
  29728. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29729. /**
  29730. * Sets a float3 on a uniform variable.
  29731. * @param uniformName Name of the variable.
  29732. * @param x First float in float3.
  29733. * @param y Second float in float3.
  29734. * @param z Third float in float3.
  29735. * @returns this effect.
  29736. */
  29737. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29738. /**
  29739. * Sets a Vector4 on a uniform variable.
  29740. * @param uniformName Name of the variable.
  29741. * @param vector4 Value to be set.
  29742. * @returns this effect.
  29743. */
  29744. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29745. /**
  29746. * Sets a float4 on a uniform variable.
  29747. * @param uniformName Name of the variable.
  29748. * @param x First float in float4.
  29749. * @param y Second float in float4.
  29750. * @param z Third float in float4.
  29751. * @param w Fourth float in float4.
  29752. * @returns this effect.
  29753. */
  29754. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29755. /**
  29756. * Sets a Color3 on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param color3 Value to be set.
  29759. * @returns this effect.
  29760. */
  29761. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29762. /**
  29763. * Sets a Color4 on a uniform variable.
  29764. * @param uniformName Name of the variable.
  29765. * @param color3 Value to be set.
  29766. * @param alpha Alpha value to be set.
  29767. * @returns this effect.
  29768. */
  29769. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29770. /**
  29771. * Sets a Color4 on a uniform variable
  29772. * @param uniformName defines the name of the variable
  29773. * @param color4 defines the value to be set
  29774. * @returns this effect.
  29775. */
  29776. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29777. /** Release all associated resources */
  29778. dispose(): void;
  29779. /**
  29780. * This function will add a new shader to the shader store
  29781. * @param name the name of the shader
  29782. * @param pixelShader optional pixel shader content
  29783. * @param vertexShader optional vertex shader content
  29784. */
  29785. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29786. /**
  29787. * Store of each shader (The can be looked up using effect.key)
  29788. */
  29789. static ShadersStore: {
  29790. [key: string]: string;
  29791. };
  29792. /**
  29793. * Store of each included file for a shader (The can be looked up using effect.key)
  29794. */
  29795. static IncludesShadersStore: {
  29796. [key: string]: string;
  29797. };
  29798. /**
  29799. * Resets the cache of effects.
  29800. */
  29801. static ResetCache(): void;
  29802. }
  29803. }
  29804. declare module "babylonjs/Engines/engineCapabilities" {
  29805. /**
  29806. * Interface used to describe the capabilities of the engine relatively to the current browser
  29807. */
  29808. export interface EngineCapabilities {
  29809. /** Maximum textures units per fragment shader */
  29810. maxTexturesImageUnits: number;
  29811. /** Maximum texture units per vertex shader */
  29812. maxVertexTextureImageUnits: number;
  29813. /** Maximum textures units in the entire pipeline */
  29814. maxCombinedTexturesImageUnits: number;
  29815. /** Maximum texture size */
  29816. maxTextureSize: number;
  29817. /** Maximum texture samples */
  29818. maxSamples?: number;
  29819. /** Maximum cube texture size */
  29820. maxCubemapTextureSize: number;
  29821. /** Maximum render texture size */
  29822. maxRenderTextureSize: number;
  29823. /** Maximum number of vertex attributes */
  29824. maxVertexAttribs: number;
  29825. /** Maximum number of varyings */
  29826. maxVaryingVectors: number;
  29827. /** Maximum number of uniforms per vertex shader */
  29828. maxVertexUniformVectors: number;
  29829. /** Maximum number of uniforms per fragment shader */
  29830. maxFragmentUniformVectors: number;
  29831. /** Defines if standard derivates (dx/dy) are supported */
  29832. standardDerivatives: boolean;
  29833. /** Defines if s3tc texture compression is supported */
  29834. s3tc?: WEBGL_compressed_texture_s3tc;
  29835. /** Defines if pvrtc texture compression is supported */
  29836. pvrtc: any;
  29837. /** Defines if etc1 texture compression is supported */
  29838. etc1: any;
  29839. /** Defines if etc2 texture compression is supported */
  29840. etc2: any;
  29841. /** Defines if astc texture compression is supported */
  29842. astc: any;
  29843. /** Defines if float textures are supported */
  29844. textureFloat: boolean;
  29845. /** Defines if vertex array objects are supported */
  29846. vertexArrayObject: boolean;
  29847. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29848. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29849. /** Gets the maximum level of anisotropy supported */
  29850. maxAnisotropy: number;
  29851. /** Defines if instancing is supported */
  29852. instancedArrays: boolean;
  29853. /** Defines if 32 bits indices are supported */
  29854. uintIndices: boolean;
  29855. /** Defines if high precision shaders are supported */
  29856. highPrecisionShaderSupported: boolean;
  29857. /** Defines if depth reading in the fragment shader is supported */
  29858. fragmentDepthSupported: boolean;
  29859. /** Defines if float texture linear filtering is supported*/
  29860. textureFloatLinearFiltering: boolean;
  29861. /** Defines if rendering to float textures is supported */
  29862. textureFloatRender: boolean;
  29863. /** Defines if half float textures are supported*/
  29864. textureHalfFloat: boolean;
  29865. /** Defines if half float texture linear filtering is supported*/
  29866. textureHalfFloatLinearFiltering: boolean;
  29867. /** Defines if rendering to half float textures is supported */
  29868. textureHalfFloatRender: boolean;
  29869. /** Defines if textureLOD shader command is supported */
  29870. textureLOD: boolean;
  29871. /** Defines if draw buffers extension is supported */
  29872. drawBuffersExtension: boolean;
  29873. /** Defines if depth textures are supported */
  29874. depthTextureExtension: boolean;
  29875. /** Defines if float color buffer are supported */
  29876. colorBufferFloat: boolean;
  29877. /** Gets disjoint timer query extension (null if not supported) */
  29878. timerQuery?: EXT_disjoint_timer_query;
  29879. /** Defines if timestamp can be used with timer query */
  29880. canUseTimestampForTimerQuery: boolean;
  29881. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29882. multiview?: any;
  29883. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29884. oculusMultiview?: any;
  29885. /** Function used to let the system compiles shaders in background */
  29886. parallelShaderCompile?: {
  29887. COMPLETION_STATUS_KHR: number;
  29888. };
  29889. /** Max number of texture samples for MSAA */
  29890. maxMSAASamples: number;
  29891. /** Defines if the blend min max extension is supported */
  29892. blendMinMax: boolean;
  29893. }
  29894. }
  29895. declare module "babylonjs/States/depthCullingState" {
  29896. import { Nullable } from "babylonjs/types";
  29897. /**
  29898. * @hidden
  29899. **/
  29900. export class DepthCullingState {
  29901. private _isDepthTestDirty;
  29902. private _isDepthMaskDirty;
  29903. private _isDepthFuncDirty;
  29904. private _isCullFaceDirty;
  29905. private _isCullDirty;
  29906. private _isZOffsetDirty;
  29907. private _isFrontFaceDirty;
  29908. private _depthTest;
  29909. private _depthMask;
  29910. private _depthFunc;
  29911. private _cull;
  29912. private _cullFace;
  29913. private _zOffset;
  29914. private _frontFace;
  29915. /**
  29916. * Initializes the state.
  29917. */
  29918. constructor();
  29919. readonly isDirty: boolean;
  29920. zOffset: number;
  29921. cullFace: Nullable<number>;
  29922. cull: Nullable<boolean>;
  29923. depthFunc: Nullable<number>;
  29924. depthMask: boolean;
  29925. depthTest: boolean;
  29926. frontFace: Nullable<number>;
  29927. reset(): void;
  29928. apply(gl: WebGLRenderingContext): void;
  29929. }
  29930. }
  29931. declare module "babylonjs/States/stencilState" {
  29932. /**
  29933. * @hidden
  29934. **/
  29935. export class StencilState {
  29936. /** 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 */
  29937. static readonly ALWAYS: number;
  29938. /** Passed to stencilOperation to specify that stencil value must be kept */
  29939. static readonly KEEP: number;
  29940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29941. static readonly REPLACE: number;
  29942. private _isStencilTestDirty;
  29943. private _isStencilMaskDirty;
  29944. private _isStencilFuncDirty;
  29945. private _isStencilOpDirty;
  29946. private _stencilTest;
  29947. private _stencilMask;
  29948. private _stencilFunc;
  29949. private _stencilFuncRef;
  29950. private _stencilFuncMask;
  29951. private _stencilOpStencilFail;
  29952. private _stencilOpDepthFail;
  29953. private _stencilOpStencilDepthPass;
  29954. readonly isDirty: boolean;
  29955. stencilFunc: number;
  29956. stencilFuncRef: number;
  29957. stencilFuncMask: number;
  29958. stencilOpStencilFail: number;
  29959. stencilOpDepthFail: number;
  29960. stencilOpStencilDepthPass: number;
  29961. stencilMask: number;
  29962. stencilTest: boolean;
  29963. constructor();
  29964. reset(): void;
  29965. apply(gl: WebGLRenderingContext): void;
  29966. }
  29967. }
  29968. declare module "babylonjs/States/alphaCullingState" {
  29969. /**
  29970. * @hidden
  29971. **/
  29972. export class AlphaState {
  29973. private _isAlphaBlendDirty;
  29974. private _isBlendFunctionParametersDirty;
  29975. private _isBlendEquationParametersDirty;
  29976. private _isBlendConstantsDirty;
  29977. private _alphaBlend;
  29978. private _blendFunctionParameters;
  29979. private _blendEquationParameters;
  29980. private _blendConstants;
  29981. /**
  29982. * Initializes the state.
  29983. */
  29984. constructor();
  29985. readonly isDirty: boolean;
  29986. alphaBlend: boolean;
  29987. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29988. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29989. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29990. reset(): void;
  29991. apply(gl: WebGLRenderingContext): void;
  29992. }
  29993. }
  29994. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29995. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29996. /** @hidden */
  29997. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29998. attributeProcessor(attribute: string): string;
  29999. varyingProcessor(varying: string, isFragment: boolean): string;
  30000. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30001. }
  30002. }
  30003. declare module "babylonjs/Engines/instancingAttributeInfo" {
  30004. /**
  30005. * Interface for attribute information associated with buffer instanciation
  30006. */
  30007. export interface InstancingAttributeInfo {
  30008. /**
  30009. * Index/offset of the attribute in the vertex shader
  30010. */
  30011. index: number;
  30012. /**
  30013. * size of the attribute, 1, 2, 3 or 4
  30014. */
  30015. attributeSize: number;
  30016. /**
  30017. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30018. * default is FLOAT
  30019. */
  30020. attributeType: number;
  30021. /**
  30022. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30023. */
  30024. normalized: boolean;
  30025. /**
  30026. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30027. */
  30028. offset: number;
  30029. /**
  30030. * Name of the GLSL attribute, for debugging purpose only
  30031. */
  30032. attributeName: string;
  30033. }
  30034. }
  30035. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30037. import { Nullable } from "babylonjs/types";
  30038. module "babylonjs/Engines/thinEngine" {
  30039. interface ThinEngine {
  30040. /**
  30041. * Update a video texture
  30042. * @param texture defines the texture to update
  30043. * @param video defines the video element to use
  30044. * @param invertY defines if data must be stored with Y axis inverted
  30045. */
  30046. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30047. }
  30048. }
  30049. }
  30050. declare module "babylonjs/Materials/Textures/videoTexture" {
  30051. import { Observable } from "babylonjs/Misc/observable";
  30052. import { Nullable } from "babylonjs/types";
  30053. import { Scene } from "babylonjs/scene";
  30054. import { Texture } from "babylonjs/Materials/Textures/texture";
  30055. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30056. /**
  30057. * Settings for finer control over video usage
  30058. */
  30059. export interface VideoTextureSettings {
  30060. /**
  30061. * Applies `autoplay` to video, if specified
  30062. */
  30063. autoPlay?: boolean;
  30064. /**
  30065. * Applies `loop` to video, if specified
  30066. */
  30067. loop?: boolean;
  30068. /**
  30069. * Automatically updates internal texture from video at every frame in the render loop
  30070. */
  30071. autoUpdateTexture: boolean;
  30072. /**
  30073. * Image src displayed during the video loading or until the user interacts with the video.
  30074. */
  30075. poster?: string;
  30076. }
  30077. /**
  30078. * If you want to display a video in your scene, this is the special texture for that.
  30079. * This special texture works similar to other textures, with the exception of a few parameters.
  30080. * @see https://doc.babylonjs.com/how_to/video_texture
  30081. */
  30082. export class VideoTexture extends Texture {
  30083. /**
  30084. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30085. */
  30086. readonly autoUpdateTexture: boolean;
  30087. /**
  30088. * The video instance used by the texture internally
  30089. */
  30090. readonly video: HTMLVideoElement;
  30091. private _onUserActionRequestedObservable;
  30092. /**
  30093. * Event triggerd when a dom action is required by the user to play the video.
  30094. * This happens due to recent changes in browser policies preventing video to auto start.
  30095. */
  30096. readonly onUserActionRequestedObservable: Observable<Texture>;
  30097. private _generateMipMaps;
  30098. private _engine;
  30099. private _stillImageCaptured;
  30100. private _displayingPosterTexture;
  30101. private _settings;
  30102. private _createInternalTextureOnEvent;
  30103. private _frameId;
  30104. /**
  30105. * Creates a video texture.
  30106. * If you want to display a video in your scene, this is the special texture for that.
  30107. * This special texture works similar to other textures, with the exception of a few parameters.
  30108. * @see https://doc.babylonjs.com/how_to/video_texture
  30109. * @param name optional name, will detect from video source, if not defined
  30110. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30111. * @param scene is obviously the current scene.
  30112. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30113. * @param invertY is false by default but can be used to invert video on Y axis
  30114. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30115. * @param settings allows finer control over video usage
  30116. */
  30117. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30118. private _getName;
  30119. private _getVideo;
  30120. private _createInternalTexture;
  30121. private reset;
  30122. /**
  30123. * @hidden Internal method to initiate `update`.
  30124. */
  30125. _rebuild(): void;
  30126. /**
  30127. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30128. */
  30129. update(): void;
  30130. /**
  30131. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30132. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30133. */
  30134. updateTexture(isVisible: boolean): void;
  30135. protected _updateInternalTexture: () => void;
  30136. /**
  30137. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30138. * @param url New url.
  30139. */
  30140. updateURL(url: string): void;
  30141. /**
  30142. * Dispose the texture and release its associated resources.
  30143. */
  30144. dispose(): void;
  30145. /**
  30146. * Creates a video texture straight from a stream.
  30147. * @param scene Define the scene the texture should be created in
  30148. * @param stream Define the stream the texture should be created from
  30149. * @returns The created video texture as a promise
  30150. */
  30151. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30152. /**
  30153. * Creates a video texture straight from your WebCam video feed.
  30154. * @param scene Define the scene the texture should be created in
  30155. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30156. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30157. * @returns The created video texture as a promise
  30158. */
  30159. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30160. minWidth: number;
  30161. maxWidth: number;
  30162. minHeight: number;
  30163. maxHeight: number;
  30164. deviceId: string;
  30165. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30166. /**
  30167. * Creates a video texture straight from your WebCam video feed.
  30168. * @param scene Define the scene the texture should be created in
  30169. * @param onReady Define a callback to triggered once the texture will be ready
  30170. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30171. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30172. */
  30173. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30174. minWidth: number;
  30175. maxWidth: number;
  30176. minHeight: number;
  30177. maxHeight: number;
  30178. deviceId: string;
  30179. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30180. }
  30181. }
  30182. declare module "babylonjs/Engines/thinEngine" {
  30183. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30184. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30186. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30187. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30188. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30189. import { Observable } from "babylonjs/Misc/observable";
  30190. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30191. import { StencilState } from "babylonjs/States/stencilState";
  30192. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30193. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30194. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30195. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30196. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30197. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30198. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30200. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30202. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30203. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30204. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30205. /**
  30206. * Defines the interface used by objects working like Scene
  30207. * @hidden
  30208. */
  30209. interface ISceneLike {
  30210. _addPendingData(data: any): void;
  30211. _removePendingData(data: any): void;
  30212. offlineProvider: IOfflineProvider;
  30213. }
  30214. /** Interface defining initialization parameters for Engine class */
  30215. export interface EngineOptions extends WebGLContextAttributes {
  30216. /**
  30217. * Defines if the engine should no exceed a specified device ratio
  30218. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30219. */
  30220. limitDeviceRatio?: number;
  30221. /**
  30222. * Defines if webvr should be enabled automatically
  30223. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30224. */
  30225. autoEnableWebVR?: boolean;
  30226. /**
  30227. * Defines if webgl2 should be turned off even if supported
  30228. * @see http://doc.babylonjs.com/features/webgl2
  30229. */
  30230. disableWebGL2Support?: boolean;
  30231. /**
  30232. * Defines if webaudio should be initialized as well
  30233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30234. */
  30235. audioEngine?: boolean;
  30236. /**
  30237. * Defines if animations should run using a deterministic lock step
  30238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30239. */
  30240. deterministicLockstep?: boolean;
  30241. /** Defines the maximum steps to use with deterministic lock step mode */
  30242. lockstepMaxSteps?: number;
  30243. /**
  30244. * Defines that engine should ignore context lost events
  30245. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30246. */
  30247. doNotHandleContextLost?: boolean;
  30248. /**
  30249. * Defines that engine should ignore modifying touch action attribute and style
  30250. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30251. */
  30252. doNotHandleTouchAction?: boolean;
  30253. /**
  30254. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30255. */
  30256. useHighPrecisionFloats?: boolean;
  30257. }
  30258. /**
  30259. * The base engine class (root of all engines)
  30260. */
  30261. export class ThinEngine {
  30262. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30263. static ExceptionList: ({
  30264. key: string;
  30265. capture: string;
  30266. captureConstraint: number;
  30267. targets: string[];
  30268. } | {
  30269. key: string;
  30270. capture: null;
  30271. captureConstraint: null;
  30272. targets: string[];
  30273. })[];
  30274. /** @hidden */
  30275. static _TextureLoaders: IInternalTextureLoader[];
  30276. /**
  30277. * Returns the current npm package of the sdk
  30278. */
  30279. static readonly NpmPackage: string;
  30280. /**
  30281. * Returns the current version of the framework
  30282. */
  30283. static readonly Version: string;
  30284. /**
  30285. * Returns a string describing the current engine
  30286. */
  30287. readonly description: string;
  30288. /**
  30289. * Gets or sets the epsilon value used by collision engine
  30290. */
  30291. static CollisionsEpsilon: number;
  30292. /**
  30293. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30294. */
  30295. static ShadersRepository: string;
  30296. /** @hidden */
  30297. _shaderProcessor: IShaderProcessor;
  30298. /**
  30299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30300. */
  30301. forcePOTTextures: boolean;
  30302. /**
  30303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30304. */
  30305. isFullscreen: boolean;
  30306. /**
  30307. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30308. */
  30309. cullBackFaces: boolean;
  30310. /**
  30311. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30312. */
  30313. renderEvenInBackground: boolean;
  30314. /**
  30315. * Gets or sets a boolean indicating that cache can be kept between frames
  30316. */
  30317. preventCacheWipeBetweenFrames: boolean;
  30318. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30319. validateShaderPrograms: boolean;
  30320. /**
  30321. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30322. */
  30323. disableUniformBuffers: boolean;
  30324. /** @hidden */
  30325. _uniformBuffers: UniformBuffer[];
  30326. /**
  30327. * Gets a boolean indicating that the engine supports uniform buffers
  30328. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30329. */
  30330. readonly supportsUniformBuffers: boolean;
  30331. /** @hidden */
  30332. _gl: WebGLRenderingContext;
  30333. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30334. protected _windowIsBackground: boolean;
  30335. protected _webGLVersion: number;
  30336. protected _creationOptions: EngineOptions;
  30337. protected _highPrecisionShadersAllowed: boolean;
  30338. /** @hidden */
  30339. readonly _shouldUseHighPrecisionShader: boolean;
  30340. /**
  30341. * Gets a boolean indicating that only power of 2 textures are supported
  30342. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30343. */
  30344. readonly needPOTTextures: boolean;
  30345. /** @hidden */
  30346. _badOS: boolean;
  30347. /** @hidden */
  30348. _badDesktopOS: boolean;
  30349. private _hardwareScalingLevel;
  30350. /** @hidden */
  30351. _caps: EngineCapabilities;
  30352. private _isStencilEnable;
  30353. protected _colorWrite: boolean;
  30354. private _glVersion;
  30355. private _glRenderer;
  30356. private _glVendor;
  30357. /** @hidden */
  30358. _videoTextureSupported: boolean;
  30359. protected _renderingQueueLaunched: boolean;
  30360. protected _activeRenderLoops: (() => void)[];
  30361. /**
  30362. * Observable signaled when a context lost event is raised
  30363. */
  30364. onContextLostObservable: Observable<ThinEngine>;
  30365. /**
  30366. * Observable signaled when a context restored event is raised
  30367. */
  30368. onContextRestoredObservable: Observable<ThinEngine>;
  30369. private _onContextLost;
  30370. private _onContextRestored;
  30371. protected _contextWasLost: boolean;
  30372. /** @hidden */
  30373. _doNotHandleContextLost: boolean;
  30374. /**
  30375. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30377. */
  30378. doNotHandleContextLost: boolean;
  30379. /**
  30380. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30381. */
  30382. disableVertexArrayObjects: boolean;
  30383. /** @hidden */
  30384. protected _depthCullingState: DepthCullingState;
  30385. /** @hidden */
  30386. protected _stencilState: StencilState;
  30387. /** @hidden */
  30388. protected _alphaState: AlphaState;
  30389. /** @hidden */
  30390. _internalTexturesCache: InternalTexture[];
  30391. /** @hidden */
  30392. protected _activeChannel: number;
  30393. private _currentTextureChannel;
  30394. /** @hidden */
  30395. protected _boundTexturesCache: {
  30396. [key: string]: Nullable<InternalTexture>;
  30397. };
  30398. /** @hidden */
  30399. protected _currentEffect: Nullable<Effect>;
  30400. /** @hidden */
  30401. protected _currentProgram: Nullable<WebGLProgram>;
  30402. private _compiledEffects;
  30403. private _vertexAttribArraysEnabled;
  30404. /** @hidden */
  30405. protected _cachedViewport: Nullable<IViewportLike>;
  30406. private _cachedVertexArrayObject;
  30407. /** @hidden */
  30408. protected _cachedVertexBuffers: any;
  30409. /** @hidden */
  30410. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30411. /** @hidden */
  30412. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30413. /** @hidden */
  30414. _currentRenderTarget: Nullable<InternalTexture>;
  30415. private _uintIndicesCurrentlySet;
  30416. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30417. /** @hidden */
  30418. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30419. private _currentBufferPointers;
  30420. private _currentInstanceLocations;
  30421. private _currentInstanceBuffers;
  30422. private _textureUnits;
  30423. /** @hidden */
  30424. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30425. /** @hidden */
  30426. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30427. /** @hidden */
  30428. _boundRenderFunction: any;
  30429. private _vaoRecordInProgress;
  30430. private _mustWipeVertexAttributes;
  30431. private _emptyTexture;
  30432. private _emptyCubeTexture;
  30433. private _emptyTexture3D;
  30434. private _emptyTexture2DArray;
  30435. /** @hidden */
  30436. _frameHandler: number;
  30437. private _nextFreeTextureSlots;
  30438. private _maxSimultaneousTextures;
  30439. private _activeRequests;
  30440. protected _texturesSupported: string[];
  30441. /** @hidden */
  30442. _textureFormatInUse: Nullable<string>;
  30443. protected readonly _supportsHardwareTextureRescaling: boolean;
  30444. /**
  30445. * Gets the list of texture formats supported
  30446. */
  30447. readonly texturesSupported: Array<string>;
  30448. /**
  30449. * Gets the list of texture formats in use
  30450. */
  30451. readonly textureFormatInUse: Nullable<string>;
  30452. /**
  30453. * Gets the current viewport
  30454. */
  30455. readonly currentViewport: Nullable<IViewportLike>;
  30456. /**
  30457. * Gets the default empty texture
  30458. */
  30459. readonly emptyTexture: InternalTexture;
  30460. /**
  30461. * Gets the default empty 3D texture
  30462. */
  30463. readonly emptyTexture3D: InternalTexture;
  30464. /**
  30465. * Gets the default empty 2D array texture
  30466. */
  30467. readonly emptyTexture2DArray: InternalTexture;
  30468. /**
  30469. * Gets the default empty cube texture
  30470. */
  30471. readonly emptyCubeTexture: InternalTexture;
  30472. /**
  30473. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30474. */
  30475. readonly premultipliedAlpha: boolean;
  30476. /**
  30477. * Observable event triggered before each texture is initialized
  30478. */
  30479. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30480. /**
  30481. * Creates a new engine
  30482. * @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
  30483. * @param antialias defines enable antialiasing (default: false)
  30484. * @param options defines further options to be sent to the getContext() function
  30485. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30486. */
  30487. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30488. private _rebuildInternalTextures;
  30489. private _rebuildEffects;
  30490. /**
  30491. * Gets a boolean indicating if all created effects are ready
  30492. * @returns true if all effects are ready
  30493. */
  30494. areAllEffectsReady(): boolean;
  30495. protected _rebuildBuffers(): void;
  30496. private _initGLContext;
  30497. /**
  30498. * Gets version of the current webGL context
  30499. */
  30500. readonly webGLVersion: number;
  30501. /**
  30502. * Gets a string idenfifying the name of the class
  30503. * @returns "Engine" string
  30504. */
  30505. getClassName(): string;
  30506. /**
  30507. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30508. */
  30509. readonly isStencilEnable: boolean;
  30510. /** @hidden */
  30511. _prepareWorkingCanvas(): void;
  30512. /**
  30513. * Reset the texture cache to empty state
  30514. */
  30515. resetTextureCache(): void;
  30516. /**
  30517. * Gets an object containing information about the current webGL context
  30518. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30519. */
  30520. getGlInfo(): {
  30521. vendor: string;
  30522. renderer: string;
  30523. version: string;
  30524. };
  30525. /**
  30526. * Defines the hardware scaling level.
  30527. * By default the hardware scaling level is computed from the window device ratio.
  30528. * 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.
  30529. * @param level defines the level to use
  30530. */
  30531. setHardwareScalingLevel(level: number): void;
  30532. /**
  30533. * Gets the current hardware scaling level.
  30534. * By default the hardware scaling level is computed from the window device ratio.
  30535. * 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.
  30536. * @returns a number indicating the current hardware scaling level
  30537. */
  30538. getHardwareScalingLevel(): number;
  30539. /**
  30540. * Gets the list of loaded textures
  30541. * @returns an array containing all loaded textures
  30542. */
  30543. getLoadedTexturesCache(): InternalTexture[];
  30544. /**
  30545. * Gets the object containing all engine capabilities
  30546. * @returns the EngineCapabilities object
  30547. */
  30548. getCaps(): EngineCapabilities;
  30549. /**
  30550. * stop executing a render loop function and remove it from the execution array
  30551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30552. */
  30553. stopRenderLoop(renderFunction?: () => void): void;
  30554. /** @hidden */
  30555. _renderLoop(): void;
  30556. /**
  30557. * Gets the HTML canvas attached with the current webGL context
  30558. * @returns a HTML canvas
  30559. */
  30560. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30561. /**
  30562. * Gets host window
  30563. * @returns the host window object
  30564. */
  30565. getHostWindow(): Nullable<Window>;
  30566. /**
  30567. * Gets the current render width
  30568. * @param useScreen defines if screen size must be used (or the current render target if any)
  30569. * @returns a number defining the current render width
  30570. */
  30571. getRenderWidth(useScreen?: boolean): number;
  30572. /**
  30573. * Gets the current render height
  30574. * @param useScreen defines if screen size must be used (or the current render target if any)
  30575. * @returns a number defining the current render height
  30576. */
  30577. getRenderHeight(useScreen?: boolean): number;
  30578. /**
  30579. * Can be used to override the current requestAnimationFrame requester.
  30580. * @hidden
  30581. */
  30582. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30583. /**
  30584. * Register and execute a render loop. The engine can have more than one render function
  30585. * @param renderFunction defines the function to continuously execute
  30586. */
  30587. runRenderLoop(renderFunction: () => void): void;
  30588. /**
  30589. * Clear the current render buffer or the current render target (if any is set up)
  30590. * @param color defines the color to use
  30591. * @param backBuffer defines if the back buffer must be cleared
  30592. * @param depth defines if the depth buffer must be cleared
  30593. * @param stencil defines if the stencil buffer must be cleared
  30594. */
  30595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30596. private _viewportCached;
  30597. /** @hidden */
  30598. _viewport(x: number, y: number, width: number, height: number): void;
  30599. /**
  30600. * Set the WebGL's viewport
  30601. * @param viewport defines the viewport element to be used
  30602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30604. */
  30605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30606. /**
  30607. * Begin a new frame
  30608. */
  30609. beginFrame(): void;
  30610. /**
  30611. * Enf the current frame
  30612. */
  30613. endFrame(): void;
  30614. /**
  30615. * Resize the view according to the canvas' size
  30616. */
  30617. resize(): void;
  30618. /**
  30619. * Force a specific size of the canvas
  30620. * @param width defines the new canvas' width
  30621. * @param height defines the new canvas' height
  30622. */
  30623. setSize(width: number, height: number): void;
  30624. /**
  30625. * Binds the frame buffer to the specified texture.
  30626. * @param texture The texture to render to or null for the default canvas
  30627. * @param faceIndex The face of the texture to render to in case of cube texture
  30628. * @param requiredWidth The width of the target to render to
  30629. * @param requiredHeight The height of the target to render to
  30630. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30631. * @param depthStencilTexture The depth stencil texture to use to render
  30632. * @param lodLevel defines le lod level to bind to the frame buffer
  30633. */
  30634. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30635. /** @hidden */
  30636. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30637. /**
  30638. * Unbind the current render target texture from the webGL context
  30639. * @param texture defines the render target texture to unbind
  30640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30642. */
  30643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30644. /**
  30645. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30646. */
  30647. flushFramebuffer(): void;
  30648. /**
  30649. * Unbind the current render target and bind the default framebuffer
  30650. */
  30651. restoreDefaultFramebuffer(): void;
  30652. /** @hidden */
  30653. protected _resetVertexBufferBinding(): void;
  30654. /**
  30655. * Creates a vertex buffer
  30656. * @param data the data for the vertex buffer
  30657. * @returns the new WebGL static buffer
  30658. */
  30659. createVertexBuffer(data: DataArray): DataBuffer;
  30660. private _createVertexBuffer;
  30661. /**
  30662. * Creates a dynamic vertex buffer
  30663. * @param data the data for the dynamic vertex buffer
  30664. * @returns the new WebGL dynamic buffer
  30665. */
  30666. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30667. protected _resetIndexBufferBinding(): void;
  30668. /**
  30669. * Creates a new index buffer
  30670. * @param indices defines the content of the index buffer
  30671. * @param updatable defines if the index buffer must be updatable
  30672. * @returns a new webGL buffer
  30673. */
  30674. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30675. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30676. /**
  30677. * Bind a webGL buffer to the webGL context
  30678. * @param buffer defines the buffer to bind
  30679. */
  30680. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30681. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30682. private bindBuffer;
  30683. /**
  30684. * update the bound buffer with the given data
  30685. * @param data defines the data to update
  30686. */
  30687. updateArrayBuffer(data: Float32Array): void;
  30688. private _vertexAttribPointer;
  30689. private _bindIndexBufferWithCache;
  30690. private _bindVertexBuffersAttributes;
  30691. /**
  30692. * Records a vertex array object
  30693. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30694. * @param vertexBuffers defines the list of vertex buffers to store
  30695. * @param indexBuffer defines the index buffer to store
  30696. * @param effect defines the effect to store
  30697. * @returns the new vertex array object
  30698. */
  30699. recordVertexArrayObject(vertexBuffers: {
  30700. [key: string]: VertexBuffer;
  30701. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30702. /**
  30703. * Bind a specific vertex array object
  30704. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30705. * @param vertexArrayObject defines the vertex array object to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. */
  30708. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30709. /**
  30710. * Bind webGl buffers directly to the webGL context
  30711. * @param vertexBuffer defines the vertex buffer to bind
  30712. * @param indexBuffer defines the index buffer to bind
  30713. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30714. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30715. * @param effect defines the effect associated with the vertex buffer
  30716. */
  30717. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30718. private _unbindVertexArrayObject;
  30719. /**
  30720. * Bind a list of vertex buffers to the webGL context
  30721. * @param vertexBuffers defines the list of vertex buffers to bind
  30722. * @param indexBuffer defines the index buffer to bind
  30723. * @param effect defines the effect associated with the vertex buffers
  30724. */
  30725. bindBuffers(vertexBuffers: {
  30726. [key: string]: Nullable<VertexBuffer>;
  30727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30728. /**
  30729. * Unbind all instance attributes
  30730. */
  30731. unbindInstanceAttributes(): void;
  30732. /**
  30733. * Release and free the memory of a vertex array object
  30734. * @param vao defines the vertex array object to delete
  30735. */
  30736. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30737. /** @hidden */
  30738. _releaseBuffer(buffer: DataBuffer): boolean;
  30739. protected _deleteBuffer(buffer: DataBuffer): void;
  30740. /**
  30741. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30742. * @param instancesBuffer defines the webGL buffer to update and bind
  30743. * @param data defines the data to store in the buffer
  30744. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30745. */
  30746. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30747. /**
  30748. * Apply all cached states (depth, culling, stencil and alpha)
  30749. */
  30750. applyStates(): void;
  30751. /**
  30752. * Send a draw order
  30753. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30754. * @param indexStart defines the starting index
  30755. * @param indexCount defines the number of index to draw
  30756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30757. */
  30758. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30759. /**
  30760. * Draw a list of points
  30761. * @param verticesStart defines the index of first vertex to draw
  30762. * @param verticesCount defines the count of vertices to draw
  30763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30764. */
  30765. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30766. /**
  30767. * Draw a list of unindexed primitives
  30768. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30769. * @param verticesStart defines the index of first vertex to draw
  30770. * @param verticesCount defines the count of vertices to draw
  30771. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30772. */
  30773. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30774. /**
  30775. * Draw a list of indexed primitives
  30776. * @param fillMode defines the primitive to use
  30777. * @param indexStart defines the starting index
  30778. * @param indexCount defines the number of index to draw
  30779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30780. */
  30781. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30782. /**
  30783. * Draw a list of unindexed primitives
  30784. * @param fillMode defines the primitive to use
  30785. * @param verticesStart defines the index of first vertex to draw
  30786. * @param verticesCount defines the count of vertices to draw
  30787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30788. */
  30789. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30790. private _drawMode;
  30791. /** @hidden */
  30792. protected _reportDrawCall(): void;
  30793. /** @hidden */
  30794. _releaseEffect(effect: Effect): void;
  30795. /** @hidden */
  30796. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30797. /**
  30798. * Create a new effect (used to store vertex/fragment shaders)
  30799. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30800. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30801. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30802. * @param samplers defines an array of string used to represent textures
  30803. * @param defines defines the string containing the defines to use to compile the shaders
  30804. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30805. * @param onCompiled defines a function to call when the effect creation is successful
  30806. * @param onError defines a function to call when the effect creation has failed
  30807. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30808. * @returns the new Effect
  30809. */
  30810. 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;
  30811. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30812. private _compileShader;
  30813. private _compileRawShader;
  30814. /**
  30815. * Directly creates a webGL program
  30816. * @param pipelineContext defines the pipeline context to attach to
  30817. * @param vertexCode defines the vertex shader code to use
  30818. * @param fragmentCode defines the fragment shader code to use
  30819. * @param context defines the webGL context to use (if not set, the current one will be used)
  30820. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30821. * @returns the new webGL program
  30822. */
  30823. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30824. /**
  30825. * Creates a webGL program
  30826. * @param pipelineContext defines the pipeline context to attach to
  30827. * @param vertexCode defines the vertex shader code to use
  30828. * @param fragmentCode defines the fragment shader code to use
  30829. * @param defines defines the string containing the defines to use to compile the shaders
  30830. * @param context defines the webGL context to use (if not set, the current one will be used)
  30831. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30832. * @returns the new webGL program
  30833. */
  30834. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30835. /**
  30836. * Creates a new pipeline context
  30837. * @returns the new pipeline
  30838. */
  30839. createPipelineContext(): IPipelineContext;
  30840. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30841. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30842. /** @hidden */
  30843. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30844. /** @hidden */
  30845. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30846. /** @hidden */
  30847. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30848. /**
  30849. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30850. * @param pipelineContext defines the pipeline context to use
  30851. * @param uniformsNames defines the list of uniform names
  30852. * @returns an array of webGL uniform locations
  30853. */
  30854. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30855. /**
  30856. * Gets the lsit of active attributes for a given webGL program
  30857. * @param pipelineContext defines the pipeline context to use
  30858. * @param attributesNames defines the list of attribute names to get
  30859. * @returns an array of indices indicating the offset of each attribute
  30860. */
  30861. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30862. /**
  30863. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30864. * @param effect defines the effect to activate
  30865. */
  30866. enableEffect(effect: Nullable<Effect>): void;
  30867. /**
  30868. * Set the value of an uniform to a number (int)
  30869. * @param uniform defines the webGL uniform location where to store the value
  30870. * @param value defines the int number to store
  30871. */
  30872. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30873. /**
  30874. * Set the value of an uniform to an array of int32
  30875. * @param uniform defines the webGL uniform location where to store the value
  30876. * @param array defines the array of int32 to store
  30877. */
  30878. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30879. /**
  30880. * Set the value of an uniform to an array of int32 (stored as vec2)
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param array defines the array of int32 to store
  30883. */
  30884. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30885. /**
  30886. * Set the value of an uniform to an array of int32 (stored as vec3)
  30887. * @param uniform defines the webGL uniform location where to store the value
  30888. * @param array defines the array of int32 to store
  30889. */
  30890. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30891. /**
  30892. * Set the value of an uniform to an array of int32 (stored as vec4)
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of int32 to store
  30895. */
  30896. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of number
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param array defines the array of number to store
  30901. */
  30902. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30903. /**
  30904. * Set the value of an uniform to an array of number (stored as vec2)
  30905. * @param uniform defines the webGL uniform location where to store the value
  30906. * @param array defines the array of number to store
  30907. */
  30908. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30909. /**
  30910. * Set the value of an uniform to an array of number (stored as vec3)
  30911. * @param uniform defines the webGL uniform location where to store the value
  30912. * @param array defines the array of number to store
  30913. */
  30914. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30915. /**
  30916. * Set the value of an uniform to an array of number (stored as vec4)
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param array defines the array of number to store
  30919. */
  30920. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30921. /**
  30922. * Set the value of an uniform to an array of float32 (stored as matrices)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param matrices defines the array of float32 to store
  30925. */
  30926. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to a matrix (3x3)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30931. */
  30932. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to a matrix (2x2)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30937. */
  30938. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30939. /**
  30940. * Set the value of an uniform to a number (float)
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param value defines the float number to store
  30943. */
  30944. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30945. /**
  30946. * Set the value of an uniform to a vec2
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param x defines the 1st component of the value
  30949. * @param y defines the 2nd component of the value
  30950. */
  30951. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30952. /**
  30953. * Set the value of an uniform to a vec3
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param x defines the 1st component of the value
  30956. * @param y defines the 2nd component of the value
  30957. * @param z defines the 3rd component of the value
  30958. */
  30959. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30960. /**
  30961. * Set the value of an uniform to a vec4
  30962. * @param uniform defines the webGL uniform location where to store the value
  30963. * @param x defines the 1st component of the value
  30964. * @param y defines the 2nd component of the value
  30965. * @param z defines the 3rd component of the value
  30966. * @param w defines the 4th component of the value
  30967. */
  30968. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30969. /**
  30970. * Gets the depth culling state manager
  30971. */
  30972. readonly depthCullingState: DepthCullingState;
  30973. /**
  30974. * Gets the alpha state manager
  30975. */
  30976. readonly alphaState: AlphaState;
  30977. /**
  30978. * Gets the stencil state manager
  30979. */
  30980. readonly stencilState: StencilState;
  30981. /**
  30982. * Clears the list of texture accessible through engine.
  30983. * This can help preventing texture load conflict due to name collision.
  30984. */
  30985. clearInternalTexturesCache(): void;
  30986. /**
  30987. * Force the entire cache to be cleared
  30988. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30989. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30990. */
  30991. wipeCaches(bruteForce?: boolean): void;
  30992. /** @hidden */
  30993. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30994. min: number;
  30995. mag: number;
  30996. };
  30997. /** @hidden */
  30998. _createTexture(): WebGLTexture;
  30999. /**
  31000. * Usually called from Texture.ts.
  31001. * Passed information to create a WebGLTexture
  31002. * @param urlArg defines a value which contains one of the following:
  31003. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31004. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31005. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31006. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31007. * @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)
  31008. * @param scene needed for loading to the correct scene
  31009. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31010. * @param onLoad optional callback to be called upon successful completion
  31011. * @param onError optional callback to be called upon failure
  31012. * @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
  31013. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31014. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31015. * @param forcedExtension defines the extension to use to pick the right loader
  31016. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31017. * @param mimeType defines an optional mime type
  31018. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31019. */
  31020. 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;
  31021. /**
  31022. * @hidden
  31023. */
  31024. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31025. /**
  31026. * Creates a raw texture
  31027. * @param data defines the data to store in the texture
  31028. * @param width defines the width of the texture
  31029. * @param height defines the height of the texture
  31030. * @param format defines the format of the data
  31031. * @param generateMipMaps defines if the engine should generate the mip levels
  31032. * @param invertY defines if data must be stored with Y axis inverted
  31033. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31034. * @param compression defines the compression used (null by default)
  31035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31036. * @returns the raw texture inside an InternalTexture
  31037. */
  31038. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31039. /**
  31040. * Creates a new raw cube texture
  31041. * @param data defines the array of data to use to create each face
  31042. * @param size defines the size of the textures
  31043. * @param format defines the format of the data
  31044. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31045. * @param generateMipMaps defines if the engine should generate the mip levels
  31046. * @param invertY defines if data must be stored with Y axis inverted
  31047. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31048. * @param compression defines the compression used (null by default)
  31049. * @returns the cube texture as an InternalTexture
  31050. */
  31051. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31052. /**
  31053. * Creates a new raw 3D texture
  31054. * @param data defines the data used to create the texture
  31055. * @param width defines the width of the texture
  31056. * @param height defines the height of the texture
  31057. * @param depth defines the depth of the texture
  31058. * @param format defines the format of the texture
  31059. * @param generateMipMaps defines if the engine must generate mip levels
  31060. * @param invertY defines if data must be stored with Y axis inverted
  31061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31062. * @param compression defines the compressed used (can be null)
  31063. * @param textureType defines the compressed used (can be null)
  31064. * @returns a new raw 3D texture (stored in an InternalTexture)
  31065. */
  31066. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31067. /**
  31068. * Creates a new raw 2D array texture
  31069. * @param data defines the data used to create the texture
  31070. * @param width defines the width of the texture
  31071. * @param height defines the height of the texture
  31072. * @param depth defines the number of layers of the texture
  31073. * @param format defines the format of the texture
  31074. * @param generateMipMaps defines if the engine must generate mip levels
  31075. * @param invertY defines if data must be stored with Y axis inverted
  31076. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31077. * @param compression defines the compressed used (can be null)
  31078. * @param textureType defines the compressed used (can be null)
  31079. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31080. */
  31081. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31082. private _unpackFlipYCached;
  31083. /**
  31084. * In case you are sharing the context with other applications, it might
  31085. * be interested to not cache the unpack flip y state to ensure a consistent
  31086. * value would be set.
  31087. */
  31088. enableUnpackFlipYCached: boolean;
  31089. /** @hidden */
  31090. _unpackFlipY(value: boolean): void;
  31091. /** @hidden */
  31092. _getUnpackAlignement(): number;
  31093. /**
  31094. * Update the sampling mode of a given texture
  31095. * @param samplingMode defines the required sampling mode
  31096. * @param texture defines the texture to update
  31097. */
  31098. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31099. /** @hidden */
  31100. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31101. width: number;
  31102. height: number;
  31103. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31104. /** @hidden */
  31105. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31106. /** @hidden */
  31107. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31108. /** @hidden */
  31109. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31110. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31111. private _prepareWebGLTexture;
  31112. /** @hidden */
  31113. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31114. /** @hidden */
  31115. _releaseFramebufferObjects(texture: InternalTexture): void;
  31116. /** @hidden */
  31117. _releaseTexture(texture: InternalTexture): void;
  31118. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31119. protected _setProgram(program: WebGLProgram): void;
  31120. protected _boundUniforms: {
  31121. [key: number]: WebGLUniformLocation;
  31122. };
  31123. /**
  31124. * Binds an effect to the webGL context
  31125. * @param effect defines the effect to bind
  31126. */
  31127. bindSamplers(effect: Effect): void;
  31128. private _activateCurrentTexture;
  31129. /** @hidden */
  31130. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31131. /** @hidden */
  31132. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31133. /**
  31134. * Unbind all textures from the webGL context
  31135. */
  31136. unbindAllTextures(): void;
  31137. /**
  31138. * Sets a texture to the according uniform.
  31139. * @param channel The texture channel
  31140. * @param uniform The uniform to set
  31141. * @param texture The texture to apply
  31142. */
  31143. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31144. private _bindSamplerUniformToChannel;
  31145. private _getTextureWrapMode;
  31146. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31147. /**
  31148. * Sets an array of texture to the webGL context
  31149. * @param channel defines the channel where the texture array must be set
  31150. * @param uniform defines the associated uniform location
  31151. * @param textures defines the array of textures to bind
  31152. */
  31153. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31154. /** @hidden */
  31155. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31156. private _setTextureParameterFloat;
  31157. private _setTextureParameterInteger;
  31158. /**
  31159. * Unbind all vertex attributes from the webGL context
  31160. */
  31161. unbindAllAttributes(): void;
  31162. /**
  31163. * 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
  31164. */
  31165. releaseEffects(): void;
  31166. /**
  31167. * Dispose and release all associated resources
  31168. */
  31169. dispose(): void;
  31170. /**
  31171. * Attach a new callback raised when context lost event is fired
  31172. * @param callback defines the callback to call
  31173. */
  31174. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31175. /**
  31176. * Attach a new callback raised when context restored event is fired
  31177. * @param callback defines the callback to call
  31178. */
  31179. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31180. /**
  31181. * Get the current error code of the webGL context
  31182. * @returns the error code
  31183. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31184. */
  31185. getError(): number;
  31186. private _canRenderToFloatFramebuffer;
  31187. private _canRenderToHalfFloatFramebuffer;
  31188. private _canRenderToFramebuffer;
  31189. /** @hidden */
  31190. _getWebGLTextureType(type: number): number;
  31191. /** @hidden */
  31192. _getInternalFormat(format: number): number;
  31193. /** @hidden */
  31194. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31195. /** @hidden */
  31196. _getRGBAMultiSampleBufferFormat(type: number): number;
  31197. /** @hidden */
  31198. _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;
  31199. /**
  31200. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31201. * @returns true if the engine can be created
  31202. * @ignorenaming
  31203. */
  31204. static isSupported(): boolean;
  31205. /**
  31206. * Find the next highest power of two.
  31207. * @param x Number to start search from.
  31208. * @return Next highest power of two.
  31209. */
  31210. static CeilingPOT(x: number): number;
  31211. /**
  31212. * Find the next lowest power of two.
  31213. * @param x Number to start search from.
  31214. * @return Next lowest power of two.
  31215. */
  31216. static FloorPOT(x: number): number;
  31217. /**
  31218. * Find the nearest power of two.
  31219. * @param x Number to start search from.
  31220. * @return Next nearest power of two.
  31221. */
  31222. static NearestPOT(x: number): number;
  31223. /**
  31224. * Get the closest exponent of two
  31225. * @param value defines the value to approximate
  31226. * @param max defines the maximum value to return
  31227. * @param mode defines how to define the closest value
  31228. * @returns closest exponent of two of the given value
  31229. */
  31230. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31231. /**
  31232. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31233. * @param func - the function to be called
  31234. * @param requester - the object that will request the next frame. Falls back to window.
  31235. * @returns frame number
  31236. */
  31237. static QueueNewFrame(func: () => void, requester?: any): number;
  31238. }
  31239. }
  31240. declare module "babylonjs/Maths/sphericalPolynomial" {
  31241. import { Vector3 } from "babylonjs/Maths/math.vector";
  31242. import { Color3 } from "babylonjs/Maths/math.color";
  31243. /**
  31244. * Class representing spherical harmonics coefficients to the 3rd degree
  31245. */
  31246. export class SphericalHarmonics {
  31247. /**
  31248. * Defines whether or not the harmonics have been prescaled for rendering.
  31249. */
  31250. preScaled: boolean;
  31251. /**
  31252. * The l0,0 coefficients of the spherical harmonics
  31253. */
  31254. l00: Vector3;
  31255. /**
  31256. * The l1,-1 coefficients of the spherical harmonics
  31257. */
  31258. l1_1: Vector3;
  31259. /**
  31260. * The l1,0 coefficients of the spherical harmonics
  31261. */
  31262. l10: Vector3;
  31263. /**
  31264. * The l1,1 coefficients of the spherical harmonics
  31265. */
  31266. l11: Vector3;
  31267. /**
  31268. * The l2,-2 coefficients of the spherical harmonics
  31269. */
  31270. l2_2: Vector3;
  31271. /**
  31272. * The l2,-1 coefficients of the spherical harmonics
  31273. */
  31274. l2_1: Vector3;
  31275. /**
  31276. * The l2,0 coefficients of the spherical harmonics
  31277. */
  31278. l20: Vector3;
  31279. /**
  31280. * The l2,1 coefficients of the spherical harmonics
  31281. */
  31282. l21: Vector3;
  31283. /**
  31284. * The l2,2 coefficients of the spherical harmonics
  31285. */
  31286. l22: Vector3;
  31287. /**
  31288. * Adds a light to the spherical harmonics
  31289. * @param direction the direction of the light
  31290. * @param color the color of the light
  31291. * @param deltaSolidAngle the delta solid angle of the light
  31292. */
  31293. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31294. /**
  31295. * Scales the spherical harmonics by the given amount
  31296. * @param scale the amount to scale
  31297. */
  31298. scaleInPlace(scale: number): void;
  31299. /**
  31300. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31301. *
  31302. * ```
  31303. * E_lm = A_l * L_lm
  31304. * ```
  31305. *
  31306. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31307. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31308. * the scaling factors are given in equation 9.
  31309. */
  31310. convertIncidentRadianceToIrradiance(): void;
  31311. /**
  31312. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31313. *
  31314. * ```
  31315. * L = (1/pi) * E * rho
  31316. * ```
  31317. *
  31318. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31319. */
  31320. convertIrradianceToLambertianRadiance(): void;
  31321. /**
  31322. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31323. * required operations at run time.
  31324. *
  31325. * This is simply done by scaling back the SH with Ylm constants parameter.
  31326. * The trigonometric part being applied by the shader at run time.
  31327. */
  31328. preScaleForRendering(): void;
  31329. /**
  31330. * Constructs a spherical harmonics from an array.
  31331. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31332. * @returns the spherical harmonics
  31333. */
  31334. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31335. /**
  31336. * Gets the spherical harmonics from polynomial
  31337. * @param polynomial the spherical polynomial
  31338. * @returns the spherical harmonics
  31339. */
  31340. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31341. }
  31342. /**
  31343. * Class representing spherical polynomial coefficients to the 3rd degree
  31344. */
  31345. export class SphericalPolynomial {
  31346. private _harmonics;
  31347. /**
  31348. * The spherical harmonics used to create the polynomials.
  31349. */
  31350. readonly preScaledHarmonics: SphericalHarmonics;
  31351. /**
  31352. * The x coefficients of the spherical polynomial
  31353. */
  31354. x: Vector3;
  31355. /**
  31356. * The y coefficients of the spherical polynomial
  31357. */
  31358. y: Vector3;
  31359. /**
  31360. * The z coefficients of the spherical polynomial
  31361. */
  31362. z: Vector3;
  31363. /**
  31364. * The xx coefficients of the spherical polynomial
  31365. */
  31366. xx: Vector3;
  31367. /**
  31368. * The yy coefficients of the spherical polynomial
  31369. */
  31370. yy: Vector3;
  31371. /**
  31372. * The zz coefficients of the spherical polynomial
  31373. */
  31374. zz: Vector3;
  31375. /**
  31376. * The xy coefficients of the spherical polynomial
  31377. */
  31378. xy: Vector3;
  31379. /**
  31380. * The yz coefficients of the spherical polynomial
  31381. */
  31382. yz: Vector3;
  31383. /**
  31384. * The zx coefficients of the spherical polynomial
  31385. */
  31386. zx: Vector3;
  31387. /**
  31388. * Adds an ambient color to the spherical polynomial
  31389. * @param color the color to add
  31390. */
  31391. addAmbient(color: Color3): void;
  31392. /**
  31393. * Scales the spherical polynomial by the given amount
  31394. * @param scale the amount to scale
  31395. */
  31396. scaleInPlace(scale: number): void;
  31397. /**
  31398. * Gets the spherical polynomial from harmonics
  31399. * @param harmonics the spherical harmonics
  31400. * @returns the spherical polynomial
  31401. */
  31402. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31403. /**
  31404. * Constructs a spherical polynomial from an array.
  31405. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31406. * @returns the spherical polynomial
  31407. */
  31408. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31409. }
  31410. }
  31411. declare module "babylonjs/Materials/Textures/internalTexture" {
  31412. import { Observable } from "babylonjs/Misc/observable";
  31413. import { Nullable, int } from "babylonjs/types";
  31414. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31416. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31417. /**
  31418. * Defines the source of the internal texture
  31419. */
  31420. export enum InternalTextureSource {
  31421. /**
  31422. * The source of the texture data is unknown
  31423. */
  31424. Unknown = 0,
  31425. /**
  31426. * Texture data comes from an URL
  31427. */
  31428. Url = 1,
  31429. /**
  31430. * Texture data is only used for temporary storage
  31431. */
  31432. Temp = 2,
  31433. /**
  31434. * Texture data comes from raw data (ArrayBuffer)
  31435. */
  31436. Raw = 3,
  31437. /**
  31438. * Texture content is dynamic (video or dynamic texture)
  31439. */
  31440. Dynamic = 4,
  31441. /**
  31442. * Texture content is generated by rendering to it
  31443. */
  31444. RenderTarget = 5,
  31445. /**
  31446. * Texture content is part of a multi render target process
  31447. */
  31448. MultiRenderTarget = 6,
  31449. /**
  31450. * Texture data comes from a cube data file
  31451. */
  31452. Cube = 7,
  31453. /**
  31454. * Texture data comes from a raw cube data
  31455. */
  31456. CubeRaw = 8,
  31457. /**
  31458. * Texture data come from a prefiltered cube data file
  31459. */
  31460. CubePrefiltered = 9,
  31461. /**
  31462. * Texture content is raw 3D data
  31463. */
  31464. Raw3D = 10,
  31465. /**
  31466. * Texture content is raw 2D array data
  31467. */
  31468. Raw2DArray = 11,
  31469. /**
  31470. * Texture content is a depth texture
  31471. */
  31472. Depth = 12,
  31473. /**
  31474. * Texture data comes from a raw cube data encoded with RGBD
  31475. */
  31476. CubeRawRGBD = 13
  31477. }
  31478. /**
  31479. * Class used to store data associated with WebGL texture data for the engine
  31480. * This class should not be used directly
  31481. */
  31482. export class InternalTexture {
  31483. /** @hidden */
  31484. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31485. /**
  31486. * Defines if the texture is ready
  31487. */
  31488. isReady: boolean;
  31489. /**
  31490. * Defines if the texture is a cube texture
  31491. */
  31492. isCube: boolean;
  31493. /**
  31494. * Defines if the texture contains 3D data
  31495. */
  31496. is3D: boolean;
  31497. /**
  31498. * Defines if the texture contains 2D array data
  31499. */
  31500. is2DArray: boolean;
  31501. /**
  31502. * Defines if the texture contains multiview data
  31503. */
  31504. isMultiview: boolean;
  31505. /**
  31506. * Gets the URL used to load this texture
  31507. */
  31508. url: string;
  31509. /**
  31510. * Gets the sampling mode of the texture
  31511. */
  31512. samplingMode: number;
  31513. /**
  31514. * Gets a boolean indicating if the texture needs mipmaps generation
  31515. */
  31516. generateMipMaps: boolean;
  31517. /**
  31518. * Gets the number of samples used by the texture (WebGL2+ only)
  31519. */
  31520. samples: number;
  31521. /**
  31522. * Gets the type of the texture (int, float...)
  31523. */
  31524. type: number;
  31525. /**
  31526. * Gets the format of the texture (RGB, RGBA...)
  31527. */
  31528. format: number;
  31529. /**
  31530. * Observable called when the texture is loaded
  31531. */
  31532. onLoadedObservable: Observable<InternalTexture>;
  31533. /**
  31534. * Gets the width of the texture
  31535. */
  31536. width: number;
  31537. /**
  31538. * Gets the height of the texture
  31539. */
  31540. height: number;
  31541. /**
  31542. * Gets the depth of the texture
  31543. */
  31544. depth: number;
  31545. /**
  31546. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31547. */
  31548. baseWidth: number;
  31549. /**
  31550. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31551. */
  31552. baseHeight: number;
  31553. /**
  31554. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31555. */
  31556. baseDepth: number;
  31557. /**
  31558. * Gets a boolean indicating if the texture is inverted on Y axis
  31559. */
  31560. invertY: boolean;
  31561. /** @hidden */
  31562. _invertVScale: boolean;
  31563. /** @hidden */
  31564. _associatedChannel: number;
  31565. /** @hidden */
  31566. _source: InternalTextureSource;
  31567. /** @hidden */
  31568. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31569. /** @hidden */
  31570. _bufferView: Nullable<ArrayBufferView>;
  31571. /** @hidden */
  31572. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31573. /** @hidden */
  31574. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31575. /** @hidden */
  31576. _size: number;
  31577. /** @hidden */
  31578. _extension: string;
  31579. /** @hidden */
  31580. _files: Nullable<string[]>;
  31581. /** @hidden */
  31582. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31583. /** @hidden */
  31584. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31585. /** @hidden */
  31586. _framebuffer: Nullable<WebGLFramebuffer>;
  31587. /** @hidden */
  31588. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31589. /** @hidden */
  31590. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31591. /** @hidden */
  31592. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31593. /** @hidden */
  31594. _attachments: Nullable<number[]>;
  31595. /** @hidden */
  31596. _cachedCoordinatesMode: Nullable<number>;
  31597. /** @hidden */
  31598. _cachedWrapU: Nullable<number>;
  31599. /** @hidden */
  31600. _cachedWrapV: Nullable<number>;
  31601. /** @hidden */
  31602. _cachedWrapR: Nullable<number>;
  31603. /** @hidden */
  31604. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31605. /** @hidden */
  31606. _isDisabled: boolean;
  31607. /** @hidden */
  31608. _compression: Nullable<string>;
  31609. /** @hidden */
  31610. _generateStencilBuffer: boolean;
  31611. /** @hidden */
  31612. _generateDepthBuffer: boolean;
  31613. /** @hidden */
  31614. _comparisonFunction: number;
  31615. /** @hidden */
  31616. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31617. /** @hidden */
  31618. _lodGenerationScale: number;
  31619. /** @hidden */
  31620. _lodGenerationOffset: number;
  31621. /** @hidden */
  31622. _colorTextureArray: Nullable<WebGLTexture>;
  31623. /** @hidden */
  31624. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31625. /** @hidden */
  31626. _lodTextureHigh: Nullable<BaseTexture>;
  31627. /** @hidden */
  31628. _lodTextureMid: Nullable<BaseTexture>;
  31629. /** @hidden */
  31630. _lodTextureLow: Nullable<BaseTexture>;
  31631. /** @hidden */
  31632. _isRGBD: boolean;
  31633. /** @hidden */
  31634. _linearSpecularLOD: boolean;
  31635. /** @hidden */
  31636. _irradianceTexture: Nullable<BaseTexture>;
  31637. /** @hidden */
  31638. _webGLTexture: Nullable<WebGLTexture>;
  31639. /** @hidden */
  31640. _references: number;
  31641. private _engine;
  31642. /**
  31643. * Gets the Engine the texture belongs to.
  31644. * @returns The babylon engine
  31645. */
  31646. getEngine(): ThinEngine;
  31647. /**
  31648. * Gets the data source type of the texture
  31649. */
  31650. readonly source: InternalTextureSource;
  31651. /**
  31652. * Creates a new InternalTexture
  31653. * @param engine defines the engine to use
  31654. * @param source defines the type of data that will be used
  31655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31656. */
  31657. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31658. /**
  31659. * Increments the number of references (ie. the number of Texture that point to it)
  31660. */
  31661. incrementReferences(): void;
  31662. /**
  31663. * Change the size of the texture (not the size of the content)
  31664. * @param width defines the new width
  31665. * @param height defines the new height
  31666. * @param depth defines the new depth (1 by default)
  31667. */
  31668. updateSize(width: int, height: int, depth?: int): void;
  31669. /** @hidden */
  31670. _rebuild(): void;
  31671. /** @hidden */
  31672. _swapAndDie(target: InternalTexture): void;
  31673. /**
  31674. * Dispose the current allocated resources
  31675. */
  31676. dispose(): void;
  31677. }
  31678. }
  31679. declare module "babylonjs/Audio/analyser" {
  31680. import { Scene } from "babylonjs/scene";
  31681. /**
  31682. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31684. */
  31685. export class Analyser {
  31686. /**
  31687. * Gets or sets the smoothing
  31688. * @ignorenaming
  31689. */
  31690. SMOOTHING: number;
  31691. /**
  31692. * Gets or sets the FFT table size
  31693. * @ignorenaming
  31694. */
  31695. FFT_SIZE: number;
  31696. /**
  31697. * Gets or sets the bar graph amplitude
  31698. * @ignorenaming
  31699. */
  31700. BARGRAPHAMPLITUDE: number;
  31701. /**
  31702. * Gets or sets the position of the debug canvas
  31703. * @ignorenaming
  31704. */
  31705. DEBUGCANVASPOS: {
  31706. x: number;
  31707. y: number;
  31708. };
  31709. /**
  31710. * Gets or sets the debug canvas size
  31711. * @ignorenaming
  31712. */
  31713. DEBUGCANVASSIZE: {
  31714. width: number;
  31715. height: number;
  31716. };
  31717. private _byteFreqs;
  31718. private _byteTime;
  31719. private _floatFreqs;
  31720. private _webAudioAnalyser;
  31721. private _debugCanvas;
  31722. private _debugCanvasContext;
  31723. private _scene;
  31724. private _registerFunc;
  31725. private _audioEngine;
  31726. /**
  31727. * Creates a new analyser
  31728. * @param scene defines hosting scene
  31729. */
  31730. constructor(scene: Scene);
  31731. /**
  31732. * Get the number of data values you will have to play with for the visualization
  31733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31734. * @returns a number
  31735. */
  31736. getFrequencyBinCount(): number;
  31737. /**
  31738. * Gets the current frequency data as a byte array
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31740. * @returns a Uint8Array
  31741. */
  31742. getByteFrequencyData(): Uint8Array;
  31743. /**
  31744. * Gets the current waveform as a byte array
  31745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31746. * @returns a Uint8Array
  31747. */
  31748. getByteTimeDomainData(): Uint8Array;
  31749. /**
  31750. * Gets the current frequency data as a float array
  31751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31752. * @returns a Float32Array
  31753. */
  31754. getFloatFrequencyData(): Float32Array;
  31755. /**
  31756. * Renders the debug canvas
  31757. */
  31758. drawDebugCanvas(): void;
  31759. /**
  31760. * Stops rendering the debug canvas and removes it
  31761. */
  31762. stopDebugCanvas(): void;
  31763. /**
  31764. * Connects two audio nodes
  31765. * @param inputAudioNode defines first node to connect
  31766. * @param outputAudioNode defines second node to connect
  31767. */
  31768. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31769. /**
  31770. * Releases all associated resources
  31771. */
  31772. dispose(): void;
  31773. }
  31774. }
  31775. declare module "babylonjs/Audio/audioEngine" {
  31776. import { IDisposable } from "babylonjs/scene";
  31777. import { Analyser } from "babylonjs/Audio/analyser";
  31778. import { Nullable } from "babylonjs/types";
  31779. import { Observable } from "babylonjs/Misc/observable";
  31780. /**
  31781. * This represents an audio engine and it is responsible
  31782. * to play, synchronize and analyse sounds throughout the application.
  31783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31784. */
  31785. export interface IAudioEngine extends IDisposable {
  31786. /**
  31787. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31788. */
  31789. readonly canUseWebAudio: boolean;
  31790. /**
  31791. * Gets the current AudioContext if available.
  31792. */
  31793. readonly audioContext: Nullable<AudioContext>;
  31794. /**
  31795. * The master gain node defines the global audio volume of your audio engine.
  31796. */
  31797. readonly masterGain: GainNode;
  31798. /**
  31799. * Gets whether or not mp3 are supported by your browser.
  31800. */
  31801. readonly isMP3supported: boolean;
  31802. /**
  31803. * Gets whether or not ogg are supported by your browser.
  31804. */
  31805. readonly isOGGsupported: boolean;
  31806. /**
  31807. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31808. * @ignoreNaming
  31809. */
  31810. WarnedWebAudioUnsupported: boolean;
  31811. /**
  31812. * Defines if the audio engine relies on a custom unlocked button.
  31813. * In this case, the embedded button will not be displayed.
  31814. */
  31815. useCustomUnlockedButton: boolean;
  31816. /**
  31817. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31818. */
  31819. readonly unlocked: boolean;
  31820. /**
  31821. * Event raised when audio has been unlocked on the browser.
  31822. */
  31823. onAudioUnlockedObservable: Observable<AudioEngine>;
  31824. /**
  31825. * Event raised when audio has been locked on the browser.
  31826. */
  31827. onAudioLockedObservable: Observable<AudioEngine>;
  31828. /**
  31829. * Flags the audio engine in Locked state.
  31830. * This happens due to new browser policies preventing audio to autoplay.
  31831. */
  31832. lock(): void;
  31833. /**
  31834. * Unlocks the audio engine once a user action has been done on the dom.
  31835. * This is helpful to resume play once browser policies have been satisfied.
  31836. */
  31837. unlock(): void;
  31838. }
  31839. /**
  31840. * This represents the default audio engine used in babylon.
  31841. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31843. */
  31844. export class AudioEngine implements IAudioEngine {
  31845. private _audioContext;
  31846. private _audioContextInitialized;
  31847. private _muteButton;
  31848. private _hostElement;
  31849. /**
  31850. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31851. */
  31852. canUseWebAudio: boolean;
  31853. /**
  31854. * The master gain node defines the global audio volume of your audio engine.
  31855. */
  31856. masterGain: GainNode;
  31857. /**
  31858. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31859. * @ignoreNaming
  31860. */
  31861. WarnedWebAudioUnsupported: boolean;
  31862. /**
  31863. * Gets whether or not mp3 are supported by your browser.
  31864. */
  31865. isMP3supported: boolean;
  31866. /**
  31867. * Gets whether or not ogg are supported by your browser.
  31868. */
  31869. isOGGsupported: boolean;
  31870. /**
  31871. * Gets whether audio has been unlocked on the device.
  31872. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31873. * a user interaction has happened.
  31874. */
  31875. unlocked: boolean;
  31876. /**
  31877. * Defines if the audio engine relies on a custom unlocked button.
  31878. * In this case, the embedded button will not be displayed.
  31879. */
  31880. useCustomUnlockedButton: boolean;
  31881. /**
  31882. * Event raised when audio has been unlocked on the browser.
  31883. */
  31884. onAudioUnlockedObservable: Observable<AudioEngine>;
  31885. /**
  31886. * Event raised when audio has been locked on the browser.
  31887. */
  31888. onAudioLockedObservable: Observable<AudioEngine>;
  31889. /**
  31890. * Gets the current AudioContext if available.
  31891. */
  31892. readonly audioContext: Nullable<AudioContext>;
  31893. private _connectedAnalyser;
  31894. /**
  31895. * Instantiates a new audio engine.
  31896. *
  31897. * There should be only one per page as some browsers restrict the number
  31898. * of audio contexts you can create.
  31899. * @param hostElement defines the host element where to display the mute icon if necessary
  31900. */
  31901. constructor(hostElement?: Nullable<HTMLElement>);
  31902. /**
  31903. * Flags the audio engine in Locked state.
  31904. * This happens due to new browser policies preventing audio to autoplay.
  31905. */
  31906. lock(): void;
  31907. /**
  31908. * Unlocks the audio engine once a user action has been done on the dom.
  31909. * This is helpful to resume play once browser policies have been satisfied.
  31910. */
  31911. unlock(): void;
  31912. private _resumeAudioContext;
  31913. private _initializeAudioContext;
  31914. private _tryToRun;
  31915. private _triggerRunningState;
  31916. private _triggerSuspendedState;
  31917. private _displayMuteButton;
  31918. private _moveButtonToTopLeft;
  31919. private _onResize;
  31920. private _hideMuteButton;
  31921. /**
  31922. * Destroy and release the resources associated with the audio ccontext.
  31923. */
  31924. dispose(): void;
  31925. /**
  31926. * Gets the global volume sets on the master gain.
  31927. * @returns the global volume if set or -1 otherwise
  31928. */
  31929. getGlobalVolume(): number;
  31930. /**
  31931. * Sets the global volume of your experience (sets on the master gain).
  31932. * @param newVolume Defines the new global volume of the application
  31933. */
  31934. setGlobalVolume(newVolume: number): void;
  31935. /**
  31936. * Connect the audio engine to an audio analyser allowing some amazing
  31937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31939. * @param analyser The analyser to connect to the engine
  31940. */
  31941. connectToAnalyser(analyser: Analyser): void;
  31942. }
  31943. }
  31944. declare module "babylonjs/Loading/loadingScreen" {
  31945. /**
  31946. * Interface used to present a loading screen while loading a scene
  31947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31948. */
  31949. export interface ILoadingScreen {
  31950. /**
  31951. * Function called to display the loading screen
  31952. */
  31953. displayLoadingUI: () => void;
  31954. /**
  31955. * Function called to hide the loading screen
  31956. */
  31957. hideLoadingUI: () => void;
  31958. /**
  31959. * Gets or sets the color to use for the background
  31960. */
  31961. loadingUIBackgroundColor: string;
  31962. /**
  31963. * Gets or sets the text to display while loading
  31964. */
  31965. loadingUIText: string;
  31966. }
  31967. /**
  31968. * Class used for the default loading screen
  31969. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31970. */
  31971. export class DefaultLoadingScreen implements ILoadingScreen {
  31972. private _renderingCanvas;
  31973. private _loadingText;
  31974. private _loadingDivBackgroundColor;
  31975. private _loadingDiv;
  31976. private _loadingTextDiv;
  31977. /** Gets or sets the logo url to use for the default loading screen */
  31978. static DefaultLogoUrl: string;
  31979. /** Gets or sets the spinner url to use for the default loading screen */
  31980. static DefaultSpinnerUrl: string;
  31981. /**
  31982. * Creates a new default loading screen
  31983. * @param _renderingCanvas defines the canvas used to render the scene
  31984. * @param _loadingText defines the default text to display
  31985. * @param _loadingDivBackgroundColor defines the default background color
  31986. */
  31987. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31988. /**
  31989. * Function called to display the loading screen
  31990. */
  31991. displayLoadingUI(): void;
  31992. /**
  31993. * Function called to hide the loading screen
  31994. */
  31995. hideLoadingUI(): void;
  31996. /**
  31997. * Gets or sets the text to display while loading
  31998. */
  31999. loadingUIText: string;
  32000. /**
  32001. * Gets or sets the color to use for the background
  32002. */
  32003. loadingUIBackgroundColor: string;
  32004. private _resizeLoadingUI;
  32005. }
  32006. }
  32007. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32008. /**
  32009. * Interface for any object that can request an animation frame
  32010. */
  32011. export interface ICustomAnimationFrameRequester {
  32012. /**
  32013. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32014. */
  32015. renderFunction?: Function;
  32016. /**
  32017. * Called to request the next frame to render to
  32018. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32019. */
  32020. requestAnimationFrame: Function;
  32021. /**
  32022. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32023. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32024. */
  32025. requestID?: number;
  32026. }
  32027. }
  32028. declare module "babylonjs/Misc/performanceMonitor" {
  32029. /**
  32030. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32031. */
  32032. export class PerformanceMonitor {
  32033. private _enabled;
  32034. private _rollingFrameTime;
  32035. private _lastFrameTimeMs;
  32036. /**
  32037. * constructor
  32038. * @param frameSampleSize The number of samples required to saturate the sliding window
  32039. */
  32040. constructor(frameSampleSize?: number);
  32041. /**
  32042. * Samples current frame
  32043. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32044. */
  32045. sampleFrame(timeMs?: number): void;
  32046. /**
  32047. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32048. */
  32049. readonly averageFrameTime: number;
  32050. /**
  32051. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32052. */
  32053. readonly averageFrameTimeVariance: number;
  32054. /**
  32055. * Returns the frame time of the most recent frame
  32056. */
  32057. readonly instantaneousFrameTime: number;
  32058. /**
  32059. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32060. */
  32061. readonly averageFPS: number;
  32062. /**
  32063. * Returns the average framerate in frames per second using the most recent frame time
  32064. */
  32065. readonly instantaneousFPS: number;
  32066. /**
  32067. * Returns true if enough samples have been taken to completely fill the sliding window
  32068. */
  32069. readonly isSaturated: boolean;
  32070. /**
  32071. * Enables contributions to the sliding window sample set
  32072. */
  32073. enable(): void;
  32074. /**
  32075. * Disables contributions to the sliding window sample set
  32076. * Samples will not be interpolated over the disabled period
  32077. */
  32078. disable(): void;
  32079. /**
  32080. * Returns true if sampling is enabled
  32081. */
  32082. readonly isEnabled: boolean;
  32083. /**
  32084. * Resets performance monitor
  32085. */
  32086. reset(): void;
  32087. }
  32088. /**
  32089. * RollingAverage
  32090. *
  32091. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32092. */
  32093. export class RollingAverage {
  32094. /**
  32095. * Current average
  32096. */
  32097. average: number;
  32098. /**
  32099. * Current variance
  32100. */
  32101. variance: number;
  32102. protected _samples: Array<number>;
  32103. protected _sampleCount: number;
  32104. protected _pos: number;
  32105. protected _m2: number;
  32106. /**
  32107. * constructor
  32108. * @param length The number of samples required to saturate the sliding window
  32109. */
  32110. constructor(length: number);
  32111. /**
  32112. * Adds a sample to the sample set
  32113. * @param v The sample value
  32114. */
  32115. add(v: number): void;
  32116. /**
  32117. * Returns previously added values or null if outside of history or outside the sliding window domain
  32118. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32119. * @return Value previously recorded with add() or null if outside of range
  32120. */
  32121. history(i: number): number;
  32122. /**
  32123. * Returns true if enough samples have been taken to completely fill the sliding window
  32124. * @return true if sample-set saturated
  32125. */
  32126. isSaturated(): boolean;
  32127. /**
  32128. * Resets the rolling average (equivalent to 0 samples taken so far)
  32129. */
  32130. reset(): void;
  32131. /**
  32132. * Wraps a value around the sample range boundaries
  32133. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32134. * @return Wrapped position in sample range
  32135. */
  32136. protected _wrapPosition(i: number): number;
  32137. }
  32138. }
  32139. declare module "babylonjs/Misc/perfCounter" {
  32140. /**
  32141. * This class is used to track a performance counter which is number based.
  32142. * The user has access to many properties which give statistics of different nature.
  32143. *
  32144. * The implementer can track two kinds of Performance Counter: time and count.
  32145. * 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.
  32146. * 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.
  32147. */
  32148. export class PerfCounter {
  32149. /**
  32150. * Gets or sets a global boolean to turn on and off all the counters
  32151. */
  32152. static Enabled: boolean;
  32153. /**
  32154. * Returns the smallest value ever
  32155. */
  32156. readonly min: number;
  32157. /**
  32158. * Returns the biggest value ever
  32159. */
  32160. readonly max: number;
  32161. /**
  32162. * Returns the average value since the performance counter is running
  32163. */
  32164. readonly average: number;
  32165. /**
  32166. * Returns the average value of the last second the counter was monitored
  32167. */
  32168. readonly lastSecAverage: number;
  32169. /**
  32170. * Returns the current value
  32171. */
  32172. readonly current: number;
  32173. /**
  32174. * Gets the accumulated total
  32175. */
  32176. readonly total: number;
  32177. /**
  32178. * Gets the total value count
  32179. */
  32180. readonly count: number;
  32181. /**
  32182. * Creates a new counter
  32183. */
  32184. constructor();
  32185. /**
  32186. * Call this method to start monitoring a new frame.
  32187. * 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.
  32188. */
  32189. fetchNewFrame(): void;
  32190. /**
  32191. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32192. * @param newCount the count value to add to the monitored count
  32193. * @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.
  32194. */
  32195. addCount(newCount: number, fetchResult: boolean): void;
  32196. /**
  32197. * Start monitoring this performance counter
  32198. */
  32199. beginMonitoring(): void;
  32200. /**
  32201. * Compute the time lapsed since the previous beginMonitoring() call.
  32202. * @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
  32203. */
  32204. endMonitoring(newFrame?: boolean): void;
  32205. private _fetchResult;
  32206. private _startMonitoringTime;
  32207. private _min;
  32208. private _max;
  32209. private _average;
  32210. private _current;
  32211. private _totalValueCount;
  32212. private _totalAccumulated;
  32213. private _lastSecAverage;
  32214. private _lastSecAccumulated;
  32215. private _lastSecTime;
  32216. private _lastSecValueCount;
  32217. }
  32218. }
  32219. declare module "babylonjs/Engines/engine" {
  32220. import { Observable } from "babylonjs/Misc/observable";
  32221. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32222. import { Scene } from "babylonjs/scene";
  32223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32224. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32225. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32226. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32227. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32228. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32229. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32230. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32231. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32233. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32234. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32235. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32236. import { Material } from "babylonjs/Materials/material";
  32237. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32238. /**
  32239. * Defines the interface used by display changed events
  32240. */
  32241. export interface IDisplayChangedEventArgs {
  32242. /** Gets the vrDisplay object (if any) */
  32243. vrDisplay: Nullable<any>;
  32244. /** Gets a boolean indicating if webVR is supported */
  32245. vrSupported: boolean;
  32246. }
  32247. /**
  32248. * Defines the interface used by objects containing a viewport (like a camera)
  32249. */
  32250. interface IViewportOwnerLike {
  32251. /**
  32252. * Gets or sets the viewport
  32253. */
  32254. viewport: IViewportLike;
  32255. }
  32256. /**
  32257. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32258. */
  32259. export class Engine extends ThinEngine {
  32260. /** Defines that alpha blending is disabled */
  32261. static readonly ALPHA_DISABLE: number;
  32262. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32263. static readonly ALPHA_ADD: number;
  32264. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32265. static readonly ALPHA_COMBINE: number;
  32266. /** Defines that alpha blending to DEST - SRC * DEST */
  32267. static readonly ALPHA_SUBTRACT: number;
  32268. /** Defines that alpha blending to SRC * DEST */
  32269. static readonly ALPHA_MULTIPLY: number;
  32270. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32271. static readonly ALPHA_MAXIMIZED: number;
  32272. /** Defines that alpha blending to SRC + DEST */
  32273. static readonly ALPHA_ONEONE: number;
  32274. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32275. static readonly ALPHA_PREMULTIPLIED: number;
  32276. /**
  32277. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32278. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32279. */
  32280. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32281. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32282. static readonly ALPHA_INTERPOLATE: number;
  32283. /**
  32284. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32285. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32286. */
  32287. static readonly ALPHA_SCREENMODE: number;
  32288. /** Defines that the ressource is not delayed*/
  32289. static readonly DELAYLOADSTATE_NONE: number;
  32290. /** Defines that the ressource was successfully delay loaded */
  32291. static readonly DELAYLOADSTATE_LOADED: number;
  32292. /** Defines that the ressource is currently delay loading */
  32293. static readonly DELAYLOADSTATE_LOADING: number;
  32294. /** Defines that the ressource is delayed and has not started loading */
  32295. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32297. static readonly NEVER: number;
  32298. /** 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 */
  32299. static readonly ALWAYS: number;
  32300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32301. static readonly LESS: number;
  32302. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32303. static readonly EQUAL: number;
  32304. /** 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 */
  32305. static readonly LEQUAL: number;
  32306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32307. static readonly GREATER: number;
  32308. /** 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 */
  32309. static readonly GEQUAL: number;
  32310. /** 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 */
  32311. static readonly NOTEQUAL: number;
  32312. /** Passed to stencilOperation to specify that stencil value must be kept */
  32313. static readonly KEEP: number;
  32314. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32315. static readonly REPLACE: number;
  32316. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32317. static readonly INCR: number;
  32318. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32319. static readonly DECR: number;
  32320. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32321. static readonly INVERT: number;
  32322. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32323. static readonly INCR_WRAP: number;
  32324. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32325. static readonly DECR_WRAP: number;
  32326. /** Texture is not repeating outside of 0..1 UVs */
  32327. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32328. /** Texture is repeating outside of 0..1 UVs */
  32329. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32330. /** Texture is repeating and mirrored */
  32331. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32332. /** ALPHA */
  32333. static readonly TEXTUREFORMAT_ALPHA: number;
  32334. /** LUMINANCE */
  32335. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32336. /** LUMINANCE_ALPHA */
  32337. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32338. /** RGB */
  32339. static readonly TEXTUREFORMAT_RGB: number;
  32340. /** RGBA */
  32341. static readonly TEXTUREFORMAT_RGBA: number;
  32342. /** RED */
  32343. static readonly TEXTUREFORMAT_RED: number;
  32344. /** RED (2nd reference) */
  32345. static readonly TEXTUREFORMAT_R: number;
  32346. /** RG */
  32347. static readonly TEXTUREFORMAT_RG: number;
  32348. /** RED_INTEGER */
  32349. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32350. /** RED_INTEGER (2nd reference) */
  32351. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32352. /** RG_INTEGER */
  32353. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32354. /** RGB_INTEGER */
  32355. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32356. /** RGBA_INTEGER */
  32357. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32358. /** UNSIGNED_BYTE */
  32359. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32360. /** UNSIGNED_BYTE (2nd reference) */
  32361. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32362. /** FLOAT */
  32363. static readonly TEXTURETYPE_FLOAT: number;
  32364. /** HALF_FLOAT */
  32365. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32366. /** BYTE */
  32367. static readonly TEXTURETYPE_BYTE: number;
  32368. /** SHORT */
  32369. static readonly TEXTURETYPE_SHORT: number;
  32370. /** UNSIGNED_SHORT */
  32371. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32372. /** INT */
  32373. static readonly TEXTURETYPE_INT: number;
  32374. /** UNSIGNED_INT */
  32375. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32376. /** UNSIGNED_SHORT_4_4_4_4 */
  32377. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32378. /** UNSIGNED_SHORT_5_5_5_1 */
  32379. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32380. /** UNSIGNED_SHORT_5_6_5 */
  32381. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32382. /** UNSIGNED_INT_2_10_10_10_REV */
  32383. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32384. /** UNSIGNED_INT_24_8 */
  32385. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32386. /** UNSIGNED_INT_10F_11F_11F_REV */
  32387. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32388. /** UNSIGNED_INT_5_9_9_9_REV */
  32389. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32390. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32391. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32392. /** nearest is mag = nearest and min = nearest and mip = linear */
  32393. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32394. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32395. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32396. /** Trilinear is mag = linear and min = linear and mip = linear */
  32397. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32398. /** nearest is mag = nearest and min = nearest and mip = linear */
  32399. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32400. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32401. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32402. /** Trilinear is mag = linear and min = linear and mip = linear */
  32403. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32404. /** mag = nearest and min = nearest and mip = nearest */
  32405. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32406. /** mag = nearest and min = linear and mip = nearest */
  32407. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32408. /** mag = nearest and min = linear and mip = linear */
  32409. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32410. /** mag = nearest and min = linear and mip = none */
  32411. static readonly TEXTURE_NEAREST_LINEAR: number;
  32412. /** mag = nearest and min = nearest and mip = none */
  32413. static readonly TEXTURE_NEAREST_NEAREST: number;
  32414. /** mag = linear and min = nearest and mip = nearest */
  32415. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32416. /** mag = linear and min = nearest and mip = linear */
  32417. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32418. /** mag = linear and min = linear and mip = none */
  32419. static readonly TEXTURE_LINEAR_LINEAR: number;
  32420. /** mag = linear and min = nearest and mip = none */
  32421. static readonly TEXTURE_LINEAR_NEAREST: number;
  32422. /** Explicit coordinates mode */
  32423. static readonly TEXTURE_EXPLICIT_MODE: number;
  32424. /** Spherical coordinates mode */
  32425. static readonly TEXTURE_SPHERICAL_MODE: number;
  32426. /** Planar coordinates mode */
  32427. static readonly TEXTURE_PLANAR_MODE: number;
  32428. /** Cubic coordinates mode */
  32429. static readonly TEXTURE_CUBIC_MODE: number;
  32430. /** Projection coordinates mode */
  32431. static readonly TEXTURE_PROJECTION_MODE: number;
  32432. /** Skybox coordinates mode */
  32433. static readonly TEXTURE_SKYBOX_MODE: number;
  32434. /** Inverse Cubic coordinates mode */
  32435. static readonly TEXTURE_INVCUBIC_MODE: number;
  32436. /** Equirectangular coordinates mode */
  32437. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32438. /** Equirectangular Fixed coordinates mode */
  32439. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32440. /** Equirectangular Fixed Mirrored coordinates mode */
  32441. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32442. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32443. static readonly SCALEMODE_FLOOR: number;
  32444. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32445. static readonly SCALEMODE_NEAREST: number;
  32446. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32447. static readonly SCALEMODE_CEILING: number;
  32448. /**
  32449. * Returns the current npm package of the sdk
  32450. */
  32451. static readonly NpmPackage: string;
  32452. /**
  32453. * Returns the current version of the framework
  32454. */
  32455. static readonly Version: string;
  32456. /** Gets the list of created engines */
  32457. static readonly Instances: Engine[];
  32458. /**
  32459. * Gets the latest created engine
  32460. */
  32461. static readonly LastCreatedEngine: Nullable<Engine>;
  32462. /**
  32463. * Gets the latest created scene
  32464. */
  32465. static readonly LastCreatedScene: Nullable<Scene>;
  32466. /**
  32467. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32468. * @param flag defines which part of the materials must be marked as dirty
  32469. * @param predicate defines a predicate used to filter which materials should be affected
  32470. */
  32471. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32472. /**
  32473. * Method called to create the default loading screen.
  32474. * This can be overriden in your own app.
  32475. * @param canvas The rendering canvas element
  32476. * @returns The loading screen
  32477. */
  32478. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32479. /**
  32480. * Method called to create the default rescale post process on each engine.
  32481. */
  32482. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32483. /**
  32484. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32485. **/
  32486. enableOfflineSupport: boolean;
  32487. /**
  32488. * 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)
  32489. **/
  32490. disableManifestCheck: boolean;
  32491. /**
  32492. * Gets the list of created scenes
  32493. */
  32494. scenes: Scene[];
  32495. /**
  32496. * Event raised when a new scene is created
  32497. */
  32498. onNewSceneAddedObservable: Observable<Scene>;
  32499. /**
  32500. * Gets the list of created postprocesses
  32501. */
  32502. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32503. /**
  32504. * Gets a boolean indicating if the pointer is currently locked
  32505. */
  32506. isPointerLock: boolean;
  32507. /**
  32508. * Observable event triggered each time the rendering canvas is resized
  32509. */
  32510. onResizeObservable: Observable<Engine>;
  32511. /**
  32512. * Observable event triggered each time the canvas loses focus
  32513. */
  32514. onCanvasBlurObservable: Observable<Engine>;
  32515. /**
  32516. * Observable event triggered each time the canvas gains focus
  32517. */
  32518. onCanvasFocusObservable: Observable<Engine>;
  32519. /**
  32520. * Observable event triggered each time the canvas receives pointerout event
  32521. */
  32522. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32523. /**
  32524. * Observable raised when the engine begins a new frame
  32525. */
  32526. onBeginFrameObservable: Observable<Engine>;
  32527. /**
  32528. * If set, will be used to request the next animation frame for the render loop
  32529. */
  32530. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32531. /**
  32532. * Observable raised when the engine ends the current frame
  32533. */
  32534. onEndFrameObservable: Observable<Engine>;
  32535. /**
  32536. * Observable raised when the engine is about to compile a shader
  32537. */
  32538. onBeforeShaderCompilationObservable: Observable<Engine>;
  32539. /**
  32540. * Observable raised when the engine has jsut compiled a shader
  32541. */
  32542. onAfterShaderCompilationObservable: Observable<Engine>;
  32543. /**
  32544. * Gets the audio engine
  32545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32546. * @ignorenaming
  32547. */
  32548. static audioEngine: IAudioEngine;
  32549. /**
  32550. * Default AudioEngine factory responsible of creating the Audio Engine.
  32551. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32552. */
  32553. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32554. /**
  32555. * Default offline support factory responsible of creating a tool used to store data locally.
  32556. * By default, this will create a Database object if the workload has been embedded.
  32557. */
  32558. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32559. private _loadingScreen;
  32560. private _pointerLockRequested;
  32561. private _dummyFramebuffer;
  32562. private _rescalePostProcess;
  32563. /** @hidden */
  32564. protected _alphaMode: number;
  32565. /** @hidden */
  32566. protected _alphaEquation: number;
  32567. private _deterministicLockstep;
  32568. private _lockstepMaxSteps;
  32569. protected readonly _supportsHardwareTextureRescaling: boolean;
  32570. private _fps;
  32571. private _deltaTime;
  32572. /** @hidden */
  32573. _drawCalls: PerfCounter;
  32574. /**
  32575. * Turn this value on if you want to pause FPS computation when in background
  32576. */
  32577. disablePerformanceMonitorInBackground: boolean;
  32578. private _performanceMonitor;
  32579. /**
  32580. * Gets the performance monitor attached to this engine
  32581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32582. */
  32583. readonly performanceMonitor: PerformanceMonitor;
  32584. private _onFocus;
  32585. private _onBlur;
  32586. private _onCanvasPointerOut;
  32587. private _onCanvasBlur;
  32588. private _onCanvasFocus;
  32589. private _onFullscreenChange;
  32590. private _onPointerLockChange;
  32591. /**
  32592. * Gets the HTML element used to attach event listeners
  32593. * @returns a HTML element
  32594. */
  32595. getInputElement(): Nullable<HTMLElement>;
  32596. /**
  32597. * Creates a new engine
  32598. * @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
  32599. * @param antialias defines enable antialiasing (default: false)
  32600. * @param options defines further options to be sent to the getContext() function
  32601. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32602. */
  32603. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32604. /**
  32605. * Gets current aspect ratio
  32606. * @param viewportOwner defines the camera to use to get the aspect ratio
  32607. * @param useScreen defines if screen size must be used (or the current render target if any)
  32608. * @returns a number defining the aspect ratio
  32609. */
  32610. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32611. /**
  32612. * Gets current screen aspect ratio
  32613. * @returns a number defining the aspect ratio
  32614. */
  32615. getScreenAspectRatio(): number;
  32616. /**
  32617. * Gets host document
  32618. * @returns the host document object
  32619. */
  32620. getHostDocument(): Document;
  32621. /**
  32622. * Gets the client rect of the HTML canvas attached with the current webGL context
  32623. * @returns a client rectanglee
  32624. */
  32625. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32626. /**
  32627. * Gets the client rect of the HTML element used for events
  32628. * @returns a client rectanglee
  32629. */
  32630. getInputElementClientRect(): Nullable<ClientRect>;
  32631. /**
  32632. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32634. * @returns true if engine is in deterministic lock step mode
  32635. */
  32636. isDeterministicLockStep(): boolean;
  32637. /**
  32638. * Gets the max steps when engine is running in deterministic lock step
  32639. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32640. * @returns the max steps
  32641. */
  32642. getLockstepMaxSteps(): number;
  32643. /**
  32644. * Force the mipmap generation for the given render target texture
  32645. * @param texture defines the render target texture to use
  32646. */
  32647. generateMipMapsForCubemap(texture: InternalTexture): void;
  32648. /** States */
  32649. /**
  32650. * Set various states to the webGL context
  32651. * @param culling defines backface culling state
  32652. * @param zOffset defines the value to apply to zOffset (0 by default)
  32653. * @param force defines if states must be applied even if cache is up to date
  32654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32655. */
  32656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32657. /**
  32658. * Set the z offset to apply to current rendering
  32659. * @param value defines the offset to apply
  32660. */
  32661. setZOffset(value: number): void;
  32662. /**
  32663. * Gets the current value of the zOffset
  32664. * @returns the current zOffset state
  32665. */
  32666. getZOffset(): number;
  32667. /**
  32668. * Enable or disable depth buffering
  32669. * @param enable defines the state to set
  32670. */
  32671. setDepthBuffer(enable: boolean): void;
  32672. /**
  32673. * Gets a boolean indicating if depth writing is enabled
  32674. * @returns the current depth writing state
  32675. */
  32676. getDepthWrite(): boolean;
  32677. /**
  32678. * Enable or disable depth writing
  32679. * @param enable defines the state to set
  32680. */
  32681. setDepthWrite(enable: boolean): void;
  32682. /**
  32683. * Enable or disable color writing
  32684. * @param enable defines the state to set
  32685. */
  32686. setColorWrite(enable: boolean): void;
  32687. /**
  32688. * Gets a boolean indicating if color writing is enabled
  32689. * @returns the current color writing state
  32690. */
  32691. getColorWrite(): boolean;
  32692. /**
  32693. * Sets alpha constants used by some alpha blending modes
  32694. * @param r defines the red component
  32695. * @param g defines the green component
  32696. * @param b defines the blue component
  32697. * @param a defines the alpha component
  32698. */
  32699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32700. /**
  32701. * Sets the current alpha mode
  32702. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32705. */
  32706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32707. /**
  32708. * Gets the current alpha mode
  32709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32710. * @returns the current alpha mode
  32711. */
  32712. getAlphaMode(): number;
  32713. /**
  32714. * Sets the current alpha equation
  32715. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32716. */
  32717. setAlphaEquation(equation: number): void;
  32718. /**
  32719. * Gets the current alpha equation.
  32720. * @returns the current alpha equation
  32721. */
  32722. getAlphaEquation(): number;
  32723. /**
  32724. * Gets a boolean indicating if stencil buffer is enabled
  32725. * @returns the current stencil buffer state
  32726. */
  32727. getStencilBuffer(): boolean;
  32728. /**
  32729. * Enable or disable the stencil buffer
  32730. * @param enable defines if the stencil buffer must be enabled or disabled
  32731. */
  32732. setStencilBuffer(enable: boolean): void;
  32733. /**
  32734. * Gets the current stencil mask
  32735. * @returns a number defining the new stencil mask to use
  32736. */
  32737. getStencilMask(): number;
  32738. /**
  32739. * Sets the current stencil mask
  32740. * @param mask defines the new stencil mask to use
  32741. */
  32742. setStencilMask(mask: number): void;
  32743. /**
  32744. * Gets the current stencil function
  32745. * @returns a number defining the stencil function to use
  32746. */
  32747. getStencilFunction(): number;
  32748. /**
  32749. * Gets the current stencil reference value
  32750. * @returns a number defining the stencil reference value to use
  32751. */
  32752. getStencilFunctionReference(): number;
  32753. /**
  32754. * Gets the current stencil mask
  32755. * @returns a number defining the stencil mask to use
  32756. */
  32757. getStencilFunctionMask(): number;
  32758. /**
  32759. * Sets the current stencil function
  32760. * @param stencilFunc defines the new stencil function to use
  32761. */
  32762. setStencilFunction(stencilFunc: number): void;
  32763. /**
  32764. * Sets the current stencil reference
  32765. * @param reference defines the new stencil reference to use
  32766. */
  32767. setStencilFunctionReference(reference: number): void;
  32768. /**
  32769. * Sets the current stencil mask
  32770. * @param mask defines the new stencil mask to use
  32771. */
  32772. setStencilFunctionMask(mask: number): void;
  32773. /**
  32774. * Gets the current stencil operation when stencil fails
  32775. * @returns a number defining stencil operation to use when stencil fails
  32776. */
  32777. getStencilOperationFail(): number;
  32778. /**
  32779. * Gets the current stencil operation when depth fails
  32780. * @returns a number defining stencil operation to use when depth fails
  32781. */
  32782. getStencilOperationDepthFail(): number;
  32783. /**
  32784. * Gets the current stencil operation when stencil passes
  32785. * @returns a number defining stencil operation to use when stencil passes
  32786. */
  32787. getStencilOperationPass(): number;
  32788. /**
  32789. * Sets the stencil operation to use when stencil fails
  32790. * @param operation defines the stencil operation to use when stencil fails
  32791. */
  32792. setStencilOperationFail(operation: number): void;
  32793. /**
  32794. * Sets the stencil operation to use when depth fails
  32795. * @param operation defines the stencil operation to use when depth fails
  32796. */
  32797. setStencilOperationDepthFail(operation: number): void;
  32798. /**
  32799. * Sets the stencil operation to use when stencil passes
  32800. * @param operation defines the stencil operation to use when stencil passes
  32801. */
  32802. setStencilOperationPass(operation: number): void;
  32803. /**
  32804. * Sets a boolean indicating if the dithering state is enabled or disabled
  32805. * @param value defines the dithering state
  32806. */
  32807. setDitheringState(value: boolean): void;
  32808. /**
  32809. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32810. * @param value defines the rasterizer state
  32811. */
  32812. setRasterizerState(value: boolean): void;
  32813. /**
  32814. * Gets the current depth function
  32815. * @returns a number defining the depth function
  32816. */
  32817. getDepthFunction(): Nullable<number>;
  32818. /**
  32819. * Sets the current depth function
  32820. * @param depthFunc defines the function to use
  32821. */
  32822. setDepthFunction(depthFunc: number): void;
  32823. /**
  32824. * Sets the current depth function to GREATER
  32825. */
  32826. setDepthFunctionToGreater(): void;
  32827. /**
  32828. * Sets the current depth function to GEQUAL
  32829. */
  32830. setDepthFunctionToGreaterOrEqual(): void;
  32831. /**
  32832. * Sets the current depth function to LESS
  32833. */
  32834. setDepthFunctionToLess(): void;
  32835. /**
  32836. * Sets the current depth function to LEQUAL
  32837. */
  32838. setDepthFunctionToLessOrEqual(): void;
  32839. private _cachedStencilBuffer;
  32840. private _cachedStencilFunction;
  32841. private _cachedStencilMask;
  32842. private _cachedStencilOperationPass;
  32843. private _cachedStencilOperationFail;
  32844. private _cachedStencilOperationDepthFail;
  32845. private _cachedStencilReference;
  32846. /**
  32847. * Caches the the state of the stencil buffer
  32848. */
  32849. cacheStencilState(): void;
  32850. /**
  32851. * Restores the state of the stencil buffer
  32852. */
  32853. restoreStencilState(): void;
  32854. /**
  32855. * Directly set the WebGL Viewport
  32856. * @param x defines the x coordinate of the viewport (in screen space)
  32857. * @param y defines the y coordinate of the viewport (in screen space)
  32858. * @param width defines the width of the viewport (in screen space)
  32859. * @param height defines the height of the viewport (in screen space)
  32860. * @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
  32861. */
  32862. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32863. /**
  32864. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32865. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32866. * @param y defines the y-coordinate of the corner of the clear rectangle
  32867. * @param width defines the width of the clear rectangle
  32868. * @param height defines the height of the clear rectangle
  32869. * @param clearColor defines the clear color
  32870. */
  32871. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32872. /**
  32873. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32874. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32875. * @param y defines the y-coordinate of the corner of the clear rectangle
  32876. * @param width defines the width of the clear rectangle
  32877. * @param height defines the height of the clear rectangle
  32878. */
  32879. enableScissor(x: number, y: number, width: number, height: number): void;
  32880. /**
  32881. * Disable previously set scissor test rectangle
  32882. */
  32883. disableScissor(): void;
  32884. protected _reportDrawCall(): void;
  32885. /**
  32886. * Initializes a webVR display and starts listening to display change events
  32887. * The onVRDisplayChangedObservable will be notified upon these changes
  32888. * @returns The onVRDisplayChangedObservable
  32889. */
  32890. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32891. /** @hidden */
  32892. _prepareVRComponent(): void;
  32893. /** @hidden */
  32894. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32895. /** @hidden */
  32896. _submitVRFrame(): void;
  32897. /**
  32898. * Call this function to leave webVR mode
  32899. * Will do nothing if webVR is not supported or if there is no webVR device
  32900. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32901. */
  32902. disableVR(): void;
  32903. /**
  32904. * Gets a boolean indicating that the system is in VR mode and is presenting
  32905. * @returns true if VR mode is engaged
  32906. */
  32907. isVRPresenting(): boolean;
  32908. /** @hidden */
  32909. _requestVRFrame(): void;
  32910. /** @hidden */
  32911. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32912. /**
  32913. * Gets the source code of the vertex shader associated with a specific webGL program
  32914. * @param program defines the program to use
  32915. * @returns a string containing the source code of the vertex shader associated with the program
  32916. */
  32917. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32918. /**
  32919. * Gets the source code of the fragment shader associated with a specific webGL program
  32920. * @param program defines the program to use
  32921. * @returns a string containing the source code of the fragment shader associated with the program
  32922. */
  32923. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32924. /**
  32925. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32926. * @param x defines the x coordinate of the rectangle where pixels must be read
  32927. * @param y defines the y coordinate of the rectangle where pixels must be read
  32928. * @param width defines the width of the rectangle where pixels must be read
  32929. * @param height defines the height of the rectangle where pixels must be read
  32930. * @returns a Uint8Array containing RGBA colors
  32931. */
  32932. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32933. /**
  32934. * Sets a depth stencil texture from a render target to the according uniform.
  32935. * @param channel The texture channel
  32936. * @param uniform The uniform to set
  32937. * @param texture The render target texture containing the depth stencil texture to apply
  32938. */
  32939. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32940. /**
  32941. * Sets a texture to the webGL context from a postprocess
  32942. * @param channel defines the channel to use
  32943. * @param postProcess defines the source postprocess
  32944. */
  32945. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32946. /**
  32947. * Binds the output of the passed in post process to the texture channel specified
  32948. * @param channel The channel the texture should be bound to
  32949. * @param postProcess The post process which's output should be bound
  32950. */
  32951. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32952. /** @hidden */
  32953. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32954. protected _rebuildBuffers(): void;
  32955. /** @hidden */
  32956. _renderFrame(): void;
  32957. _renderLoop(): void;
  32958. /** @hidden */
  32959. _renderViews(): boolean;
  32960. /**
  32961. * Toggle full screen mode
  32962. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32963. */
  32964. switchFullscreen(requestPointerLock: boolean): void;
  32965. /**
  32966. * Enters full screen mode
  32967. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32968. */
  32969. enterFullscreen(requestPointerLock: boolean): void;
  32970. /**
  32971. * Exits full screen mode
  32972. */
  32973. exitFullscreen(): void;
  32974. /**
  32975. * Enters Pointerlock mode
  32976. */
  32977. enterPointerlock(): void;
  32978. /**
  32979. * Exits Pointerlock mode
  32980. */
  32981. exitPointerlock(): void;
  32982. /**
  32983. * Begin a new frame
  32984. */
  32985. beginFrame(): void;
  32986. /**
  32987. * Enf the current frame
  32988. */
  32989. endFrame(): void;
  32990. resize(): void;
  32991. /**
  32992. * Set the compressed texture format to use, based on the formats you have, and the formats
  32993. * supported by the hardware / browser.
  32994. *
  32995. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32996. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32997. * to API arguments needed to compressed textures. This puts the burden on the container
  32998. * generator to house the arcane code for determining these for current & future formats.
  32999. *
  33000. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33001. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33002. *
  33003. * Note: The result of this call is not taken into account when a texture is base64.
  33004. *
  33005. * @param formatsAvailable defines the list of those format families you have created
  33006. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33007. *
  33008. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33009. * @returns The extension selected.
  33010. */
  33011. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33012. /**
  33013. * Force a specific size of the canvas
  33014. * @param width defines the new canvas' width
  33015. * @param height defines the new canvas' height
  33016. */
  33017. setSize(width: number, height: number): void;
  33018. /**
  33019. * Updates a dynamic vertex buffer.
  33020. * @param vertexBuffer the vertex buffer to update
  33021. * @param data the data used to update the vertex buffer
  33022. * @param byteOffset the byte offset of the data
  33023. * @param byteLength the byte length of the data
  33024. */
  33025. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33026. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33027. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33028. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33029. _releaseTexture(texture: InternalTexture): void;
  33030. /**
  33031. * @hidden
  33032. * Rescales a texture
  33033. * @param source input texutre
  33034. * @param destination destination texture
  33035. * @param scene scene to use to render the resize
  33036. * @param internalFormat format to use when resizing
  33037. * @param onComplete callback to be called when resize has completed
  33038. */
  33039. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33040. /**
  33041. * Gets the current framerate
  33042. * @returns a number representing the framerate
  33043. */
  33044. getFps(): number;
  33045. /**
  33046. * Gets the time spent between current and previous frame
  33047. * @returns a number representing the delta time in ms
  33048. */
  33049. getDeltaTime(): number;
  33050. private _measureFps;
  33051. /** @hidden */
  33052. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33053. /**
  33054. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33055. * @param renderTarget The render target to set the frame buffer for
  33056. */
  33057. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33058. /**
  33059. * Update a dynamic index buffer
  33060. * @param indexBuffer defines the target index buffer
  33061. * @param indices defines the data to update
  33062. * @param offset defines the offset in the target index buffer where update should start
  33063. */
  33064. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33065. /**
  33066. * Updates the sample count of a render target texture
  33067. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33068. * @param texture defines the texture to update
  33069. * @param samples defines the sample count to set
  33070. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33071. */
  33072. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33073. /**
  33074. * Updates a depth texture Comparison Mode and Function.
  33075. * If the comparison Function is equal to 0, the mode will be set to none.
  33076. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33077. * @param texture The texture to set the comparison function for
  33078. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33079. */
  33080. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33081. /**
  33082. * Creates a webGL buffer to use with instanciation
  33083. * @param capacity defines the size of the buffer
  33084. * @returns the webGL buffer
  33085. */
  33086. createInstancesBuffer(capacity: number): DataBuffer;
  33087. /**
  33088. * Delete a webGL buffer used with instanciation
  33089. * @param buffer defines the webGL buffer to delete
  33090. */
  33091. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33092. /** @hidden */
  33093. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33094. dispose(): void;
  33095. private _disableTouchAction;
  33096. /**
  33097. * Display the loading screen
  33098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33099. */
  33100. displayLoadingUI(): void;
  33101. /**
  33102. * Hide the loading screen
  33103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33104. */
  33105. hideLoadingUI(): void;
  33106. /**
  33107. * Gets the current loading screen object
  33108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33109. */
  33110. /**
  33111. * Sets the current loading screen object
  33112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33113. */
  33114. loadingScreen: ILoadingScreen;
  33115. /**
  33116. * Sets the current loading screen text
  33117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33118. */
  33119. loadingUIText: string;
  33120. /**
  33121. * Sets the current loading screen background color
  33122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33123. */
  33124. loadingUIBackgroundColor: string;
  33125. /** Pointerlock and fullscreen */
  33126. /**
  33127. * Ask the browser to promote the current element to pointerlock mode
  33128. * @param element defines the DOM element to promote
  33129. */
  33130. static _RequestPointerlock(element: HTMLElement): void;
  33131. /**
  33132. * Asks the browser to exit pointerlock mode
  33133. */
  33134. static _ExitPointerlock(): void;
  33135. /**
  33136. * Ask the browser to promote the current element to fullscreen rendering mode
  33137. * @param element defines the DOM element to promote
  33138. */
  33139. static _RequestFullscreen(element: HTMLElement): void;
  33140. /**
  33141. * Asks the browser to exit fullscreen mode
  33142. */
  33143. static _ExitFullscreen(): void;
  33144. }
  33145. }
  33146. declare module "babylonjs/Engines/engineStore" {
  33147. import { Nullable } from "babylonjs/types";
  33148. import { Engine } from "babylonjs/Engines/engine";
  33149. import { Scene } from "babylonjs/scene";
  33150. /**
  33151. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33152. * during the life time of the application.
  33153. */
  33154. export class EngineStore {
  33155. /** Gets the list of created engines */
  33156. static Instances: import("babylonjs/Engines/engine").Engine[];
  33157. /** @hidden */
  33158. static _LastCreatedScene: Nullable<Scene>;
  33159. /**
  33160. * Gets the latest created engine
  33161. */
  33162. static readonly LastCreatedEngine: Nullable<Engine>;
  33163. /**
  33164. * Gets the latest created scene
  33165. */
  33166. static readonly LastCreatedScene: Nullable<Scene>;
  33167. /**
  33168. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33169. * @ignorenaming
  33170. */
  33171. static UseFallbackTexture: boolean;
  33172. /**
  33173. * Texture content used if a texture cannot loaded
  33174. * @ignorenaming
  33175. */
  33176. static FallbackTexture: string;
  33177. }
  33178. }
  33179. declare module "babylonjs/Misc/promise" {
  33180. /**
  33181. * Helper class that provides a small promise polyfill
  33182. */
  33183. export class PromisePolyfill {
  33184. /**
  33185. * Static function used to check if the polyfill is required
  33186. * If this is the case then the function will inject the polyfill to window.Promise
  33187. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33188. */
  33189. static Apply(force?: boolean): void;
  33190. }
  33191. }
  33192. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33193. /**
  33194. * Interface for screenshot methods with describe argument called `size` as object with options
  33195. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33196. */
  33197. export interface IScreenshotSize {
  33198. /**
  33199. * number in pixels for canvas height
  33200. */
  33201. height?: number;
  33202. /**
  33203. * multiplier allowing render at a higher or lower resolution
  33204. * If value is defined then height and width will be ignored and taken from camera
  33205. */
  33206. precision?: number;
  33207. /**
  33208. * number in pixels for canvas width
  33209. */
  33210. width?: number;
  33211. }
  33212. }
  33213. declare module "babylonjs/Misc/tools" {
  33214. import { Nullable, float } from "babylonjs/types";
  33215. import { DomManagement } from "babylonjs/Misc/domManagement";
  33216. import { WebRequest } from "babylonjs/Misc/webRequest";
  33217. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33218. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33219. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33220. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33221. import { Camera } from "babylonjs/Cameras/camera";
  33222. import { Engine } from "babylonjs/Engines/engine";
  33223. interface IColor4Like {
  33224. r: float;
  33225. g: float;
  33226. b: float;
  33227. a: float;
  33228. }
  33229. /**
  33230. * Class containing a set of static utilities functions
  33231. */
  33232. export class Tools {
  33233. /**
  33234. * Gets or sets the base URL to use to load assets
  33235. */
  33236. static BaseUrl: string;
  33237. /**
  33238. * Enable/Disable Custom HTTP Request Headers globally.
  33239. * default = false
  33240. * @see CustomRequestHeaders
  33241. */
  33242. static UseCustomRequestHeaders: boolean;
  33243. /**
  33244. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33245. * i.e. when loading files, where the server/service expects an Authorization header
  33246. */
  33247. static CustomRequestHeaders: {
  33248. [key: string]: string;
  33249. };
  33250. /**
  33251. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33252. */
  33253. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33254. /**
  33255. * Default behaviour for cors in the application.
  33256. * It can be a string if the expected behavior is identical in the entire app.
  33257. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33258. */
  33259. static CorsBehavior: string | ((url: string | string[]) => string);
  33260. /**
  33261. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33262. * @ignorenaming
  33263. */
  33264. static UseFallbackTexture: boolean;
  33265. /**
  33266. * Use this object to register external classes like custom textures or material
  33267. * to allow the laoders to instantiate them
  33268. */
  33269. static RegisteredExternalClasses: {
  33270. [key: string]: Object;
  33271. };
  33272. /**
  33273. * Texture content used if a texture cannot loaded
  33274. * @ignorenaming
  33275. */
  33276. static fallbackTexture: string;
  33277. /**
  33278. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33279. * @param u defines the coordinate on X axis
  33280. * @param v defines the coordinate on Y axis
  33281. * @param width defines the width of the source data
  33282. * @param height defines the height of the source data
  33283. * @param pixels defines the source byte array
  33284. * @param color defines the output color
  33285. */
  33286. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33287. /**
  33288. * Interpolates between a and b via alpha
  33289. * @param a The lower value (returned when alpha = 0)
  33290. * @param b The upper value (returned when alpha = 1)
  33291. * @param alpha The interpolation-factor
  33292. * @return The mixed value
  33293. */
  33294. static Mix(a: number, b: number, alpha: number): number;
  33295. /**
  33296. * Tries to instantiate a new object from a given class name
  33297. * @param className defines the class name to instantiate
  33298. * @returns the new object or null if the system was not able to do the instantiation
  33299. */
  33300. static Instantiate(className: string): any;
  33301. /**
  33302. * Provides a slice function that will work even on IE
  33303. * @param data defines the array to slice
  33304. * @param start defines the start of the data (optional)
  33305. * @param end defines the end of the data (optional)
  33306. * @returns the new sliced array
  33307. */
  33308. static Slice<T>(data: T, start?: number, end?: number): T;
  33309. /**
  33310. * Polyfill for setImmediate
  33311. * @param action defines the action to execute after the current execution block
  33312. */
  33313. static SetImmediate(action: () => void): void;
  33314. /**
  33315. * Function indicating if a number is an exponent of 2
  33316. * @param value defines the value to test
  33317. * @returns true if the value is an exponent of 2
  33318. */
  33319. static IsExponentOfTwo(value: number): boolean;
  33320. private static _tmpFloatArray;
  33321. /**
  33322. * Returns the nearest 32-bit single precision float representation of a Number
  33323. * @param value A Number. If the parameter is of a different type, it will get converted
  33324. * to a number or to NaN if it cannot be converted
  33325. * @returns number
  33326. */
  33327. static FloatRound(value: number): number;
  33328. /**
  33329. * Extracts the filename from a path
  33330. * @param path defines the path to use
  33331. * @returns the filename
  33332. */
  33333. static GetFilename(path: string): string;
  33334. /**
  33335. * Extracts the "folder" part of a path (everything before the filename).
  33336. * @param uri The URI to extract the info from
  33337. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33338. * @returns The "folder" part of the path
  33339. */
  33340. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33341. /**
  33342. * Extracts text content from a DOM element hierarchy
  33343. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33344. */
  33345. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33346. /**
  33347. * Convert an angle in radians to degrees
  33348. * @param angle defines the angle to convert
  33349. * @returns the angle in degrees
  33350. */
  33351. static ToDegrees(angle: number): number;
  33352. /**
  33353. * Convert an angle in degrees to radians
  33354. * @param angle defines the angle to convert
  33355. * @returns the angle in radians
  33356. */
  33357. static ToRadians(angle: number): number;
  33358. /**
  33359. * Returns an array if obj is not an array
  33360. * @param obj defines the object to evaluate as an array
  33361. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33362. * @returns either obj directly if obj is an array or a new array containing obj
  33363. */
  33364. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33365. /**
  33366. * Gets the pointer prefix to use
  33367. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33368. */
  33369. static GetPointerPrefix(): string;
  33370. /**
  33371. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33372. * @param url define the url we are trying
  33373. * @param element define the dom element where to configure the cors policy
  33374. */
  33375. static SetCorsBehavior(url: string | string[], element: {
  33376. crossOrigin: string | null;
  33377. }): void;
  33378. /**
  33379. * Removes unwanted characters from an url
  33380. * @param url defines the url to clean
  33381. * @returns the cleaned url
  33382. */
  33383. static CleanUrl(url: string): string;
  33384. /**
  33385. * Gets or sets a function used to pre-process url before using them to load assets
  33386. */
  33387. static PreprocessUrl: (url: string) => string;
  33388. /**
  33389. * Loads an image as an HTMLImageElement.
  33390. * @param input url string, ArrayBuffer, or Blob to load
  33391. * @param onLoad callback called when the image successfully loads
  33392. * @param onError callback called when the image fails to load
  33393. * @param offlineProvider offline provider for caching
  33394. * @param mimeType optional mime type
  33395. * @returns the HTMLImageElement of the loaded image
  33396. */
  33397. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33398. /**
  33399. * Loads a file from a url
  33400. * @param url url string, ArrayBuffer, or Blob to load
  33401. * @param onSuccess callback called when the file successfully loads
  33402. * @param onProgress callback called while file is loading (if the server supports this mode)
  33403. * @param offlineProvider defines the offline provider for caching
  33404. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33405. * @param onError callback called when the file fails to load
  33406. * @returns a file request object
  33407. */
  33408. 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;
  33409. /**
  33410. * Loads a file from a url
  33411. * @param url the file url to load
  33412. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33413. */
  33414. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33415. /**
  33416. * Load a script (identified by an url). When the url returns, the
  33417. * content of this file is added into a new script element, attached to the DOM (body element)
  33418. * @param scriptUrl defines the url of the script to laod
  33419. * @param onSuccess defines the callback called when the script is loaded
  33420. * @param onError defines the callback to call if an error occurs
  33421. * @param scriptId defines the id of the script element
  33422. */
  33423. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33424. /**
  33425. * Load an asynchronous script (identified by an url). When the url returns, the
  33426. * content of this file is added into a new script element, attached to the DOM (body element)
  33427. * @param scriptUrl defines the url of the script to laod
  33428. * @param scriptId defines the id of the script element
  33429. * @returns a promise request object
  33430. */
  33431. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33432. /**
  33433. * Loads a file from a blob
  33434. * @param fileToLoad defines the blob to use
  33435. * @param callback defines the callback to call when data is loaded
  33436. * @param progressCallback defines the callback to call during loading process
  33437. * @returns a file request object
  33438. */
  33439. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33440. /**
  33441. * Reads a file from a File object
  33442. * @param file defines the file to load
  33443. * @param onSuccess defines the callback to call when data is loaded
  33444. * @param onProgress defines the callback to call during loading process
  33445. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33446. * @param onError defines the callback to call when an error occurs
  33447. * @returns a file request object
  33448. */
  33449. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33450. /**
  33451. * Creates a data url from a given string content
  33452. * @param content defines the content to convert
  33453. * @returns the new data url link
  33454. */
  33455. static FileAsURL(content: string): string;
  33456. /**
  33457. * Format the given number to a specific decimal format
  33458. * @param value defines the number to format
  33459. * @param decimals defines the number of decimals to use
  33460. * @returns the formatted string
  33461. */
  33462. static Format(value: number, decimals?: number): string;
  33463. /**
  33464. * Tries to copy an object by duplicating every property
  33465. * @param source defines the source object
  33466. * @param destination defines the target object
  33467. * @param doNotCopyList defines a list of properties to avoid
  33468. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33469. */
  33470. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33471. /**
  33472. * Gets a boolean indicating if the given object has no own property
  33473. * @param obj defines the object to test
  33474. * @returns true if object has no own property
  33475. */
  33476. static IsEmpty(obj: any): boolean;
  33477. /**
  33478. * Function used to register events at window level
  33479. * @param windowElement defines the Window object to use
  33480. * @param events defines the events to register
  33481. */
  33482. static RegisterTopRootEvents(windowElement: Window, events: {
  33483. name: string;
  33484. handler: Nullable<(e: FocusEvent) => any>;
  33485. }[]): void;
  33486. /**
  33487. * Function used to unregister events from window level
  33488. * @param windowElement defines the Window object to use
  33489. * @param events defines the events to unregister
  33490. */
  33491. static UnregisterTopRootEvents(windowElement: Window, events: {
  33492. name: string;
  33493. handler: Nullable<(e: FocusEvent) => any>;
  33494. }[]): void;
  33495. /**
  33496. * @ignore
  33497. */
  33498. static _ScreenshotCanvas: HTMLCanvasElement;
  33499. /**
  33500. * Dumps the current bound framebuffer
  33501. * @param width defines the rendering width
  33502. * @param height defines the rendering height
  33503. * @param engine defines the hosting engine
  33504. * @param successCallback defines the callback triggered once the data are available
  33505. * @param mimeType defines the mime type of the result
  33506. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33507. */
  33508. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33509. /**
  33510. * Converts the canvas data to blob.
  33511. * This acts as a polyfill for browsers not supporting the to blob function.
  33512. * @param canvas Defines the canvas to extract the data from
  33513. * @param successCallback Defines the callback triggered once the data are available
  33514. * @param mimeType Defines the mime type of the result
  33515. */
  33516. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33517. /**
  33518. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33519. * @param successCallback defines the callback triggered once the data are available
  33520. * @param mimeType defines the mime type of the result
  33521. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33522. */
  33523. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33524. /**
  33525. * Downloads a blob in the browser
  33526. * @param blob defines the blob to download
  33527. * @param fileName defines the name of the downloaded file
  33528. */
  33529. static Download(blob: Blob, fileName: string): void;
  33530. /**
  33531. * Captures a screenshot of the current rendering
  33532. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33533. * @param engine defines the rendering engine
  33534. * @param camera defines the source camera
  33535. * @param size This parameter can be set to a single number or to an object with the
  33536. * following (optional) properties: precision, width, height. If a single number is passed,
  33537. * it will be used for both width and height. If an object is passed, the screenshot size
  33538. * will be derived from the parameters. The precision property is a multiplier allowing
  33539. * rendering at a higher or lower resolution
  33540. * @param successCallback defines the callback receives a single parameter which contains the
  33541. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33542. * src parameter of an <img> to display it
  33543. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33544. * Check your browser for supported MIME types
  33545. */
  33546. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33547. /**
  33548. * Captures a screenshot of the current rendering
  33549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33550. * @param engine defines the rendering engine
  33551. * @param camera defines the source camera
  33552. * @param size This parameter can be set to a single number or to an object with the
  33553. * following (optional) properties: precision, width, height. If a single number is passed,
  33554. * it will be used for both width and height. If an object is passed, the screenshot size
  33555. * will be derived from the parameters. The precision property is a multiplier allowing
  33556. * rendering at a higher or lower resolution
  33557. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33558. * Check your browser for supported MIME types
  33559. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33560. * to the src parameter of an <img> to display it
  33561. */
  33562. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33563. /**
  33564. * Generates an image screenshot from the specified camera.
  33565. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33566. * @param engine The engine to use for rendering
  33567. * @param camera The camera to use for rendering
  33568. * @param size This parameter can be set to a single number or to an object with the
  33569. * following (optional) properties: precision, width, height. If a single number is passed,
  33570. * it will be used for both width and height. If an object is passed, the screenshot size
  33571. * will be derived from the parameters. The precision property is a multiplier allowing
  33572. * rendering at a higher or lower resolution
  33573. * @param successCallback The callback receives a single parameter which contains the
  33574. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33575. * src parameter of an <img> to display it
  33576. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33577. * Check your browser for supported MIME types
  33578. * @param samples Texture samples (default: 1)
  33579. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33580. * @param fileName A name for for the downloaded file.
  33581. */
  33582. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33583. /**
  33584. * Generates an image screenshot from the specified camera.
  33585. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33586. * @param engine The engine to use for rendering
  33587. * @param camera The camera to use for rendering
  33588. * @param size This parameter can be set to a single number or to an object with the
  33589. * following (optional) properties: precision, width, height. If a single number is passed,
  33590. * it will be used for both width and height. If an object is passed, the screenshot size
  33591. * will be derived from the parameters. The precision property is a multiplier allowing
  33592. * rendering at a higher or lower resolution
  33593. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33594. * Check your browser for supported MIME types
  33595. * @param samples Texture samples (default: 1)
  33596. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33597. * @param fileName A name for for the downloaded file.
  33598. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33599. * to the src parameter of an <img> to display it
  33600. */
  33601. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33602. /**
  33603. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33604. * Be aware Math.random() could cause collisions, but:
  33605. * "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"
  33606. * @returns a pseudo random id
  33607. */
  33608. static RandomId(): string;
  33609. /**
  33610. * Test if the given uri is a base64 string
  33611. * @param uri The uri to test
  33612. * @return True if the uri is a base64 string or false otherwise
  33613. */
  33614. static IsBase64(uri: string): boolean;
  33615. /**
  33616. * Decode the given base64 uri.
  33617. * @param uri The uri to decode
  33618. * @return The decoded base64 data.
  33619. */
  33620. static DecodeBase64(uri: string): ArrayBuffer;
  33621. /**
  33622. * Gets the absolute url.
  33623. * @param url the input url
  33624. * @return the absolute url
  33625. */
  33626. static GetAbsoluteUrl(url: string): string;
  33627. /**
  33628. * No log
  33629. */
  33630. static readonly NoneLogLevel: number;
  33631. /**
  33632. * Only message logs
  33633. */
  33634. static readonly MessageLogLevel: number;
  33635. /**
  33636. * Only warning logs
  33637. */
  33638. static readonly WarningLogLevel: number;
  33639. /**
  33640. * Only error logs
  33641. */
  33642. static readonly ErrorLogLevel: number;
  33643. /**
  33644. * All logs
  33645. */
  33646. static readonly AllLogLevel: number;
  33647. /**
  33648. * Gets a value indicating the number of loading errors
  33649. * @ignorenaming
  33650. */
  33651. static readonly errorsCount: number;
  33652. /**
  33653. * Callback called when a new log is added
  33654. */
  33655. static OnNewCacheEntry: (entry: string) => void;
  33656. /**
  33657. * Log a message to the console
  33658. * @param message defines the message to log
  33659. */
  33660. static Log(message: string): void;
  33661. /**
  33662. * Write a warning message to the console
  33663. * @param message defines the message to log
  33664. */
  33665. static Warn(message: string): void;
  33666. /**
  33667. * Write an error message to the console
  33668. * @param message defines the message to log
  33669. */
  33670. static Error(message: string): void;
  33671. /**
  33672. * Gets current log cache (list of logs)
  33673. */
  33674. static readonly LogCache: string;
  33675. /**
  33676. * Clears the log cache
  33677. */
  33678. static ClearLogCache(): void;
  33679. /**
  33680. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33681. */
  33682. static LogLevels: number;
  33683. /**
  33684. * Checks if the window object exists
  33685. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33686. */
  33687. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33688. /**
  33689. * No performance log
  33690. */
  33691. static readonly PerformanceNoneLogLevel: number;
  33692. /**
  33693. * Use user marks to log performance
  33694. */
  33695. static readonly PerformanceUserMarkLogLevel: number;
  33696. /**
  33697. * Log performance to the console
  33698. */
  33699. static readonly PerformanceConsoleLogLevel: number;
  33700. private static _performance;
  33701. /**
  33702. * Sets the current performance log level
  33703. */
  33704. static PerformanceLogLevel: number;
  33705. private static _StartPerformanceCounterDisabled;
  33706. private static _EndPerformanceCounterDisabled;
  33707. private static _StartUserMark;
  33708. private static _EndUserMark;
  33709. private static _StartPerformanceConsole;
  33710. private static _EndPerformanceConsole;
  33711. /**
  33712. * Starts a performance counter
  33713. */
  33714. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33715. /**
  33716. * Ends a specific performance coutner
  33717. */
  33718. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33719. /**
  33720. * Gets either window.performance.now() if supported or Date.now() else
  33721. */
  33722. static readonly Now: number;
  33723. /**
  33724. * This method will return the name of the class used to create the instance of the given object.
  33725. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33726. * @param object the object to get the class name from
  33727. * @param isType defines if the object is actually a type
  33728. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33729. */
  33730. static GetClassName(object: any, isType?: boolean): string;
  33731. /**
  33732. * Gets the first element of an array satisfying a given predicate
  33733. * @param array defines the array to browse
  33734. * @param predicate defines the predicate to use
  33735. * @returns null if not found or the element
  33736. */
  33737. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33738. /**
  33739. * This method will return the name of the full name of the class, including its owning module (if any).
  33740. * 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).
  33741. * @param object the object to get the class name from
  33742. * @param isType defines if the object is actually a type
  33743. * @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.
  33744. * @ignorenaming
  33745. */
  33746. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33747. /**
  33748. * Returns a promise that resolves after the given amount of time.
  33749. * @param delay Number of milliseconds to delay
  33750. * @returns Promise that resolves after the given amount of time
  33751. */
  33752. static DelayAsync(delay: number): Promise<void>;
  33753. }
  33754. /**
  33755. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33756. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33757. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33758. * @param name The name of the class, case should be preserved
  33759. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33760. */
  33761. export function className(name: string, module?: string): (target: Object) => void;
  33762. /**
  33763. * An implementation of a loop for asynchronous functions.
  33764. */
  33765. export class AsyncLoop {
  33766. /**
  33767. * Defines the number of iterations for the loop
  33768. */
  33769. iterations: number;
  33770. /**
  33771. * Defines the current index of the loop.
  33772. */
  33773. index: number;
  33774. private _done;
  33775. private _fn;
  33776. private _successCallback;
  33777. /**
  33778. * Constructor.
  33779. * @param iterations the number of iterations.
  33780. * @param func the function to run each iteration
  33781. * @param successCallback the callback that will be called upon succesful execution
  33782. * @param offset starting offset.
  33783. */
  33784. constructor(
  33785. /**
  33786. * Defines the number of iterations for the loop
  33787. */
  33788. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33789. /**
  33790. * Execute the next iteration. Must be called after the last iteration was finished.
  33791. */
  33792. executeNext(): void;
  33793. /**
  33794. * Break the loop and run the success callback.
  33795. */
  33796. breakLoop(): void;
  33797. /**
  33798. * Create and run an async loop.
  33799. * @param iterations the number of iterations.
  33800. * @param fn the function to run each iteration
  33801. * @param successCallback the callback that will be called upon succesful execution
  33802. * @param offset starting offset.
  33803. * @returns the created async loop object
  33804. */
  33805. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33806. /**
  33807. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33808. * @param iterations total number of iterations
  33809. * @param syncedIterations number of synchronous iterations in each async iteration.
  33810. * @param fn the function to call each iteration.
  33811. * @param callback a success call back that will be called when iterating stops.
  33812. * @param breakFunction a break condition (optional)
  33813. * @param timeout timeout settings for the setTimeout function. default - 0.
  33814. * @returns the created async loop object
  33815. */
  33816. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33817. }
  33818. }
  33819. declare module "babylonjs/Misc/stringDictionary" {
  33820. import { Nullable } from "babylonjs/types";
  33821. /**
  33822. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33823. * The underlying implementation relies on an associative array to ensure the best performances.
  33824. * The value can be anything including 'null' but except 'undefined'
  33825. */
  33826. export class StringDictionary<T> {
  33827. /**
  33828. * This will clear this dictionary and copy the content from the 'source' one.
  33829. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33830. * @param source the dictionary to take the content from and copy to this dictionary
  33831. */
  33832. copyFrom(source: StringDictionary<T>): void;
  33833. /**
  33834. * Get a value based from its key
  33835. * @param key the given key to get the matching value from
  33836. * @return the value if found, otherwise undefined is returned
  33837. */
  33838. get(key: string): T | undefined;
  33839. /**
  33840. * Get a value from its key or add it if it doesn't exist.
  33841. * This method will ensure you that a given key/data will be present in the dictionary.
  33842. * @param key the given key to get the matching value from
  33843. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33844. * The factory will only be invoked if there's no data for the given key.
  33845. * @return the value corresponding to the key.
  33846. */
  33847. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33848. /**
  33849. * Get a value from its key if present in the dictionary otherwise add it
  33850. * @param key the key to get the value from
  33851. * @param val if there's no such key/value pair in the dictionary add it with this value
  33852. * @return the value corresponding to the key
  33853. */
  33854. getOrAdd(key: string, val: T): T;
  33855. /**
  33856. * Check if there's a given key in the dictionary
  33857. * @param key the key to check for
  33858. * @return true if the key is present, false otherwise
  33859. */
  33860. contains(key: string): boolean;
  33861. /**
  33862. * Add a new key and its corresponding value
  33863. * @param key the key to add
  33864. * @param value the value corresponding to the key
  33865. * @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
  33866. */
  33867. add(key: string, value: T): boolean;
  33868. /**
  33869. * Update a specific value associated to a key
  33870. * @param key defines the key to use
  33871. * @param value defines the value to store
  33872. * @returns true if the value was updated (or false if the key was not found)
  33873. */
  33874. set(key: string, value: T): boolean;
  33875. /**
  33876. * Get the element of the given key and remove it from the dictionary
  33877. * @param key defines the key to search
  33878. * @returns the value associated with the key or null if not found
  33879. */
  33880. getAndRemove(key: string): Nullable<T>;
  33881. /**
  33882. * Remove a key/value from the dictionary.
  33883. * @param key the key to remove
  33884. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33885. */
  33886. remove(key: string): boolean;
  33887. /**
  33888. * Clear the whole content of the dictionary
  33889. */
  33890. clear(): void;
  33891. /**
  33892. * Gets the current count
  33893. */
  33894. readonly count: number;
  33895. /**
  33896. * Execute a callback on each key/val of the dictionary.
  33897. * Note that you can remove any element in this dictionary in the callback implementation
  33898. * @param callback the callback to execute on a given key/value pair
  33899. */
  33900. forEach(callback: (key: string, val: T) => void): void;
  33901. /**
  33902. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33903. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33904. * Note that you can remove any element in this dictionary in the callback implementation
  33905. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33906. * @returns the first item
  33907. */
  33908. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33909. private _count;
  33910. private _data;
  33911. }
  33912. }
  33913. declare module "babylonjs/Collisions/collisionCoordinator" {
  33914. import { Nullable } from "babylonjs/types";
  33915. import { Scene } from "babylonjs/scene";
  33916. import { Vector3 } from "babylonjs/Maths/math.vector";
  33917. import { Collider } from "babylonjs/Collisions/collider";
  33918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33919. /** @hidden */
  33920. export interface ICollisionCoordinator {
  33921. createCollider(): Collider;
  33922. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33923. init(scene: Scene): void;
  33924. }
  33925. /** @hidden */
  33926. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33927. private _scene;
  33928. private _scaledPosition;
  33929. private _scaledVelocity;
  33930. private _finalPosition;
  33931. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33932. createCollider(): Collider;
  33933. init(scene: Scene): void;
  33934. private _collideWithWorld;
  33935. }
  33936. }
  33937. declare module "babylonjs/Inputs/scene.inputManager" {
  33938. import { Nullable } from "babylonjs/types";
  33939. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33940. import { Vector2 } from "babylonjs/Maths/math.vector";
  33941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33942. import { Scene } from "babylonjs/scene";
  33943. /**
  33944. * Class used to manage all inputs for the scene.
  33945. */
  33946. export class InputManager {
  33947. /** The distance in pixel that you have to move to prevent some events */
  33948. static DragMovementThreshold: number;
  33949. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33950. static LongPressDelay: number;
  33951. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33952. static DoubleClickDelay: number;
  33953. /** If you need to check double click without raising a single click at first click, enable this flag */
  33954. static ExclusiveDoubleClickMode: boolean;
  33955. private _wheelEventName;
  33956. private _onPointerMove;
  33957. private _onPointerDown;
  33958. private _onPointerUp;
  33959. private _initClickEvent;
  33960. private _initActionManager;
  33961. private _delayedSimpleClick;
  33962. private _delayedSimpleClickTimeout;
  33963. private _previousDelayedSimpleClickTimeout;
  33964. private _meshPickProceed;
  33965. private _previousButtonPressed;
  33966. private _currentPickResult;
  33967. private _previousPickResult;
  33968. private _totalPointersPressed;
  33969. private _doubleClickOccured;
  33970. private _pointerOverMesh;
  33971. private _pickedDownMesh;
  33972. private _pickedUpMesh;
  33973. private _pointerX;
  33974. private _pointerY;
  33975. private _unTranslatedPointerX;
  33976. private _unTranslatedPointerY;
  33977. private _startingPointerPosition;
  33978. private _previousStartingPointerPosition;
  33979. private _startingPointerTime;
  33980. private _previousStartingPointerTime;
  33981. private _pointerCaptures;
  33982. private _onKeyDown;
  33983. private _onKeyUp;
  33984. private _onCanvasFocusObserver;
  33985. private _onCanvasBlurObserver;
  33986. private _scene;
  33987. /**
  33988. * Creates a new InputManager
  33989. * @param scene defines the hosting scene
  33990. */
  33991. constructor(scene: Scene);
  33992. /**
  33993. * Gets the mesh that is currently under the pointer
  33994. */
  33995. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33996. /**
  33997. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33998. */
  33999. readonly unTranslatedPointer: Vector2;
  34000. /**
  34001. * Gets or sets the current on-screen X position of the pointer
  34002. */
  34003. pointerX: number;
  34004. /**
  34005. * Gets or sets the current on-screen Y position of the pointer
  34006. */
  34007. pointerY: number;
  34008. private _updatePointerPosition;
  34009. private _processPointerMove;
  34010. private _setRayOnPointerInfo;
  34011. private _checkPrePointerObservable;
  34012. /**
  34013. * Use this method to simulate a pointer move on a mesh
  34014. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34015. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34016. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34017. */
  34018. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34019. /**
  34020. * Use this method to simulate a pointer down on a mesh
  34021. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34022. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34023. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34024. */
  34025. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34026. private _processPointerDown;
  34027. /** @hidden */
  34028. _isPointerSwiping(): boolean;
  34029. /**
  34030. * Use this method to simulate a pointer up on a mesh
  34031. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34032. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34033. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34034. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34035. */
  34036. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34037. private _processPointerUp;
  34038. /**
  34039. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34040. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34041. * @returns true if the pointer was captured
  34042. */
  34043. isPointerCaptured(pointerId?: number): boolean;
  34044. /**
  34045. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34046. * @param attachUp defines if you want to attach events to pointerup
  34047. * @param attachDown defines if you want to attach events to pointerdown
  34048. * @param attachMove defines if you want to attach events to pointermove
  34049. */
  34050. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34051. /**
  34052. * Detaches all event handlers
  34053. */
  34054. detachControl(): void;
  34055. /**
  34056. * Force the value of meshUnderPointer
  34057. * @param mesh defines the mesh to use
  34058. */
  34059. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34060. /**
  34061. * Gets the mesh under the pointer
  34062. * @returns a Mesh or null if no mesh is under the pointer
  34063. */
  34064. getPointerOverMesh(): Nullable<AbstractMesh>;
  34065. }
  34066. }
  34067. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34068. /**
  34069. * Helper class used to generate session unique ID
  34070. */
  34071. export class UniqueIdGenerator {
  34072. private static _UniqueIdCounter;
  34073. /**
  34074. * Gets an unique (relatively to the current scene) Id
  34075. */
  34076. static readonly UniqueId: number;
  34077. }
  34078. }
  34079. declare module "babylonjs/Animations/animationGroup" {
  34080. import { Animatable } from "babylonjs/Animations/animatable";
  34081. import { Animation } from "babylonjs/Animations/animation";
  34082. import { Scene, IDisposable } from "babylonjs/scene";
  34083. import { Observable } from "babylonjs/Misc/observable";
  34084. import { Nullable } from "babylonjs/types";
  34085. import "babylonjs/Animations/animatable";
  34086. /**
  34087. * This class defines the direct association between an animation and a target
  34088. */
  34089. export class TargetedAnimation {
  34090. /**
  34091. * Animation to perform
  34092. */
  34093. animation: Animation;
  34094. /**
  34095. * Target to animate
  34096. */
  34097. target: any;
  34098. /**
  34099. * Serialize the object
  34100. * @returns the JSON object representing the current entity
  34101. */
  34102. serialize(): any;
  34103. }
  34104. /**
  34105. * Use this class to create coordinated animations on multiple targets
  34106. */
  34107. export class AnimationGroup implements IDisposable {
  34108. /** The name of the animation group */
  34109. name: string;
  34110. private _scene;
  34111. private _targetedAnimations;
  34112. private _animatables;
  34113. private _from;
  34114. private _to;
  34115. private _isStarted;
  34116. private _isPaused;
  34117. private _speedRatio;
  34118. private _loopAnimation;
  34119. /**
  34120. * Gets or sets the unique id of the node
  34121. */
  34122. uniqueId: number;
  34123. /**
  34124. * This observable will notify when one animation have ended
  34125. */
  34126. onAnimationEndObservable: Observable<TargetedAnimation>;
  34127. /**
  34128. * Observer raised when one animation loops
  34129. */
  34130. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34131. /**
  34132. * Observer raised when all animations have looped
  34133. */
  34134. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34135. /**
  34136. * This observable will notify when all animations have ended.
  34137. */
  34138. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34139. /**
  34140. * This observable will notify when all animations have paused.
  34141. */
  34142. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34143. /**
  34144. * This observable will notify when all animations are playing.
  34145. */
  34146. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34147. /**
  34148. * Gets the first frame
  34149. */
  34150. readonly from: number;
  34151. /**
  34152. * Gets the last frame
  34153. */
  34154. readonly to: number;
  34155. /**
  34156. * Define if the animations are started
  34157. */
  34158. readonly isStarted: boolean;
  34159. /**
  34160. * Gets a value indicating that the current group is playing
  34161. */
  34162. readonly isPlaying: boolean;
  34163. /**
  34164. * Gets or sets the speed ratio to use for all animations
  34165. */
  34166. /**
  34167. * Gets or sets the speed ratio to use for all animations
  34168. */
  34169. speedRatio: number;
  34170. /**
  34171. * Gets or sets if all animations should loop or not
  34172. */
  34173. loopAnimation: boolean;
  34174. /**
  34175. * Gets the targeted animations for this animation group
  34176. */
  34177. readonly targetedAnimations: Array<TargetedAnimation>;
  34178. /**
  34179. * returning the list of animatables controlled by this animation group.
  34180. */
  34181. readonly animatables: Array<Animatable>;
  34182. /**
  34183. * Instantiates a new Animation Group.
  34184. * This helps managing several animations at once.
  34185. * @see http://doc.babylonjs.com/how_to/group
  34186. * @param name Defines the name of the group
  34187. * @param scene Defines the scene the group belongs to
  34188. */
  34189. constructor(
  34190. /** The name of the animation group */
  34191. name: string, scene?: Nullable<Scene>);
  34192. /**
  34193. * Add an animation (with its target) in the group
  34194. * @param animation defines the animation we want to add
  34195. * @param target defines the target of the animation
  34196. * @returns the TargetedAnimation object
  34197. */
  34198. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34199. /**
  34200. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34201. * It can add constant keys at begin or end
  34202. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34203. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34204. * @returns the animation group
  34205. */
  34206. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34207. private _animationLoopCount;
  34208. private _animationLoopFlags;
  34209. private _processLoop;
  34210. /**
  34211. * Start all animations on given targets
  34212. * @param loop defines if animations must loop
  34213. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34214. * @param from defines the from key (optional)
  34215. * @param to defines the to key (optional)
  34216. * @returns the current animation group
  34217. */
  34218. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34219. /**
  34220. * Pause all animations
  34221. * @returns the animation group
  34222. */
  34223. pause(): AnimationGroup;
  34224. /**
  34225. * Play all animations to initial state
  34226. * This function will start() the animations if they were not started or will restart() them if they were paused
  34227. * @param loop defines if animations must loop
  34228. * @returns the animation group
  34229. */
  34230. play(loop?: boolean): AnimationGroup;
  34231. /**
  34232. * Reset all animations to initial state
  34233. * @returns the animation group
  34234. */
  34235. reset(): AnimationGroup;
  34236. /**
  34237. * Restart animations from key 0
  34238. * @returns the animation group
  34239. */
  34240. restart(): AnimationGroup;
  34241. /**
  34242. * Stop all animations
  34243. * @returns the animation group
  34244. */
  34245. stop(): AnimationGroup;
  34246. /**
  34247. * Set animation weight for all animatables
  34248. * @param weight defines the weight to use
  34249. * @return the animationGroup
  34250. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34251. */
  34252. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34253. /**
  34254. * Synchronize and normalize all animatables with a source animatable
  34255. * @param root defines the root animatable to synchronize with
  34256. * @return the animationGroup
  34257. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34258. */
  34259. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34260. /**
  34261. * Goes to a specific frame in this animation group
  34262. * @param frame the frame number to go to
  34263. * @return the animationGroup
  34264. */
  34265. goToFrame(frame: number): AnimationGroup;
  34266. /**
  34267. * Dispose all associated resources
  34268. */
  34269. dispose(): void;
  34270. private _checkAnimationGroupEnded;
  34271. /**
  34272. * Clone the current animation group and returns a copy
  34273. * @param newName defines the name of the new group
  34274. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34275. * @returns the new aniamtion group
  34276. */
  34277. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34278. /**
  34279. * Serializes the animationGroup to an object
  34280. * @returns Serialized object
  34281. */
  34282. serialize(): any;
  34283. /**
  34284. * Returns a new AnimationGroup object parsed from the source provided.
  34285. * @param parsedAnimationGroup defines the source
  34286. * @param scene defines the scene that will receive the animationGroup
  34287. * @returns a new AnimationGroup
  34288. */
  34289. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34290. /**
  34291. * Returns the string "AnimationGroup"
  34292. * @returns "AnimationGroup"
  34293. */
  34294. getClassName(): string;
  34295. /**
  34296. * Creates a detailled string about the object
  34297. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34298. * @returns a string representing the object
  34299. */
  34300. toString(fullDetails?: boolean): string;
  34301. }
  34302. }
  34303. declare module "babylonjs/scene" {
  34304. import { Nullable } from "babylonjs/types";
  34305. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34306. import { Observable } from "babylonjs/Misc/observable";
  34307. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34308. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34309. import { Geometry } from "babylonjs/Meshes/geometry";
  34310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34313. import { Mesh } from "babylonjs/Meshes/mesh";
  34314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34315. import { Bone } from "babylonjs/Bones/bone";
  34316. import { Skeleton } from "babylonjs/Bones/skeleton";
  34317. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34318. import { Camera } from "babylonjs/Cameras/camera";
  34319. import { AbstractScene } from "babylonjs/abstractScene";
  34320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34322. import { Material } from "babylonjs/Materials/material";
  34323. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34324. import { Effect } from "babylonjs/Materials/effect";
  34325. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34326. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34327. import { Light } from "babylonjs/Lights/light";
  34328. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34329. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34330. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34331. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34333. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34335. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34336. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34337. import { Engine } from "babylonjs/Engines/engine";
  34338. import { Node } from "babylonjs/node";
  34339. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34340. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34341. import { WebRequest } from "babylonjs/Misc/webRequest";
  34342. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34343. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34345. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34346. import { Plane } from "babylonjs/Maths/math.plane";
  34347. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34348. import { Ray } from "babylonjs/Culling/ray";
  34349. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34350. import { Animation } from "babylonjs/Animations/animation";
  34351. import { Animatable } from "babylonjs/Animations/animatable";
  34352. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34353. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34354. import { Collider } from "babylonjs/Collisions/collider";
  34355. /**
  34356. * Define an interface for all classes that will hold resources
  34357. */
  34358. export interface IDisposable {
  34359. /**
  34360. * Releases all held resources
  34361. */
  34362. dispose(): void;
  34363. }
  34364. /** Interface defining initialization parameters for Scene class */
  34365. export interface SceneOptions {
  34366. /**
  34367. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34368. * It will improve performance when the number of geometries becomes important.
  34369. */
  34370. useGeometryUniqueIdsMap?: boolean;
  34371. /**
  34372. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34373. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34374. */
  34375. useMaterialMeshMap?: boolean;
  34376. /**
  34377. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34378. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34379. */
  34380. useClonedMeshhMap?: boolean;
  34381. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34382. virtual?: boolean;
  34383. }
  34384. /**
  34385. * Represents a scene to be rendered by the engine.
  34386. * @see http://doc.babylonjs.com/features/scene
  34387. */
  34388. export class Scene extends AbstractScene implements IAnimatable {
  34389. /** The fog is deactivated */
  34390. static readonly FOGMODE_NONE: number;
  34391. /** The fog density is following an exponential function */
  34392. static readonly FOGMODE_EXP: number;
  34393. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34394. static readonly FOGMODE_EXP2: number;
  34395. /** The fog density is following a linear function. */
  34396. static readonly FOGMODE_LINEAR: number;
  34397. /**
  34398. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34399. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34400. */
  34401. static MinDeltaTime: number;
  34402. /**
  34403. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34405. */
  34406. static MaxDeltaTime: number;
  34407. /**
  34408. * Factory used to create the default material.
  34409. * @param name The name of the material to create
  34410. * @param scene The scene to create the material for
  34411. * @returns The default material
  34412. */
  34413. static DefaultMaterialFactory(scene: Scene): Material;
  34414. /**
  34415. * Factory used to create the a collision coordinator.
  34416. * @returns The collision coordinator
  34417. */
  34418. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34419. /** @hidden */
  34420. _inputManager: InputManager;
  34421. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34422. cameraToUseForPointers: Nullable<Camera>;
  34423. /** @hidden */
  34424. readonly _isScene: boolean;
  34425. /**
  34426. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34427. */
  34428. autoClear: boolean;
  34429. /**
  34430. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34431. */
  34432. autoClearDepthAndStencil: boolean;
  34433. /**
  34434. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34435. */
  34436. clearColor: Color4;
  34437. /**
  34438. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34439. */
  34440. ambientColor: Color3;
  34441. /**
  34442. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34443. * It should only be one of the following (if not the default embedded one):
  34444. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34445. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34446. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34447. * The material properties need to be setup according to the type of texture in use.
  34448. */
  34449. environmentBRDFTexture: BaseTexture;
  34450. /** @hidden */
  34451. protected _environmentTexture: Nullable<BaseTexture>;
  34452. /**
  34453. * Texture used in all pbr material as the reflection texture.
  34454. * As in the majority of the scene they are the same (exception for multi room and so on),
  34455. * this is easier to reference from here than from all the materials.
  34456. */
  34457. /**
  34458. * Texture used in all pbr material as the reflection texture.
  34459. * As in the majority of the scene they are the same (exception for multi room and so on),
  34460. * this is easier to set here than in all the materials.
  34461. */
  34462. environmentTexture: Nullable<BaseTexture>;
  34463. /** @hidden */
  34464. protected _environmentIntensity: number;
  34465. /**
  34466. * Intensity of the environment in all pbr material.
  34467. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34468. * As in the majority of the scene they are the same (exception for multi room and so on),
  34469. * this is easier to reference from here than from all the materials.
  34470. */
  34471. /**
  34472. * Intensity of the environment in all pbr material.
  34473. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34474. * As in the majority of the scene they are the same (exception for multi room and so on),
  34475. * this is easier to set here than in all the materials.
  34476. */
  34477. environmentIntensity: number;
  34478. /** @hidden */
  34479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34480. /**
  34481. * Default image processing configuration used either in the rendering
  34482. * Forward main pass or through the imageProcessingPostProcess if present.
  34483. * As in the majority of the scene they are the same (exception for multi camera),
  34484. * this is easier to reference from here than from all the materials and post process.
  34485. *
  34486. * No setter as we it is a shared configuration, you can set the values instead.
  34487. */
  34488. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34489. private _forceWireframe;
  34490. /**
  34491. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34492. */
  34493. forceWireframe: boolean;
  34494. private _forcePointsCloud;
  34495. /**
  34496. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34497. */
  34498. forcePointsCloud: boolean;
  34499. /**
  34500. * Gets or sets the active clipplane 1
  34501. */
  34502. clipPlane: Nullable<Plane>;
  34503. /**
  34504. * Gets or sets the active clipplane 2
  34505. */
  34506. clipPlane2: Nullable<Plane>;
  34507. /**
  34508. * Gets or sets the active clipplane 3
  34509. */
  34510. clipPlane3: Nullable<Plane>;
  34511. /**
  34512. * Gets or sets the active clipplane 4
  34513. */
  34514. clipPlane4: Nullable<Plane>;
  34515. /**
  34516. * Gets or sets a boolean indicating if animations are enabled
  34517. */
  34518. animationsEnabled: boolean;
  34519. private _animationPropertiesOverride;
  34520. /**
  34521. * Gets or sets the animation properties override
  34522. */
  34523. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34524. /**
  34525. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34526. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34527. */
  34528. useConstantAnimationDeltaTime: boolean;
  34529. /**
  34530. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34531. * Please note that it requires to run a ray cast through the scene on every frame
  34532. */
  34533. constantlyUpdateMeshUnderPointer: boolean;
  34534. /**
  34535. * Defines the HTML cursor to use when hovering over interactive elements
  34536. */
  34537. hoverCursor: string;
  34538. /**
  34539. * Defines the HTML default cursor to use (empty by default)
  34540. */
  34541. defaultCursor: string;
  34542. /**
  34543. * Defines wether cursors are handled by the scene.
  34544. */
  34545. doNotHandleCursors: boolean;
  34546. /**
  34547. * This is used to call preventDefault() on pointer down
  34548. * in order to block unwanted artifacts like system double clicks
  34549. */
  34550. preventDefaultOnPointerDown: boolean;
  34551. /**
  34552. * This is used to call preventDefault() on pointer up
  34553. * in order to block unwanted artifacts like system double clicks
  34554. */
  34555. preventDefaultOnPointerUp: boolean;
  34556. /**
  34557. * Gets or sets user defined metadata
  34558. */
  34559. metadata: any;
  34560. /**
  34561. * For internal use only. Please do not use.
  34562. */
  34563. reservedDataStore: any;
  34564. /**
  34565. * Gets the name of the plugin used to load this scene (null by default)
  34566. */
  34567. loadingPluginName: string;
  34568. /**
  34569. * Use this array to add regular expressions used to disable offline support for specific urls
  34570. */
  34571. disableOfflineSupportExceptionRules: RegExp[];
  34572. /**
  34573. * An event triggered when the scene is disposed.
  34574. */
  34575. onDisposeObservable: Observable<Scene>;
  34576. private _onDisposeObserver;
  34577. /** Sets a function to be executed when this scene is disposed. */
  34578. onDispose: () => void;
  34579. /**
  34580. * An event triggered before rendering the scene (right after animations and physics)
  34581. */
  34582. onBeforeRenderObservable: Observable<Scene>;
  34583. private _onBeforeRenderObserver;
  34584. /** Sets a function to be executed before rendering this scene */
  34585. beforeRender: Nullable<() => void>;
  34586. /**
  34587. * An event triggered after rendering the scene
  34588. */
  34589. onAfterRenderObservable: Observable<Scene>;
  34590. /**
  34591. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34592. */
  34593. onAfterRenderCameraObservable: Observable<Camera>;
  34594. private _onAfterRenderObserver;
  34595. /** Sets a function to be executed after rendering this scene */
  34596. afterRender: Nullable<() => void>;
  34597. /**
  34598. * An event triggered before animating the scene
  34599. */
  34600. onBeforeAnimationsObservable: Observable<Scene>;
  34601. /**
  34602. * An event triggered after animations processing
  34603. */
  34604. onAfterAnimationsObservable: Observable<Scene>;
  34605. /**
  34606. * An event triggered before draw calls are ready to be sent
  34607. */
  34608. onBeforeDrawPhaseObservable: Observable<Scene>;
  34609. /**
  34610. * An event triggered after draw calls have been sent
  34611. */
  34612. onAfterDrawPhaseObservable: Observable<Scene>;
  34613. /**
  34614. * An event triggered when the scene is ready
  34615. */
  34616. onReadyObservable: Observable<Scene>;
  34617. /**
  34618. * An event triggered before rendering a camera
  34619. */
  34620. onBeforeCameraRenderObservable: Observable<Camera>;
  34621. private _onBeforeCameraRenderObserver;
  34622. /** Sets a function to be executed before rendering a camera*/
  34623. beforeCameraRender: () => void;
  34624. /**
  34625. * An event triggered after rendering a camera
  34626. */
  34627. onAfterCameraRenderObservable: Observable<Camera>;
  34628. private _onAfterCameraRenderObserver;
  34629. /** Sets a function to be executed after rendering a camera*/
  34630. afterCameraRender: () => void;
  34631. /**
  34632. * An event triggered when active meshes evaluation is about to start
  34633. */
  34634. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34635. /**
  34636. * An event triggered when active meshes evaluation is done
  34637. */
  34638. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34639. /**
  34640. * An event triggered when particles rendering is about to start
  34641. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34642. */
  34643. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34644. /**
  34645. * An event triggered when particles rendering is done
  34646. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34647. */
  34648. onAfterParticlesRenderingObservable: Observable<Scene>;
  34649. /**
  34650. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34651. */
  34652. onDataLoadedObservable: Observable<Scene>;
  34653. /**
  34654. * An event triggered when a camera is created
  34655. */
  34656. onNewCameraAddedObservable: Observable<Camera>;
  34657. /**
  34658. * An event triggered when a camera is removed
  34659. */
  34660. onCameraRemovedObservable: Observable<Camera>;
  34661. /**
  34662. * An event triggered when a light is created
  34663. */
  34664. onNewLightAddedObservable: Observable<Light>;
  34665. /**
  34666. * An event triggered when a light is removed
  34667. */
  34668. onLightRemovedObservable: Observable<Light>;
  34669. /**
  34670. * An event triggered when a geometry is created
  34671. */
  34672. onNewGeometryAddedObservable: Observable<Geometry>;
  34673. /**
  34674. * An event triggered when a geometry is removed
  34675. */
  34676. onGeometryRemovedObservable: Observable<Geometry>;
  34677. /**
  34678. * An event triggered when a transform node is created
  34679. */
  34680. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34681. /**
  34682. * An event triggered when a transform node is removed
  34683. */
  34684. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34685. /**
  34686. * An event triggered when a mesh is created
  34687. */
  34688. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34689. /**
  34690. * An event triggered when a mesh is removed
  34691. */
  34692. onMeshRemovedObservable: Observable<AbstractMesh>;
  34693. /**
  34694. * An event triggered when a skeleton is created
  34695. */
  34696. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34697. /**
  34698. * An event triggered when a skeleton is removed
  34699. */
  34700. onSkeletonRemovedObservable: Observable<Skeleton>;
  34701. /**
  34702. * An event triggered when a material is created
  34703. */
  34704. onNewMaterialAddedObservable: Observable<Material>;
  34705. /**
  34706. * An event triggered when a material is removed
  34707. */
  34708. onMaterialRemovedObservable: Observable<Material>;
  34709. /**
  34710. * An event triggered when a texture is created
  34711. */
  34712. onNewTextureAddedObservable: Observable<BaseTexture>;
  34713. /**
  34714. * An event triggered when a texture is removed
  34715. */
  34716. onTextureRemovedObservable: Observable<BaseTexture>;
  34717. /**
  34718. * An event triggered when render targets are about to be rendered
  34719. * Can happen multiple times per frame.
  34720. */
  34721. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34722. /**
  34723. * An event triggered when render targets were rendered.
  34724. * Can happen multiple times per frame.
  34725. */
  34726. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34727. /**
  34728. * An event triggered before calculating deterministic simulation step
  34729. */
  34730. onBeforeStepObservable: Observable<Scene>;
  34731. /**
  34732. * An event triggered after calculating deterministic simulation step
  34733. */
  34734. onAfterStepObservable: Observable<Scene>;
  34735. /**
  34736. * An event triggered when the activeCamera property is updated
  34737. */
  34738. onActiveCameraChanged: Observable<Scene>;
  34739. /**
  34740. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34741. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34742. * 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)
  34743. */
  34744. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34745. /**
  34746. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34747. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34748. * 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)
  34749. */
  34750. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34751. /**
  34752. * This Observable will when a mesh has been imported into the scene.
  34753. */
  34754. onMeshImportedObservable: Observable<AbstractMesh>;
  34755. /**
  34756. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34757. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34758. */
  34759. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34760. /** @hidden */
  34761. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34762. /**
  34763. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34764. */
  34765. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34766. /**
  34767. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34768. */
  34769. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34770. /**
  34771. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34772. */
  34773. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34774. /** Callback called when a pointer move is detected */
  34775. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34776. /** Callback called when a pointer down is detected */
  34777. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34778. /** Callback called when a pointer up is detected */
  34779. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34780. /** Callback called when a pointer pick is detected */
  34781. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34782. /**
  34783. * 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).
  34784. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34785. */
  34786. onPrePointerObservable: Observable<PointerInfoPre>;
  34787. /**
  34788. * Observable event triggered each time an input event is received from the rendering canvas
  34789. */
  34790. onPointerObservable: Observable<PointerInfo>;
  34791. /**
  34792. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34793. */
  34794. readonly unTranslatedPointer: Vector2;
  34795. /**
  34796. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34797. */
  34798. static DragMovementThreshold: number;
  34799. /**
  34800. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34801. */
  34802. static LongPressDelay: number;
  34803. /**
  34804. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34805. */
  34806. static DoubleClickDelay: number;
  34807. /** If you need to check double click without raising a single click at first click, enable this flag */
  34808. static ExclusiveDoubleClickMode: boolean;
  34809. /** @hidden */
  34810. _mirroredCameraPosition: Nullable<Vector3>;
  34811. /**
  34812. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34813. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34814. */
  34815. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34816. /**
  34817. * Observable event triggered each time an keyboard event is received from the hosting window
  34818. */
  34819. onKeyboardObservable: Observable<KeyboardInfo>;
  34820. private _useRightHandedSystem;
  34821. /**
  34822. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34823. */
  34824. useRightHandedSystem: boolean;
  34825. private _timeAccumulator;
  34826. private _currentStepId;
  34827. private _currentInternalStep;
  34828. /**
  34829. * Sets the step Id used by deterministic lock step
  34830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34831. * @param newStepId defines the step Id
  34832. */
  34833. setStepId(newStepId: number): void;
  34834. /**
  34835. * Gets the step Id used by deterministic lock step
  34836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34837. * @returns the step Id
  34838. */
  34839. getStepId(): number;
  34840. /**
  34841. * Gets the internal step used by deterministic lock step
  34842. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34843. * @returns the internal step
  34844. */
  34845. getInternalStep(): number;
  34846. private _fogEnabled;
  34847. /**
  34848. * Gets or sets a boolean indicating if fog is enabled on this scene
  34849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34850. * (Default is true)
  34851. */
  34852. fogEnabled: boolean;
  34853. private _fogMode;
  34854. /**
  34855. * Gets or sets the fog mode to use
  34856. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34857. * | mode | value |
  34858. * | --- | --- |
  34859. * | FOGMODE_NONE | 0 |
  34860. * | FOGMODE_EXP | 1 |
  34861. * | FOGMODE_EXP2 | 2 |
  34862. * | FOGMODE_LINEAR | 3 |
  34863. */
  34864. fogMode: number;
  34865. /**
  34866. * Gets or sets the fog color to use
  34867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34868. * (Default is Color3(0.2, 0.2, 0.3))
  34869. */
  34870. fogColor: Color3;
  34871. /**
  34872. * Gets or sets the fog density to use
  34873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34874. * (Default is 0.1)
  34875. */
  34876. fogDensity: number;
  34877. /**
  34878. * Gets or sets the fog start distance to use
  34879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34880. * (Default is 0)
  34881. */
  34882. fogStart: number;
  34883. /**
  34884. * Gets or sets the fog end distance to use
  34885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34886. * (Default is 1000)
  34887. */
  34888. fogEnd: number;
  34889. private _shadowsEnabled;
  34890. /**
  34891. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34892. */
  34893. shadowsEnabled: boolean;
  34894. private _lightsEnabled;
  34895. /**
  34896. * Gets or sets a boolean indicating if lights are enabled on this scene
  34897. */
  34898. lightsEnabled: boolean;
  34899. /** All of the active cameras added to this scene. */
  34900. activeCameras: Camera[];
  34901. /** @hidden */
  34902. _activeCamera: Nullable<Camera>;
  34903. /** Gets or sets the current active camera */
  34904. activeCamera: Nullable<Camera>;
  34905. private _defaultMaterial;
  34906. /** The default material used on meshes when no material is affected */
  34907. /** The default material used on meshes when no material is affected */
  34908. defaultMaterial: Material;
  34909. private _texturesEnabled;
  34910. /**
  34911. * Gets or sets a boolean indicating if textures are enabled on this scene
  34912. */
  34913. texturesEnabled: boolean;
  34914. /**
  34915. * Gets or sets a boolean indicating if particles are enabled on this scene
  34916. */
  34917. particlesEnabled: boolean;
  34918. /**
  34919. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34920. */
  34921. spritesEnabled: boolean;
  34922. private _skeletonsEnabled;
  34923. /**
  34924. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34925. */
  34926. skeletonsEnabled: boolean;
  34927. /**
  34928. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34929. */
  34930. lensFlaresEnabled: boolean;
  34931. /**
  34932. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34934. */
  34935. collisionsEnabled: boolean;
  34936. private _collisionCoordinator;
  34937. /** @hidden */
  34938. readonly collisionCoordinator: ICollisionCoordinator;
  34939. /**
  34940. * Defines the gravity applied to this scene (used only for collisions)
  34941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34942. */
  34943. gravity: Vector3;
  34944. /**
  34945. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34946. */
  34947. postProcessesEnabled: boolean;
  34948. /**
  34949. * The list of postprocesses added to the scene
  34950. */
  34951. postProcesses: PostProcess[];
  34952. /**
  34953. * Gets the current postprocess manager
  34954. */
  34955. postProcessManager: PostProcessManager;
  34956. /**
  34957. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34958. */
  34959. renderTargetsEnabled: boolean;
  34960. /**
  34961. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34962. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34963. */
  34964. dumpNextRenderTargets: boolean;
  34965. /**
  34966. * The list of user defined render targets added to the scene
  34967. */
  34968. customRenderTargets: RenderTargetTexture[];
  34969. /**
  34970. * Defines if texture loading must be delayed
  34971. * If true, textures will only be loaded when they need to be rendered
  34972. */
  34973. useDelayedTextureLoading: boolean;
  34974. /**
  34975. * Gets the list of meshes imported to the scene through SceneLoader
  34976. */
  34977. importedMeshesFiles: String[];
  34978. /**
  34979. * Gets or sets a boolean indicating if probes are enabled on this scene
  34980. */
  34981. probesEnabled: boolean;
  34982. /**
  34983. * Gets or sets the current offline provider to use to store scene data
  34984. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34985. */
  34986. offlineProvider: IOfflineProvider;
  34987. /**
  34988. * Gets or sets the action manager associated with the scene
  34989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34990. */
  34991. actionManager: AbstractActionManager;
  34992. private _meshesForIntersections;
  34993. /**
  34994. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34995. */
  34996. proceduralTexturesEnabled: boolean;
  34997. private _engine;
  34998. private _totalVertices;
  34999. /** @hidden */
  35000. _activeIndices: PerfCounter;
  35001. /** @hidden */
  35002. _activeParticles: PerfCounter;
  35003. /** @hidden */
  35004. _activeBones: PerfCounter;
  35005. private _animationRatio;
  35006. /** @hidden */
  35007. _animationTimeLast: number;
  35008. /** @hidden */
  35009. _animationTime: number;
  35010. /**
  35011. * Gets or sets a general scale for animation speed
  35012. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35013. */
  35014. animationTimeScale: number;
  35015. /** @hidden */
  35016. _cachedMaterial: Nullable<Material>;
  35017. /** @hidden */
  35018. _cachedEffect: Nullable<Effect>;
  35019. /** @hidden */
  35020. _cachedVisibility: Nullable<number>;
  35021. private _renderId;
  35022. private _frameId;
  35023. private _executeWhenReadyTimeoutId;
  35024. private _intermediateRendering;
  35025. private _viewUpdateFlag;
  35026. private _projectionUpdateFlag;
  35027. /** @hidden */
  35028. _toBeDisposed: Nullable<IDisposable>[];
  35029. private _activeRequests;
  35030. /** @hidden */
  35031. _pendingData: any[];
  35032. private _isDisposed;
  35033. /**
  35034. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35035. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35036. */
  35037. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35038. private _activeMeshes;
  35039. private _processedMaterials;
  35040. private _renderTargets;
  35041. /** @hidden */
  35042. _activeParticleSystems: SmartArray<IParticleSystem>;
  35043. private _activeSkeletons;
  35044. private _softwareSkinnedMeshes;
  35045. private _renderingManager;
  35046. /** @hidden */
  35047. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35048. private _transformMatrix;
  35049. private _sceneUbo;
  35050. /** @hidden */
  35051. _viewMatrix: Matrix;
  35052. private _projectionMatrix;
  35053. /** @hidden */
  35054. _forcedViewPosition: Nullable<Vector3>;
  35055. /** @hidden */
  35056. _frustumPlanes: Plane[];
  35057. /**
  35058. * Gets the list of frustum planes (built from the active camera)
  35059. */
  35060. readonly frustumPlanes: Plane[];
  35061. /**
  35062. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35063. * This is useful if there are more lights that the maximum simulteanous authorized
  35064. */
  35065. requireLightSorting: boolean;
  35066. /** @hidden */
  35067. readonly useMaterialMeshMap: boolean;
  35068. /** @hidden */
  35069. readonly useClonedMeshhMap: boolean;
  35070. private _externalData;
  35071. private _uid;
  35072. /**
  35073. * @hidden
  35074. * Backing store of defined scene components.
  35075. */
  35076. _components: ISceneComponent[];
  35077. /**
  35078. * @hidden
  35079. * Backing store of defined scene components.
  35080. */
  35081. _serializableComponents: ISceneSerializableComponent[];
  35082. /**
  35083. * List of components to register on the next registration step.
  35084. */
  35085. private _transientComponents;
  35086. /**
  35087. * Registers the transient components if needed.
  35088. */
  35089. private _registerTransientComponents;
  35090. /**
  35091. * @hidden
  35092. * Add a component to the scene.
  35093. * Note that the ccomponent could be registered on th next frame if this is called after
  35094. * the register component stage.
  35095. * @param component Defines the component to add to the scene
  35096. */
  35097. _addComponent(component: ISceneComponent): void;
  35098. /**
  35099. * @hidden
  35100. * Gets a component from the scene.
  35101. * @param name defines the name of the component to retrieve
  35102. * @returns the component or null if not present
  35103. */
  35104. _getComponent(name: string): Nullable<ISceneComponent>;
  35105. /**
  35106. * @hidden
  35107. * Defines the actions happening before camera updates.
  35108. */
  35109. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35110. /**
  35111. * @hidden
  35112. * Defines the actions happening before clear the canvas.
  35113. */
  35114. _beforeClearStage: Stage<SimpleStageAction>;
  35115. /**
  35116. * @hidden
  35117. * Defines the actions when collecting render targets for the frame.
  35118. */
  35119. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35120. /**
  35121. * @hidden
  35122. * Defines the actions happening for one camera in the frame.
  35123. */
  35124. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35125. /**
  35126. * @hidden
  35127. * Defines the actions happening during the per mesh ready checks.
  35128. */
  35129. _isReadyForMeshStage: Stage<MeshStageAction>;
  35130. /**
  35131. * @hidden
  35132. * Defines the actions happening before evaluate active mesh checks.
  35133. */
  35134. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35135. /**
  35136. * @hidden
  35137. * Defines the actions happening during the evaluate sub mesh checks.
  35138. */
  35139. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35140. /**
  35141. * @hidden
  35142. * Defines the actions happening during the active mesh stage.
  35143. */
  35144. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35145. /**
  35146. * @hidden
  35147. * Defines the actions happening during the per camera render target step.
  35148. */
  35149. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35150. /**
  35151. * @hidden
  35152. * Defines the actions happening just before the active camera is drawing.
  35153. */
  35154. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35155. /**
  35156. * @hidden
  35157. * Defines the actions happening just before a render target is drawing.
  35158. */
  35159. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35160. /**
  35161. * @hidden
  35162. * Defines the actions happening just before a rendering group is drawing.
  35163. */
  35164. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35165. /**
  35166. * @hidden
  35167. * Defines the actions happening just before a mesh is drawing.
  35168. */
  35169. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35170. /**
  35171. * @hidden
  35172. * Defines the actions happening just after a mesh has been drawn.
  35173. */
  35174. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35175. /**
  35176. * @hidden
  35177. * Defines the actions happening just after a rendering group has been drawn.
  35178. */
  35179. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions happening just after the active camera has been drawn.
  35183. */
  35184. _afterCameraDrawStage: Stage<CameraStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening just after a render target has been drawn.
  35188. */
  35189. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions happening just after rendering all cameras and computing intersections.
  35193. */
  35194. _afterRenderStage: Stage<SimpleStageAction>;
  35195. /**
  35196. * @hidden
  35197. * Defines the actions happening when a pointer move event happens.
  35198. */
  35199. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35200. /**
  35201. * @hidden
  35202. * Defines the actions happening when a pointer down event happens.
  35203. */
  35204. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35205. /**
  35206. * @hidden
  35207. * Defines the actions happening when a pointer up event happens.
  35208. */
  35209. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35210. /**
  35211. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35212. */
  35213. private geometriesByUniqueId;
  35214. /**
  35215. * Creates a new Scene
  35216. * @param engine defines the engine to use to render this scene
  35217. * @param options defines the scene options
  35218. */
  35219. constructor(engine: Engine, options?: SceneOptions);
  35220. /**
  35221. * Gets a string idenfifying the name of the class
  35222. * @returns "Scene" string
  35223. */
  35224. getClassName(): string;
  35225. private _defaultMeshCandidates;
  35226. /**
  35227. * @hidden
  35228. */
  35229. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35230. private _defaultSubMeshCandidates;
  35231. /**
  35232. * @hidden
  35233. */
  35234. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35235. /**
  35236. * Sets the default candidate providers for the scene.
  35237. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35238. * and getCollidingSubMeshCandidates to their default function
  35239. */
  35240. setDefaultCandidateProviders(): void;
  35241. /**
  35242. * Gets the mesh that is currently under the pointer
  35243. */
  35244. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35245. /**
  35246. * Gets or sets the current on-screen X position of the pointer
  35247. */
  35248. pointerX: number;
  35249. /**
  35250. * Gets or sets the current on-screen Y position of the pointer
  35251. */
  35252. pointerY: number;
  35253. /**
  35254. * Gets the cached material (ie. the latest rendered one)
  35255. * @returns the cached material
  35256. */
  35257. getCachedMaterial(): Nullable<Material>;
  35258. /**
  35259. * Gets the cached effect (ie. the latest rendered one)
  35260. * @returns the cached effect
  35261. */
  35262. getCachedEffect(): Nullable<Effect>;
  35263. /**
  35264. * Gets the cached visibility state (ie. the latest rendered one)
  35265. * @returns the cached visibility state
  35266. */
  35267. getCachedVisibility(): Nullable<number>;
  35268. /**
  35269. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35270. * @param material defines the current material
  35271. * @param effect defines the current effect
  35272. * @param visibility defines the current visibility state
  35273. * @returns true if one parameter is not cached
  35274. */
  35275. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35276. /**
  35277. * Gets the engine associated with the scene
  35278. * @returns an Engine
  35279. */
  35280. getEngine(): Engine;
  35281. /**
  35282. * Gets the total number of vertices rendered per frame
  35283. * @returns the total number of vertices rendered per frame
  35284. */
  35285. getTotalVertices(): number;
  35286. /**
  35287. * Gets the performance counter for total vertices
  35288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35289. */
  35290. readonly totalVerticesPerfCounter: PerfCounter;
  35291. /**
  35292. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35293. * @returns the total number of active indices rendered per frame
  35294. */
  35295. getActiveIndices(): number;
  35296. /**
  35297. * Gets the performance counter for active indices
  35298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35299. */
  35300. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35301. /**
  35302. * Gets the total number of active particles rendered per frame
  35303. * @returns the total number of active particles rendered per frame
  35304. */
  35305. getActiveParticles(): number;
  35306. /**
  35307. * Gets the performance counter for active particles
  35308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35309. */
  35310. readonly activeParticlesPerfCounter: PerfCounter;
  35311. /**
  35312. * Gets the total number of active bones rendered per frame
  35313. * @returns the total number of active bones rendered per frame
  35314. */
  35315. getActiveBones(): number;
  35316. /**
  35317. * Gets the performance counter for active bones
  35318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35319. */
  35320. readonly activeBonesPerfCounter: PerfCounter;
  35321. /**
  35322. * Gets the array of active meshes
  35323. * @returns an array of AbstractMesh
  35324. */
  35325. getActiveMeshes(): SmartArray<AbstractMesh>;
  35326. /**
  35327. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35328. * @returns a number
  35329. */
  35330. getAnimationRatio(): number;
  35331. /**
  35332. * Gets an unique Id for the current render phase
  35333. * @returns a number
  35334. */
  35335. getRenderId(): number;
  35336. /**
  35337. * Gets an unique Id for the current frame
  35338. * @returns a number
  35339. */
  35340. getFrameId(): number;
  35341. /** Call this function if you want to manually increment the render Id*/
  35342. incrementRenderId(): void;
  35343. private _createUbo;
  35344. /**
  35345. * Use this method to simulate a pointer move on a mesh
  35346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35349. * @returns the current scene
  35350. */
  35351. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35352. /**
  35353. * Use this method to simulate a pointer down on a mesh
  35354. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35355. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35356. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35357. * @returns the current scene
  35358. */
  35359. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35360. /**
  35361. * Use this method to simulate a pointer up on a mesh
  35362. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35363. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35364. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35365. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35366. * @returns the current scene
  35367. */
  35368. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35369. /**
  35370. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35371. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35372. * @returns true if the pointer was captured
  35373. */
  35374. isPointerCaptured(pointerId?: number): boolean;
  35375. /**
  35376. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35377. * @param attachUp defines if you want to attach events to pointerup
  35378. * @param attachDown defines if you want to attach events to pointerdown
  35379. * @param attachMove defines if you want to attach events to pointermove
  35380. */
  35381. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35382. /** Detaches all event handlers*/
  35383. detachControl(): void;
  35384. /**
  35385. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35386. * Delay loaded resources are not taking in account
  35387. * @return true if all required resources are ready
  35388. */
  35389. isReady(): boolean;
  35390. /** Resets all cached information relative to material (including effect and visibility) */
  35391. resetCachedMaterial(): void;
  35392. /**
  35393. * Registers a function to be called before every frame render
  35394. * @param func defines the function to register
  35395. */
  35396. registerBeforeRender(func: () => void): void;
  35397. /**
  35398. * Unregisters a function called before every frame render
  35399. * @param func defines the function to unregister
  35400. */
  35401. unregisterBeforeRender(func: () => void): void;
  35402. /**
  35403. * Registers a function to be called after every frame render
  35404. * @param func defines the function to register
  35405. */
  35406. registerAfterRender(func: () => void): void;
  35407. /**
  35408. * Unregisters a function called after every frame render
  35409. * @param func defines the function to unregister
  35410. */
  35411. unregisterAfterRender(func: () => void): void;
  35412. private _executeOnceBeforeRender;
  35413. /**
  35414. * The provided function will run before render once and will be disposed afterwards.
  35415. * A timeout delay can be provided so that the function will be executed in N ms.
  35416. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35417. * @param func The function to be executed.
  35418. * @param timeout optional delay in ms
  35419. */
  35420. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35421. /** @hidden */
  35422. _addPendingData(data: any): void;
  35423. /** @hidden */
  35424. _removePendingData(data: any): void;
  35425. /**
  35426. * Returns the number of items waiting to be loaded
  35427. * @returns the number of items waiting to be loaded
  35428. */
  35429. getWaitingItemsCount(): number;
  35430. /**
  35431. * Returns a boolean indicating if the scene is still loading data
  35432. */
  35433. readonly isLoading: boolean;
  35434. /**
  35435. * Registers a function to be executed when the scene is ready
  35436. * @param {Function} func - the function to be executed
  35437. */
  35438. executeWhenReady(func: () => void): void;
  35439. /**
  35440. * Returns a promise that resolves when the scene is ready
  35441. * @returns A promise that resolves when the scene is ready
  35442. */
  35443. whenReadyAsync(): Promise<void>;
  35444. /** @hidden */
  35445. _checkIsReady(): void;
  35446. /**
  35447. * Gets all animatable attached to the scene
  35448. */
  35449. readonly animatables: Animatable[];
  35450. /**
  35451. * Resets the last animation time frame.
  35452. * Useful to override when animations start running when loading a scene for the first time.
  35453. */
  35454. resetLastAnimationTimeFrame(): void;
  35455. /**
  35456. * Gets the current view matrix
  35457. * @returns a Matrix
  35458. */
  35459. getViewMatrix(): Matrix;
  35460. /**
  35461. * Gets the current projection matrix
  35462. * @returns a Matrix
  35463. */
  35464. getProjectionMatrix(): Matrix;
  35465. /**
  35466. * Gets the current transform matrix
  35467. * @returns a Matrix made of View * Projection
  35468. */
  35469. getTransformMatrix(): Matrix;
  35470. /**
  35471. * Sets the current transform matrix
  35472. * @param viewL defines the View matrix to use
  35473. * @param projectionL defines the Projection matrix to use
  35474. * @param viewR defines the right View matrix to use (if provided)
  35475. * @param projectionR defines the right Projection matrix to use (if provided)
  35476. */
  35477. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35478. /**
  35479. * Gets the uniform buffer used to store scene data
  35480. * @returns a UniformBuffer
  35481. */
  35482. getSceneUniformBuffer(): UniformBuffer;
  35483. /**
  35484. * Gets an unique (relatively to the current scene) Id
  35485. * @returns an unique number for the scene
  35486. */
  35487. getUniqueId(): number;
  35488. /**
  35489. * Add a mesh to the list of scene's meshes
  35490. * @param newMesh defines the mesh to add
  35491. * @param recursive if all child meshes should also be added to the scene
  35492. */
  35493. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35494. /**
  35495. * Remove a mesh for the list of scene's meshes
  35496. * @param toRemove defines the mesh to remove
  35497. * @param recursive if all child meshes should also be removed from the scene
  35498. * @returns the index where the mesh was in the mesh list
  35499. */
  35500. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35501. /**
  35502. * Add a transform node to the list of scene's transform nodes
  35503. * @param newTransformNode defines the transform node to add
  35504. */
  35505. addTransformNode(newTransformNode: TransformNode): void;
  35506. /**
  35507. * Remove a transform node for the list of scene's transform nodes
  35508. * @param toRemove defines the transform node to remove
  35509. * @returns the index where the transform node was in the transform node list
  35510. */
  35511. removeTransformNode(toRemove: TransformNode): number;
  35512. /**
  35513. * Remove a skeleton for the list of scene's skeletons
  35514. * @param toRemove defines the skeleton to remove
  35515. * @returns the index where the skeleton was in the skeleton list
  35516. */
  35517. removeSkeleton(toRemove: Skeleton): number;
  35518. /**
  35519. * Remove a morph target for the list of scene's morph targets
  35520. * @param toRemove defines the morph target to remove
  35521. * @returns the index where the morph target was in the morph target list
  35522. */
  35523. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35524. /**
  35525. * Remove a light for the list of scene's lights
  35526. * @param toRemove defines the light to remove
  35527. * @returns the index where the light was in the light list
  35528. */
  35529. removeLight(toRemove: Light): number;
  35530. /**
  35531. * Remove a camera for the list of scene's cameras
  35532. * @param toRemove defines the camera to remove
  35533. * @returns the index where the camera was in the camera list
  35534. */
  35535. removeCamera(toRemove: Camera): number;
  35536. /**
  35537. * Remove a particle system for the list of scene's particle systems
  35538. * @param toRemove defines the particle system to remove
  35539. * @returns the index where the particle system was in the particle system list
  35540. */
  35541. removeParticleSystem(toRemove: IParticleSystem): number;
  35542. /**
  35543. * Remove a animation for the list of scene's animations
  35544. * @param toRemove defines the animation to remove
  35545. * @returns the index where the animation was in the animation list
  35546. */
  35547. removeAnimation(toRemove: Animation): number;
  35548. /**
  35549. * Will stop the animation of the given target
  35550. * @param target - the target
  35551. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35552. * @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)
  35553. */
  35554. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35555. /**
  35556. * Removes the given animation group from this scene.
  35557. * @param toRemove The animation group to remove
  35558. * @returns The index of the removed animation group
  35559. */
  35560. removeAnimationGroup(toRemove: AnimationGroup): number;
  35561. /**
  35562. * Removes the given multi-material from this scene.
  35563. * @param toRemove The multi-material to remove
  35564. * @returns The index of the removed multi-material
  35565. */
  35566. removeMultiMaterial(toRemove: MultiMaterial): number;
  35567. /**
  35568. * Removes the given material from this scene.
  35569. * @param toRemove The material to remove
  35570. * @returns The index of the removed material
  35571. */
  35572. removeMaterial(toRemove: Material): number;
  35573. /**
  35574. * Removes the given action manager from this scene.
  35575. * @param toRemove The action manager to remove
  35576. * @returns The index of the removed action manager
  35577. */
  35578. removeActionManager(toRemove: AbstractActionManager): number;
  35579. /**
  35580. * Removes the given texture from this scene.
  35581. * @param toRemove The texture to remove
  35582. * @returns The index of the removed texture
  35583. */
  35584. removeTexture(toRemove: BaseTexture): number;
  35585. /**
  35586. * Adds the given light to this scene
  35587. * @param newLight The light to add
  35588. */
  35589. addLight(newLight: Light): void;
  35590. /**
  35591. * Sorts the list list based on light priorities
  35592. */
  35593. sortLightsByPriority(): void;
  35594. /**
  35595. * Adds the given camera to this scene
  35596. * @param newCamera The camera to add
  35597. */
  35598. addCamera(newCamera: Camera): void;
  35599. /**
  35600. * Adds the given skeleton to this scene
  35601. * @param newSkeleton The skeleton to add
  35602. */
  35603. addSkeleton(newSkeleton: Skeleton): void;
  35604. /**
  35605. * Adds the given particle system to this scene
  35606. * @param newParticleSystem The particle system to add
  35607. */
  35608. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35609. /**
  35610. * Adds the given animation to this scene
  35611. * @param newAnimation The animation to add
  35612. */
  35613. addAnimation(newAnimation: Animation): void;
  35614. /**
  35615. * Adds the given animation group to this scene.
  35616. * @param newAnimationGroup The animation group to add
  35617. */
  35618. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35619. /**
  35620. * Adds the given multi-material to this scene
  35621. * @param newMultiMaterial The multi-material to add
  35622. */
  35623. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35624. /**
  35625. * Adds the given material to this scene
  35626. * @param newMaterial The material to add
  35627. */
  35628. addMaterial(newMaterial: Material): void;
  35629. /**
  35630. * Adds the given morph target to this scene
  35631. * @param newMorphTargetManager The morph target to add
  35632. */
  35633. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35634. /**
  35635. * Adds the given geometry to this scene
  35636. * @param newGeometry The geometry to add
  35637. */
  35638. addGeometry(newGeometry: Geometry): void;
  35639. /**
  35640. * Adds the given action manager to this scene
  35641. * @param newActionManager The action manager to add
  35642. */
  35643. addActionManager(newActionManager: AbstractActionManager): void;
  35644. /**
  35645. * Adds the given texture to this scene.
  35646. * @param newTexture The texture to add
  35647. */
  35648. addTexture(newTexture: BaseTexture): void;
  35649. /**
  35650. * Switch active camera
  35651. * @param newCamera defines the new active camera
  35652. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35653. */
  35654. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35655. /**
  35656. * sets the active camera of the scene using its ID
  35657. * @param id defines the camera's ID
  35658. * @return the new active camera or null if none found.
  35659. */
  35660. setActiveCameraByID(id: string): Nullable<Camera>;
  35661. /**
  35662. * sets the active camera of the scene using its name
  35663. * @param name defines the camera's name
  35664. * @returns the new active camera or null if none found.
  35665. */
  35666. setActiveCameraByName(name: string): Nullable<Camera>;
  35667. /**
  35668. * get an animation group using its name
  35669. * @param name defines the material's name
  35670. * @return the animation group or null if none found.
  35671. */
  35672. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35673. /**
  35674. * Get a material using its unique id
  35675. * @param uniqueId defines the material's unique id
  35676. * @return the material or null if none found.
  35677. */
  35678. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35679. /**
  35680. * get a material using its id
  35681. * @param id defines the material's ID
  35682. * @return the material or null if none found.
  35683. */
  35684. getMaterialByID(id: string): Nullable<Material>;
  35685. /**
  35686. * Gets a the last added material using a given id
  35687. * @param id defines the material's ID
  35688. * @return the last material with the given id or null if none found.
  35689. */
  35690. getLastMaterialByID(id: string): Nullable<Material>;
  35691. /**
  35692. * Gets a material using its name
  35693. * @param name defines the material's name
  35694. * @return the material or null if none found.
  35695. */
  35696. getMaterialByName(name: string): Nullable<Material>;
  35697. /**
  35698. * Get a texture using its unique id
  35699. * @param uniqueId defines the texture's unique id
  35700. * @return the texture or null if none found.
  35701. */
  35702. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35703. /**
  35704. * Gets a camera using its id
  35705. * @param id defines the id to look for
  35706. * @returns the camera or null if not found
  35707. */
  35708. getCameraByID(id: string): Nullable<Camera>;
  35709. /**
  35710. * Gets a camera using its unique id
  35711. * @param uniqueId defines the unique id to look for
  35712. * @returns the camera or null if not found
  35713. */
  35714. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35715. /**
  35716. * Gets a camera using its name
  35717. * @param name defines the camera's name
  35718. * @return the camera or null if none found.
  35719. */
  35720. getCameraByName(name: string): Nullable<Camera>;
  35721. /**
  35722. * Gets a bone using its id
  35723. * @param id defines the bone's id
  35724. * @return the bone or null if not found
  35725. */
  35726. getBoneByID(id: string): Nullable<Bone>;
  35727. /**
  35728. * Gets a bone using its id
  35729. * @param name defines the bone's name
  35730. * @return the bone or null if not found
  35731. */
  35732. getBoneByName(name: string): Nullable<Bone>;
  35733. /**
  35734. * Gets a light node using its name
  35735. * @param name defines the the light's name
  35736. * @return the light or null if none found.
  35737. */
  35738. getLightByName(name: string): Nullable<Light>;
  35739. /**
  35740. * Gets a light node using its id
  35741. * @param id defines the light's id
  35742. * @return the light or null if none found.
  35743. */
  35744. getLightByID(id: string): Nullable<Light>;
  35745. /**
  35746. * Gets a light node using its scene-generated unique ID
  35747. * @param uniqueId defines the light's unique id
  35748. * @return the light or null if none found.
  35749. */
  35750. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35751. /**
  35752. * Gets a particle system by id
  35753. * @param id defines the particle system id
  35754. * @return the corresponding system or null if none found
  35755. */
  35756. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35757. /**
  35758. * Gets a geometry using its ID
  35759. * @param id defines the geometry's id
  35760. * @return the geometry or null if none found.
  35761. */
  35762. getGeometryByID(id: string): Nullable<Geometry>;
  35763. private _getGeometryByUniqueID;
  35764. /**
  35765. * Add a new geometry to this scene
  35766. * @param geometry defines the geometry to be added to the scene.
  35767. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35768. * @return a boolean defining if the geometry was added or not
  35769. */
  35770. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35771. /**
  35772. * Removes an existing geometry
  35773. * @param geometry defines the geometry to be removed from the scene
  35774. * @return a boolean defining if the geometry was removed or not
  35775. */
  35776. removeGeometry(geometry: Geometry): boolean;
  35777. /**
  35778. * Gets the list of geometries attached to the scene
  35779. * @returns an array of Geometry
  35780. */
  35781. getGeometries(): Geometry[];
  35782. /**
  35783. * Gets the first added mesh found of a given ID
  35784. * @param id defines the id to search for
  35785. * @return the mesh found or null if not found at all
  35786. */
  35787. getMeshByID(id: string): Nullable<AbstractMesh>;
  35788. /**
  35789. * Gets a list of meshes using their id
  35790. * @param id defines the id to search for
  35791. * @returns a list of meshes
  35792. */
  35793. getMeshesByID(id: string): Array<AbstractMesh>;
  35794. /**
  35795. * Gets the first added transform node found of a given ID
  35796. * @param id defines the id to search for
  35797. * @return the found transform node or null if not found at all.
  35798. */
  35799. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35800. /**
  35801. * Gets a transform node with its auto-generated unique id
  35802. * @param uniqueId efines the unique id to search for
  35803. * @return the found transform node or null if not found at all.
  35804. */
  35805. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35806. /**
  35807. * Gets a list of transform nodes using their id
  35808. * @param id defines the id to search for
  35809. * @returns a list of transform nodes
  35810. */
  35811. getTransformNodesByID(id: string): Array<TransformNode>;
  35812. /**
  35813. * Gets a mesh with its auto-generated unique id
  35814. * @param uniqueId defines the unique id to search for
  35815. * @return the found mesh or null if not found at all.
  35816. */
  35817. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35818. /**
  35819. * Gets a the last added mesh using a given id
  35820. * @param id defines the id to search for
  35821. * @return the found mesh or null if not found at all.
  35822. */
  35823. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35824. /**
  35825. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35826. * @param id defines the id to search for
  35827. * @return the found node or null if not found at all
  35828. */
  35829. getLastEntryByID(id: string): Nullable<Node>;
  35830. /**
  35831. * Gets a node (Mesh, Camera, Light) using a given id
  35832. * @param id defines the id to search for
  35833. * @return the found node or null if not found at all
  35834. */
  35835. getNodeByID(id: string): Nullable<Node>;
  35836. /**
  35837. * Gets a node (Mesh, Camera, Light) using a given name
  35838. * @param name defines the name to search for
  35839. * @return the found node or null if not found at all.
  35840. */
  35841. getNodeByName(name: string): Nullable<Node>;
  35842. /**
  35843. * Gets a mesh using a given name
  35844. * @param name defines the name to search for
  35845. * @return the found mesh or null if not found at all.
  35846. */
  35847. getMeshByName(name: string): Nullable<AbstractMesh>;
  35848. /**
  35849. * Gets a transform node using a given name
  35850. * @param name defines the name to search for
  35851. * @return the found transform node or null if not found at all.
  35852. */
  35853. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35854. /**
  35855. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35856. * @param id defines the id to search for
  35857. * @return the found skeleton or null if not found at all.
  35858. */
  35859. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35860. /**
  35861. * Gets a skeleton using a given auto generated unique id
  35862. * @param uniqueId defines the unique id to search for
  35863. * @return the found skeleton or null if not found at all.
  35864. */
  35865. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35866. /**
  35867. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35868. * @param id defines the id to search for
  35869. * @return the found skeleton or null if not found at all.
  35870. */
  35871. getSkeletonById(id: string): Nullable<Skeleton>;
  35872. /**
  35873. * Gets a skeleton using a given name
  35874. * @param name defines the name to search for
  35875. * @return the found skeleton or null if not found at all.
  35876. */
  35877. getSkeletonByName(name: string): Nullable<Skeleton>;
  35878. /**
  35879. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35880. * @param id defines the id to search for
  35881. * @return the found morph target manager or null if not found at all.
  35882. */
  35883. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35884. /**
  35885. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35886. * @param id defines the id to search for
  35887. * @return the found morph target or null if not found at all.
  35888. */
  35889. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35890. /**
  35891. * Gets a boolean indicating if the given mesh is active
  35892. * @param mesh defines the mesh to look for
  35893. * @returns true if the mesh is in the active list
  35894. */
  35895. isActiveMesh(mesh: AbstractMesh): boolean;
  35896. /**
  35897. * Return a unique id as a string which can serve as an identifier for the scene
  35898. */
  35899. readonly uid: string;
  35900. /**
  35901. * Add an externaly attached data from its key.
  35902. * This method call will fail and return false, if such key already exists.
  35903. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35904. * @param key the unique key that identifies the data
  35905. * @param data the data object to associate to the key for this Engine instance
  35906. * @return true if no such key were already present and the data was added successfully, false otherwise
  35907. */
  35908. addExternalData<T>(key: string, data: T): boolean;
  35909. /**
  35910. * Get an externaly attached data from its key
  35911. * @param key the unique key that identifies the data
  35912. * @return the associated data, if present (can be null), or undefined if not present
  35913. */
  35914. getExternalData<T>(key: string): Nullable<T>;
  35915. /**
  35916. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35917. * @param key the unique key that identifies the data
  35918. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35919. * @return the associated data, can be null if the factory returned null.
  35920. */
  35921. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35922. /**
  35923. * Remove an externaly attached data from the Engine instance
  35924. * @param key the unique key that identifies the data
  35925. * @return true if the data was successfully removed, false if it doesn't exist
  35926. */
  35927. removeExternalData(key: string): boolean;
  35928. private _evaluateSubMesh;
  35929. /**
  35930. * Clear the processed materials smart array preventing retention point in material dispose.
  35931. */
  35932. freeProcessedMaterials(): void;
  35933. private _preventFreeActiveMeshesAndRenderingGroups;
  35934. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35935. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35936. * when disposing several meshes in a row or a hierarchy of meshes.
  35937. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35938. */
  35939. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35940. /**
  35941. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35942. */
  35943. freeActiveMeshes(): void;
  35944. /**
  35945. * Clear the info related to rendering groups preventing retention points during dispose.
  35946. */
  35947. freeRenderingGroups(): void;
  35948. /** @hidden */
  35949. _isInIntermediateRendering(): boolean;
  35950. /**
  35951. * Lambda returning the list of potentially active meshes.
  35952. */
  35953. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35954. /**
  35955. * Lambda returning the list of potentially active sub meshes.
  35956. */
  35957. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35958. /**
  35959. * Lambda returning the list of potentially intersecting sub meshes.
  35960. */
  35961. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35962. /**
  35963. * Lambda returning the list of potentially colliding sub meshes.
  35964. */
  35965. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35966. private _activeMeshesFrozen;
  35967. private _skipEvaluateActiveMeshesCompletely;
  35968. /**
  35969. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35970. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35971. * @returns the current scene
  35972. */
  35973. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35974. /**
  35975. * Use this function to restart evaluating active meshes on every frame
  35976. * @returns the current scene
  35977. */
  35978. unfreezeActiveMeshes(): Scene;
  35979. private _evaluateActiveMeshes;
  35980. private _activeMesh;
  35981. /**
  35982. * Update the transform matrix to update from the current active camera
  35983. * @param force defines a boolean used to force the update even if cache is up to date
  35984. */
  35985. updateTransformMatrix(force?: boolean): void;
  35986. private _bindFrameBuffer;
  35987. /** @hidden */
  35988. _allowPostProcessClearColor: boolean;
  35989. /** @hidden */
  35990. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35991. private _processSubCameras;
  35992. private _checkIntersections;
  35993. /** @hidden */
  35994. _advancePhysicsEngineStep(step: number): void;
  35995. /**
  35996. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35997. */
  35998. getDeterministicFrameTime: () => number;
  35999. /** @hidden */
  36000. _animate(): void;
  36001. /** Execute all animations (for a frame) */
  36002. animate(): void;
  36003. /**
  36004. * Render the scene
  36005. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36006. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36007. */
  36008. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36009. /**
  36010. * Freeze all materials
  36011. * A frozen material will not be updatable but should be faster to render
  36012. */
  36013. freezeMaterials(): void;
  36014. /**
  36015. * Unfreeze all materials
  36016. * A frozen material will not be updatable but should be faster to render
  36017. */
  36018. unfreezeMaterials(): void;
  36019. /**
  36020. * Releases all held ressources
  36021. */
  36022. dispose(): void;
  36023. /**
  36024. * Gets if the scene is already disposed
  36025. */
  36026. readonly isDisposed: boolean;
  36027. /**
  36028. * Call this function to reduce memory footprint of the scene.
  36029. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36030. */
  36031. clearCachedVertexData(): void;
  36032. /**
  36033. * This function will remove the local cached buffer data from texture.
  36034. * It will save memory but will prevent the texture from being rebuilt
  36035. */
  36036. cleanCachedTextureBuffer(): void;
  36037. /**
  36038. * Get the world extend vectors with an optional filter
  36039. *
  36040. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36041. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36042. */
  36043. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36044. min: Vector3;
  36045. max: Vector3;
  36046. };
  36047. /**
  36048. * Creates a ray that can be used to pick in the scene
  36049. * @param x defines the x coordinate of the origin (on-screen)
  36050. * @param y defines the y coordinate of the origin (on-screen)
  36051. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36052. * @param camera defines the camera to use for the picking
  36053. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36054. * @returns a Ray
  36055. */
  36056. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36057. /**
  36058. * Creates a ray that can be used to pick in the scene
  36059. * @param x defines the x coordinate of the origin (on-screen)
  36060. * @param y defines the y coordinate of the origin (on-screen)
  36061. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36062. * @param result defines the ray where to store the picking ray
  36063. * @param camera defines the camera to use for the picking
  36064. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36065. * @returns the current scene
  36066. */
  36067. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36068. /**
  36069. * Creates a ray that can be used to pick in the scene
  36070. * @param x defines the x coordinate of the origin (on-screen)
  36071. * @param y defines the y coordinate of the origin (on-screen)
  36072. * @param camera defines the camera to use for the picking
  36073. * @returns a Ray
  36074. */
  36075. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36076. /**
  36077. * Creates a ray that can be used to pick in the scene
  36078. * @param x defines the x coordinate of the origin (on-screen)
  36079. * @param y defines the y coordinate of the origin (on-screen)
  36080. * @param result defines the ray where to store the picking ray
  36081. * @param camera defines the camera to use for the picking
  36082. * @returns the current scene
  36083. */
  36084. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36085. /** Launch a ray to try to pick a mesh in the scene
  36086. * @param x position on screen
  36087. * @param y position on screen
  36088. * @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
  36089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36090. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36091. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36092. * @returns a PickingInfo
  36093. */
  36094. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36095. /** Use the given ray to pick a mesh in the scene
  36096. * @param ray The ray to use to pick meshes
  36097. * @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
  36098. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36100. * @returns a PickingInfo
  36101. */
  36102. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36103. /**
  36104. * Launch a ray to try to pick a mesh in the scene
  36105. * @param x X position on screen
  36106. * @param y Y position on screen
  36107. * @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
  36108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36110. * @returns an array of PickingInfo
  36111. */
  36112. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36113. /**
  36114. * Launch a ray to try to pick a mesh in the scene
  36115. * @param ray Ray to use
  36116. * @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
  36117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36118. * @returns an array of PickingInfo
  36119. */
  36120. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36121. /**
  36122. * Force the value of meshUnderPointer
  36123. * @param mesh defines the mesh to use
  36124. */
  36125. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36126. /**
  36127. * Gets the mesh under the pointer
  36128. * @returns a Mesh or null if no mesh is under the pointer
  36129. */
  36130. getPointerOverMesh(): Nullable<AbstractMesh>;
  36131. /** @hidden */
  36132. _rebuildGeometries(): void;
  36133. /** @hidden */
  36134. _rebuildTextures(): void;
  36135. private _getByTags;
  36136. /**
  36137. * Get a list of meshes by tags
  36138. * @param tagsQuery defines the tags query to use
  36139. * @param forEach defines a predicate used to filter results
  36140. * @returns an array of Mesh
  36141. */
  36142. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36143. /**
  36144. * Get a list of cameras by tags
  36145. * @param tagsQuery defines the tags query to use
  36146. * @param forEach defines a predicate used to filter results
  36147. * @returns an array of Camera
  36148. */
  36149. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36150. /**
  36151. * Get a list of lights by tags
  36152. * @param tagsQuery defines the tags query to use
  36153. * @param forEach defines a predicate used to filter results
  36154. * @returns an array of Light
  36155. */
  36156. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36157. /**
  36158. * Get a list of materials by tags
  36159. * @param tagsQuery defines the tags query to use
  36160. * @param forEach defines a predicate used to filter results
  36161. * @returns an array of Material
  36162. */
  36163. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36164. /**
  36165. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36166. * This allowed control for front to back rendering or reversly depending of the special needs.
  36167. *
  36168. * @param renderingGroupId The rendering group id corresponding to its index
  36169. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36170. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36171. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36172. */
  36173. 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;
  36174. /**
  36175. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36176. *
  36177. * @param renderingGroupId The rendering group id corresponding to its index
  36178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36179. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36180. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36181. */
  36182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36183. /**
  36184. * Gets the current auto clear configuration for one rendering group of the rendering
  36185. * manager.
  36186. * @param index the rendering group index to get the information for
  36187. * @returns The auto clear setup for the requested rendering group
  36188. */
  36189. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36190. private _blockMaterialDirtyMechanism;
  36191. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36192. blockMaterialDirtyMechanism: boolean;
  36193. /**
  36194. * Will flag all materials as dirty to trigger new shader compilation
  36195. * @param flag defines the flag used to specify which material part must be marked as dirty
  36196. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36197. */
  36198. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36199. /** @hidden */
  36200. _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;
  36201. /** @hidden */
  36202. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36203. /** @hidden */
  36204. _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;
  36205. /** @hidden */
  36206. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36207. /** @hidden */
  36208. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36209. /** @hidden */
  36210. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36211. }
  36212. }
  36213. declare module "babylonjs/assetContainer" {
  36214. import { AbstractScene } from "babylonjs/abstractScene";
  36215. import { Scene } from "babylonjs/scene";
  36216. import { Mesh } from "babylonjs/Meshes/mesh";
  36217. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36218. import { Skeleton } from "babylonjs/Bones/skeleton";
  36219. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36220. /**
  36221. * Set of assets to keep when moving a scene into an asset container.
  36222. */
  36223. export class KeepAssets extends AbstractScene {
  36224. }
  36225. /**
  36226. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36227. */
  36228. export class InstantiatedEntries {
  36229. /**
  36230. * List of new root nodes (eg. nodes with no parent)
  36231. */
  36232. rootNodes: TransformNode[];
  36233. /**
  36234. * List of new skeletons
  36235. */
  36236. skeletons: Skeleton[];
  36237. /**
  36238. * List of new animation groups
  36239. */
  36240. animationGroups: AnimationGroup[];
  36241. }
  36242. /**
  36243. * Container with a set of assets that can be added or removed from a scene.
  36244. */
  36245. export class AssetContainer extends AbstractScene {
  36246. /**
  36247. * The scene the AssetContainer belongs to.
  36248. */
  36249. scene: Scene;
  36250. /**
  36251. * Instantiates an AssetContainer.
  36252. * @param scene The scene the AssetContainer belongs to.
  36253. */
  36254. constructor(scene: Scene);
  36255. /**
  36256. * Instantiate or clone all meshes and add the new ones to the scene.
  36257. * Skeletons and animation groups will all be cloned
  36258. * @param nameFunction defines an optional function used to get new names for clones
  36259. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36260. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36261. */
  36262. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36263. /**
  36264. * Adds all the assets from the container to the scene.
  36265. */
  36266. addAllToScene(): void;
  36267. /**
  36268. * Removes all the assets in the container from the scene
  36269. */
  36270. removeAllFromScene(): void;
  36271. /**
  36272. * Disposes all the assets in the container
  36273. */
  36274. dispose(): void;
  36275. private _moveAssets;
  36276. /**
  36277. * Removes all the assets contained in the scene and adds them to the container.
  36278. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36279. */
  36280. moveAllFromScene(keepAssets?: KeepAssets): void;
  36281. /**
  36282. * 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.
  36283. * @returns the root mesh
  36284. */
  36285. createRootMesh(): Mesh;
  36286. }
  36287. }
  36288. declare module "babylonjs/abstractScene" {
  36289. import { Scene } from "babylonjs/scene";
  36290. import { Nullable } from "babylonjs/types";
  36291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36293. import { Geometry } from "babylonjs/Meshes/geometry";
  36294. import { Skeleton } from "babylonjs/Bones/skeleton";
  36295. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36296. import { AssetContainer } from "babylonjs/assetContainer";
  36297. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36298. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36300. import { Material } from "babylonjs/Materials/material";
  36301. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36302. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36303. import { Camera } from "babylonjs/Cameras/camera";
  36304. import { Light } from "babylonjs/Lights/light";
  36305. import { Node } from "babylonjs/node";
  36306. import { Animation } from "babylonjs/Animations/animation";
  36307. /**
  36308. * Defines how the parser contract is defined.
  36309. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36310. */
  36311. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36312. /**
  36313. * Defines how the individual parser contract is defined.
  36314. * These parser can parse an individual asset
  36315. */
  36316. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36317. /**
  36318. * Base class of the scene acting as a container for the different elements composing a scene.
  36319. * This class is dynamically extended by the different components of the scene increasing
  36320. * flexibility and reducing coupling
  36321. */
  36322. export abstract class AbstractScene {
  36323. /**
  36324. * Stores the list of available parsers in the application.
  36325. */
  36326. private static _BabylonFileParsers;
  36327. /**
  36328. * Stores the list of available individual parsers in the application.
  36329. */
  36330. private static _IndividualBabylonFileParsers;
  36331. /**
  36332. * Adds a parser in the list of available ones
  36333. * @param name Defines the name of the parser
  36334. * @param parser Defines the parser to add
  36335. */
  36336. static AddParser(name: string, parser: BabylonFileParser): void;
  36337. /**
  36338. * Gets a general parser from the list of avaialble ones
  36339. * @param name Defines the name of the parser
  36340. * @returns the requested parser or null
  36341. */
  36342. static GetParser(name: string): Nullable<BabylonFileParser>;
  36343. /**
  36344. * Adds n individual parser in the list of available ones
  36345. * @param name Defines the name of the parser
  36346. * @param parser Defines the parser to add
  36347. */
  36348. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36349. /**
  36350. * Gets an individual parser from the list of avaialble ones
  36351. * @param name Defines the name of the parser
  36352. * @returns the requested parser or null
  36353. */
  36354. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36355. /**
  36356. * Parser json data and populate both a scene and its associated container object
  36357. * @param jsonData Defines the data to parse
  36358. * @param scene Defines the scene to parse the data for
  36359. * @param container Defines the container attached to the parsing sequence
  36360. * @param rootUrl Defines the root url of the data
  36361. */
  36362. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36363. /**
  36364. * Gets the list of root nodes (ie. nodes with no parent)
  36365. */
  36366. rootNodes: Node[];
  36367. /** All of the cameras added to this scene
  36368. * @see http://doc.babylonjs.com/babylon101/cameras
  36369. */
  36370. cameras: Camera[];
  36371. /**
  36372. * All of the lights added to this scene
  36373. * @see http://doc.babylonjs.com/babylon101/lights
  36374. */
  36375. lights: Light[];
  36376. /**
  36377. * All of the (abstract) meshes added to this scene
  36378. */
  36379. meshes: AbstractMesh[];
  36380. /**
  36381. * The list of skeletons added to the scene
  36382. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36383. */
  36384. skeletons: Skeleton[];
  36385. /**
  36386. * All of the particle systems added to this scene
  36387. * @see http://doc.babylonjs.com/babylon101/particles
  36388. */
  36389. particleSystems: IParticleSystem[];
  36390. /**
  36391. * Gets a list of Animations associated with the scene
  36392. */
  36393. animations: Animation[];
  36394. /**
  36395. * All of the animation groups added to this scene
  36396. * @see http://doc.babylonjs.com/how_to/group
  36397. */
  36398. animationGroups: AnimationGroup[];
  36399. /**
  36400. * All of the multi-materials added to this scene
  36401. * @see http://doc.babylonjs.com/how_to/multi_materials
  36402. */
  36403. multiMaterials: MultiMaterial[];
  36404. /**
  36405. * All of the materials added to this scene
  36406. * In the context of a Scene, it is not supposed to be modified manually.
  36407. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36408. * Note also that the order of the Material within the array is not significant and might change.
  36409. * @see http://doc.babylonjs.com/babylon101/materials
  36410. */
  36411. materials: Material[];
  36412. /**
  36413. * The list of morph target managers added to the scene
  36414. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36415. */
  36416. morphTargetManagers: MorphTargetManager[];
  36417. /**
  36418. * The list of geometries used in the scene.
  36419. */
  36420. geometries: Geometry[];
  36421. /**
  36422. * All of the tranform nodes added to this scene
  36423. * In the context of a Scene, it is not supposed to be modified manually.
  36424. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36425. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36426. * @see http://doc.babylonjs.com/how_to/transformnode
  36427. */
  36428. transformNodes: TransformNode[];
  36429. /**
  36430. * ActionManagers available on the scene.
  36431. */
  36432. actionManagers: AbstractActionManager[];
  36433. /**
  36434. * Textures to keep.
  36435. */
  36436. textures: BaseTexture[];
  36437. /**
  36438. * Environment texture for the scene
  36439. */
  36440. environmentTexture: Nullable<BaseTexture>;
  36441. }
  36442. }
  36443. declare module "babylonjs/Audio/sound" {
  36444. import { Observable } from "babylonjs/Misc/observable";
  36445. import { Vector3 } from "babylonjs/Maths/math.vector";
  36446. import { Nullable } from "babylonjs/types";
  36447. import { Scene } from "babylonjs/scene";
  36448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36449. /**
  36450. * Interface used to define options for Sound class
  36451. */
  36452. export interface ISoundOptions {
  36453. /**
  36454. * Does the sound autoplay once loaded.
  36455. */
  36456. autoplay?: boolean;
  36457. /**
  36458. * Does the sound loop after it finishes playing once.
  36459. */
  36460. loop?: boolean;
  36461. /**
  36462. * Sound's volume
  36463. */
  36464. volume?: number;
  36465. /**
  36466. * Is it a spatial sound?
  36467. */
  36468. spatialSound?: boolean;
  36469. /**
  36470. * Maximum distance to hear that sound
  36471. */
  36472. maxDistance?: number;
  36473. /**
  36474. * Uses user defined attenuation function
  36475. */
  36476. useCustomAttenuation?: boolean;
  36477. /**
  36478. * Define the roll off factor of spatial sounds.
  36479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36480. */
  36481. rolloffFactor?: number;
  36482. /**
  36483. * Define the reference distance the sound should be heard perfectly.
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36485. */
  36486. refDistance?: number;
  36487. /**
  36488. * Define the distance attenuation model the sound will follow.
  36489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36490. */
  36491. distanceModel?: string;
  36492. /**
  36493. * Defines the playback speed (1 by default)
  36494. */
  36495. playbackRate?: number;
  36496. /**
  36497. * Defines if the sound is from a streaming source
  36498. */
  36499. streaming?: boolean;
  36500. /**
  36501. * Defines an optional length (in seconds) inside the sound file
  36502. */
  36503. length?: number;
  36504. /**
  36505. * Defines an optional offset (in seconds) inside the sound file
  36506. */
  36507. offset?: number;
  36508. /**
  36509. * If true, URLs will not be required to state the audio file codec to use.
  36510. */
  36511. skipCodecCheck?: boolean;
  36512. }
  36513. /**
  36514. * Defines a sound that can be played in the application.
  36515. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36517. */
  36518. export class Sound {
  36519. /**
  36520. * The name of the sound in the scene.
  36521. */
  36522. name: string;
  36523. /**
  36524. * Does the sound autoplay once loaded.
  36525. */
  36526. autoplay: boolean;
  36527. /**
  36528. * Does the sound loop after it finishes playing once.
  36529. */
  36530. loop: boolean;
  36531. /**
  36532. * Does the sound use a custom attenuation curve to simulate the falloff
  36533. * happening when the source gets further away from the camera.
  36534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36535. */
  36536. useCustomAttenuation: boolean;
  36537. /**
  36538. * The sound track id this sound belongs to.
  36539. */
  36540. soundTrackId: number;
  36541. /**
  36542. * Is this sound currently played.
  36543. */
  36544. isPlaying: boolean;
  36545. /**
  36546. * Is this sound currently paused.
  36547. */
  36548. isPaused: boolean;
  36549. /**
  36550. * Does this sound enables spatial sound.
  36551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36552. */
  36553. spatialSound: boolean;
  36554. /**
  36555. * Define the reference distance the sound should be heard perfectly.
  36556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36557. */
  36558. refDistance: number;
  36559. /**
  36560. * Define the roll off factor of spatial sounds.
  36561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36562. */
  36563. rolloffFactor: number;
  36564. /**
  36565. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36567. */
  36568. maxDistance: number;
  36569. /**
  36570. * Define the distance attenuation model the sound will follow.
  36571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36572. */
  36573. distanceModel: string;
  36574. /**
  36575. * @hidden
  36576. * Back Compat
  36577. **/
  36578. onended: () => any;
  36579. /**
  36580. * Observable event when the current playing sound finishes.
  36581. */
  36582. onEndedObservable: Observable<Sound>;
  36583. private _panningModel;
  36584. private _playbackRate;
  36585. private _streaming;
  36586. private _startTime;
  36587. private _startOffset;
  36588. private _position;
  36589. /** @hidden */
  36590. _positionInEmitterSpace: boolean;
  36591. private _localDirection;
  36592. private _volume;
  36593. private _isReadyToPlay;
  36594. private _isDirectional;
  36595. private _readyToPlayCallback;
  36596. private _audioBuffer;
  36597. private _soundSource;
  36598. private _streamingSource;
  36599. private _soundPanner;
  36600. private _soundGain;
  36601. private _inputAudioNode;
  36602. private _outputAudioNode;
  36603. private _coneInnerAngle;
  36604. private _coneOuterAngle;
  36605. private _coneOuterGain;
  36606. private _scene;
  36607. private _connectedTransformNode;
  36608. private _customAttenuationFunction;
  36609. private _registerFunc;
  36610. private _isOutputConnected;
  36611. private _htmlAudioElement;
  36612. private _urlType;
  36613. private _length?;
  36614. private _offset?;
  36615. /** @hidden */
  36616. static _SceneComponentInitialization: (scene: Scene) => void;
  36617. /**
  36618. * Create a sound and attach it to a scene
  36619. * @param name Name of your sound
  36620. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36621. * @param scene defines the scene the sound belongs to
  36622. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36623. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36624. */
  36625. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36626. /**
  36627. * Release the sound and its associated resources
  36628. */
  36629. dispose(): void;
  36630. /**
  36631. * Gets if the sounds is ready to be played or not.
  36632. * @returns true if ready, otherwise false
  36633. */
  36634. isReady(): boolean;
  36635. private _soundLoaded;
  36636. /**
  36637. * Sets the data of the sound from an audiobuffer
  36638. * @param audioBuffer The audioBuffer containing the data
  36639. */
  36640. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36641. /**
  36642. * Updates the current sounds options such as maxdistance, loop...
  36643. * @param options A JSON object containing values named as the object properties
  36644. */
  36645. updateOptions(options: ISoundOptions): void;
  36646. private _createSpatialParameters;
  36647. private _updateSpatialParameters;
  36648. /**
  36649. * Switch the panning model to HRTF:
  36650. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36652. */
  36653. switchPanningModelToHRTF(): void;
  36654. /**
  36655. * Switch the panning model to Equal Power:
  36656. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36658. */
  36659. switchPanningModelToEqualPower(): void;
  36660. private _switchPanningModel;
  36661. /**
  36662. * Connect this sound to a sound track audio node like gain...
  36663. * @param soundTrackAudioNode the sound track audio node to connect to
  36664. */
  36665. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36666. /**
  36667. * Transform this sound into a directional source
  36668. * @param coneInnerAngle Size of the inner cone in degree
  36669. * @param coneOuterAngle Size of the outer cone in degree
  36670. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36671. */
  36672. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36673. /**
  36674. * Gets or sets the inner angle for the directional cone.
  36675. */
  36676. /**
  36677. * Gets or sets the inner angle for the directional cone.
  36678. */
  36679. directionalConeInnerAngle: number;
  36680. /**
  36681. * Gets or sets the outer angle for the directional cone.
  36682. */
  36683. /**
  36684. * Gets or sets the outer angle for the directional cone.
  36685. */
  36686. directionalConeOuterAngle: number;
  36687. /**
  36688. * Sets the position of the emitter if spatial sound is enabled
  36689. * @param newPosition Defines the new posisiton
  36690. */
  36691. setPosition(newPosition: Vector3): void;
  36692. /**
  36693. * Sets the local direction of the emitter if spatial sound is enabled
  36694. * @param newLocalDirection Defines the new local direction
  36695. */
  36696. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36697. private _updateDirection;
  36698. /** @hidden */
  36699. updateDistanceFromListener(): void;
  36700. /**
  36701. * Sets a new custom attenuation function for the sound.
  36702. * @param callback Defines the function used for the attenuation
  36703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36704. */
  36705. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36706. /**
  36707. * Play the sound
  36708. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36709. * @param offset (optional) Start the sound at a specific time in seconds
  36710. * @param length (optional) Sound duration (in seconds)
  36711. */
  36712. play(time?: number, offset?: number, length?: number): void;
  36713. private _onended;
  36714. /**
  36715. * Stop the sound
  36716. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36717. */
  36718. stop(time?: number): void;
  36719. /**
  36720. * Put the sound in pause
  36721. */
  36722. pause(): void;
  36723. /**
  36724. * Sets a dedicated volume for this sounds
  36725. * @param newVolume Define the new volume of the sound
  36726. * @param time Define time for gradual change to new volume
  36727. */
  36728. setVolume(newVolume: number, time?: number): void;
  36729. /**
  36730. * Set the sound play back rate
  36731. * @param newPlaybackRate Define the playback rate the sound should be played at
  36732. */
  36733. setPlaybackRate(newPlaybackRate: number): void;
  36734. /**
  36735. * Gets the volume of the sound.
  36736. * @returns the volume of the sound
  36737. */
  36738. getVolume(): number;
  36739. /**
  36740. * Attach the sound to a dedicated mesh
  36741. * @param transformNode The transform node to connect the sound with
  36742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36743. */
  36744. attachToMesh(transformNode: TransformNode): void;
  36745. /**
  36746. * Detach the sound from the previously attached mesh
  36747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36748. */
  36749. detachFromMesh(): void;
  36750. private _onRegisterAfterWorldMatrixUpdate;
  36751. /**
  36752. * Clone the current sound in the scene.
  36753. * @returns the new sound clone
  36754. */
  36755. clone(): Nullable<Sound>;
  36756. /**
  36757. * Gets the current underlying audio buffer containing the data
  36758. * @returns the audio buffer
  36759. */
  36760. getAudioBuffer(): Nullable<AudioBuffer>;
  36761. /**
  36762. * Serializes the Sound in a JSON representation
  36763. * @returns the JSON representation of the sound
  36764. */
  36765. serialize(): any;
  36766. /**
  36767. * Parse a JSON representation of a sound to innstantiate in a given scene
  36768. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36769. * @param scene Define the scene the new parsed sound should be created in
  36770. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36771. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36772. * @returns the newly parsed sound
  36773. */
  36774. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36775. }
  36776. }
  36777. declare module "babylonjs/Actions/directAudioActions" {
  36778. import { Action } from "babylonjs/Actions/action";
  36779. import { Condition } from "babylonjs/Actions/condition";
  36780. import { Sound } from "babylonjs/Audio/sound";
  36781. /**
  36782. * This defines an action helpful to play a defined sound on a triggered action.
  36783. */
  36784. export class PlaySoundAction extends Action {
  36785. private _sound;
  36786. /**
  36787. * Instantiate the action
  36788. * @param triggerOptions defines the trigger options
  36789. * @param sound defines the sound to play
  36790. * @param condition defines the trigger related conditions
  36791. */
  36792. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36793. /** @hidden */
  36794. _prepare(): void;
  36795. /**
  36796. * Execute the action and play the sound.
  36797. */
  36798. execute(): void;
  36799. /**
  36800. * Serializes the actions and its related information.
  36801. * @param parent defines the object to serialize in
  36802. * @returns the serialized object
  36803. */
  36804. serialize(parent: any): any;
  36805. }
  36806. /**
  36807. * This defines an action helpful to stop a defined sound on a triggered action.
  36808. */
  36809. export class StopSoundAction extends Action {
  36810. private _sound;
  36811. /**
  36812. * Instantiate the action
  36813. * @param triggerOptions defines the trigger options
  36814. * @param sound defines the sound to stop
  36815. * @param condition defines the trigger related conditions
  36816. */
  36817. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36818. /** @hidden */
  36819. _prepare(): void;
  36820. /**
  36821. * Execute the action and stop the sound.
  36822. */
  36823. execute(): void;
  36824. /**
  36825. * Serializes the actions and its related information.
  36826. * @param parent defines the object to serialize in
  36827. * @returns the serialized object
  36828. */
  36829. serialize(parent: any): any;
  36830. }
  36831. }
  36832. declare module "babylonjs/Actions/interpolateValueAction" {
  36833. import { Action } from "babylonjs/Actions/action";
  36834. import { Condition } from "babylonjs/Actions/condition";
  36835. import { Observable } from "babylonjs/Misc/observable";
  36836. /**
  36837. * This defines an action responsible to change the value of a property
  36838. * by interpolating between its current value and the newly set one once triggered.
  36839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36840. */
  36841. export class InterpolateValueAction extends Action {
  36842. /**
  36843. * Defines the path of the property where the value should be interpolated
  36844. */
  36845. propertyPath: string;
  36846. /**
  36847. * Defines the target value at the end of the interpolation.
  36848. */
  36849. value: any;
  36850. /**
  36851. * Defines the time it will take for the property to interpolate to the value.
  36852. */
  36853. duration: number;
  36854. /**
  36855. * Defines if the other scene animations should be stopped when the action has been triggered
  36856. */
  36857. stopOtherAnimations?: boolean;
  36858. /**
  36859. * Defines a callback raised once the interpolation animation has been done.
  36860. */
  36861. onInterpolationDone?: () => void;
  36862. /**
  36863. * Observable triggered once the interpolation animation has been done.
  36864. */
  36865. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36866. private _target;
  36867. private _effectiveTarget;
  36868. private _property;
  36869. /**
  36870. * Instantiate the action
  36871. * @param triggerOptions defines the trigger options
  36872. * @param target defines the object containing the value to interpolate
  36873. * @param propertyPath defines the path to the property in the target object
  36874. * @param value defines the target value at the end of the interpolation
  36875. * @param duration deines the time it will take for the property to interpolate to the value.
  36876. * @param condition defines the trigger related conditions
  36877. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36878. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36879. */
  36880. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36881. /** @hidden */
  36882. _prepare(): void;
  36883. /**
  36884. * Execute the action starts the value interpolation.
  36885. */
  36886. execute(): void;
  36887. /**
  36888. * Serializes the actions and its related information.
  36889. * @param parent defines the object to serialize in
  36890. * @returns the serialized object
  36891. */
  36892. serialize(parent: any): any;
  36893. }
  36894. }
  36895. declare module "babylonjs/Actions/index" {
  36896. export * from "babylonjs/Actions/abstractActionManager";
  36897. export * from "babylonjs/Actions/action";
  36898. export * from "babylonjs/Actions/actionEvent";
  36899. export * from "babylonjs/Actions/actionManager";
  36900. export * from "babylonjs/Actions/condition";
  36901. export * from "babylonjs/Actions/directActions";
  36902. export * from "babylonjs/Actions/directAudioActions";
  36903. export * from "babylonjs/Actions/interpolateValueAction";
  36904. }
  36905. declare module "babylonjs/Animations/index" {
  36906. export * from "babylonjs/Animations/animatable";
  36907. export * from "babylonjs/Animations/animation";
  36908. export * from "babylonjs/Animations/animationGroup";
  36909. export * from "babylonjs/Animations/animationPropertiesOverride";
  36910. export * from "babylonjs/Animations/easing";
  36911. export * from "babylonjs/Animations/runtimeAnimation";
  36912. export * from "babylonjs/Animations/animationEvent";
  36913. export * from "babylonjs/Animations/animationGroup";
  36914. export * from "babylonjs/Animations/animationKey";
  36915. export * from "babylonjs/Animations/animationRange";
  36916. export * from "babylonjs/Animations/animatable.interface";
  36917. }
  36918. declare module "babylonjs/Audio/soundTrack" {
  36919. import { Sound } from "babylonjs/Audio/sound";
  36920. import { Analyser } from "babylonjs/Audio/analyser";
  36921. import { Scene } from "babylonjs/scene";
  36922. /**
  36923. * Options allowed during the creation of a sound track.
  36924. */
  36925. export interface ISoundTrackOptions {
  36926. /**
  36927. * The volume the sound track should take during creation
  36928. */
  36929. volume?: number;
  36930. /**
  36931. * Define if the sound track is the main sound track of the scene
  36932. */
  36933. mainTrack?: boolean;
  36934. }
  36935. /**
  36936. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36937. * It will be also used in a future release to apply effects on a specific track.
  36938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36939. */
  36940. export class SoundTrack {
  36941. /**
  36942. * The unique identifier of the sound track in the scene.
  36943. */
  36944. id: number;
  36945. /**
  36946. * The list of sounds included in the sound track.
  36947. */
  36948. soundCollection: Array<Sound>;
  36949. private _outputAudioNode;
  36950. private _scene;
  36951. private _connectedAnalyser;
  36952. private _options;
  36953. private _isInitialized;
  36954. /**
  36955. * Creates a new sound track.
  36956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36957. * @param scene Define the scene the sound track belongs to
  36958. * @param options
  36959. */
  36960. constructor(scene: Scene, options?: ISoundTrackOptions);
  36961. private _initializeSoundTrackAudioGraph;
  36962. /**
  36963. * Release the sound track and its associated resources
  36964. */
  36965. dispose(): void;
  36966. /**
  36967. * Adds a sound to this sound track
  36968. * @param sound define the cound to add
  36969. * @ignoreNaming
  36970. */
  36971. AddSound(sound: Sound): void;
  36972. /**
  36973. * Removes a sound to this sound track
  36974. * @param sound define the cound to remove
  36975. * @ignoreNaming
  36976. */
  36977. RemoveSound(sound: Sound): void;
  36978. /**
  36979. * Set a global volume for the full sound track.
  36980. * @param newVolume Define the new volume of the sound track
  36981. */
  36982. setVolume(newVolume: number): void;
  36983. /**
  36984. * Switch the panning model to HRTF:
  36985. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36987. */
  36988. switchPanningModelToHRTF(): void;
  36989. /**
  36990. * Switch the panning model to Equal Power:
  36991. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36993. */
  36994. switchPanningModelToEqualPower(): void;
  36995. /**
  36996. * Connect the sound track to an audio analyser allowing some amazing
  36997. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36999. * @param analyser The analyser to connect to the engine
  37000. */
  37001. connectToAnalyser(analyser: Analyser): void;
  37002. }
  37003. }
  37004. declare module "babylonjs/Audio/audioSceneComponent" {
  37005. import { Sound } from "babylonjs/Audio/sound";
  37006. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37007. import { Nullable } from "babylonjs/types";
  37008. import { Vector3 } from "babylonjs/Maths/math.vector";
  37009. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37010. import { Scene } from "babylonjs/scene";
  37011. import { AbstractScene } from "babylonjs/abstractScene";
  37012. import "babylonjs/Audio/audioEngine";
  37013. module "babylonjs/abstractScene" {
  37014. interface AbstractScene {
  37015. /**
  37016. * The list of sounds used in the scene.
  37017. */
  37018. sounds: Nullable<Array<Sound>>;
  37019. }
  37020. }
  37021. module "babylonjs/scene" {
  37022. interface Scene {
  37023. /**
  37024. * @hidden
  37025. * Backing field
  37026. */
  37027. _mainSoundTrack: SoundTrack;
  37028. /**
  37029. * The main sound track played by the scene.
  37030. * It cotains your primary collection of sounds.
  37031. */
  37032. mainSoundTrack: SoundTrack;
  37033. /**
  37034. * The list of sound tracks added to the scene
  37035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37036. */
  37037. soundTracks: Nullable<Array<SoundTrack>>;
  37038. /**
  37039. * Gets a sound using a given name
  37040. * @param name defines the name to search for
  37041. * @return the found sound or null if not found at all.
  37042. */
  37043. getSoundByName(name: string): Nullable<Sound>;
  37044. /**
  37045. * Gets or sets if audio support is enabled
  37046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37047. */
  37048. audioEnabled: boolean;
  37049. /**
  37050. * Gets or sets if audio will be output to headphones
  37051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37052. */
  37053. headphone: boolean;
  37054. /**
  37055. * Gets or sets custom audio listener position provider
  37056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37057. */
  37058. audioListenerPositionProvider: Nullable<() => Vector3>;
  37059. /**
  37060. * Gets or sets a refresh rate when using 3D audio positioning
  37061. */
  37062. audioPositioningRefreshRate: number;
  37063. }
  37064. }
  37065. /**
  37066. * Defines the sound scene component responsible to manage any sounds
  37067. * in a given scene.
  37068. */
  37069. export class AudioSceneComponent implements ISceneSerializableComponent {
  37070. /**
  37071. * The component name helpfull to identify the component in the list of scene components.
  37072. */
  37073. readonly name: string;
  37074. /**
  37075. * The scene the component belongs to.
  37076. */
  37077. scene: Scene;
  37078. private _audioEnabled;
  37079. /**
  37080. * Gets whether audio is enabled or not.
  37081. * Please use related enable/disable method to switch state.
  37082. */
  37083. readonly audioEnabled: boolean;
  37084. private _headphone;
  37085. /**
  37086. * Gets whether audio is outputing to headphone or not.
  37087. * Please use the according Switch methods to change output.
  37088. */
  37089. readonly headphone: boolean;
  37090. /**
  37091. * Gets or sets a refresh rate when using 3D audio positioning
  37092. */
  37093. audioPositioningRefreshRate: number;
  37094. private _audioListenerPositionProvider;
  37095. /**
  37096. * Gets the current audio listener position provider
  37097. */
  37098. /**
  37099. * Sets a custom listener position for all sounds in the scene
  37100. * By default, this is the position of the first active camera
  37101. */
  37102. audioListenerPositionProvider: Nullable<() => Vector3>;
  37103. /**
  37104. * Creates a new instance of the component for the given scene
  37105. * @param scene Defines the scene to register the component in
  37106. */
  37107. constructor(scene: Scene);
  37108. /**
  37109. * Registers the component in a given scene
  37110. */
  37111. register(): void;
  37112. /**
  37113. * Rebuilds the elements related to this component in case of
  37114. * context lost for instance.
  37115. */
  37116. rebuild(): void;
  37117. /**
  37118. * Serializes the component data to the specified json object
  37119. * @param serializationObject The object to serialize to
  37120. */
  37121. serialize(serializationObject: any): void;
  37122. /**
  37123. * Adds all the elements from the container to the scene
  37124. * @param container the container holding the elements
  37125. */
  37126. addFromContainer(container: AbstractScene): void;
  37127. /**
  37128. * Removes all the elements in the container from the scene
  37129. * @param container contains the elements to remove
  37130. * @param dispose if the removed element should be disposed (default: false)
  37131. */
  37132. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37133. /**
  37134. * Disposes the component and the associated ressources.
  37135. */
  37136. dispose(): void;
  37137. /**
  37138. * Disables audio in the associated scene.
  37139. */
  37140. disableAudio(): void;
  37141. /**
  37142. * Enables audio in the associated scene.
  37143. */
  37144. enableAudio(): void;
  37145. /**
  37146. * Switch audio to headphone output.
  37147. */
  37148. switchAudioModeForHeadphones(): void;
  37149. /**
  37150. * Switch audio to normal speakers.
  37151. */
  37152. switchAudioModeForNormalSpeakers(): void;
  37153. private _cachedCameraDirection;
  37154. private _cachedCameraPosition;
  37155. private _lastCheck;
  37156. private _afterRender;
  37157. }
  37158. }
  37159. declare module "babylonjs/Audio/weightedsound" {
  37160. import { Sound } from "babylonjs/Audio/sound";
  37161. /**
  37162. * Wraps one or more Sound objects and selects one with random weight for playback.
  37163. */
  37164. export class WeightedSound {
  37165. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37166. loop: boolean;
  37167. private _coneInnerAngle;
  37168. private _coneOuterAngle;
  37169. private _volume;
  37170. /** A Sound is currently playing. */
  37171. isPlaying: boolean;
  37172. /** A Sound is currently paused. */
  37173. isPaused: boolean;
  37174. private _sounds;
  37175. private _weights;
  37176. private _currentIndex?;
  37177. /**
  37178. * Creates a new WeightedSound from the list of sounds given.
  37179. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37180. * @param sounds Array of Sounds that will be selected from.
  37181. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37182. */
  37183. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37184. /**
  37185. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37186. */
  37187. /**
  37188. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37189. */
  37190. directionalConeInnerAngle: number;
  37191. /**
  37192. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37193. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37194. */
  37195. /**
  37196. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37197. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37198. */
  37199. directionalConeOuterAngle: number;
  37200. /**
  37201. * Playback volume.
  37202. */
  37203. /**
  37204. * Playback volume.
  37205. */
  37206. volume: number;
  37207. private _onended;
  37208. /**
  37209. * Suspend playback
  37210. */
  37211. pause(): void;
  37212. /**
  37213. * Stop playback
  37214. */
  37215. stop(): void;
  37216. /**
  37217. * Start playback.
  37218. * @param startOffset Position the clip head at a specific time in seconds.
  37219. */
  37220. play(startOffset?: number): void;
  37221. }
  37222. }
  37223. declare module "babylonjs/Audio/index" {
  37224. export * from "babylonjs/Audio/analyser";
  37225. export * from "babylonjs/Audio/audioEngine";
  37226. export * from "babylonjs/Audio/audioSceneComponent";
  37227. export * from "babylonjs/Audio/sound";
  37228. export * from "babylonjs/Audio/soundTrack";
  37229. export * from "babylonjs/Audio/weightedsound";
  37230. }
  37231. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37232. import { Behavior } from "babylonjs/Behaviors/behavior";
  37233. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37234. import { BackEase } from "babylonjs/Animations/easing";
  37235. /**
  37236. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37238. */
  37239. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37240. /**
  37241. * Gets the name of the behavior.
  37242. */
  37243. readonly name: string;
  37244. /**
  37245. * The easing function used by animations
  37246. */
  37247. static EasingFunction: BackEase;
  37248. /**
  37249. * The easing mode used by animations
  37250. */
  37251. static EasingMode: number;
  37252. /**
  37253. * The duration of the animation, in milliseconds
  37254. */
  37255. transitionDuration: number;
  37256. /**
  37257. * Length of the distance animated by the transition when lower radius is reached
  37258. */
  37259. lowerRadiusTransitionRange: number;
  37260. /**
  37261. * Length of the distance animated by the transition when upper radius is reached
  37262. */
  37263. upperRadiusTransitionRange: number;
  37264. private _autoTransitionRange;
  37265. /**
  37266. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37267. */
  37268. /**
  37269. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37270. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37271. */
  37272. autoTransitionRange: boolean;
  37273. private _attachedCamera;
  37274. private _onAfterCheckInputsObserver;
  37275. private _onMeshTargetChangedObserver;
  37276. /**
  37277. * Initializes the behavior.
  37278. */
  37279. init(): void;
  37280. /**
  37281. * Attaches the behavior to its arc rotate camera.
  37282. * @param camera Defines the camera to attach the behavior to
  37283. */
  37284. attach(camera: ArcRotateCamera): void;
  37285. /**
  37286. * Detaches the behavior from its current arc rotate camera.
  37287. */
  37288. detach(): void;
  37289. private _radiusIsAnimating;
  37290. private _radiusBounceTransition;
  37291. private _animatables;
  37292. private _cachedWheelPrecision;
  37293. /**
  37294. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37295. * @param radiusLimit The limit to check against.
  37296. * @return Bool to indicate if at limit.
  37297. */
  37298. private _isRadiusAtLimit;
  37299. /**
  37300. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37301. * @param radiusDelta The delta by which to animate to. Can be negative.
  37302. */
  37303. private _applyBoundRadiusAnimation;
  37304. /**
  37305. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37306. */
  37307. protected _clearAnimationLocks(): void;
  37308. /**
  37309. * Stops and removes all animations that have been applied to the camera
  37310. */
  37311. stopAllAnimations(): void;
  37312. }
  37313. }
  37314. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37315. import { Behavior } from "babylonjs/Behaviors/behavior";
  37316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37317. import { ExponentialEase } from "babylonjs/Animations/easing";
  37318. import { Nullable } from "babylonjs/types";
  37319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37320. import { Vector3 } from "babylonjs/Maths/math.vector";
  37321. /**
  37322. * 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.
  37323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37324. */
  37325. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37326. /**
  37327. * Gets the name of the behavior.
  37328. */
  37329. readonly name: string;
  37330. private _mode;
  37331. private _radiusScale;
  37332. private _positionScale;
  37333. private _defaultElevation;
  37334. private _elevationReturnTime;
  37335. private _elevationReturnWaitTime;
  37336. private _zoomStopsAnimation;
  37337. private _framingTime;
  37338. /**
  37339. * The easing function used by animations
  37340. */
  37341. static EasingFunction: ExponentialEase;
  37342. /**
  37343. * The easing mode used by animations
  37344. */
  37345. static EasingMode: number;
  37346. /**
  37347. * Sets the current mode used by the behavior
  37348. */
  37349. /**
  37350. * Gets current mode used by the behavior.
  37351. */
  37352. mode: number;
  37353. /**
  37354. * Sets the scale applied to the radius (1 by default)
  37355. */
  37356. /**
  37357. * Gets the scale applied to the radius
  37358. */
  37359. radiusScale: number;
  37360. /**
  37361. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37362. */
  37363. /**
  37364. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37365. */
  37366. positionScale: number;
  37367. /**
  37368. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37369. * behaviour is triggered, in radians.
  37370. */
  37371. /**
  37372. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37373. * behaviour is triggered, in radians.
  37374. */
  37375. defaultElevation: number;
  37376. /**
  37377. * Sets the time (in milliseconds) taken to return to the default beta position.
  37378. * Negative value indicates camera should not return to default.
  37379. */
  37380. /**
  37381. * Gets the time (in milliseconds) taken to return to the default beta position.
  37382. * Negative value indicates camera should not return to default.
  37383. */
  37384. elevationReturnTime: number;
  37385. /**
  37386. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37387. */
  37388. /**
  37389. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37390. */
  37391. elevationReturnWaitTime: number;
  37392. /**
  37393. * Sets the flag that indicates if user zooming should stop animation.
  37394. */
  37395. /**
  37396. * Gets the flag that indicates if user zooming should stop animation.
  37397. */
  37398. zoomStopsAnimation: boolean;
  37399. /**
  37400. * Sets the transition time when framing the mesh, in milliseconds
  37401. */
  37402. /**
  37403. * Gets the transition time when framing the mesh, in milliseconds
  37404. */
  37405. framingTime: number;
  37406. /**
  37407. * Define if the behavior should automatically change the configured
  37408. * camera limits and sensibilities.
  37409. */
  37410. autoCorrectCameraLimitsAndSensibility: boolean;
  37411. private _onPrePointerObservableObserver;
  37412. private _onAfterCheckInputsObserver;
  37413. private _onMeshTargetChangedObserver;
  37414. private _attachedCamera;
  37415. private _isPointerDown;
  37416. private _lastInteractionTime;
  37417. /**
  37418. * Initializes the behavior.
  37419. */
  37420. init(): void;
  37421. /**
  37422. * Attaches the behavior to its arc rotate camera.
  37423. * @param camera Defines the camera to attach the behavior to
  37424. */
  37425. attach(camera: ArcRotateCamera): void;
  37426. /**
  37427. * Detaches the behavior from its current arc rotate camera.
  37428. */
  37429. detach(): void;
  37430. private _animatables;
  37431. private _betaIsAnimating;
  37432. private _betaTransition;
  37433. private _radiusTransition;
  37434. private _vectorTransition;
  37435. /**
  37436. * Targets the given mesh and updates zoom level accordingly.
  37437. * @param mesh The mesh to target.
  37438. * @param radius Optional. If a cached radius position already exists, overrides default.
  37439. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37440. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37441. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37442. */
  37443. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37444. /**
  37445. * Targets the given mesh with its children and updates zoom level accordingly.
  37446. * @param mesh The mesh to target.
  37447. * @param radius Optional. If a cached radius position already exists, overrides default.
  37448. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37451. */
  37452. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37453. /**
  37454. * Targets the given meshes with their children and updates zoom level accordingly.
  37455. * @param meshes The mesh to target.
  37456. * @param radius Optional. If a cached radius position already exists, overrides default.
  37457. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37458. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37459. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37460. */
  37461. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37462. /**
  37463. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37464. * @param minimumWorld Determines the smaller position of the bounding box extend
  37465. * @param maximumWorld Determines the bigger position of the bounding box extend
  37466. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37467. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37468. */
  37469. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37470. /**
  37471. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37472. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37473. * frustum width.
  37474. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37475. * to fully enclose the mesh in the viewing frustum.
  37476. */
  37477. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37478. /**
  37479. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37480. * is automatically returned to its default position (expected to be above ground plane).
  37481. */
  37482. private _maintainCameraAboveGround;
  37483. /**
  37484. * Returns the frustum slope based on the canvas ratio and camera FOV
  37485. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37486. */
  37487. private _getFrustumSlope;
  37488. /**
  37489. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37490. */
  37491. private _clearAnimationLocks;
  37492. /**
  37493. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37494. */
  37495. private _applyUserInteraction;
  37496. /**
  37497. * Stops and removes all animations that have been applied to the camera
  37498. */
  37499. stopAllAnimations(): void;
  37500. /**
  37501. * Gets a value indicating if the user is moving the camera
  37502. */
  37503. readonly isUserIsMoving: boolean;
  37504. /**
  37505. * The camera can move all the way towards the mesh.
  37506. */
  37507. static IgnoreBoundsSizeMode: number;
  37508. /**
  37509. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37510. */
  37511. static FitFrustumSidesMode: number;
  37512. }
  37513. }
  37514. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37515. import { Nullable } from "babylonjs/types";
  37516. import { Camera } from "babylonjs/Cameras/camera";
  37517. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37518. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37519. /**
  37520. * Base class for Camera Pointer Inputs.
  37521. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37522. * for example usage.
  37523. */
  37524. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37525. /**
  37526. * Defines the camera the input is attached to.
  37527. */
  37528. abstract camera: Camera;
  37529. /**
  37530. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37531. */
  37532. protected _altKey: boolean;
  37533. protected _ctrlKey: boolean;
  37534. protected _metaKey: boolean;
  37535. protected _shiftKey: boolean;
  37536. /**
  37537. * Which mouse buttons were pressed at time of last mouse event.
  37538. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37539. */
  37540. protected _buttonsPressed: number;
  37541. /**
  37542. * Defines the buttons associated with the input to handle camera move.
  37543. */
  37544. buttons: number[];
  37545. /**
  37546. * Attach the input controls to a specific dom element to get the input from.
  37547. * @param element Defines the element the controls should be listened from
  37548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37549. */
  37550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37551. /**
  37552. * Detach the current controls from the specified dom element.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: Nullable<HTMLElement>): void;
  37556. /**
  37557. * Gets the class name of the current input.
  37558. * @returns the class name
  37559. */
  37560. getClassName(): string;
  37561. /**
  37562. * Get the friendly name associated with the input class.
  37563. * @returns the input friendly name
  37564. */
  37565. getSimpleName(): string;
  37566. /**
  37567. * Called on pointer POINTERDOUBLETAP event.
  37568. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37569. */
  37570. protected onDoubleTap(type: string): void;
  37571. /**
  37572. * Called on pointer POINTERMOVE event if only a single touch is active.
  37573. * Override this method to provide functionality.
  37574. */
  37575. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37576. /**
  37577. * Called on pointer POINTERMOVE event if multiple touches are active.
  37578. * Override this method to provide functionality.
  37579. */
  37580. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37581. /**
  37582. * Called on JS contextmenu event.
  37583. * Override this method to provide functionality.
  37584. */
  37585. protected onContextMenu(evt: PointerEvent): void;
  37586. /**
  37587. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37588. * press.
  37589. * Override this method to provide functionality.
  37590. */
  37591. protected onButtonDown(evt: PointerEvent): void;
  37592. /**
  37593. * Called each time a new POINTERUP event occurs. Ie, for each button
  37594. * release.
  37595. * Override this method to provide functionality.
  37596. */
  37597. protected onButtonUp(evt: PointerEvent): void;
  37598. /**
  37599. * Called when window becomes inactive.
  37600. * Override this method to provide functionality.
  37601. */
  37602. protected onLostFocus(): void;
  37603. private _pointerInput;
  37604. private _observer;
  37605. private _onLostFocus;
  37606. private pointA;
  37607. private pointB;
  37608. }
  37609. }
  37610. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37611. import { Nullable } from "babylonjs/types";
  37612. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37613. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37614. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37615. /**
  37616. * Manage the pointers inputs to control an arc rotate camera.
  37617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37618. */
  37619. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37620. /**
  37621. * Defines the camera the input is attached to.
  37622. */
  37623. camera: ArcRotateCamera;
  37624. /**
  37625. * Gets the class name of the current input.
  37626. * @returns the class name
  37627. */
  37628. getClassName(): string;
  37629. /**
  37630. * Defines the buttons associated with the input to handle camera move.
  37631. */
  37632. buttons: number[];
  37633. /**
  37634. * Defines the pointer angular sensibility along the X axis or how fast is
  37635. * the camera rotating.
  37636. */
  37637. angularSensibilityX: number;
  37638. /**
  37639. * Defines the pointer angular sensibility along the Y axis or how fast is
  37640. * the camera rotating.
  37641. */
  37642. angularSensibilityY: number;
  37643. /**
  37644. * Defines the pointer pinch precision or how fast is the camera zooming.
  37645. */
  37646. pinchPrecision: number;
  37647. /**
  37648. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37649. * from 0.
  37650. * It defines the percentage of current camera.radius to use as delta when
  37651. * pinch zoom is used.
  37652. */
  37653. pinchDeltaPercentage: number;
  37654. /**
  37655. * Defines the pointer panning sensibility or how fast is the camera moving.
  37656. */
  37657. panningSensibility: number;
  37658. /**
  37659. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37660. */
  37661. multiTouchPanning: boolean;
  37662. /**
  37663. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37664. * zoom (pinch) through multitouch.
  37665. */
  37666. multiTouchPanAndZoom: boolean;
  37667. /**
  37668. * Revers pinch action direction.
  37669. */
  37670. pinchInwards: boolean;
  37671. private _isPanClick;
  37672. private _twoFingerActivityCount;
  37673. private _isPinching;
  37674. /**
  37675. * Called on pointer POINTERMOVE event if only a single touch is active.
  37676. */
  37677. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37678. /**
  37679. * Called on pointer POINTERDOUBLETAP event.
  37680. */
  37681. protected onDoubleTap(type: string): void;
  37682. /**
  37683. * Called on pointer POINTERMOVE event if multiple touches are active.
  37684. */
  37685. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37686. /**
  37687. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37688. * press.
  37689. */
  37690. protected onButtonDown(evt: PointerEvent): void;
  37691. /**
  37692. * Called each time a new POINTERUP event occurs. Ie, for each button
  37693. * release.
  37694. */
  37695. protected onButtonUp(evt: PointerEvent): void;
  37696. /**
  37697. * Called when window becomes inactive.
  37698. */
  37699. protected onLostFocus(): void;
  37700. }
  37701. }
  37702. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37703. import { Nullable } from "babylonjs/types";
  37704. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37705. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37706. /**
  37707. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37709. */
  37710. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37711. /**
  37712. * Defines the camera the input is attached to.
  37713. */
  37714. camera: ArcRotateCamera;
  37715. /**
  37716. * Defines the list of key codes associated with the up action (increase alpha)
  37717. */
  37718. keysUp: number[];
  37719. /**
  37720. * Defines the list of key codes associated with the down action (decrease alpha)
  37721. */
  37722. keysDown: number[];
  37723. /**
  37724. * Defines the list of key codes associated with the left action (increase beta)
  37725. */
  37726. keysLeft: number[];
  37727. /**
  37728. * Defines the list of key codes associated with the right action (decrease beta)
  37729. */
  37730. keysRight: number[];
  37731. /**
  37732. * Defines the list of key codes associated with the reset action.
  37733. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37734. */
  37735. keysReset: number[];
  37736. /**
  37737. * Defines the panning sensibility of the inputs.
  37738. * (How fast is the camera paning)
  37739. */
  37740. panningSensibility: number;
  37741. /**
  37742. * Defines the zooming sensibility of the inputs.
  37743. * (How fast is the camera zooming)
  37744. */
  37745. zoomingSensibility: number;
  37746. /**
  37747. * Defines wether maintaining the alt key down switch the movement mode from
  37748. * orientation to zoom.
  37749. */
  37750. useAltToZoom: boolean;
  37751. /**
  37752. * Rotation speed of the camera
  37753. */
  37754. angularSpeed: number;
  37755. private _keys;
  37756. private _ctrlPressed;
  37757. private _altPressed;
  37758. private _onCanvasBlurObserver;
  37759. private _onKeyboardObserver;
  37760. private _engine;
  37761. private _scene;
  37762. /**
  37763. * Attach the input controls to a specific dom element to get the input from.
  37764. * @param element Defines the element the controls should be listened from
  37765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37766. */
  37767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37768. /**
  37769. * Detach the current controls from the specified dom element.
  37770. * @param element Defines the element to stop listening the inputs from
  37771. */
  37772. detachControl(element: Nullable<HTMLElement>): void;
  37773. /**
  37774. * Update the current camera state depending on the inputs that have been used this frame.
  37775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37776. */
  37777. checkInputs(): void;
  37778. /**
  37779. * Gets the class name of the current intput.
  37780. * @returns the class name
  37781. */
  37782. getClassName(): string;
  37783. /**
  37784. * Get the friendly name associated with the input class.
  37785. * @returns the input friendly name
  37786. */
  37787. getSimpleName(): string;
  37788. }
  37789. }
  37790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37791. import { Nullable } from "babylonjs/types";
  37792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37794. /**
  37795. * Manage the mouse wheel inputs to control an arc rotate camera.
  37796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37797. */
  37798. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37799. /**
  37800. * Defines the camera the input is attached to.
  37801. */
  37802. camera: ArcRotateCamera;
  37803. /**
  37804. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37805. */
  37806. wheelPrecision: number;
  37807. /**
  37808. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37809. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37810. */
  37811. wheelDeltaPercentage: number;
  37812. private _wheel;
  37813. private _observer;
  37814. private computeDeltaFromMouseWheelLegacyEvent;
  37815. /**
  37816. * Attach the input controls to a specific dom element to get the input from.
  37817. * @param element Defines the element the controls should be listened from
  37818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37819. */
  37820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37821. /**
  37822. * Detach the current controls from the specified dom element.
  37823. * @param element Defines the element to stop listening the inputs from
  37824. */
  37825. detachControl(element: Nullable<HTMLElement>): void;
  37826. /**
  37827. * Gets the class name of the current intput.
  37828. * @returns the class name
  37829. */
  37830. getClassName(): string;
  37831. /**
  37832. * Get the friendly name associated with the input class.
  37833. * @returns the input friendly name
  37834. */
  37835. getSimpleName(): string;
  37836. }
  37837. }
  37838. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37839. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37840. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37841. /**
  37842. * Default Inputs manager for the ArcRotateCamera.
  37843. * It groups all the default supported inputs for ease of use.
  37844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37845. */
  37846. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37847. /**
  37848. * Instantiates a new ArcRotateCameraInputsManager.
  37849. * @param camera Defines the camera the inputs belong to
  37850. */
  37851. constructor(camera: ArcRotateCamera);
  37852. /**
  37853. * Add mouse wheel input support to the input manager.
  37854. * @returns the current input manager
  37855. */
  37856. addMouseWheel(): ArcRotateCameraInputsManager;
  37857. /**
  37858. * Add pointers input support to the input manager.
  37859. * @returns the current input manager
  37860. */
  37861. addPointers(): ArcRotateCameraInputsManager;
  37862. /**
  37863. * Add keyboard input support to the input manager.
  37864. * @returns the current input manager
  37865. */
  37866. addKeyboard(): ArcRotateCameraInputsManager;
  37867. }
  37868. }
  37869. declare module "babylonjs/Cameras/arcRotateCamera" {
  37870. import { Observable } from "babylonjs/Misc/observable";
  37871. import { Nullable } from "babylonjs/types";
  37872. import { Scene } from "babylonjs/scene";
  37873. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37875. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37876. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37877. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37878. import { Camera } from "babylonjs/Cameras/camera";
  37879. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37880. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37881. import { Collider } from "babylonjs/Collisions/collider";
  37882. /**
  37883. * This represents an orbital type of camera.
  37884. *
  37885. * 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.
  37886. * 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.
  37887. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37888. */
  37889. export class ArcRotateCamera extends TargetCamera {
  37890. /**
  37891. * Defines the rotation angle of the camera along the longitudinal axis.
  37892. */
  37893. alpha: number;
  37894. /**
  37895. * Defines the rotation angle of the camera along the latitudinal axis.
  37896. */
  37897. beta: number;
  37898. /**
  37899. * Defines the radius of the camera from it s target point.
  37900. */
  37901. radius: number;
  37902. protected _target: Vector3;
  37903. protected _targetHost: Nullable<AbstractMesh>;
  37904. /**
  37905. * Defines the target point of the camera.
  37906. * The camera looks towards it form the radius distance.
  37907. */
  37908. target: Vector3;
  37909. /**
  37910. * Define the current local position of the camera in the scene
  37911. */
  37912. position: Vector3;
  37913. protected _upVector: Vector3;
  37914. protected _upToYMatrix: Matrix;
  37915. protected _YToUpMatrix: Matrix;
  37916. /**
  37917. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37918. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37919. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37920. */
  37921. upVector: Vector3;
  37922. /**
  37923. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37924. */
  37925. setMatUp(): void;
  37926. /**
  37927. * Current inertia value on the longitudinal axis.
  37928. * The bigger this number the longer it will take for the camera to stop.
  37929. */
  37930. inertialAlphaOffset: number;
  37931. /**
  37932. * Current inertia value on the latitudinal axis.
  37933. * The bigger this number the longer it will take for the camera to stop.
  37934. */
  37935. inertialBetaOffset: number;
  37936. /**
  37937. * Current inertia value on the radius axis.
  37938. * The bigger this number the longer it will take for the camera to stop.
  37939. */
  37940. inertialRadiusOffset: number;
  37941. /**
  37942. * Minimum allowed angle on the longitudinal axis.
  37943. * This can help limiting how the Camera is able to move in the scene.
  37944. */
  37945. lowerAlphaLimit: Nullable<number>;
  37946. /**
  37947. * Maximum allowed angle on the longitudinal axis.
  37948. * This can help limiting how the Camera is able to move in the scene.
  37949. */
  37950. upperAlphaLimit: Nullable<number>;
  37951. /**
  37952. * Minimum allowed angle on the latitudinal axis.
  37953. * This can help limiting how the Camera is able to move in the scene.
  37954. */
  37955. lowerBetaLimit: number;
  37956. /**
  37957. * Maximum allowed angle on the latitudinal axis.
  37958. * This can help limiting how the Camera is able to move in the scene.
  37959. */
  37960. upperBetaLimit: number;
  37961. /**
  37962. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. lowerRadiusLimit: Nullable<number>;
  37966. /**
  37967. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. upperRadiusLimit: Nullable<number>;
  37971. /**
  37972. * Defines the current inertia value used during panning of the camera along the X axis.
  37973. */
  37974. inertialPanningX: number;
  37975. /**
  37976. * Defines the current inertia value used during panning of the camera along the Y axis.
  37977. */
  37978. inertialPanningY: number;
  37979. /**
  37980. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37981. * Basically if your fingers moves away from more than this distance you will be considered
  37982. * in pinch mode.
  37983. */
  37984. pinchToPanMaxDistance: number;
  37985. /**
  37986. * Defines the maximum distance the camera can pan.
  37987. * This could help keeping the cammera always in your scene.
  37988. */
  37989. panningDistanceLimit: Nullable<number>;
  37990. /**
  37991. * Defines the target of the camera before paning.
  37992. */
  37993. panningOriginTarget: Vector3;
  37994. /**
  37995. * Defines the value of the inertia used during panning.
  37996. * 0 would mean stop inertia and one would mean no decelleration at all.
  37997. */
  37998. panningInertia: number;
  37999. /**
  38000. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38001. */
  38002. angularSensibilityX: number;
  38003. /**
  38004. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38005. */
  38006. angularSensibilityY: number;
  38007. /**
  38008. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38009. */
  38010. pinchPrecision: number;
  38011. /**
  38012. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38013. * It will be used instead of pinchDeltaPrecision if different from 0.
  38014. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38015. */
  38016. pinchDeltaPercentage: number;
  38017. /**
  38018. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38019. */
  38020. panningSensibility: number;
  38021. /**
  38022. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38023. */
  38024. keysUp: number[];
  38025. /**
  38026. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38027. */
  38028. keysDown: number[];
  38029. /**
  38030. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38031. */
  38032. keysLeft: number[];
  38033. /**
  38034. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38035. */
  38036. keysRight: number[];
  38037. /**
  38038. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38039. */
  38040. wheelPrecision: number;
  38041. /**
  38042. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38043. * It will be used instead of pinchDeltaPrecision if different from 0.
  38044. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38045. */
  38046. wheelDeltaPercentage: number;
  38047. /**
  38048. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38049. */
  38050. zoomOnFactor: number;
  38051. /**
  38052. * Defines a screen offset for the camera position.
  38053. */
  38054. targetScreenOffset: Vector2;
  38055. /**
  38056. * Allows the camera to be completely reversed.
  38057. * If false the camera can not arrive upside down.
  38058. */
  38059. allowUpsideDown: boolean;
  38060. /**
  38061. * Define if double tap/click is used to restore the previously saved state of the camera.
  38062. */
  38063. useInputToRestoreState: boolean;
  38064. /** @hidden */
  38065. _viewMatrix: Matrix;
  38066. /** @hidden */
  38067. _useCtrlForPanning: boolean;
  38068. /** @hidden */
  38069. _panningMouseButton: number;
  38070. /**
  38071. * Defines the input associated to the camera.
  38072. */
  38073. inputs: ArcRotateCameraInputsManager;
  38074. /** @hidden */
  38075. _reset: () => void;
  38076. /**
  38077. * Defines the allowed panning axis.
  38078. */
  38079. panningAxis: Vector3;
  38080. protected _localDirection: Vector3;
  38081. protected _transformedDirection: Vector3;
  38082. private _bouncingBehavior;
  38083. /**
  38084. * Gets the bouncing behavior of the camera if it has been enabled.
  38085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38086. */
  38087. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38088. /**
  38089. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38091. */
  38092. useBouncingBehavior: boolean;
  38093. private _framingBehavior;
  38094. /**
  38095. * Gets the framing behavior of the camera if it has been enabled.
  38096. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38097. */
  38098. readonly framingBehavior: Nullable<FramingBehavior>;
  38099. /**
  38100. * Defines if the framing behavior of the camera is enabled on the camera.
  38101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38102. */
  38103. useFramingBehavior: boolean;
  38104. private _autoRotationBehavior;
  38105. /**
  38106. * Gets the auto rotation behavior of the camera if it has been enabled.
  38107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38108. */
  38109. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38110. /**
  38111. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38113. */
  38114. useAutoRotationBehavior: boolean;
  38115. /**
  38116. * Observable triggered when the mesh target has been changed on the camera.
  38117. */
  38118. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38119. /**
  38120. * Event raised when the camera is colliding with a mesh.
  38121. */
  38122. onCollide: (collidedMesh: AbstractMesh) => void;
  38123. /**
  38124. * Defines whether the camera should check collision with the objects oh the scene.
  38125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38126. */
  38127. checkCollisions: boolean;
  38128. /**
  38129. * Defines the collision radius of the camera.
  38130. * This simulates a sphere around the camera.
  38131. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38132. */
  38133. collisionRadius: Vector3;
  38134. protected _collider: Collider;
  38135. protected _previousPosition: Vector3;
  38136. protected _collisionVelocity: Vector3;
  38137. protected _newPosition: Vector3;
  38138. protected _previousAlpha: number;
  38139. protected _previousBeta: number;
  38140. protected _previousRadius: number;
  38141. protected _collisionTriggered: boolean;
  38142. protected _targetBoundingCenter: Nullable<Vector3>;
  38143. private _computationVector;
  38144. /**
  38145. * Instantiates a new ArcRotateCamera in a given scene
  38146. * @param name Defines the name of the camera
  38147. * @param alpha Defines the camera rotation along the logitudinal axis
  38148. * @param beta Defines the camera rotation along the latitudinal axis
  38149. * @param radius Defines the camera distance from its target
  38150. * @param target Defines the camera target
  38151. * @param scene Defines the scene the camera belongs to
  38152. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38153. */
  38154. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38155. /** @hidden */
  38156. _initCache(): void;
  38157. /** @hidden */
  38158. _updateCache(ignoreParentClass?: boolean): void;
  38159. protected _getTargetPosition(): Vector3;
  38160. private _storedAlpha;
  38161. private _storedBeta;
  38162. private _storedRadius;
  38163. private _storedTarget;
  38164. private _storedTargetScreenOffset;
  38165. /**
  38166. * Stores the current state of the camera (alpha, beta, radius and target)
  38167. * @returns the camera itself
  38168. */
  38169. storeState(): Camera;
  38170. /**
  38171. * @hidden
  38172. * Restored camera state. You must call storeState() first
  38173. */
  38174. _restoreStateValues(): boolean;
  38175. /** @hidden */
  38176. _isSynchronizedViewMatrix(): boolean;
  38177. /**
  38178. * Attached controls to the current camera.
  38179. * @param element Defines the element the controls should be listened from
  38180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38181. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38182. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38183. */
  38184. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38185. /**
  38186. * Detach the current controls from the camera.
  38187. * The camera will stop reacting to inputs.
  38188. * @param element Defines the element to stop listening the inputs from
  38189. */
  38190. detachControl(element: HTMLElement): void;
  38191. /** @hidden */
  38192. _checkInputs(): void;
  38193. protected _checkLimits(): void;
  38194. /**
  38195. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38196. */
  38197. rebuildAnglesAndRadius(): void;
  38198. /**
  38199. * Use a position to define the current camera related information like alpha, beta and radius
  38200. * @param position Defines the position to set the camera at
  38201. */
  38202. setPosition(position: Vector3): void;
  38203. /**
  38204. * Defines the target the camera should look at.
  38205. * This will automatically adapt alpha beta and radius to fit within the new target.
  38206. * @param target Defines the new target as a Vector or a mesh
  38207. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38208. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38209. */
  38210. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38211. /** @hidden */
  38212. _getViewMatrix(): Matrix;
  38213. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38214. /**
  38215. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38216. * @param meshes Defines the mesh to zoom on
  38217. * @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)
  38218. */
  38219. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38220. /**
  38221. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38222. * The target will be changed but the radius
  38223. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38224. * @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)
  38225. */
  38226. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38227. min: Vector3;
  38228. max: Vector3;
  38229. distance: number;
  38230. }, doNotUpdateMaxZ?: boolean): void;
  38231. /**
  38232. * @override
  38233. * Override Camera.createRigCamera
  38234. */
  38235. createRigCamera(name: string, cameraIndex: number): Camera;
  38236. /**
  38237. * @hidden
  38238. * @override
  38239. * Override Camera._updateRigCameras
  38240. */
  38241. _updateRigCameras(): void;
  38242. /**
  38243. * Destroy the camera and release the current resources hold by it.
  38244. */
  38245. dispose(): void;
  38246. /**
  38247. * Gets the current object class name.
  38248. * @return the class name
  38249. */
  38250. getClassName(): string;
  38251. }
  38252. }
  38253. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38254. import { Behavior } from "babylonjs/Behaviors/behavior";
  38255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38256. /**
  38257. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38259. */
  38260. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38261. /**
  38262. * Gets the name of the behavior.
  38263. */
  38264. readonly name: string;
  38265. private _zoomStopsAnimation;
  38266. private _idleRotationSpeed;
  38267. private _idleRotationWaitTime;
  38268. private _idleRotationSpinupTime;
  38269. /**
  38270. * Sets the flag that indicates if user zooming should stop animation.
  38271. */
  38272. /**
  38273. * Gets the flag that indicates if user zooming should stop animation.
  38274. */
  38275. zoomStopsAnimation: boolean;
  38276. /**
  38277. * Sets the default speed at which the camera rotates around the model.
  38278. */
  38279. /**
  38280. * Gets the default speed at which the camera rotates around the model.
  38281. */
  38282. idleRotationSpeed: number;
  38283. /**
  38284. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38285. */
  38286. /**
  38287. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38288. */
  38289. idleRotationWaitTime: number;
  38290. /**
  38291. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38292. */
  38293. /**
  38294. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38295. */
  38296. idleRotationSpinupTime: number;
  38297. /**
  38298. * Gets a value indicating if the camera is currently rotating because of this behavior
  38299. */
  38300. readonly rotationInProgress: boolean;
  38301. private _onPrePointerObservableObserver;
  38302. private _onAfterCheckInputsObserver;
  38303. private _attachedCamera;
  38304. private _isPointerDown;
  38305. private _lastFrameTime;
  38306. private _lastInteractionTime;
  38307. private _cameraRotationSpeed;
  38308. /**
  38309. * Initializes the behavior.
  38310. */
  38311. init(): void;
  38312. /**
  38313. * Attaches the behavior to its arc rotate camera.
  38314. * @param camera Defines the camera to attach the behavior to
  38315. */
  38316. attach(camera: ArcRotateCamera): void;
  38317. /**
  38318. * Detaches the behavior from its current arc rotate camera.
  38319. */
  38320. detach(): void;
  38321. /**
  38322. * Returns true if user is scrolling.
  38323. * @return true if user is scrolling.
  38324. */
  38325. private _userIsZooming;
  38326. private _lastFrameRadius;
  38327. private _shouldAnimationStopForInteraction;
  38328. /**
  38329. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38330. */
  38331. private _applyUserInteraction;
  38332. private _userIsMoving;
  38333. }
  38334. }
  38335. declare module "babylonjs/Behaviors/Cameras/index" {
  38336. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38337. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38338. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38339. }
  38340. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38341. import { Mesh } from "babylonjs/Meshes/mesh";
  38342. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38343. import { Behavior } from "babylonjs/Behaviors/behavior";
  38344. /**
  38345. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38346. */
  38347. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38348. private ui;
  38349. /**
  38350. * The name of the behavior
  38351. */
  38352. name: string;
  38353. /**
  38354. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38355. */
  38356. distanceAwayFromFace: number;
  38357. /**
  38358. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38359. */
  38360. distanceAwayFromBottomOfFace: number;
  38361. private _faceVectors;
  38362. private _target;
  38363. private _scene;
  38364. private _onRenderObserver;
  38365. private _tmpMatrix;
  38366. private _tmpVector;
  38367. /**
  38368. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38369. * @param ui The transform node that should be attched to the mesh
  38370. */
  38371. constructor(ui: TransformNode);
  38372. /**
  38373. * Initializes the behavior
  38374. */
  38375. init(): void;
  38376. private _closestFace;
  38377. private _zeroVector;
  38378. private _lookAtTmpMatrix;
  38379. private _lookAtToRef;
  38380. /**
  38381. * Attaches the AttachToBoxBehavior to the passed in mesh
  38382. * @param target The mesh that the specified node will be attached to
  38383. */
  38384. attach(target: Mesh): void;
  38385. /**
  38386. * Detaches the behavior from the mesh
  38387. */
  38388. detach(): void;
  38389. }
  38390. }
  38391. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38392. import { Behavior } from "babylonjs/Behaviors/behavior";
  38393. import { Mesh } from "babylonjs/Meshes/mesh";
  38394. /**
  38395. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38396. */
  38397. export class FadeInOutBehavior implements Behavior<Mesh> {
  38398. /**
  38399. * Time in milliseconds to delay before fading in (Default: 0)
  38400. */
  38401. delay: number;
  38402. /**
  38403. * Time in milliseconds for the mesh to fade in (Default: 300)
  38404. */
  38405. fadeInTime: number;
  38406. private _millisecondsPerFrame;
  38407. private _hovered;
  38408. private _hoverValue;
  38409. private _ownerNode;
  38410. /**
  38411. * Instatiates the FadeInOutBehavior
  38412. */
  38413. constructor();
  38414. /**
  38415. * The name of the behavior
  38416. */
  38417. readonly name: string;
  38418. /**
  38419. * Initializes the behavior
  38420. */
  38421. init(): void;
  38422. /**
  38423. * Attaches the fade behavior on the passed in mesh
  38424. * @param ownerNode The mesh that will be faded in/out once attached
  38425. */
  38426. attach(ownerNode: Mesh): void;
  38427. /**
  38428. * Detaches the behavior from the mesh
  38429. */
  38430. detach(): void;
  38431. /**
  38432. * Triggers the mesh to begin fading in or out
  38433. * @param value if the object should fade in or out (true to fade in)
  38434. */
  38435. fadeIn(value: boolean): void;
  38436. private _update;
  38437. private _setAllVisibility;
  38438. }
  38439. }
  38440. declare module "babylonjs/Misc/pivotTools" {
  38441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38442. /**
  38443. * Class containing a set of static utilities functions for managing Pivots
  38444. * @hidden
  38445. */
  38446. export class PivotTools {
  38447. private static _PivotCached;
  38448. private static _OldPivotPoint;
  38449. private static _PivotTranslation;
  38450. private static _PivotTmpVector;
  38451. /** @hidden */
  38452. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38453. /** @hidden */
  38454. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38455. }
  38456. }
  38457. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38458. import { Scene } from "babylonjs/scene";
  38459. import { Vector4 } from "babylonjs/Maths/math.vector";
  38460. import { Mesh } from "babylonjs/Meshes/mesh";
  38461. import { Nullable } from "babylonjs/types";
  38462. import { Plane } from "babylonjs/Maths/math.plane";
  38463. /**
  38464. * Class containing static functions to help procedurally build meshes
  38465. */
  38466. export class PlaneBuilder {
  38467. /**
  38468. * Creates a plane mesh
  38469. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38470. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38471. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38475. * @param name defines the name of the mesh
  38476. * @param options defines the options used to create the mesh
  38477. * @param scene defines the hosting scene
  38478. * @returns the plane mesh
  38479. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38480. */
  38481. static CreatePlane(name: string, options: {
  38482. size?: number;
  38483. width?: number;
  38484. height?: number;
  38485. sideOrientation?: number;
  38486. frontUVs?: Vector4;
  38487. backUVs?: Vector4;
  38488. updatable?: boolean;
  38489. sourcePlane?: Plane;
  38490. }, scene?: Nullable<Scene>): Mesh;
  38491. }
  38492. }
  38493. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38494. import { Behavior } from "babylonjs/Behaviors/behavior";
  38495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38496. import { Observable } from "babylonjs/Misc/observable";
  38497. import { Vector3 } from "babylonjs/Maths/math.vector";
  38498. import { Ray } from "babylonjs/Culling/ray";
  38499. import "babylonjs/Meshes/Builders/planeBuilder";
  38500. /**
  38501. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38502. */
  38503. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38504. private static _AnyMouseID;
  38505. /**
  38506. * Abstract mesh the behavior is set on
  38507. */
  38508. attachedNode: AbstractMesh;
  38509. private _dragPlane;
  38510. private _scene;
  38511. private _pointerObserver;
  38512. private _beforeRenderObserver;
  38513. private static _planeScene;
  38514. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38515. /**
  38516. * 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)
  38517. */
  38518. maxDragAngle: number;
  38519. /**
  38520. * @hidden
  38521. */
  38522. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38523. /**
  38524. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38525. */
  38526. currentDraggingPointerID: number;
  38527. /**
  38528. * The last position where the pointer hit the drag plane in world space
  38529. */
  38530. lastDragPosition: Vector3;
  38531. /**
  38532. * If the behavior is currently in a dragging state
  38533. */
  38534. dragging: boolean;
  38535. /**
  38536. * 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)
  38537. */
  38538. dragDeltaRatio: number;
  38539. /**
  38540. * If the drag plane orientation should be updated during the dragging (Default: true)
  38541. */
  38542. updateDragPlane: boolean;
  38543. private _debugMode;
  38544. private _moving;
  38545. /**
  38546. * Fires each time the attached mesh is dragged with the pointer
  38547. * * delta between last drag position and current drag position in world space
  38548. * * dragDistance along the drag axis
  38549. * * dragPlaneNormal normal of the current drag plane used during the drag
  38550. * * dragPlanePoint in world space where the drag intersects the drag plane
  38551. */
  38552. onDragObservable: Observable<{
  38553. delta: Vector3;
  38554. dragPlanePoint: Vector3;
  38555. dragPlaneNormal: Vector3;
  38556. dragDistance: number;
  38557. pointerId: number;
  38558. }>;
  38559. /**
  38560. * Fires each time a drag begins (eg. mouse down on mesh)
  38561. */
  38562. onDragStartObservable: Observable<{
  38563. dragPlanePoint: Vector3;
  38564. pointerId: number;
  38565. }>;
  38566. /**
  38567. * Fires each time a drag ends (eg. mouse release after drag)
  38568. */
  38569. onDragEndObservable: Observable<{
  38570. dragPlanePoint: Vector3;
  38571. pointerId: number;
  38572. }>;
  38573. /**
  38574. * If the attached mesh should be moved when dragged
  38575. */
  38576. moveAttached: boolean;
  38577. /**
  38578. * If the drag behavior will react to drag events (Default: true)
  38579. */
  38580. enabled: boolean;
  38581. /**
  38582. * If pointer events should start and release the drag (Default: true)
  38583. */
  38584. startAndReleaseDragOnPointerEvents: boolean;
  38585. /**
  38586. * If camera controls should be detached during the drag
  38587. */
  38588. detachCameraControls: boolean;
  38589. /**
  38590. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38591. */
  38592. useObjectOrienationForDragging: boolean;
  38593. private _options;
  38594. /**
  38595. * Creates a pointer drag behavior that can be attached to a mesh
  38596. * @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)
  38597. */
  38598. constructor(options?: {
  38599. dragAxis?: Vector3;
  38600. dragPlaneNormal?: Vector3;
  38601. });
  38602. /**
  38603. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38604. */
  38605. validateDrag: (targetPosition: Vector3) => boolean;
  38606. /**
  38607. * The name of the behavior
  38608. */
  38609. readonly name: string;
  38610. /**
  38611. * Initializes the behavior
  38612. */
  38613. init(): void;
  38614. private _tmpVector;
  38615. private _alternatePickedPoint;
  38616. private _worldDragAxis;
  38617. private _targetPosition;
  38618. private _attachedElement;
  38619. /**
  38620. * Attaches the drag behavior the passed in mesh
  38621. * @param ownerNode The mesh that will be dragged around once attached
  38622. * @param predicate Predicate to use for pick filtering
  38623. */
  38624. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38625. /**
  38626. * Force relase the drag action by code.
  38627. */
  38628. releaseDrag(): void;
  38629. private _startDragRay;
  38630. private _lastPointerRay;
  38631. /**
  38632. * Simulates the start of a pointer drag event on the behavior
  38633. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38634. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38635. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38636. */
  38637. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38638. private _startDrag;
  38639. private _dragDelta;
  38640. private _moveDrag;
  38641. private _pickWithRayOnDragPlane;
  38642. private _pointA;
  38643. private _pointB;
  38644. private _pointC;
  38645. private _lineA;
  38646. private _lineB;
  38647. private _localAxis;
  38648. private _lookAt;
  38649. private _updateDragPlanePosition;
  38650. /**
  38651. * Detaches the behavior from the mesh
  38652. */
  38653. detach(): void;
  38654. }
  38655. }
  38656. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38657. import { Mesh } from "babylonjs/Meshes/mesh";
  38658. import { Behavior } from "babylonjs/Behaviors/behavior";
  38659. /**
  38660. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38661. */
  38662. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38663. private _dragBehaviorA;
  38664. private _dragBehaviorB;
  38665. private _startDistance;
  38666. private _initialScale;
  38667. private _targetScale;
  38668. private _ownerNode;
  38669. private _sceneRenderObserver;
  38670. /**
  38671. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38672. */
  38673. constructor();
  38674. /**
  38675. * The name of the behavior
  38676. */
  38677. readonly name: string;
  38678. /**
  38679. * Initializes the behavior
  38680. */
  38681. init(): void;
  38682. private _getCurrentDistance;
  38683. /**
  38684. * Attaches the scale behavior the passed in mesh
  38685. * @param ownerNode The mesh that will be scaled around once attached
  38686. */
  38687. attach(ownerNode: Mesh): void;
  38688. /**
  38689. * Detaches the behavior from the mesh
  38690. */
  38691. detach(): void;
  38692. }
  38693. }
  38694. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38695. import { Behavior } from "babylonjs/Behaviors/behavior";
  38696. import { Mesh } from "babylonjs/Meshes/mesh";
  38697. import { Observable } from "babylonjs/Misc/observable";
  38698. /**
  38699. * 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
  38700. */
  38701. export class SixDofDragBehavior implements Behavior<Mesh> {
  38702. private static _virtualScene;
  38703. private _ownerNode;
  38704. private _sceneRenderObserver;
  38705. private _scene;
  38706. private _targetPosition;
  38707. private _virtualOriginMesh;
  38708. private _virtualDragMesh;
  38709. private _pointerObserver;
  38710. private _moving;
  38711. private _startingOrientation;
  38712. /**
  38713. * 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)
  38714. */
  38715. private zDragFactor;
  38716. /**
  38717. * If the object should rotate to face the drag origin
  38718. */
  38719. rotateDraggedObject: boolean;
  38720. /**
  38721. * If the behavior is currently in a dragging state
  38722. */
  38723. dragging: boolean;
  38724. /**
  38725. * 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)
  38726. */
  38727. dragDeltaRatio: number;
  38728. /**
  38729. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38730. */
  38731. currentDraggingPointerID: number;
  38732. /**
  38733. * If camera controls should be detached during the drag
  38734. */
  38735. detachCameraControls: boolean;
  38736. /**
  38737. * Fires each time a drag starts
  38738. */
  38739. onDragStartObservable: Observable<{}>;
  38740. /**
  38741. * Fires each time a drag ends (eg. mouse release after drag)
  38742. */
  38743. onDragEndObservable: Observable<{}>;
  38744. /**
  38745. * 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
  38746. */
  38747. constructor();
  38748. /**
  38749. * The name of the behavior
  38750. */
  38751. readonly name: string;
  38752. /**
  38753. * Initializes the behavior
  38754. */
  38755. init(): void;
  38756. /**
  38757. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38758. */
  38759. private readonly _pointerCamera;
  38760. /**
  38761. * Attaches the scale behavior the passed in mesh
  38762. * @param ownerNode The mesh that will be scaled around once attached
  38763. */
  38764. attach(ownerNode: Mesh): void;
  38765. /**
  38766. * Detaches the behavior from the mesh
  38767. */
  38768. detach(): void;
  38769. }
  38770. }
  38771. declare module "babylonjs/Behaviors/Meshes/index" {
  38772. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38773. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38774. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38775. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38776. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38777. }
  38778. declare module "babylonjs/Behaviors/index" {
  38779. export * from "babylonjs/Behaviors/behavior";
  38780. export * from "babylonjs/Behaviors/Cameras/index";
  38781. export * from "babylonjs/Behaviors/Meshes/index";
  38782. }
  38783. declare module "babylonjs/Bones/boneIKController" {
  38784. import { Bone } from "babylonjs/Bones/bone";
  38785. import { Vector3 } from "babylonjs/Maths/math.vector";
  38786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38787. import { Nullable } from "babylonjs/types";
  38788. /**
  38789. * Class used to apply inverse kinematics to bones
  38790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38791. */
  38792. export class BoneIKController {
  38793. private static _tmpVecs;
  38794. private static _tmpQuat;
  38795. private static _tmpMats;
  38796. /**
  38797. * Gets or sets the target mesh
  38798. */
  38799. targetMesh: AbstractMesh;
  38800. /** Gets or sets the mesh used as pole */
  38801. poleTargetMesh: AbstractMesh;
  38802. /**
  38803. * Gets or sets the bone used as pole
  38804. */
  38805. poleTargetBone: Nullable<Bone>;
  38806. /**
  38807. * Gets or sets the target position
  38808. */
  38809. targetPosition: Vector3;
  38810. /**
  38811. * Gets or sets the pole target position
  38812. */
  38813. poleTargetPosition: Vector3;
  38814. /**
  38815. * Gets or sets the pole target local offset
  38816. */
  38817. poleTargetLocalOffset: Vector3;
  38818. /**
  38819. * Gets or sets the pole angle
  38820. */
  38821. poleAngle: number;
  38822. /**
  38823. * Gets or sets the mesh associated with the controller
  38824. */
  38825. mesh: AbstractMesh;
  38826. /**
  38827. * 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)
  38828. */
  38829. slerpAmount: number;
  38830. private _bone1Quat;
  38831. private _bone1Mat;
  38832. private _bone2Ang;
  38833. private _bone1;
  38834. private _bone2;
  38835. private _bone1Length;
  38836. private _bone2Length;
  38837. private _maxAngle;
  38838. private _maxReach;
  38839. private _rightHandedSystem;
  38840. private _bendAxis;
  38841. private _slerping;
  38842. private _adjustRoll;
  38843. /**
  38844. * Gets or sets maximum allowed angle
  38845. */
  38846. maxAngle: number;
  38847. /**
  38848. * Creates a new BoneIKController
  38849. * @param mesh defines the mesh to control
  38850. * @param bone defines the bone to control
  38851. * @param options defines options to set up the controller
  38852. */
  38853. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38854. targetMesh?: AbstractMesh;
  38855. poleTargetMesh?: AbstractMesh;
  38856. poleTargetBone?: Bone;
  38857. poleTargetLocalOffset?: Vector3;
  38858. poleAngle?: number;
  38859. bendAxis?: Vector3;
  38860. maxAngle?: number;
  38861. slerpAmount?: number;
  38862. });
  38863. private _setMaxAngle;
  38864. /**
  38865. * Force the controller to update the bones
  38866. */
  38867. update(): void;
  38868. }
  38869. }
  38870. declare module "babylonjs/Bones/boneLookController" {
  38871. import { Vector3 } from "babylonjs/Maths/math.vector";
  38872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38873. import { Bone } from "babylonjs/Bones/bone";
  38874. import { Space } from "babylonjs/Maths/math.axis";
  38875. /**
  38876. * Class used to make a bone look toward a point in space
  38877. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38878. */
  38879. export class BoneLookController {
  38880. private static _tmpVecs;
  38881. private static _tmpQuat;
  38882. private static _tmpMats;
  38883. /**
  38884. * The target Vector3 that the bone will look at
  38885. */
  38886. target: Vector3;
  38887. /**
  38888. * The mesh that the bone is attached to
  38889. */
  38890. mesh: AbstractMesh;
  38891. /**
  38892. * The bone that will be looking to the target
  38893. */
  38894. bone: Bone;
  38895. /**
  38896. * The up axis of the coordinate system that is used when the bone is rotated
  38897. */
  38898. upAxis: Vector3;
  38899. /**
  38900. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38901. */
  38902. upAxisSpace: Space;
  38903. /**
  38904. * Used to make an adjustment to the yaw of the bone
  38905. */
  38906. adjustYaw: number;
  38907. /**
  38908. * Used to make an adjustment to the pitch of the bone
  38909. */
  38910. adjustPitch: number;
  38911. /**
  38912. * Used to make an adjustment to the roll of the bone
  38913. */
  38914. adjustRoll: number;
  38915. /**
  38916. * 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)
  38917. */
  38918. slerpAmount: number;
  38919. private _minYaw;
  38920. private _maxYaw;
  38921. private _minPitch;
  38922. private _maxPitch;
  38923. private _minYawSin;
  38924. private _minYawCos;
  38925. private _maxYawSin;
  38926. private _maxYawCos;
  38927. private _midYawConstraint;
  38928. private _minPitchTan;
  38929. private _maxPitchTan;
  38930. private _boneQuat;
  38931. private _slerping;
  38932. private _transformYawPitch;
  38933. private _transformYawPitchInv;
  38934. private _firstFrameSkipped;
  38935. private _yawRange;
  38936. private _fowardAxis;
  38937. /**
  38938. * Gets or sets the minimum yaw angle that the bone can look to
  38939. */
  38940. minYaw: number;
  38941. /**
  38942. * Gets or sets the maximum yaw angle that the bone can look to
  38943. */
  38944. maxYaw: number;
  38945. /**
  38946. * Gets or sets the minimum pitch angle that the bone can look to
  38947. */
  38948. minPitch: number;
  38949. /**
  38950. * Gets or sets the maximum pitch angle that the bone can look to
  38951. */
  38952. maxPitch: number;
  38953. /**
  38954. * Create a BoneLookController
  38955. * @param mesh the mesh that the bone belongs to
  38956. * @param bone the bone that will be looking to the target
  38957. * @param target the target Vector3 to look at
  38958. * @param options optional settings:
  38959. * * maxYaw: the maximum angle the bone will yaw to
  38960. * * minYaw: the minimum angle the bone will yaw to
  38961. * * maxPitch: the maximum angle the bone will pitch to
  38962. * * minPitch: the minimum angle the bone will yaw to
  38963. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38964. * * upAxis: the up axis of the coordinate system
  38965. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38966. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38967. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38968. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38969. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38970. * * adjustRoll: used to make an adjustment to the roll of the bone
  38971. **/
  38972. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38973. maxYaw?: number;
  38974. minYaw?: number;
  38975. maxPitch?: number;
  38976. minPitch?: number;
  38977. slerpAmount?: number;
  38978. upAxis?: Vector3;
  38979. upAxisSpace?: Space;
  38980. yawAxis?: Vector3;
  38981. pitchAxis?: Vector3;
  38982. adjustYaw?: number;
  38983. adjustPitch?: number;
  38984. adjustRoll?: number;
  38985. });
  38986. /**
  38987. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38988. */
  38989. update(): void;
  38990. private _getAngleDiff;
  38991. private _getAngleBetween;
  38992. private _isAngleBetween;
  38993. }
  38994. }
  38995. declare module "babylonjs/Bones/index" {
  38996. export * from "babylonjs/Bones/bone";
  38997. export * from "babylonjs/Bones/boneIKController";
  38998. export * from "babylonjs/Bones/boneLookController";
  38999. export * from "babylonjs/Bones/skeleton";
  39000. }
  39001. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  39002. import { Nullable } from "babylonjs/types";
  39003. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39004. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39005. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39006. /**
  39007. * Manage the gamepad inputs to control an arc rotate camera.
  39008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39009. */
  39010. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39011. /**
  39012. * Defines the camera the input is attached to.
  39013. */
  39014. camera: ArcRotateCamera;
  39015. /**
  39016. * Defines the gamepad the input is gathering event from.
  39017. */
  39018. gamepad: Nullable<Gamepad>;
  39019. /**
  39020. * Defines the gamepad rotation sensiblity.
  39021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39022. */
  39023. gamepadRotationSensibility: number;
  39024. /**
  39025. * Defines the gamepad move sensiblity.
  39026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39027. */
  39028. gamepadMoveSensibility: number;
  39029. private _yAxisScale;
  39030. /**
  39031. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39032. */
  39033. invertYAxis: boolean;
  39034. private _onGamepadConnectedObserver;
  39035. private _onGamepadDisconnectedObserver;
  39036. /**
  39037. * Attach the input controls to a specific dom element to get the input from.
  39038. * @param element Defines the element the controls should be listened from
  39039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39040. */
  39041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39042. /**
  39043. * Detach the current controls from the specified dom element.
  39044. * @param element Defines the element to stop listening the inputs from
  39045. */
  39046. detachControl(element: Nullable<HTMLElement>): void;
  39047. /**
  39048. * Update the current camera state depending on the inputs that have been used this frame.
  39049. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39050. */
  39051. checkInputs(): void;
  39052. /**
  39053. * Gets the class name of the current intput.
  39054. * @returns the class name
  39055. */
  39056. getClassName(): string;
  39057. /**
  39058. * Get the friendly name associated with the input class.
  39059. * @returns the input friendly name
  39060. */
  39061. getSimpleName(): string;
  39062. }
  39063. }
  39064. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39065. import { Nullable } from "babylonjs/types";
  39066. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39067. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39068. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39069. interface ArcRotateCameraInputsManager {
  39070. /**
  39071. * Add orientation input support to the input manager.
  39072. * @returns the current input manager
  39073. */
  39074. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39075. }
  39076. }
  39077. /**
  39078. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39080. */
  39081. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39082. /**
  39083. * Defines the camera the input is attached to.
  39084. */
  39085. camera: ArcRotateCamera;
  39086. /**
  39087. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39088. */
  39089. alphaCorrection: number;
  39090. /**
  39091. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39092. */
  39093. gammaCorrection: number;
  39094. private _alpha;
  39095. private _gamma;
  39096. private _dirty;
  39097. private _deviceOrientationHandler;
  39098. /**
  39099. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39100. */
  39101. constructor();
  39102. /**
  39103. * Attach the input controls to a specific dom element to get the input from.
  39104. * @param element Defines the element the controls should be listened from
  39105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39106. */
  39107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39108. /** @hidden */
  39109. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39110. /**
  39111. * Update the current camera state depending on the inputs that have been used this frame.
  39112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39113. */
  39114. checkInputs(): void;
  39115. /**
  39116. * Detach the current controls from the specified dom element.
  39117. * @param element Defines the element to stop listening the inputs from
  39118. */
  39119. detachControl(element: Nullable<HTMLElement>): void;
  39120. /**
  39121. * Gets the class name of the current intput.
  39122. * @returns the class name
  39123. */
  39124. getClassName(): string;
  39125. /**
  39126. * Get the friendly name associated with the input class.
  39127. * @returns the input friendly name
  39128. */
  39129. getSimpleName(): string;
  39130. }
  39131. }
  39132. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39133. import { Nullable } from "babylonjs/types";
  39134. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39135. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39136. /**
  39137. * Listen to mouse events to control the camera.
  39138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39139. */
  39140. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39141. /**
  39142. * Defines the camera the input is attached to.
  39143. */
  39144. camera: FlyCamera;
  39145. /**
  39146. * Defines if touch is enabled. (Default is true.)
  39147. */
  39148. touchEnabled: boolean;
  39149. /**
  39150. * Defines the buttons associated with the input to handle camera rotation.
  39151. */
  39152. buttons: number[];
  39153. /**
  39154. * Assign buttons for Yaw control.
  39155. */
  39156. buttonsYaw: number[];
  39157. /**
  39158. * Assign buttons for Pitch control.
  39159. */
  39160. buttonsPitch: number[];
  39161. /**
  39162. * Assign buttons for Roll control.
  39163. */
  39164. buttonsRoll: number[];
  39165. /**
  39166. * Detect if any button is being pressed while mouse is moved.
  39167. * -1 = Mouse locked.
  39168. * 0 = Left button.
  39169. * 1 = Middle Button.
  39170. * 2 = Right Button.
  39171. */
  39172. activeButton: number;
  39173. /**
  39174. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39175. * Higher values reduce its sensitivity.
  39176. */
  39177. angularSensibility: number;
  39178. private _mousemoveCallback;
  39179. private _observer;
  39180. private _rollObserver;
  39181. private previousPosition;
  39182. private noPreventDefault;
  39183. private element;
  39184. /**
  39185. * Listen to mouse events to control the camera.
  39186. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39188. */
  39189. constructor(touchEnabled?: boolean);
  39190. /**
  39191. * Attach the mouse control to the HTML DOM element.
  39192. * @param element Defines the element that listens to the input events.
  39193. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39194. */
  39195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39196. /**
  39197. * Detach the current controls from the specified dom element.
  39198. * @param element Defines the element to stop listening the inputs from
  39199. */
  39200. detachControl(element: Nullable<HTMLElement>): void;
  39201. /**
  39202. * Gets the class name of the current input.
  39203. * @returns the class name.
  39204. */
  39205. getClassName(): string;
  39206. /**
  39207. * Get the friendly name associated with the input class.
  39208. * @returns the input's friendly name.
  39209. */
  39210. getSimpleName(): string;
  39211. private _pointerInput;
  39212. private _onMouseMove;
  39213. /**
  39214. * Rotate camera by mouse offset.
  39215. */
  39216. private rotateCamera;
  39217. }
  39218. }
  39219. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39220. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39221. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39222. /**
  39223. * Default Inputs manager for the FlyCamera.
  39224. * It groups all the default supported inputs for ease of use.
  39225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39226. */
  39227. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39228. /**
  39229. * Instantiates a new FlyCameraInputsManager.
  39230. * @param camera Defines the camera the inputs belong to.
  39231. */
  39232. constructor(camera: FlyCamera);
  39233. /**
  39234. * Add keyboard input support to the input manager.
  39235. * @returns the new FlyCameraKeyboardMoveInput().
  39236. */
  39237. addKeyboard(): FlyCameraInputsManager;
  39238. /**
  39239. * Add mouse input support to the input manager.
  39240. * @param touchEnabled Enable touch screen support.
  39241. * @returns the new FlyCameraMouseInput().
  39242. */
  39243. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39244. }
  39245. }
  39246. declare module "babylonjs/Cameras/flyCamera" {
  39247. import { Scene } from "babylonjs/scene";
  39248. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39250. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39251. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39252. /**
  39253. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39254. * such as in a 3D Space Shooter or a Flight Simulator.
  39255. */
  39256. export class FlyCamera extends TargetCamera {
  39257. /**
  39258. * Define the collision ellipsoid of the camera.
  39259. * This is helpful for simulating a camera body, like a player's body.
  39260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39261. */
  39262. ellipsoid: Vector3;
  39263. /**
  39264. * Define an offset for the position of the ellipsoid around the camera.
  39265. * This can be helpful if the camera is attached away from the player's body center,
  39266. * such as at its head.
  39267. */
  39268. ellipsoidOffset: Vector3;
  39269. /**
  39270. * Enable or disable collisions of the camera with the rest of the scene objects.
  39271. */
  39272. checkCollisions: boolean;
  39273. /**
  39274. * Enable or disable gravity on the camera.
  39275. */
  39276. applyGravity: boolean;
  39277. /**
  39278. * Define the current direction the camera is moving to.
  39279. */
  39280. cameraDirection: Vector3;
  39281. /**
  39282. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39283. * This overrides and empties cameraRotation.
  39284. */
  39285. rotationQuaternion: Quaternion;
  39286. /**
  39287. * Track Roll to maintain the wanted Rolling when looking around.
  39288. */
  39289. _trackRoll: number;
  39290. /**
  39291. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39292. */
  39293. rollCorrect: number;
  39294. /**
  39295. * Mimic a banked turn, Rolling the camera when Yawing.
  39296. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39297. */
  39298. bankedTurn: boolean;
  39299. /**
  39300. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39301. */
  39302. bankedTurnLimit: number;
  39303. /**
  39304. * Value of 0 disables the banked Roll.
  39305. * Value of 1 is equal to the Yaw angle in radians.
  39306. */
  39307. bankedTurnMultiplier: number;
  39308. /**
  39309. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39310. */
  39311. inputs: FlyCameraInputsManager;
  39312. /**
  39313. * Gets the input sensibility for mouse input.
  39314. * Higher values reduce sensitivity.
  39315. */
  39316. /**
  39317. * Sets the input sensibility for a mouse input.
  39318. * Higher values reduce sensitivity.
  39319. */
  39320. angularSensibility: number;
  39321. /**
  39322. * Get the keys for camera movement forward.
  39323. */
  39324. /**
  39325. * Set the keys for camera movement forward.
  39326. */
  39327. keysForward: number[];
  39328. /**
  39329. * Get the keys for camera movement backward.
  39330. */
  39331. keysBackward: number[];
  39332. /**
  39333. * Get the keys for camera movement up.
  39334. */
  39335. /**
  39336. * Set the keys for camera movement up.
  39337. */
  39338. keysUp: number[];
  39339. /**
  39340. * Get the keys for camera movement down.
  39341. */
  39342. /**
  39343. * Set the keys for camera movement down.
  39344. */
  39345. keysDown: number[];
  39346. /**
  39347. * Get the keys for camera movement left.
  39348. */
  39349. /**
  39350. * Set the keys for camera movement left.
  39351. */
  39352. keysLeft: number[];
  39353. /**
  39354. * Set the keys for camera movement right.
  39355. */
  39356. /**
  39357. * Set the keys for camera movement right.
  39358. */
  39359. keysRight: number[];
  39360. /**
  39361. * Event raised when the camera collides with a mesh in the scene.
  39362. */
  39363. onCollide: (collidedMesh: AbstractMesh) => void;
  39364. private _collider;
  39365. private _needMoveForGravity;
  39366. private _oldPosition;
  39367. private _diffPosition;
  39368. private _newPosition;
  39369. /** @hidden */
  39370. _localDirection: Vector3;
  39371. /** @hidden */
  39372. _transformedDirection: Vector3;
  39373. /**
  39374. * Instantiates a FlyCamera.
  39375. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39376. * such as in a 3D Space Shooter or a Flight Simulator.
  39377. * @param name Define the name of the camera in the scene.
  39378. * @param position Define the starting position of the camera in the scene.
  39379. * @param scene Define the scene the camera belongs to.
  39380. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39381. */
  39382. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39383. /**
  39384. * Attach a control to the HTML DOM element.
  39385. * @param element Defines the element that listens to the input events.
  39386. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39387. */
  39388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39389. /**
  39390. * Detach a control from the HTML DOM element.
  39391. * The camera will stop reacting to that input.
  39392. * @param element Defines the element that listens to the input events.
  39393. */
  39394. detachControl(element: HTMLElement): void;
  39395. private _collisionMask;
  39396. /**
  39397. * Get the mask that the camera ignores in collision events.
  39398. */
  39399. /**
  39400. * Set the mask that the camera ignores in collision events.
  39401. */
  39402. collisionMask: number;
  39403. /** @hidden */
  39404. _collideWithWorld(displacement: Vector3): void;
  39405. /** @hidden */
  39406. private _onCollisionPositionChange;
  39407. /** @hidden */
  39408. _checkInputs(): void;
  39409. /** @hidden */
  39410. _decideIfNeedsToMove(): boolean;
  39411. /** @hidden */
  39412. _updatePosition(): void;
  39413. /**
  39414. * Restore the Roll to its target value at the rate specified.
  39415. * @param rate - Higher means slower restoring.
  39416. * @hidden
  39417. */
  39418. restoreRoll(rate: number): void;
  39419. /**
  39420. * Destroy the camera and release the current resources held by it.
  39421. */
  39422. dispose(): void;
  39423. /**
  39424. * Get the current object class name.
  39425. * @returns the class name.
  39426. */
  39427. getClassName(): string;
  39428. }
  39429. }
  39430. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39431. import { Nullable } from "babylonjs/types";
  39432. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39433. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39434. /**
  39435. * Listen to keyboard events to control the camera.
  39436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39437. */
  39438. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39439. /**
  39440. * Defines the camera the input is attached to.
  39441. */
  39442. camera: FlyCamera;
  39443. /**
  39444. * The list of keyboard keys used to control the forward move of the camera.
  39445. */
  39446. keysForward: number[];
  39447. /**
  39448. * The list of keyboard keys used to control the backward move of the camera.
  39449. */
  39450. keysBackward: number[];
  39451. /**
  39452. * The list of keyboard keys used to control the forward move of the camera.
  39453. */
  39454. keysUp: number[];
  39455. /**
  39456. * The list of keyboard keys used to control the backward move of the camera.
  39457. */
  39458. keysDown: number[];
  39459. /**
  39460. * The list of keyboard keys used to control the right strafe move of the camera.
  39461. */
  39462. keysRight: number[];
  39463. /**
  39464. * The list of keyboard keys used to control the left strafe move of the camera.
  39465. */
  39466. keysLeft: number[];
  39467. private _keys;
  39468. private _onCanvasBlurObserver;
  39469. private _onKeyboardObserver;
  39470. private _engine;
  39471. private _scene;
  39472. /**
  39473. * Attach the input controls to a specific dom element to get the input from.
  39474. * @param element Defines the element the controls should be listened from
  39475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39476. */
  39477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39478. /**
  39479. * Detach the current controls from the specified dom element.
  39480. * @param element Defines the element to stop listening the inputs from
  39481. */
  39482. detachControl(element: Nullable<HTMLElement>): void;
  39483. /**
  39484. * Gets the class name of the current intput.
  39485. * @returns the class name
  39486. */
  39487. getClassName(): string;
  39488. /** @hidden */
  39489. _onLostFocus(e: FocusEvent): void;
  39490. /**
  39491. * Get the friendly name associated with the input class.
  39492. * @returns the input friendly name
  39493. */
  39494. getSimpleName(): string;
  39495. /**
  39496. * Update the current camera state depending on the inputs that have been used this frame.
  39497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39498. */
  39499. checkInputs(): void;
  39500. }
  39501. }
  39502. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39503. import { Nullable } from "babylonjs/types";
  39504. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39506. /**
  39507. * Manage the mouse wheel inputs to control a follow camera.
  39508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39509. */
  39510. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39511. /**
  39512. * Defines the camera the input is attached to.
  39513. */
  39514. camera: FollowCamera;
  39515. /**
  39516. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39517. */
  39518. axisControlRadius: boolean;
  39519. /**
  39520. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39521. */
  39522. axisControlHeight: boolean;
  39523. /**
  39524. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39525. */
  39526. axisControlRotation: boolean;
  39527. /**
  39528. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39529. * relation to mouseWheel events.
  39530. */
  39531. wheelPrecision: number;
  39532. /**
  39533. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39534. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39535. */
  39536. wheelDeltaPercentage: number;
  39537. private _wheel;
  39538. private _observer;
  39539. /**
  39540. * Attach the input controls to a specific dom element to get the input from.
  39541. * @param element Defines the element the controls should be listened from
  39542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39543. */
  39544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39545. /**
  39546. * Detach the current controls from the specified dom element.
  39547. * @param element Defines the element to stop listening the inputs from
  39548. */
  39549. detachControl(element: Nullable<HTMLElement>): void;
  39550. /**
  39551. * Gets the class name of the current intput.
  39552. * @returns the class name
  39553. */
  39554. getClassName(): string;
  39555. /**
  39556. * Get the friendly name associated with the input class.
  39557. * @returns the input friendly name
  39558. */
  39559. getSimpleName(): string;
  39560. }
  39561. }
  39562. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39563. import { Nullable } from "babylonjs/types";
  39564. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39565. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39566. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39567. /**
  39568. * Manage the pointers inputs to control an follow camera.
  39569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39570. */
  39571. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39572. /**
  39573. * Defines the camera the input is attached to.
  39574. */
  39575. camera: FollowCamera;
  39576. /**
  39577. * Gets the class name of the current input.
  39578. * @returns the class name
  39579. */
  39580. getClassName(): string;
  39581. /**
  39582. * Defines the pointer angular sensibility along the X axis or how fast is
  39583. * the camera rotating.
  39584. * A negative number will reverse the axis direction.
  39585. */
  39586. angularSensibilityX: number;
  39587. /**
  39588. * Defines the pointer angular sensibility along the Y axis or how fast is
  39589. * the camera rotating.
  39590. * A negative number will reverse the axis direction.
  39591. */
  39592. angularSensibilityY: number;
  39593. /**
  39594. * Defines the pointer pinch precision or how fast is the camera zooming.
  39595. * A negative number will reverse the axis direction.
  39596. */
  39597. pinchPrecision: number;
  39598. /**
  39599. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39600. * from 0.
  39601. * It defines the percentage of current camera.radius to use as delta when
  39602. * pinch zoom is used.
  39603. */
  39604. pinchDeltaPercentage: number;
  39605. /**
  39606. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39607. */
  39608. axisXControlRadius: boolean;
  39609. /**
  39610. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39611. */
  39612. axisXControlHeight: boolean;
  39613. /**
  39614. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39615. */
  39616. axisXControlRotation: boolean;
  39617. /**
  39618. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39619. */
  39620. axisYControlRadius: boolean;
  39621. /**
  39622. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39623. */
  39624. axisYControlHeight: boolean;
  39625. /**
  39626. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39627. */
  39628. axisYControlRotation: boolean;
  39629. /**
  39630. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39631. */
  39632. axisPinchControlRadius: boolean;
  39633. /**
  39634. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39635. */
  39636. axisPinchControlHeight: boolean;
  39637. /**
  39638. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39639. */
  39640. axisPinchControlRotation: boolean;
  39641. /**
  39642. * Log error messages if basic misconfiguration has occurred.
  39643. */
  39644. warningEnable: boolean;
  39645. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39646. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39647. private _warningCounter;
  39648. private _warning;
  39649. }
  39650. }
  39651. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39652. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39653. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39654. /**
  39655. * Default Inputs manager for the FollowCamera.
  39656. * It groups all the default supported inputs for ease of use.
  39657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39658. */
  39659. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39660. /**
  39661. * Instantiates a new FollowCameraInputsManager.
  39662. * @param camera Defines the camera the inputs belong to
  39663. */
  39664. constructor(camera: FollowCamera);
  39665. /**
  39666. * Add keyboard input support to the input manager.
  39667. * @returns the current input manager
  39668. */
  39669. addKeyboard(): FollowCameraInputsManager;
  39670. /**
  39671. * Add mouse wheel input support to the input manager.
  39672. * @returns the current input manager
  39673. */
  39674. addMouseWheel(): FollowCameraInputsManager;
  39675. /**
  39676. * Add pointers input support to the input manager.
  39677. * @returns the current input manager
  39678. */
  39679. addPointers(): FollowCameraInputsManager;
  39680. /**
  39681. * Add orientation input support to the input manager.
  39682. * @returns the current input manager
  39683. */
  39684. addVRDeviceOrientation(): FollowCameraInputsManager;
  39685. }
  39686. }
  39687. declare module "babylonjs/Cameras/followCamera" {
  39688. import { Nullable } from "babylonjs/types";
  39689. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39690. import { Scene } from "babylonjs/scene";
  39691. import { Vector3 } from "babylonjs/Maths/math.vector";
  39692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39693. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39694. /**
  39695. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39696. * an arc rotate version arcFollowCamera are available.
  39697. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39698. */
  39699. export class FollowCamera extends TargetCamera {
  39700. /**
  39701. * Distance the follow camera should follow an object at
  39702. */
  39703. radius: number;
  39704. /**
  39705. * Minimum allowed distance of the camera to the axis of rotation
  39706. * (The camera can not get closer).
  39707. * This can help limiting how the Camera is able to move in the scene.
  39708. */
  39709. lowerRadiusLimit: Nullable<number>;
  39710. /**
  39711. * Maximum allowed distance of the camera to the axis of rotation
  39712. * (The camera can not get further).
  39713. * This can help limiting how the Camera is able to move in the scene.
  39714. */
  39715. upperRadiusLimit: Nullable<number>;
  39716. /**
  39717. * Define a rotation offset between the camera and the object it follows
  39718. */
  39719. rotationOffset: number;
  39720. /**
  39721. * Minimum allowed angle to camera position relative to target object.
  39722. * This can help limiting how the Camera is able to move in the scene.
  39723. */
  39724. lowerRotationOffsetLimit: Nullable<number>;
  39725. /**
  39726. * Maximum allowed angle to camera position relative to target object.
  39727. * This can help limiting how the Camera is able to move in the scene.
  39728. */
  39729. upperRotationOffsetLimit: Nullable<number>;
  39730. /**
  39731. * Define a height offset between the camera and the object it follows.
  39732. * It can help following an object from the top (like a car chaing a plane)
  39733. */
  39734. heightOffset: number;
  39735. /**
  39736. * Minimum allowed height of camera position relative to target object.
  39737. * This can help limiting how the Camera is able to move in the scene.
  39738. */
  39739. lowerHeightOffsetLimit: Nullable<number>;
  39740. /**
  39741. * Maximum allowed height of camera position relative to target object.
  39742. * This can help limiting how the Camera is able to move in the scene.
  39743. */
  39744. upperHeightOffsetLimit: Nullable<number>;
  39745. /**
  39746. * Define how fast the camera can accelerate to follow it s target.
  39747. */
  39748. cameraAcceleration: number;
  39749. /**
  39750. * Define the speed limit of the camera following an object.
  39751. */
  39752. maxCameraSpeed: number;
  39753. /**
  39754. * Define the target of the camera.
  39755. */
  39756. lockedTarget: Nullable<AbstractMesh>;
  39757. /**
  39758. * Defines the input associated with the camera.
  39759. */
  39760. inputs: FollowCameraInputsManager;
  39761. /**
  39762. * Instantiates the follow camera.
  39763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39764. * @param name Define the name of the camera in the scene
  39765. * @param position Define the position of the camera
  39766. * @param scene Define the scene the camera belong to
  39767. * @param lockedTarget Define the target of the camera
  39768. */
  39769. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39770. private _follow;
  39771. /**
  39772. * Attached controls to the current camera.
  39773. * @param element Defines the element the controls should be listened from
  39774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39775. */
  39776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39777. /**
  39778. * Detach the current controls from the camera.
  39779. * The camera will stop reacting to inputs.
  39780. * @param element Defines the element to stop listening the inputs from
  39781. */
  39782. detachControl(element: HTMLElement): void;
  39783. /** @hidden */
  39784. _checkInputs(): void;
  39785. private _checkLimits;
  39786. /**
  39787. * Gets the camera class name.
  39788. * @returns the class name
  39789. */
  39790. getClassName(): string;
  39791. }
  39792. /**
  39793. * Arc Rotate version of the follow camera.
  39794. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39795. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39796. */
  39797. export class ArcFollowCamera extends TargetCamera {
  39798. /** The longitudinal angle of the camera */
  39799. alpha: number;
  39800. /** The latitudinal angle of the camera */
  39801. beta: number;
  39802. /** The radius of the camera from its target */
  39803. radius: number;
  39804. /** Define the camera target (the messh it should follow) */
  39805. target: Nullable<AbstractMesh>;
  39806. private _cartesianCoordinates;
  39807. /**
  39808. * Instantiates a new ArcFollowCamera
  39809. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39810. * @param name Define the name of the camera
  39811. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39812. * @param beta Define the rotation angle of the camera around the elevation axis
  39813. * @param radius Define the radius of the camera from its target point
  39814. * @param target Define the target of the camera
  39815. * @param scene Define the scene the camera belongs to
  39816. */
  39817. constructor(name: string,
  39818. /** The longitudinal angle of the camera */
  39819. alpha: number,
  39820. /** The latitudinal angle of the camera */
  39821. beta: number,
  39822. /** The radius of the camera from its target */
  39823. radius: number,
  39824. /** Define the camera target (the messh it should follow) */
  39825. target: Nullable<AbstractMesh>, scene: Scene);
  39826. private _follow;
  39827. /** @hidden */
  39828. _checkInputs(): void;
  39829. /**
  39830. * Returns the class name of the object.
  39831. * It is mostly used internally for serialization purposes.
  39832. */
  39833. getClassName(): string;
  39834. }
  39835. }
  39836. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39837. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39838. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39839. import { Nullable } from "babylonjs/types";
  39840. /**
  39841. * Manage the keyboard inputs to control the movement of a follow camera.
  39842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39843. */
  39844. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39845. /**
  39846. * Defines the camera the input is attached to.
  39847. */
  39848. camera: FollowCamera;
  39849. /**
  39850. * Defines the list of key codes associated with the up action (increase heightOffset)
  39851. */
  39852. keysHeightOffsetIncr: number[];
  39853. /**
  39854. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39855. */
  39856. keysHeightOffsetDecr: number[];
  39857. /**
  39858. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39859. */
  39860. keysHeightOffsetModifierAlt: boolean;
  39861. /**
  39862. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39863. */
  39864. keysHeightOffsetModifierCtrl: boolean;
  39865. /**
  39866. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39867. */
  39868. keysHeightOffsetModifierShift: boolean;
  39869. /**
  39870. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39871. */
  39872. keysRotationOffsetIncr: number[];
  39873. /**
  39874. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39875. */
  39876. keysRotationOffsetDecr: number[];
  39877. /**
  39878. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39879. */
  39880. keysRotationOffsetModifierAlt: boolean;
  39881. /**
  39882. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39883. */
  39884. keysRotationOffsetModifierCtrl: boolean;
  39885. /**
  39886. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39887. */
  39888. keysRotationOffsetModifierShift: boolean;
  39889. /**
  39890. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39891. */
  39892. keysRadiusIncr: number[];
  39893. /**
  39894. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39895. */
  39896. keysRadiusDecr: number[];
  39897. /**
  39898. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39899. */
  39900. keysRadiusModifierAlt: boolean;
  39901. /**
  39902. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39903. */
  39904. keysRadiusModifierCtrl: boolean;
  39905. /**
  39906. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39907. */
  39908. keysRadiusModifierShift: boolean;
  39909. /**
  39910. * Defines the rate of change of heightOffset.
  39911. */
  39912. heightSensibility: number;
  39913. /**
  39914. * Defines the rate of change of rotationOffset.
  39915. */
  39916. rotationSensibility: number;
  39917. /**
  39918. * Defines the rate of change of radius.
  39919. */
  39920. radiusSensibility: number;
  39921. private _keys;
  39922. private _ctrlPressed;
  39923. private _altPressed;
  39924. private _shiftPressed;
  39925. private _onCanvasBlurObserver;
  39926. private _onKeyboardObserver;
  39927. private _engine;
  39928. private _scene;
  39929. /**
  39930. * Attach the input controls to a specific dom element to get the input from.
  39931. * @param element Defines the element the controls should be listened from
  39932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39933. */
  39934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39935. /**
  39936. * Detach the current controls from the specified dom element.
  39937. * @param element Defines the element to stop listening the inputs from
  39938. */
  39939. detachControl(element: Nullable<HTMLElement>): void;
  39940. /**
  39941. * Update the current camera state depending on the inputs that have been used this frame.
  39942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39943. */
  39944. checkInputs(): void;
  39945. /**
  39946. * Gets the class name of the current input.
  39947. * @returns the class name
  39948. */
  39949. getClassName(): string;
  39950. /**
  39951. * Get the friendly name associated with the input class.
  39952. * @returns the input friendly name
  39953. */
  39954. getSimpleName(): string;
  39955. /**
  39956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39957. * allow modification of the heightOffset value.
  39958. */
  39959. private _modifierHeightOffset;
  39960. /**
  39961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39962. * allow modification of the rotationOffset value.
  39963. */
  39964. private _modifierRotationOffset;
  39965. /**
  39966. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39967. * allow modification of the radius value.
  39968. */
  39969. private _modifierRadius;
  39970. }
  39971. }
  39972. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39973. import { Nullable } from "babylonjs/types";
  39974. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39976. import { Observable } from "babylonjs/Misc/observable";
  39977. module "babylonjs/Cameras/freeCameraInputsManager" {
  39978. interface FreeCameraInputsManager {
  39979. /**
  39980. * @hidden
  39981. */
  39982. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39983. /**
  39984. * Add orientation input support to the input manager.
  39985. * @returns the current input manager
  39986. */
  39987. addDeviceOrientation(): FreeCameraInputsManager;
  39988. }
  39989. }
  39990. /**
  39991. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39992. * Screen rotation is taken into account.
  39993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39994. */
  39995. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39996. private _camera;
  39997. private _screenOrientationAngle;
  39998. private _constantTranform;
  39999. private _screenQuaternion;
  40000. private _alpha;
  40001. private _beta;
  40002. private _gamma;
  40003. /**
  40004. * Can be used to detect if a device orientation sensor is availible on a device
  40005. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40006. * @returns a promise that will resolve on orientation change
  40007. */
  40008. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40009. /**
  40010. * @hidden
  40011. */
  40012. _onDeviceOrientationChangedObservable: Observable<void>;
  40013. /**
  40014. * Instantiates a new input
  40015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40016. */
  40017. constructor();
  40018. /**
  40019. * Define the camera controlled by the input.
  40020. */
  40021. camera: FreeCamera;
  40022. /**
  40023. * Attach the input controls to a specific dom element to get the input from.
  40024. * @param element Defines the element the controls should be listened from
  40025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40026. */
  40027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40028. private _orientationChanged;
  40029. private _deviceOrientation;
  40030. /**
  40031. * Detach the current controls from the specified dom element.
  40032. * @param element Defines the element to stop listening the inputs from
  40033. */
  40034. detachControl(element: Nullable<HTMLElement>): void;
  40035. /**
  40036. * Update the current camera state depending on the inputs that have been used this frame.
  40037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40038. */
  40039. checkInputs(): void;
  40040. /**
  40041. * Gets the class name of the current intput.
  40042. * @returns the class name
  40043. */
  40044. getClassName(): string;
  40045. /**
  40046. * Get the friendly name associated with the input class.
  40047. * @returns the input friendly name
  40048. */
  40049. getSimpleName(): string;
  40050. }
  40051. }
  40052. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40053. import { Nullable } from "babylonjs/types";
  40054. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40056. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40057. /**
  40058. * Manage the gamepad inputs to control a free camera.
  40059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40060. */
  40061. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40062. /**
  40063. * Define the camera the input is attached to.
  40064. */
  40065. camera: FreeCamera;
  40066. /**
  40067. * Define the Gamepad controlling the input
  40068. */
  40069. gamepad: Nullable<Gamepad>;
  40070. /**
  40071. * Defines the gamepad rotation sensiblity.
  40072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40073. */
  40074. gamepadAngularSensibility: number;
  40075. /**
  40076. * Defines the gamepad move sensiblity.
  40077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40078. */
  40079. gamepadMoveSensibility: number;
  40080. private _yAxisScale;
  40081. /**
  40082. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40083. */
  40084. invertYAxis: boolean;
  40085. private _onGamepadConnectedObserver;
  40086. private _onGamepadDisconnectedObserver;
  40087. private _cameraTransform;
  40088. private _deltaTransform;
  40089. private _vector3;
  40090. private _vector2;
  40091. /**
  40092. * Attach the input controls to a specific dom element to get the input from.
  40093. * @param element Defines the element the controls should be listened from
  40094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40095. */
  40096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40097. /**
  40098. * Detach the current controls from the specified dom element.
  40099. * @param element Defines the element to stop listening the inputs from
  40100. */
  40101. detachControl(element: Nullable<HTMLElement>): void;
  40102. /**
  40103. * Update the current camera state depending on the inputs that have been used this frame.
  40104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40105. */
  40106. checkInputs(): void;
  40107. /**
  40108. * Gets the class name of the current intput.
  40109. * @returns the class name
  40110. */
  40111. getClassName(): string;
  40112. /**
  40113. * Get the friendly name associated with the input class.
  40114. * @returns the input friendly name
  40115. */
  40116. getSimpleName(): string;
  40117. }
  40118. }
  40119. declare module "babylonjs/Misc/virtualJoystick" {
  40120. import { Nullable } from "babylonjs/types";
  40121. import { Vector3 } from "babylonjs/Maths/math.vector";
  40122. /**
  40123. * Defines the potential axis of a Joystick
  40124. */
  40125. export enum JoystickAxis {
  40126. /** X axis */
  40127. X = 0,
  40128. /** Y axis */
  40129. Y = 1,
  40130. /** Z axis */
  40131. Z = 2
  40132. }
  40133. /**
  40134. * Class used to define virtual joystick (used in touch mode)
  40135. */
  40136. export class VirtualJoystick {
  40137. /**
  40138. * Gets or sets a boolean indicating that left and right values must be inverted
  40139. */
  40140. reverseLeftRight: boolean;
  40141. /**
  40142. * Gets or sets a boolean indicating that up and down values must be inverted
  40143. */
  40144. reverseUpDown: boolean;
  40145. /**
  40146. * Gets the offset value for the position (ie. the change of the position value)
  40147. */
  40148. deltaPosition: Vector3;
  40149. /**
  40150. * Gets a boolean indicating if the virtual joystick was pressed
  40151. */
  40152. pressed: boolean;
  40153. /**
  40154. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40155. */
  40156. static Canvas: Nullable<HTMLCanvasElement>;
  40157. private static _globalJoystickIndex;
  40158. private static vjCanvasContext;
  40159. private static vjCanvasWidth;
  40160. private static vjCanvasHeight;
  40161. private static halfWidth;
  40162. private _action;
  40163. private _axisTargetedByLeftAndRight;
  40164. private _axisTargetedByUpAndDown;
  40165. private _joystickSensibility;
  40166. private _inversedSensibility;
  40167. private _joystickPointerID;
  40168. private _joystickColor;
  40169. private _joystickPointerPos;
  40170. private _joystickPreviousPointerPos;
  40171. private _joystickPointerStartPos;
  40172. private _deltaJoystickVector;
  40173. private _leftJoystick;
  40174. private _touches;
  40175. private _onPointerDownHandlerRef;
  40176. private _onPointerMoveHandlerRef;
  40177. private _onPointerUpHandlerRef;
  40178. private _onResize;
  40179. /**
  40180. * Creates a new virtual joystick
  40181. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40182. */
  40183. constructor(leftJoystick?: boolean);
  40184. /**
  40185. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40186. * @param newJoystickSensibility defines the new sensibility
  40187. */
  40188. setJoystickSensibility(newJoystickSensibility: number): void;
  40189. private _onPointerDown;
  40190. private _onPointerMove;
  40191. private _onPointerUp;
  40192. /**
  40193. * Change the color of the virtual joystick
  40194. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40195. */
  40196. setJoystickColor(newColor: string): void;
  40197. /**
  40198. * Defines a callback to call when the joystick is touched
  40199. * @param action defines the callback
  40200. */
  40201. setActionOnTouch(action: () => any): void;
  40202. /**
  40203. * Defines which axis you'd like to control for left & right
  40204. * @param axis defines the axis to use
  40205. */
  40206. setAxisForLeftRight(axis: JoystickAxis): void;
  40207. /**
  40208. * Defines which axis you'd like to control for up & down
  40209. * @param axis defines the axis to use
  40210. */
  40211. setAxisForUpDown(axis: JoystickAxis): void;
  40212. private _drawVirtualJoystick;
  40213. /**
  40214. * Release internal HTML canvas
  40215. */
  40216. releaseCanvas(): void;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40220. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40221. import { Nullable } from "babylonjs/types";
  40222. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40223. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40224. module "babylonjs/Cameras/freeCameraInputsManager" {
  40225. interface FreeCameraInputsManager {
  40226. /**
  40227. * Add virtual joystick input support to the input manager.
  40228. * @returns the current input manager
  40229. */
  40230. addVirtualJoystick(): FreeCameraInputsManager;
  40231. }
  40232. }
  40233. /**
  40234. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40236. */
  40237. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40238. /**
  40239. * Defines the camera the input is attached to.
  40240. */
  40241. camera: FreeCamera;
  40242. private _leftjoystick;
  40243. private _rightjoystick;
  40244. /**
  40245. * Gets the left stick of the virtual joystick.
  40246. * @returns The virtual Joystick
  40247. */
  40248. getLeftJoystick(): VirtualJoystick;
  40249. /**
  40250. * Gets the right stick of the virtual joystick.
  40251. * @returns The virtual Joystick
  40252. */
  40253. getRightJoystick(): VirtualJoystick;
  40254. /**
  40255. * Update the current camera state depending on the inputs that have been used this frame.
  40256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40257. */
  40258. checkInputs(): void;
  40259. /**
  40260. * Attach the input controls to a specific dom element to get the input from.
  40261. * @param element Defines the element the controls should be listened from
  40262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40263. */
  40264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40265. /**
  40266. * Detach the current controls from the specified dom element.
  40267. * @param element Defines the element to stop listening the inputs from
  40268. */
  40269. detachControl(element: Nullable<HTMLElement>): void;
  40270. /**
  40271. * Gets the class name of the current intput.
  40272. * @returns the class name
  40273. */
  40274. getClassName(): string;
  40275. /**
  40276. * Get the friendly name associated with the input class.
  40277. * @returns the input friendly name
  40278. */
  40279. getSimpleName(): string;
  40280. }
  40281. }
  40282. declare module "babylonjs/Cameras/Inputs/index" {
  40283. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40284. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40285. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40286. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40287. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40288. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40289. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40290. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40291. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40292. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40293. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40294. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40295. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40296. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40297. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40298. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40299. }
  40300. declare module "babylonjs/Cameras/touchCamera" {
  40301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40302. import { Scene } from "babylonjs/scene";
  40303. import { Vector3 } from "babylonjs/Maths/math.vector";
  40304. /**
  40305. * This represents a FPS type of camera controlled by touch.
  40306. * This is like a universal camera minus the Gamepad controls.
  40307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40308. */
  40309. export class TouchCamera extends FreeCamera {
  40310. /**
  40311. * Defines the touch sensibility for rotation.
  40312. * The higher the faster.
  40313. */
  40314. touchAngularSensibility: number;
  40315. /**
  40316. * Defines the touch sensibility for move.
  40317. * The higher the faster.
  40318. */
  40319. touchMoveSensibility: number;
  40320. /**
  40321. * Instantiates a new touch camera.
  40322. * This represents a FPS type of camera controlled by touch.
  40323. * This is like a universal camera minus the Gamepad controls.
  40324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40325. * @param name Define the name of the camera in the scene
  40326. * @param position Define the start position of the camera in the scene
  40327. * @param scene Define the scene the camera belongs to
  40328. */
  40329. constructor(name: string, position: Vector3, scene: Scene);
  40330. /**
  40331. * Gets the current object class name.
  40332. * @return the class name
  40333. */
  40334. getClassName(): string;
  40335. /** @hidden */
  40336. _setupInputs(): void;
  40337. }
  40338. }
  40339. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40341. import { Scene } from "babylonjs/scene";
  40342. import { Vector3 } from "babylonjs/Maths/math.vector";
  40343. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40344. import { Axis } from "babylonjs/Maths/math.axis";
  40345. /**
  40346. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40347. * being tilted forward or back and left or right.
  40348. */
  40349. export class DeviceOrientationCamera extends FreeCamera {
  40350. private _initialQuaternion;
  40351. private _quaternionCache;
  40352. private _tmpDragQuaternion;
  40353. private _disablePointerInputWhenUsingDeviceOrientation;
  40354. /**
  40355. * Creates a new device orientation camera
  40356. * @param name The name of the camera
  40357. * @param position The start position camera
  40358. * @param scene The scene the camera belongs to
  40359. */
  40360. constructor(name: string, position: Vector3, scene: Scene);
  40361. /**
  40362. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40363. */
  40364. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40365. private _dragFactor;
  40366. /**
  40367. * Enabled turning on the y axis when the orientation sensor is active
  40368. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40369. */
  40370. enableHorizontalDragging(dragFactor?: number): void;
  40371. /**
  40372. * Gets the current instance class name ("DeviceOrientationCamera").
  40373. * This helps avoiding instanceof at run time.
  40374. * @returns the class name
  40375. */
  40376. getClassName(): string;
  40377. /**
  40378. * @hidden
  40379. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40380. */
  40381. _checkInputs(): void;
  40382. /**
  40383. * Reset the camera to its default orientation on the specified axis only.
  40384. * @param axis The axis to reset
  40385. */
  40386. resetToCurrentRotation(axis?: Axis): void;
  40387. }
  40388. }
  40389. declare module "babylonjs/Gamepads/xboxGamepad" {
  40390. import { Observable } from "babylonjs/Misc/observable";
  40391. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40392. /**
  40393. * Defines supported buttons for XBox360 compatible gamepads
  40394. */
  40395. export enum Xbox360Button {
  40396. /** A */
  40397. A = 0,
  40398. /** B */
  40399. B = 1,
  40400. /** X */
  40401. X = 2,
  40402. /** Y */
  40403. Y = 3,
  40404. /** Start */
  40405. Start = 4,
  40406. /** Back */
  40407. Back = 5,
  40408. /** Left button */
  40409. LB = 6,
  40410. /** Right button */
  40411. RB = 7,
  40412. /** Left stick */
  40413. LeftStick = 8,
  40414. /** Right stick */
  40415. RightStick = 9
  40416. }
  40417. /** Defines values for XBox360 DPad */
  40418. export enum Xbox360Dpad {
  40419. /** Up */
  40420. Up = 0,
  40421. /** Down */
  40422. Down = 1,
  40423. /** Left */
  40424. Left = 2,
  40425. /** Right */
  40426. Right = 3
  40427. }
  40428. /**
  40429. * Defines a XBox360 gamepad
  40430. */
  40431. export class Xbox360Pad extends Gamepad {
  40432. private _leftTrigger;
  40433. private _rightTrigger;
  40434. private _onlefttriggerchanged;
  40435. private _onrighttriggerchanged;
  40436. private _onbuttondown;
  40437. private _onbuttonup;
  40438. private _ondpaddown;
  40439. private _ondpadup;
  40440. /** Observable raised when a button is pressed */
  40441. onButtonDownObservable: Observable<Xbox360Button>;
  40442. /** Observable raised when a button is released */
  40443. onButtonUpObservable: Observable<Xbox360Button>;
  40444. /** Observable raised when a pad is pressed */
  40445. onPadDownObservable: Observable<Xbox360Dpad>;
  40446. /** Observable raised when a pad is released */
  40447. onPadUpObservable: Observable<Xbox360Dpad>;
  40448. private _buttonA;
  40449. private _buttonB;
  40450. private _buttonX;
  40451. private _buttonY;
  40452. private _buttonBack;
  40453. private _buttonStart;
  40454. private _buttonLB;
  40455. private _buttonRB;
  40456. private _buttonLeftStick;
  40457. private _buttonRightStick;
  40458. private _dPadUp;
  40459. private _dPadDown;
  40460. private _dPadLeft;
  40461. private _dPadRight;
  40462. private _isXboxOnePad;
  40463. /**
  40464. * Creates a new XBox360 gamepad object
  40465. * @param id defines the id of this gamepad
  40466. * @param index defines its index
  40467. * @param gamepad defines the internal HTML gamepad object
  40468. * @param xboxOne defines if it is a XBox One gamepad
  40469. */
  40470. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40471. /**
  40472. * Defines the callback to call when left trigger is pressed
  40473. * @param callback defines the callback to use
  40474. */
  40475. onlefttriggerchanged(callback: (value: number) => void): void;
  40476. /**
  40477. * Defines the callback to call when right trigger is pressed
  40478. * @param callback defines the callback to use
  40479. */
  40480. onrighttriggerchanged(callback: (value: number) => void): void;
  40481. /**
  40482. * Gets the left trigger value
  40483. */
  40484. /**
  40485. * Sets the left trigger value
  40486. */
  40487. leftTrigger: number;
  40488. /**
  40489. * Gets the right trigger value
  40490. */
  40491. /**
  40492. * Sets the right trigger value
  40493. */
  40494. rightTrigger: number;
  40495. /**
  40496. * Defines the callback to call when a button is pressed
  40497. * @param callback defines the callback to use
  40498. */
  40499. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40500. /**
  40501. * Defines the callback to call when a button is released
  40502. * @param callback defines the callback to use
  40503. */
  40504. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40505. /**
  40506. * Defines the callback to call when a pad is pressed
  40507. * @param callback defines the callback to use
  40508. */
  40509. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40510. /**
  40511. * Defines the callback to call when a pad is released
  40512. * @param callback defines the callback to use
  40513. */
  40514. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40515. private _setButtonValue;
  40516. private _setDPadValue;
  40517. /**
  40518. * Gets the value of the `A` button
  40519. */
  40520. /**
  40521. * Sets the value of the `A` button
  40522. */
  40523. buttonA: number;
  40524. /**
  40525. * Gets the value of the `B` button
  40526. */
  40527. /**
  40528. * Sets the value of the `B` button
  40529. */
  40530. buttonB: number;
  40531. /**
  40532. * Gets the value of the `X` button
  40533. */
  40534. /**
  40535. * Sets the value of the `X` button
  40536. */
  40537. buttonX: number;
  40538. /**
  40539. * Gets the value of the `Y` button
  40540. */
  40541. /**
  40542. * Sets the value of the `Y` button
  40543. */
  40544. buttonY: number;
  40545. /**
  40546. * Gets the value of the `Start` button
  40547. */
  40548. /**
  40549. * Sets the value of the `Start` button
  40550. */
  40551. buttonStart: number;
  40552. /**
  40553. * Gets the value of the `Back` button
  40554. */
  40555. /**
  40556. * Sets the value of the `Back` button
  40557. */
  40558. buttonBack: number;
  40559. /**
  40560. * Gets the value of the `Left` button
  40561. */
  40562. /**
  40563. * Sets the value of the `Left` button
  40564. */
  40565. buttonLB: number;
  40566. /**
  40567. * Gets the value of the `Right` button
  40568. */
  40569. /**
  40570. * Sets the value of the `Right` button
  40571. */
  40572. buttonRB: number;
  40573. /**
  40574. * Gets the value of the Left joystick
  40575. */
  40576. /**
  40577. * Sets the value of the Left joystick
  40578. */
  40579. buttonLeftStick: number;
  40580. /**
  40581. * Gets the value of the Right joystick
  40582. */
  40583. /**
  40584. * Sets the value of the Right joystick
  40585. */
  40586. buttonRightStick: number;
  40587. /**
  40588. * Gets the value of D-pad up
  40589. */
  40590. /**
  40591. * Sets the value of D-pad up
  40592. */
  40593. dPadUp: number;
  40594. /**
  40595. * Gets the value of D-pad down
  40596. */
  40597. /**
  40598. * Sets the value of D-pad down
  40599. */
  40600. dPadDown: number;
  40601. /**
  40602. * Gets the value of D-pad left
  40603. */
  40604. /**
  40605. * Sets the value of D-pad left
  40606. */
  40607. dPadLeft: number;
  40608. /**
  40609. * Gets the value of D-pad right
  40610. */
  40611. /**
  40612. * Sets the value of D-pad right
  40613. */
  40614. dPadRight: number;
  40615. /**
  40616. * Force the gamepad to synchronize with device values
  40617. */
  40618. update(): void;
  40619. /**
  40620. * Disposes the gamepad
  40621. */
  40622. dispose(): void;
  40623. }
  40624. }
  40625. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40626. import { Observable } from "babylonjs/Misc/observable";
  40627. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40628. /**
  40629. * Defines supported buttons for DualShock compatible gamepads
  40630. */
  40631. export enum DualShockButton {
  40632. /** Cross */
  40633. Cross = 0,
  40634. /** Circle */
  40635. Circle = 1,
  40636. /** Square */
  40637. Square = 2,
  40638. /** Triangle */
  40639. Triangle = 3,
  40640. /** Options */
  40641. Options = 4,
  40642. /** Share */
  40643. Share = 5,
  40644. /** L1 */
  40645. L1 = 6,
  40646. /** R1 */
  40647. R1 = 7,
  40648. /** Left stick */
  40649. LeftStick = 8,
  40650. /** Right stick */
  40651. RightStick = 9
  40652. }
  40653. /** Defines values for DualShock DPad */
  40654. export enum DualShockDpad {
  40655. /** Up */
  40656. Up = 0,
  40657. /** Down */
  40658. Down = 1,
  40659. /** Left */
  40660. Left = 2,
  40661. /** Right */
  40662. Right = 3
  40663. }
  40664. /**
  40665. * Defines a DualShock gamepad
  40666. */
  40667. export class DualShockPad extends Gamepad {
  40668. private _leftTrigger;
  40669. private _rightTrigger;
  40670. private _onlefttriggerchanged;
  40671. private _onrighttriggerchanged;
  40672. private _onbuttondown;
  40673. private _onbuttonup;
  40674. private _ondpaddown;
  40675. private _ondpadup;
  40676. /** Observable raised when a button is pressed */
  40677. onButtonDownObservable: Observable<DualShockButton>;
  40678. /** Observable raised when a button is released */
  40679. onButtonUpObservable: Observable<DualShockButton>;
  40680. /** Observable raised when a pad is pressed */
  40681. onPadDownObservable: Observable<DualShockDpad>;
  40682. /** Observable raised when a pad is released */
  40683. onPadUpObservable: Observable<DualShockDpad>;
  40684. private _buttonCross;
  40685. private _buttonCircle;
  40686. private _buttonSquare;
  40687. private _buttonTriangle;
  40688. private _buttonShare;
  40689. private _buttonOptions;
  40690. private _buttonL1;
  40691. private _buttonR1;
  40692. private _buttonLeftStick;
  40693. private _buttonRightStick;
  40694. private _dPadUp;
  40695. private _dPadDown;
  40696. private _dPadLeft;
  40697. private _dPadRight;
  40698. /**
  40699. * Creates a new DualShock gamepad object
  40700. * @param id defines the id of this gamepad
  40701. * @param index defines its index
  40702. * @param gamepad defines the internal HTML gamepad object
  40703. */
  40704. constructor(id: string, index: number, gamepad: any);
  40705. /**
  40706. * Defines the callback to call when left trigger is pressed
  40707. * @param callback defines the callback to use
  40708. */
  40709. onlefttriggerchanged(callback: (value: number) => void): void;
  40710. /**
  40711. * Defines the callback to call when right trigger is pressed
  40712. * @param callback defines the callback to use
  40713. */
  40714. onrighttriggerchanged(callback: (value: number) => void): void;
  40715. /**
  40716. * Gets the left trigger value
  40717. */
  40718. /**
  40719. * Sets the left trigger value
  40720. */
  40721. leftTrigger: number;
  40722. /**
  40723. * Gets the right trigger value
  40724. */
  40725. /**
  40726. * Sets the right trigger value
  40727. */
  40728. rightTrigger: number;
  40729. /**
  40730. * Defines the callback to call when a button is pressed
  40731. * @param callback defines the callback to use
  40732. */
  40733. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40734. /**
  40735. * Defines the callback to call when a button is released
  40736. * @param callback defines the callback to use
  40737. */
  40738. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40739. /**
  40740. * Defines the callback to call when a pad is pressed
  40741. * @param callback defines the callback to use
  40742. */
  40743. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40744. /**
  40745. * Defines the callback to call when a pad is released
  40746. * @param callback defines the callback to use
  40747. */
  40748. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40749. private _setButtonValue;
  40750. private _setDPadValue;
  40751. /**
  40752. * Gets the value of the `Cross` button
  40753. */
  40754. /**
  40755. * Sets the value of the `Cross` button
  40756. */
  40757. buttonCross: number;
  40758. /**
  40759. * Gets the value of the `Circle` button
  40760. */
  40761. /**
  40762. * Sets the value of the `Circle` button
  40763. */
  40764. buttonCircle: number;
  40765. /**
  40766. * Gets the value of the `Square` button
  40767. */
  40768. /**
  40769. * Sets the value of the `Square` button
  40770. */
  40771. buttonSquare: number;
  40772. /**
  40773. * Gets the value of the `Triangle` button
  40774. */
  40775. /**
  40776. * Sets the value of the `Triangle` button
  40777. */
  40778. buttonTriangle: number;
  40779. /**
  40780. * Gets the value of the `Options` button
  40781. */
  40782. /**
  40783. * Sets the value of the `Options` button
  40784. */
  40785. buttonOptions: number;
  40786. /**
  40787. * Gets the value of the `Share` button
  40788. */
  40789. /**
  40790. * Sets the value of the `Share` button
  40791. */
  40792. buttonShare: number;
  40793. /**
  40794. * Gets the value of the `L1` button
  40795. */
  40796. /**
  40797. * Sets the value of the `L1` button
  40798. */
  40799. buttonL1: number;
  40800. /**
  40801. * Gets the value of the `R1` button
  40802. */
  40803. /**
  40804. * Sets the value of the `R1` button
  40805. */
  40806. buttonR1: number;
  40807. /**
  40808. * Gets the value of the Left joystick
  40809. */
  40810. /**
  40811. * Sets the value of the Left joystick
  40812. */
  40813. buttonLeftStick: number;
  40814. /**
  40815. * Gets the value of the Right joystick
  40816. */
  40817. /**
  40818. * Sets the value of the Right joystick
  40819. */
  40820. buttonRightStick: number;
  40821. /**
  40822. * Gets the value of D-pad up
  40823. */
  40824. /**
  40825. * Sets the value of D-pad up
  40826. */
  40827. dPadUp: number;
  40828. /**
  40829. * Gets the value of D-pad down
  40830. */
  40831. /**
  40832. * Sets the value of D-pad down
  40833. */
  40834. dPadDown: number;
  40835. /**
  40836. * Gets the value of D-pad left
  40837. */
  40838. /**
  40839. * Sets the value of D-pad left
  40840. */
  40841. dPadLeft: number;
  40842. /**
  40843. * Gets the value of D-pad right
  40844. */
  40845. /**
  40846. * Sets the value of D-pad right
  40847. */
  40848. dPadRight: number;
  40849. /**
  40850. * Force the gamepad to synchronize with device values
  40851. */
  40852. update(): void;
  40853. /**
  40854. * Disposes the gamepad
  40855. */
  40856. dispose(): void;
  40857. }
  40858. }
  40859. declare module "babylonjs/Gamepads/gamepadManager" {
  40860. import { Observable } from "babylonjs/Misc/observable";
  40861. import { Nullable } from "babylonjs/types";
  40862. import { Scene } from "babylonjs/scene";
  40863. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40864. /**
  40865. * Manager for handling gamepads
  40866. */
  40867. export class GamepadManager {
  40868. private _scene?;
  40869. private _babylonGamepads;
  40870. private _oneGamepadConnected;
  40871. /** @hidden */
  40872. _isMonitoring: boolean;
  40873. private _gamepadEventSupported;
  40874. private _gamepadSupport;
  40875. /**
  40876. * observable to be triggered when the gamepad controller has been connected
  40877. */
  40878. onGamepadConnectedObservable: Observable<Gamepad>;
  40879. /**
  40880. * observable to be triggered when the gamepad controller has been disconnected
  40881. */
  40882. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40883. private _onGamepadConnectedEvent;
  40884. private _onGamepadDisconnectedEvent;
  40885. /**
  40886. * Initializes the gamepad manager
  40887. * @param _scene BabylonJS scene
  40888. */
  40889. constructor(_scene?: Scene | undefined);
  40890. /**
  40891. * The gamepads in the game pad manager
  40892. */
  40893. readonly gamepads: Gamepad[];
  40894. /**
  40895. * Get the gamepad controllers based on type
  40896. * @param type The type of gamepad controller
  40897. * @returns Nullable gamepad
  40898. */
  40899. getGamepadByType(type?: number): Nullable<Gamepad>;
  40900. /**
  40901. * Disposes the gamepad manager
  40902. */
  40903. dispose(): void;
  40904. private _addNewGamepad;
  40905. private _startMonitoringGamepads;
  40906. private _stopMonitoringGamepads;
  40907. /** @hidden */
  40908. _checkGamepadsStatus(): void;
  40909. private _updateGamepadObjects;
  40910. }
  40911. }
  40912. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40913. import { Nullable } from "babylonjs/types";
  40914. import { Scene } from "babylonjs/scene";
  40915. import { ISceneComponent } from "babylonjs/sceneComponent";
  40916. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40917. module "babylonjs/scene" {
  40918. interface Scene {
  40919. /** @hidden */
  40920. _gamepadManager: Nullable<GamepadManager>;
  40921. /**
  40922. * Gets the gamepad manager associated with the scene
  40923. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40924. */
  40925. gamepadManager: GamepadManager;
  40926. }
  40927. }
  40928. module "babylonjs/Cameras/freeCameraInputsManager" {
  40929. /**
  40930. * Interface representing a free camera inputs manager
  40931. */
  40932. interface FreeCameraInputsManager {
  40933. /**
  40934. * Adds gamepad input support to the FreeCameraInputsManager.
  40935. * @returns the FreeCameraInputsManager
  40936. */
  40937. addGamepad(): FreeCameraInputsManager;
  40938. }
  40939. }
  40940. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40941. /**
  40942. * Interface representing an arc rotate camera inputs manager
  40943. */
  40944. interface ArcRotateCameraInputsManager {
  40945. /**
  40946. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40947. * @returns the camera inputs manager
  40948. */
  40949. addGamepad(): ArcRotateCameraInputsManager;
  40950. }
  40951. }
  40952. /**
  40953. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40954. */
  40955. export class GamepadSystemSceneComponent implements ISceneComponent {
  40956. /**
  40957. * The component name helpfull to identify the component in the list of scene components.
  40958. */
  40959. readonly name: string;
  40960. /**
  40961. * The scene the component belongs to.
  40962. */
  40963. scene: Scene;
  40964. /**
  40965. * Creates a new instance of the component for the given scene
  40966. * @param scene Defines the scene to register the component in
  40967. */
  40968. constructor(scene: Scene);
  40969. /**
  40970. * Registers the component in a given scene
  40971. */
  40972. register(): void;
  40973. /**
  40974. * Rebuilds the elements related to this component in case of
  40975. * context lost for instance.
  40976. */
  40977. rebuild(): void;
  40978. /**
  40979. * Disposes the component and the associated ressources
  40980. */
  40981. dispose(): void;
  40982. private _beforeCameraUpdate;
  40983. }
  40984. }
  40985. declare module "babylonjs/Cameras/universalCamera" {
  40986. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40987. import { Scene } from "babylonjs/scene";
  40988. import { Vector3 } from "babylonjs/Maths/math.vector";
  40989. import "babylonjs/Gamepads/gamepadSceneComponent";
  40990. /**
  40991. * 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,
  40992. * which still works and will still be found in many Playgrounds.
  40993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40994. */
  40995. export class UniversalCamera extends TouchCamera {
  40996. /**
  40997. * Defines the gamepad rotation sensiblity.
  40998. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40999. */
  41000. gamepadAngularSensibility: number;
  41001. /**
  41002. * Defines the gamepad move sensiblity.
  41003. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41004. */
  41005. gamepadMoveSensibility: number;
  41006. /**
  41007. * 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,
  41008. * which still works and will still be found in many Playgrounds.
  41009. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41010. * @param name Define the name of the camera in the scene
  41011. * @param position Define the start position of the camera in the scene
  41012. * @param scene Define the scene the camera belongs to
  41013. */
  41014. constructor(name: string, position: Vector3, scene: Scene);
  41015. /**
  41016. * Gets the current object class name.
  41017. * @return the class name
  41018. */
  41019. getClassName(): string;
  41020. }
  41021. }
  41022. declare module "babylonjs/Cameras/gamepadCamera" {
  41023. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41024. import { Scene } from "babylonjs/scene";
  41025. import { Vector3 } from "babylonjs/Maths/math.vector";
  41026. /**
  41027. * This represents a FPS type of camera. This is only here for back compat purpose.
  41028. * Please use the UniversalCamera instead as both are identical.
  41029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41030. */
  41031. export class GamepadCamera extends UniversalCamera {
  41032. /**
  41033. * Instantiates a new Gamepad Camera
  41034. * This represents a FPS type of camera. This is only here for back compat purpose.
  41035. * Please use the UniversalCamera instead as both are identical.
  41036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41037. * @param name Define the name of the camera in the scene
  41038. * @param position Define the start position of the camera in the scene
  41039. * @param scene Define the scene the camera belongs to
  41040. */
  41041. constructor(name: string, position: Vector3, scene: Scene);
  41042. /**
  41043. * Gets the current object class name.
  41044. * @return the class name
  41045. */
  41046. getClassName(): string;
  41047. }
  41048. }
  41049. declare module "babylonjs/Shaders/pass.fragment" {
  41050. /** @hidden */
  41051. export var passPixelShader: {
  41052. name: string;
  41053. shader: string;
  41054. };
  41055. }
  41056. declare module "babylonjs/Shaders/passCube.fragment" {
  41057. /** @hidden */
  41058. export var passCubePixelShader: {
  41059. name: string;
  41060. shader: string;
  41061. };
  41062. }
  41063. declare module "babylonjs/PostProcesses/passPostProcess" {
  41064. import { Nullable } from "babylonjs/types";
  41065. import { Camera } from "babylonjs/Cameras/camera";
  41066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41067. import { Engine } from "babylonjs/Engines/engine";
  41068. import "babylonjs/Shaders/pass.fragment";
  41069. import "babylonjs/Shaders/passCube.fragment";
  41070. /**
  41071. * PassPostProcess which produces an output the same as it's input
  41072. */
  41073. export class PassPostProcess extends PostProcess {
  41074. /**
  41075. * Creates the PassPostProcess
  41076. * @param name The name of the effect.
  41077. * @param options The required width/height ratio to downsize to before computing the render pass.
  41078. * @param camera The camera to apply the render pass to.
  41079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41080. * @param engine The engine which the post process will be applied. (default: current engine)
  41081. * @param reusable If the post process can be reused on the same frame. (default: false)
  41082. * @param textureType The type of texture to be used when performing the post processing.
  41083. * @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)
  41084. */
  41085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41086. }
  41087. /**
  41088. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41089. */
  41090. export class PassCubePostProcess extends PostProcess {
  41091. private _face;
  41092. /**
  41093. * Gets or sets the cube face to display.
  41094. * * 0 is +X
  41095. * * 1 is -X
  41096. * * 2 is +Y
  41097. * * 3 is -Y
  41098. * * 4 is +Z
  41099. * * 5 is -Z
  41100. */
  41101. face: number;
  41102. /**
  41103. * Creates the PassCubePostProcess
  41104. * @param name The name of the effect.
  41105. * @param options The required width/height ratio to downsize to before computing the render pass.
  41106. * @param camera The camera to apply the render pass to.
  41107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41108. * @param engine The engine which the post process will be applied. (default: current engine)
  41109. * @param reusable If the post process can be reused on the same frame. (default: false)
  41110. * @param textureType The type of texture to be used when performing the post processing.
  41111. * @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)
  41112. */
  41113. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41114. }
  41115. }
  41116. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41117. /** @hidden */
  41118. export var anaglyphPixelShader: {
  41119. name: string;
  41120. shader: string;
  41121. };
  41122. }
  41123. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41124. import { Engine } from "babylonjs/Engines/engine";
  41125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41126. import { Camera } from "babylonjs/Cameras/camera";
  41127. import "babylonjs/Shaders/anaglyph.fragment";
  41128. /**
  41129. * Postprocess used to generate anaglyphic rendering
  41130. */
  41131. export class AnaglyphPostProcess extends PostProcess {
  41132. private _passedProcess;
  41133. /**
  41134. * Creates a new AnaglyphPostProcess
  41135. * @param name defines postprocess name
  41136. * @param options defines creation options or target ratio scale
  41137. * @param rigCameras defines cameras using this postprocess
  41138. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41139. * @param engine defines hosting engine
  41140. * @param reusable defines if the postprocess will be reused multiple times per frame
  41141. */
  41142. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41143. }
  41144. }
  41145. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41146. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41147. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41148. import { Scene } from "babylonjs/scene";
  41149. import { Vector3 } from "babylonjs/Maths/math.vector";
  41150. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41151. /**
  41152. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41154. */
  41155. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41156. /**
  41157. * Creates a new AnaglyphArcRotateCamera
  41158. * @param name defines camera name
  41159. * @param alpha defines alpha angle (in radians)
  41160. * @param beta defines beta angle (in radians)
  41161. * @param radius defines radius
  41162. * @param target defines camera target
  41163. * @param interaxialDistance defines distance between each color axis
  41164. * @param scene defines the hosting scene
  41165. */
  41166. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41167. /**
  41168. * Gets camera class name
  41169. * @returns AnaglyphArcRotateCamera
  41170. */
  41171. getClassName(): string;
  41172. }
  41173. }
  41174. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41175. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41176. import { Scene } from "babylonjs/scene";
  41177. import { Vector3 } from "babylonjs/Maths/math.vector";
  41178. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41179. /**
  41180. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41181. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41182. */
  41183. export class AnaglyphFreeCamera extends FreeCamera {
  41184. /**
  41185. * Creates a new AnaglyphFreeCamera
  41186. * @param name defines camera name
  41187. * @param position defines initial position
  41188. * @param interaxialDistance defines distance between each color axis
  41189. * @param scene defines the hosting scene
  41190. */
  41191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41192. /**
  41193. * Gets camera class name
  41194. * @returns AnaglyphFreeCamera
  41195. */
  41196. getClassName(): string;
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41200. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41201. import { Scene } from "babylonjs/scene";
  41202. import { Vector3 } from "babylonjs/Maths/math.vector";
  41203. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41204. /**
  41205. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41207. */
  41208. export class AnaglyphGamepadCamera extends GamepadCamera {
  41209. /**
  41210. * Creates a new AnaglyphGamepadCamera
  41211. * @param name defines camera name
  41212. * @param position defines initial position
  41213. * @param interaxialDistance defines distance between each color axis
  41214. * @param scene defines the hosting scene
  41215. */
  41216. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41217. /**
  41218. * Gets camera class name
  41219. * @returns AnaglyphGamepadCamera
  41220. */
  41221. getClassName(): string;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41225. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41226. import { Scene } from "babylonjs/scene";
  41227. import { Vector3 } from "babylonjs/Maths/math.vector";
  41228. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41229. /**
  41230. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41231. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41232. */
  41233. export class AnaglyphUniversalCamera extends UniversalCamera {
  41234. /**
  41235. * Creates a new AnaglyphUniversalCamera
  41236. * @param name defines camera name
  41237. * @param position defines initial position
  41238. * @param interaxialDistance defines distance between each color axis
  41239. * @param scene defines the hosting scene
  41240. */
  41241. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41242. /**
  41243. * Gets camera class name
  41244. * @returns AnaglyphUniversalCamera
  41245. */
  41246. getClassName(): string;
  41247. }
  41248. }
  41249. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41250. /** @hidden */
  41251. export var stereoscopicInterlacePixelShader: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41257. import { Camera } from "babylonjs/Cameras/camera";
  41258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41259. import { Engine } from "babylonjs/Engines/engine";
  41260. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41261. /**
  41262. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41263. */
  41264. export class StereoscopicInterlacePostProcess extends PostProcess {
  41265. private _stepSize;
  41266. private _passedProcess;
  41267. /**
  41268. * Initializes a StereoscopicInterlacePostProcess
  41269. * @param name The name of the effect.
  41270. * @param rigCameras The rig cameras to be appled to the post process
  41271. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41273. * @param engine The engine which the post process will be applied. (default: current engine)
  41274. * @param reusable If the post process can be reused on the same frame. (default: false)
  41275. */
  41276. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41277. }
  41278. }
  41279. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41280. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41281. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41282. import { Scene } from "babylonjs/scene";
  41283. import { Vector3 } from "babylonjs/Maths/math.vector";
  41284. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41285. /**
  41286. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41287. * @see http://doc.babylonjs.com/features/cameras
  41288. */
  41289. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41290. /**
  41291. * Creates a new StereoscopicArcRotateCamera
  41292. * @param name defines camera name
  41293. * @param alpha defines alpha angle (in radians)
  41294. * @param beta defines beta angle (in radians)
  41295. * @param radius defines radius
  41296. * @param target defines camera target
  41297. * @param interaxialDistance defines distance between each color axis
  41298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41299. * @param scene defines the hosting scene
  41300. */
  41301. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41302. /**
  41303. * Gets camera class name
  41304. * @returns StereoscopicArcRotateCamera
  41305. */
  41306. getClassName(): string;
  41307. }
  41308. }
  41309. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41310. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41311. import { Scene } from "babylonjs/scene";
  41312. import { Vector3 } from "babylonjs/Maths/math.vector";
  41313. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41314. /**
  41315. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41316. * @see http://doc.babylonjs.com/features/cameras
  41317. */
  41318. export class StereoscopicFreeCamera extends FreeCamera {
  41319. /**
  41320. * Creates a new StereoscopicFreeCamera
  41321. * @param name defines camera name
  41322. * @param position defines initial position
  41323. * @param interaxialDistance defines distance between each color axis
  41324. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41325. * @param scene defines the hosting scene
  41326. */
  41327. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41328. /**
  41329. * Gets camera class name
  41330. * @returns StereoscopicFreeCamera
  41331. */
  41332. getClassName(): string;
  41333. }
  41334. }
  41335. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41336. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41337. import { Scene } from "babylonjs/scene";
  41338. import { Vector3 } from "babylonjs/Maths/math.vector";
  41339. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41340. /**
  41341. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41342. * @see http://doc.babylonjs.com/features/cameras
  41343. */
  41344. export class StereoscopicGamepadCamera extends GamepadCamera {
  41345. /**
  41346. * Creates a new StereoscopicGamepadCamera
  41347. * @param name defines camera name
  41348. * @param position defines initial position
  41349. * @param interaxialDistance defines distance between each color axis
  41350. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41351. * @param scene defines the hosting scene
  41352. */
  41353. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41354. /**
  41355. * Gets camera class name
  41356. * @returns StereoscopicGamepadCamera
  41357. */
  41358. getClassName(): string;
  41359. }
  41360. }
  41361. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41362. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41363. import { Scene } from "babylonjs/scene";
  41364. import { Vector3 } from "babylonjs/Maths/math.vector";
  41365. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41366. /**
  41367. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41368. * @see http://doc.babylonjs.com/features/cameras
  41369. */
  41370. export class StereoscopicUniversalCamera extends UniversalCamera {
  41371. /**
  41372. * Creates a new StereoscopicUniversalCamera
  41373. * @param name defines camera name
  41374. * @param position defines initial position
  41375. * @param interaxialDistance defines distance between each color axis
  41376. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41377. * @param scene defines the hosting scene
  41378. */
  41379. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41380. /**
  41381. * Gets camera class name
  41382. * @returns StereoscopicUniversalCamera
  41383. */
  41384. getClassName(): string;
  41385. }
  41386. }
  41387. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41388. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41389. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41390. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41391. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41392. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41393. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41394. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41395. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41396. }
  41397. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41398. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41399. import { Scene } from "babylonjs/scene";
  41400. import { Vector3 } from "babylonjs/Maths/math.vector";
  41401. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41402. /**
  41403. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41404. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41405. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41406. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41407. */
  41408. export class VirtualJoysticksCamera extends FreeCamera {
  41409. /**
  41410. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41411. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41412. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41413. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41414. * @param name Define the name of the camera in the scene
  41415. * @param position Define the start position of the camera in the scene
  41416. * @param scene Define the scene the camera belongs to
  41417. */
  41418. constructor(name: string, position: Vector3, scene: Scene);
  41419. /**
  41420. * Gets the current object class name.
  41421. * @return the class name
  41422. */
  41423. getClassName(): string;
  41424. }
  41425. }
  41426. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41427. import { Matrix } from "babylonjs/Maths/math.vector";
  41428. /**
  41429. * This represents all the required metrics to create a VR camera.
  41430. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41431. */
  41432. export class VRCameraMetrics {
  41433. /**
  41434. * Define the horizontal resolution off the screen.
  41435. */
  41436. hResolution: number;
  41437. /**
  41438. * Define the vertical resolution off the screen.
  41439. */
  41440. vResolution: number;
  41441. /**
  41442. * Define the horizontal screen size.
  41443. */
  41444. hScreenSize: number;
  41445. /**
  41446. * Define the vertical screen size.
  41447. */
  41448. vScreenSize: number;
  41449. /**
  41450. * Define the vertical screen center position.
  41451. */
  41452. vScreenCenter: number;
  41453. /**
  41454. * Define the distance of the eyes to the screen.
  41455. */
  41456. eyeToScreenDistance: number;
  41457. /**
  41458. * Define the distance between both lenses
  41459. */
  41460. lensSeparationDistance: number;
  41461. /**
  41462. * Define the distance between both viewer's eyes.
  41463. */
  41464. interpupillaryDistance: number;
  41465. /**
  41466. * Define the distortion factor of the VR postprocess.
  41467. * Please, touch with care.
  41468. */
  41469. distortionK: number[];
  41470. /**
  41471. * Define the chromatic aberration correction factors for the VR post process.
  41472. */
  41473. chromaAbCorrection: number[];
  41474. /**
  41475. * Define the scale factor of the post process.
  41476. * The smaller the better but the slower.
  41477. */
  41478. postProcessScaleFactor: number;
  41479. /**
  41480. * Define an offset for the lens center.
  41481. */
  41482. lensCenterOffset: number;
  41483. /**
  41484. * Define if the current vr camera should compensate the distortion of the lense or not.
  41485. */
  41486. compensateDistortion: boolean;
  41487. /**
  41488. * Defines if multiview should be enabled when rendering (Default: false)
  41489. */
  41490. multiviewEnabled: boolean;
  41491. /**
  41492. * Gets the rendering aspect ratio based on the provided resolutions.
  41493. */
  41494. readonly aspectRatio: number;
  41495. /**
  41496. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41497. */
  41498. readonly aspectRatioFov: number;
  41499. /**
  41500. * @hidden
  41501. */
  41502. readonly leftHMatrix: Matrix;
  41503. /**
  41504. * @hidden
  41505. */
  41506. readonly rightHMatrix: Matrix;
  41507. /**
  41508. * @hidden
  41509. */
  41510. readonly leftPreViewMatrix: Matrix;
  41511. /**
  41512. * @hidden
  41513. */
  41514. readonly rightPreViewMatrix: Matrix;
  41515. /**
  41516. * Get the default VRMetrics based on the most generic setup.
  41517. * @returns the default vr metrics
  41518. */
  41519. static GetDefault(): VRCameraMetrics;
  41520. }
  41521. }
  41522. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41523. /** @hidden */
  41524. export var vrDistortionCorrectionPixelShader: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41530. import { Camera } from "babylonjs/Cameras/camera";
  41531. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41532. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41533. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41534. /**
  41535. * VRDistortionCorrectionPostProcess used for mobile VR
  41536. */
  41537. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41538. private _isRightEye;
  41539. private _distortionFactors;
  41540. private _postProcessScaleFactor;
  41541. private _lensCenterOffset;
  41542. private _scaleIn;
  41543. private _scaleFactor;
  41544. private _lensCenter;
  41545. /**
  41546. * Initializes the VRDistortionCorrectionPostProcess
  41547. * @param name The name of the effect.
  41548. * @param camera The camera to apply the render pass to.
  41549. * @param isRightEye If this is for the right eye distortion
  41550. * @param vrMetrics All the required metrics for the VR camera
  41551. */
  41552. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41553. }
  41554. }
  41555. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41556. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41557. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41558. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41559. import { Scene } from "babylonjs/scene";
  41560. import { Vector3 } from "babylonjs/Maths/math.vector";
  41561. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41562. import "babylonjs/Cameras/RigModes/vrRigMode";
  41563. /**
  41564. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41565. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41566. */
  41567. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41568. /**
  41569. * Creates a new VRDeviceOrientationArcRotateCamera
  41570. * @param name defines camera name
  41571. * @param alpha defines the camera rotation along the logitudinal axis
  41572. * @param beta defines the camera rotation along the latitudinal axis
  41573. * @param radius defines the camera distance from its target
  41574. * @param target defines the camera target
  41575. * @param scene defines the scene the camera belongs to
  41576. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41577. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41578. */
  41579. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41580. /**
  41581. * Gets camera class name
  41582. * @returns VRDeviceOrientationArcRotateCamera
  41583. */
  41584. getClassName(): string;
  41585. }
  41586. }
  41587. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41588. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41589. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41590. import { Scene } from "babylonjs/scene";
  41591. import { Vector3 } from "babylonjs/Maths/math.vector";
  41592. import "babylonjs/Cameras/RigModes/vrRigMode";
  41593. /**
  41594. * Camera used to simulate VR rendering (based on FreeCamera)
  41595. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41596. */
  41597. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41598. /**
  41599. * Creates a new VRDeviceOrientationFreeCamera
  41600. * @param name defines camera name
  41601. * @param position defines the start position of the camera
  41602. * @param scene defines the scene the camera belongs to
  41603. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41604. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41605. */
  41606. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41607. /**
  41608. * Gets camera class name
  41609. * @returns VRDeviceOrientationFreeCamera
  41610. */
  41611. getClassName(): string;
  41612. }
  41613. }
  41614. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41615. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41616. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41617. import { Scene } from "babylonjs/scene";
  41618. import { Vector3 } from "babylonjs/Maths/math.vector";
  41619. import "babylonjs/Gamepads/gamepadSceneComponent";
  41620. /**
  41621. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41622. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41623. */
  41624. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41625. /**
  41626. * Creates a new VRDeviceOrientationGamepadCamera
  41627. * @param name defines camera name
  41628. * @param position defines the start position of the camera
  41629. * @param scene defines the scene the camera belongs to
  41630. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41631. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41632. */
  41633. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41634. /**
  41635. * Gets camera class name
  41636. * @returns VRDeviceOrientationGamepadCamera
  41637. */
  41638. getClassName(): string;
  41639. }
  41640. }
  41641. declare module "babylonjs/Materials/pushMaterial" {
  41642. import { Nullable } from "babylonjs/types";
  41643. import { Scene } from "babylonjs/scene";
  41644. import { Matrix } from "babylonjs/Maths/math.vector";
  41645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41646. import { Mesh } from "babylonjs/Meshes/mesh";
  41647. import { Material } from "babylonjs/Materials/material";
  41648. import { Effect } from "babylonjs/Materials/effect";
  41649. /**
  41650. * Base class of materials working in push mode in babylon JS
  41651. * @hidden
  41652. */
  41653. export class PushMaterial extends Material {
  41654. protected _activeEffect: Effect;
  41655. protected _normalMatrix: Matrix;
  41656. /**
  41657. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41658. * This means that the material can keep using a previous shader while a new one is being compiled.
  41659. * This is mostly used when shader parallel compilation is supported (true by default)
  41660. */
  41661. allowShaderHotSwapping: boolean;
  41662. constructor(name: string, scene: Scene);
  41663. getEffect(): Effect;
  41664. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41665. /**
  41666. * Binds the given world matrix to the active effect
  41667. *
  41668. * @param world the matrix to bind
  41669. */
  41670. bindOnlyWorldMatrix(world: Matrix): void;
  41671. /**
  41672. * Binds the given normal matrix to the active effect
  41673. *
  41674. * @param normalMatrix the matrix to bind
  41675. */
  41676. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41677. bind(world: Matrix, mesh?: Mesh): void;
  41678. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41679. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41680. }
  41681. }
  41682. declare module "babylonjs/Materials/materialFlags" {
  41683. /**
  41684. * This groups all the flags used to control the materials channel.
  41685. */
  41686. export class MaterialFlags {
  41687. private static _DiffuseTextureEnabled;
  41688. /**
  41689. * Are diffuse textures enabled in the application.
  41690. */
  41691. static DiffuseTextureEnabled: boolean;
  41692. private static _AmbientTextureEnabled;
  41693. /**
  41694. * Are ambient textures enabled in the application.
  41695. */
  41696. static AmbientTextureEnabled: boolean;
  41697. private static _OpacityTextureEnabled;
  41698. /**
  41699. * Are opacity textures enabled in the application.
  41700. */
  41701. static OpacityTextureEnabled: boolean;
  41702. private static _ReflectionTextureEnabled;
  41703. /**
  41704. * Are reflection textures enabled in the application.
  41705. */
  41706. static ReflectionTextureEnabled: boolean;
  41707. private static _EmissiveTextureEnabled;
  41708. /**
  41709. * Are emissive textures enabled in the application.
  41710. */
  41711. static EmissiveTextureEnabled: boolean;
  41712. private static _SpecularTextureEnabled;
  41713. /**
  41714. * Are specular textures enabled in the application.
  41715. */
  41716. static SpecularTextureEnabled: boolean;
  41717. private static _BumpTextureEnabled;
  41718. /**
  41719. * Are bump textures enabled in the application.
  41720. */
  41721. static BumpTextureEnabled: boolean;
  41722. private static _LightmapTextureEnabled;
  41723. /**
  41724. * Are lightmap textures enabled in the application.
  41725. */
  41726. static LightmapTextureEnabled: boolean;
  41727. private static _RefractionTextureEnabled;
  41728. /**
  41729. * Are refraction textures enabled in the application.
  41730. */
  41731. static RefractionTextureEnabled: boolean;
  41732. private static _ColorGradingTextureEnabled;
  41733. /**
  41734. * Are color grading textures enabled in the application.
  41735. */
  41736. static ColorGradingTextureEnabled: boolean;
  41737. private static _FresnelEnabled;
  41738. /**
  41739. * Are fresnels enabled in the application.
  41740. */
  41741. static FresnelEnabled: boolean;
  41742. private static _ClearCoatTextureEnabled;
  41743. /**
  41744. * Are clear coat textures enabled in the application.
  41745. */
  41746. static ClearCoatTextureEnabled: boolean;
  41747. private static _ClearCoatBumpTextureEnabled;
  41748. /**
  41749. * Are clear coat bump textures enabled in the application.
  41750. */
  41751. static ClearCoatBumpTextureEnabled: boolean;
  41752. private static _ClearCoatTintTextureEnabled;
  41753. /**
  41754. * Are clear coat tint textures enabled in the application.
  41755. */
  41756. static ClearCoatTintTextureEnabled: boolean;
  41757. private static _SheenTextureEnabled;
  41758. /**
  41759. * Are sheen textures enabled in the application.
  41760. */
  41761. static SheenTextureEnabled: boolean;
  41762. private static _AnisotropicTextureEnabled;
  41763. /**
  41764. * Are anisotropic textures enabled in the application.
  41765. */
  41766. static AnisotropicTextureEnabled: boolean;
  41767. private static _ThicknessTextureEnabled;
  41768. /**
  41769. * Are thickness textures enabled in the application.
  41770. */
  41771. static ThicknessTextureEnabled: boolean;
  41772. }
  41773. }
  41774. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41775. /** @hidden */
  41776. export var defaultFragmentDeclaration: {
  41777. name: string;
  41778. shader: string;
  41779. };
  41780. }
  41781. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41782. /** @hidden */
  41783. export var defaultUboDeclaration: {
  41784. name: string;
  41785. shader: string;
  41786. };
  41787. }
  41788. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41789. /** @hidden */
  41790. export var lightFragmentDeclaration: {
  41791. name: string;
  41792. shader: string;
  41793. };
  41794. }
  41795. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41796. /** @hidden */
  41797. export var lightUboDeclaration: {
  41798. name: string;
  41799. shader: string;
  41800. };
  41801. }
  41802. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41803. /** @hidden */
  41804. export var lightsFragmentFunctions: {
  41805. name: string;
  41806. shader: string;
  41807. };
  41808. }
  41809. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41810. /** @hidden */
  41811. export var shadowsFragmentFunctions: {
  41812. name: string;
  41813. shader: string;
  41814. };
  41815. }
  41816. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41817. /** @hidden */
  41818. export var fresnelFunction: {
  41819. name: string;
  41820. shader: string;
  41821. };
  41822. }
  41823. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41824. /** @hidden */
  41825. export var reflectionFunction: {
  41826. name: string;
  41827. shader: string;
  41828. };
  41829. }
  41830. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41831. /** @hidden */
  41832. export var bumpFragmentFunctions: {
  41833. name: string;
  41834. shader: string;
  41835. };
  41836. }
  41837. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41838. /** @hidden */
  41839. export var logDepthDeclaration: {
  41840. name: string;
  41841. shader: string;
  41842. };
  41843. }
  41844. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41845. /** @hidden */
  41846. export var bumpFragment: {
  41847. name: string;
  41848. shader: string;
  41849. };
  41850. }
  41851. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41852. /** @hidden */
  41853. export var depthPrePass: {
  41854. name: string;
  41855. shader: string;
  41856. };
  41857. }
  41858. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41859. /** @hidden */
  41860. export var lightFragment: {
  41861. name: string;
  41862. shader: string;
  41863. };
  41864. }
  41865. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41866. /** @hidden */
  41867. export var logDepthFragment: {
  41868. name: string;
  41869. shader: string;
  41870. };
  41871. }
  41872. declare module "babylonjs/Shaders/default.fragment" {
  41873. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41874. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41876. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41877. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41878. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41879. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41881. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41882. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41883. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41886. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41887. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41888. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41889. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41890. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41891. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41892. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41893. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41894. /** @hidden */
  41895. export var defaultPixelShader: {
  41896. name: string;
  41897. shader: string;
  41898. };
  41899. }
  41900. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41901. /** @hidden */
  41902. export var defaultVertexDeclaration: {
  41903. name: string;
  41904. shader: string;
  41905. };
  41906. }
  41907. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41908. /** @hidden */
  41909. export var bumpVertexDeclaration: {
  41910. name: string;
  41911. shader: string;
  41912. };
  41913. }
  41914. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41915. /** @hidden */
  41916. export var bumpVertex: {
  41917. name: string;
  41918. shader: string;
  41919. };
  41920. }
  41921. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41922. /** @hidden */
  41923. export var fogVertex: {
  41924. name: string;
  41925. shader: string;
  41926. };
  41927. }
  41928. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41929. /** @hidden */
  41930. export var shadowsVertex: {
  41931. name: string;
  41932. shader: string;
  41933. };
  41934. }
  41935. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41936. /** @hidden */
  41937. export var pointCloudVertex: {
  41938. name: string;
  41939. shader: string;
  41940. };
  41941. }
  41942. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41943. /** @hidden */
  41944. export var logDepthVertex: {
  41945. name: string;
  41946. shader: string;
  41947. };
  41948. }
  41949. declare module "babylonjs/Shaders/default.vertex" {
  41950. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41951. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41953. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41955. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41956. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41957. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41958. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41959. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41960. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41961. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41962. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41964. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41965. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41966. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41967. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41968. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41969. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41970. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41971. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41972. /** @hidden */
  41973. export var defaultVertexShader: {
  41974. name: string;
  41975. shader: string;
  41976. };
  41977. }
  41978. declare module "babylonjs/Materials/standardMaterial" {
  41979. import { SmartArray } from "babylonjs/Misc/smartArray";
  41980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41981. import { Nullable } from "babylonjs/types";
  41982. import { Scene } from "babylonjs/scene";
  41983. import { Matrix } from "babylonjs/Maths/math.vector";
  41984. import { Color3 } from "babylonjs/Maths/math.color";
  41985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41987. import { Mesh } from "babylonjs/Meshes/mesh";
  41988. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41989. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41990. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41992. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41995. import "babylonjs/Shaders/default.fragment";
  41996. import "babylonjs/Shaders/default.vertex";
  41997. /** @hidden */
  41998. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41999. MAINUV1: boolean;
  42000. MAINUV2: boolean;
  42001. DIFFUSE: boolean;
  42002. DIFFUSEDIRECTUV: number;
  42003. AMBIENT: boolean;
  42004. AMBIENTDIRECTUV: number;
  42005. OPACITY: boolean;
  42006. OPACITYDIRECTUV: number;
  42007. OPACITYRGB: boolean;
  42008. REFLECTION: boolean;
  42009. EMISSIVE: boolean;
  42010. EMISSIVEDIRECTUV: number;
  42011. SPECULAR: boolean;
  42012. SPECULARDIRECTUV: number;
  42013. BUMP: boolean;
  42014. BUMPDIRECTUV: number;
  42015. PARALLAX: boolean;
  42016. PARALLAXOCCLUSION: boolean;
  42017. SPECULAROVERALPHA: boolean;
  42018. CLIPPLANE: boolean;
  42019. CLIPPLANE2: boolean;
  42020. CLIPPLANE3: boolean;
  42021. CLIPPLANE4: boolean;
  42022. ALPHATEST: boolean;
  42023. DEPTHPREPASS: boolean;
  42024. ALPHAFROMDIFFUSE: boolean;
  42025. POINTSIZE: boolean;
  42026. FOG: boolean;
  42027. SPECULARTERM: boolean;
  42028. DIFFUSEFRESNEL: boolean;
  42029. OPACITYFRESNEL: boolean;
  42030. REFLECTIONFRESNEL: boolean;
  42031. REFRACTIONFRESNEL: boolean;
  42032. EMISSIVEFRESNEL: boolean;
  42033. FRESNEL: boolean;
  42034. NORMAL: boolean;
  42035. UV1: boolean;
  42036. UV2: boolean;
  42037. VERTEXCOLOR: boolean;
  42038. VERTEXALPHA: boolean;
  42039. NUM_BONE_INFLUENCERS: number;
  42040. BonesPerMesh: number;
  42041. BONETEXTURE: boolean;
  42042. INSTANCES: boolean;
  42043. GLOSSINESS: boolean;
  42044. ROUGHNESS: boolean;
  42045. EMISSIVEASILLUMINATION: boolean;
  42046. LINKEMISSIVEWITHDIFFUSE: boolean;
  42047. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42048. LIGHTMAP: boolean;
  42049. LIGHTMAPDIRECTUV: number;
  42050. OBJECTSPACE_NORMALMAP: boolean;
  42051. USELIGHTMAPASSHADOWMAP: boolean;
  42052. REFLECTIONMAP_3D: boolean;
  42053. REFLECTIONMAP_SPHERICAL: boolean;
  42054. REFLECTIONMAP_PLANAR: boolean;
  42055. REFLECTIONMAP_CUBIC: boolean;
  42056. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42057. REFLECTIONMAP_PROJECTION: boolean;
  42058. REFLECTIONMAP_SKYBOX: boolean;
  42059. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42060. REFLECTIONMAP_EXPLICIT: boolean;
  42061. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42062. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42063. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42064. INVERTCUBICMAP: boolean;
  42065. LOGARITHMICDEPTH: boolean;
  42066. REFRACTION: boolean;
  42067. REFRACTIONMAP_3D: boolean;
  42068. REFLECTIONOVERALPHA: boolean;
  42069. TWOSIDEDLIGHTING: boolean;
  42070. SHADOWFLOAT: boolean;
  42071. MORPHTARGETS: boolean;
  42072. MORPHTARGETS_NORMAL: boolean;
  42073. MORPHTARGETS_TANGENT: boolean;
  42074. MORPHTARGETS_UV: boolean;
  42075. NUM_MORPH_INFLUENCERS: number;
  42076. NONUNIFORMSCALING: boolean;
  42077. PREMULTIPLYALPHA: boolean;
  42078. IMAGEPROCESSING: boolean;
  42079. VIGNETTE: boolean;
  42080. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42081. VIGNETTEBLENDMODEOPAQUE: boolean;
  42082. TONEMAPPING: boolean;
  42083. TONEMAPPING_ACES: boolean;
  42084. CONTRAST: boolean;
  42085. COLORCURVES: boolean;
  42086. COLORGRADING: boolean;
  42087. COLORGRADING3D: boolean;
  42088. SAMPLER3DGREENDEPTH: boolean;
  42089. SAMPLER3DBGRMAP: boolean;
  42090. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42091. MULTIVIEW: boolean;
  42092. /**
  42093. * If the reflection texture on this material is in linear color space
  42094. * @hidden
  42095. */
  42096. IS_REFLECTION_LINEAR: boolean;
  42097. /**
  42098. * If the refraction texture on this material is in linear color space
  42099. * @hidden
  42100. */
  42101. IS_REFRACTION_LINEAR: boolean;
  42102. EXPOSURE: boolean;
  42103. constructor();
  42104. setReflectionMode(modeToEnable: string): void;
  42105. }
  42106. /**
  42107. * This is the default material used in Babylon. It is the best trade off between quality
  42108. * and performances.
  42109. * @see http://doc.babylonjs.com/babylon101/materials
  42110. */
  42111. export class StandardMaterial extends PushMaterial {
  42112. private _diffuseTexture;
  42113. /**
  42114. * The basic texture of the material as viewed under a light.
  42115. */
  42116. diffuseTexture: Nullable<BaseTexture>;
  42117. private _ambientTexture;
  42118. /**
  42119. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42120. */
  42121. ambientTexture: Nullable<BaseTexture>;
  42122. private _opacityTexture;
  42123. /**
  42124. * Define the transparency of the material from a texture.
  42125. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42126. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42127. */
  42128. opacityTexture: Nullable<BaseTexture>;
  42129. private _reflectionTexture;
  42130. /**
  42131. * Define the texture used to display the reflection.
  42132. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42133. */
  42134. reflectionTexture: Nullable<BaseTexture>;
  42135. private _emissiveTexture;
  42136. /**
  42137. * Define texture of the material as if self lit.
  42138. * This will be mixed in the final result even in the absence of light.
  42139. */
  42140. emissiveTexture: Nullable<BaseTexture>;
  42141. private _specularTexture;
  42142. /**
  42143. * Define how the color and intensity of the highlight given by the light in the material.
  42144. */
  42145. specularTexture: Nullable<BaseTexture>;
  42146. private _bumpTexture;
  42147. /**
  42148. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42149. * 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.
  42150. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42151. */
  42152. bumpTexture: Nullable<BaseTexture>;
  42153. private _lightmapTexture;
  42154. /**
  42155. * Complex lighting can be computationally expensive to compute at runtime.
  42156. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42157. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42158. */
  42159. lightmapTexture: Nullable<BaseTexture>;
  42160. private _refractionTexture;
  42161. /**
  42162. * Define the texture used to display the refraction.
  42163. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42164. */
  42165. refractionTexture: Nullable<BaseTexture>;
  42166. /**
  42167. * The color of the material lit by the environmental background lighting.
  42168. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42169. */
  42170. ambientColor: Color3;
  42171. /**
  42172. * The basic color of the material as viewed under a light.
  42173. */
  42174. diffuseColor: Color3;
  42175. /**
  42176. * Define how the color and intensity of the highlight given by the light in the material.
  42177. */
  42178. specularColor: Color3;
  42179. /**
  42180. * Define the color of the material as if self lit.
  42181. * This will be mixed in the final result even in the absence of light.
  42182. */
  42183. emissiveColor: Color3;
  42184. /**
  42185. * Defines how sharp are the highlights in the material.
  42186. * The bigger the value the sharper giving a more glossy feeling to the result.
  42187. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42188. */
  42189. specularPower: number;
  42190. private _useAlphaFromDiffuseTexture;
  42191. /**
  42192. * Does the transparency come from the diffuse texture alpha channel.
  42193. */
  42194. useAlphaFromDiffuseTexture: boolean;
  42195. private _useEmissiveAsIllumination;
  42196. /**
  42197. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42198. */
  42199. useEmissiveAsIllumination: boolean;
  42200. private _linkEmissiveWithDiffuse;
  42201. /**
  42202. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42203. * the emissive level when the final color is close to one.
  42204. */
  42205. linkEmissiveWithDiffuse: boolean;
  42206. private _useSpecularOverAlpha;
  42207. /**
  42208. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42209. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42210. */
  42211. useSpecularOverAlpha: boolean;
  42212. private _useReflectionOverAlpha;
  42213. /**
  42214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42216. */
  42217. useReflectionOverAlpha: boolean;
  42218. private _disableLighting;
  42219. /**
  42220. * Does lights from the scene impacts this material.
  42221. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42222. */
  42223. disableLighting: boolean;
  42224. private _useObjectSpaceNormalMap;
  42225. /**
  42226. * Allows using an object space normal map (instead of tangent space).
  42227. */
  42228. useObjectSpaceNormalMap: boolean;
  42229. private _useParallax;
  42230. /**
  42231. * Is parallax enabled or not.
  42232. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42233. */
  42234. useParallax: boolean;
  42235. private _useParallaxOcclusion;
  42236. /**
  42237. * Is parallax occlusion enabled or not.
  42238. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42239. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42240. */
  42241. useParallaxOcclusion: boolean;
  42242. /**
  42243. * 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.
  42244. */
  42245. parallaxScaleBias: number;
  42246. private _roughness;
  42247. /**
  42248. * Helps to define how blurry the reflections should appears in the material.
  42249. */
  42250. roughness: number;
  42251. /**
  42252. * In case of refraction, define the value of the index of refraction.
  42253. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42254. */
  42255. indexOfRefraction: number;
  42256. /**
  42257. * Invert the refraction texture alongside the y axis.
  42258. * It can be useful with procedural textures or probe for instance.
  42259. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42260. */
  42261. invertRefractionY: boolean;
  42262. /**
  42263. * Defines the alpha limits in alpha test mode.
  42264. */
  42265. alphaCutOff: number;
  42266. private _useLightmapAsShadowmap;
  42267. /**
  42268. * In case of light mapping, define whether the map contains light or shadow informations.
  42269. */
  42270. useLightmapAsShadowmap: boolean;
  42271. private _diffuseFresnelParameters;
  42272. /**
  42273. * Define the diffuse fresnel parameters of the material.
  42274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42275. */
  42276. diffuseFresnelParameters: FresnelParameters;
  42277. private _opacityFresnelParameters;
  42278. /**
  42279. * Define the opacity fresnel parameters of the material.
  42280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42281. */
  42282. opacityFresnelParameters: FresnelParameters;
  42283. private _reflectionFresnelParameters;
  42284. /**
  42285. * Define the reflection fresnel parameters of the material.
  42286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42287. */
  42288. reflectionFresnelParameters: FresnelParameters;
  42289. private _refractionFresnelParameters;
  42290. /**
  42291. * Define the refraction fresnel parameters of the material.
  42292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42293. */
  42294. refractionFresnelParameters: FresnelParameters;
  42295. private _emissiveFresnelParameters;
  42296. /**
  42297. * Define the emissive fresnel parameters of the material.
  42298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42299. */
  42300. emissiveFresnelParameters: FresnelParameters;
  42301. private _useReflectionFresnelFromSpecular;
  42302. /**
  42303. * If true automatically deducts the fresnels values from the material specularity.
  42304. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42305. */
  42306. useReflectionFresnelFromSpecular: boolean;
  42307. private _useGlossinessFromSpecularMapAlpha;
  42308. /**
  42309. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42310. */
  42311. useGlossinessFromSpecularMapAlpha: boolean;
  42312. private _maxSimultaneousLights;
  42313. /**
  42314. * Defines the maximum number of lights that can be used in the material
  42315. */
  42316. maxSimultaneousLights: number;
  42317. private _invertNormalMapX;
  42318. /**
  42319. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42320. */
  42321. invertNormalMapX: boolean;
  42322. private _invertNormalMapY;
  42323. /**
  42324. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42325. */
  42326. invertNormalMapY: boolean;
  42327. private _twoSidedLighting;
  42328. /**
  42329. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42330. */
  42331. twoSidedLighting: boolean;
  42332. /**
  42333. * Default configuration related to image processing available in the standard Material.
  42334. */
  42335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42336. /**
  42337. * Gets the image processing configuration used either in this material.
  42338. */
  42339. /**
  42340. * Sets the Default image processing configuration used either in the this material.
  42341. *
  42342. * If sets to null, the scene one is in use.
  42343. */
  42344. imageProcessingConfiguration: ImageProcessingConfiguration;
  42345. /**
  42346. * Keep track of the image processing observer to allow dispose and replace.
  42347. */
  42348. private _imageProcessingObserver;
  42349. /**
  42350. * Attaches a new image processing configuration to the Standard Material.
  42351. * @param configuration
  42352. */
  42353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42354. /**
  42355. * Gets wether the color curves effect is enabled.
  42356. */
  42357. /**
  42358. * Sets wether the color curves effect is enabled.
  42359. */
  42360. cameraColorCurvesEnabled: boolean;
  42361. /**
  42362. * Gets wether the color grading effect is enabled.
  42363. */
  42364. /**
  42365. * Gets wether the color grading effect is enabled.
  42366. */
  42367. cameraColorGradingEnabled: boolean;
  42368. /**
  42369. * Gets wether tonemapping is enabled or not.
  42370. */
  42371. /**
  42372. * Sets wether tonemapping is enabled or not
  42373. */
  42374. cameraToneMappingEnabled: boolean;
  42375. /**
  42376. * The camera exposure used on this material.
  42377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42378. * This corresponds to a photographic exposure.
  42379. */
  42380. /**
  42381. * The camera exposure used on this material.
  42382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42383. * This corresponds to a photographic exposure.
  42384. */
  42385. cameraExposure: number;
  42386. /**
  42387. * Gets The camera contrast used on this material.
  42388. */
  42389. /**
  42390. * Sets The camera contrast used on this material.
  42391. */
  42392. cameraContrast: number;
  42393. /**
  42394. * Gets the Color Grading 2D Lookup Texture.
  42395. */
  42396. /**
  42397. * Sets the Color Grading 2D Lookup Texture.
  42398. */
  42399. cameraColorGradingTexture: Nullable<BaseTexture>;
  42400. /**
  42401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42403. * 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;
  42404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42405. */
  42406. /**
  42407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42409. * 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;
  42410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42411. */
  42412. cameraColorCurves: Nullable<ColorCurves>;
  42413. /**
  42414. * Custom callback helping to override the default shader used in the material.
  42415. */
  42416. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42417. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42418. protected _worldViewProjectionMatrix: Matrix;
  42419. protected _globalAmbientColor: Color3;
  42420. protected _useLogarithmicDepth: boolean;
  42421. protected _rebuildInParallel: boolean;
  42422. /**
  42423. * Instantiates a new standard material.
  42424. * This is the default material used in Babylon. It is the best trade off between quality
  42425. * and performances.
  42426. * @see http://doc.babylonjs.com/babylon101/materials
  42427. * @param name Define the name of the material in the scene
  42428. * @param scene Define the scene the material belong to
  42429. */
  42430. constructor(name: string, scene: Scene);
  42431. /**
  42432. * Gets a boolean indicating that current material needs to register RTT
  42433. */
  42434. readonly hasRenderTargetTextures: boolean;
  42435. /**
  42436. * Gets the current class name of the material e.g. "StandardMaterial"
  42437. * Mainly use in serialization.
  42438. * @returns the class name
  42439. */
  42440. getClassName(): string;
  42441. /**
  42442. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42443. * You can try switching to logarithmic depth.
  42444. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42445. */
  42446. useLogarithmicDepth: boolean;
  42447. /**
  42448. * Specifies if the material will require alpha blending
  42449. * @returns a boolean specifying if alpha blending is needed
  42450. */
  42451. needAlphaBlending(): boolean;
  42452. /**
  42453. * Specifies if this material should be rendered in alpha test mode
  42454. * @returns a boolean specifying if an alpha test is needed.
  42455. */
  42456. needAlphaTesting(): boolean;
  42457. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42458. /**
  42459. * Get the texture used for alpha test purpose.
  42460. * @returns the diffuse texture in case of the standard material.
  42461. */
  42462. getAlphaTestTexture(): Nullable<BaseTexture>;
  42463. /**
  42464. * Get if the submesh is ready to be used and all its information available.
  42465. * Child classes can use it to update shaders
  42466. * @param mesh defines the mesh to check
  42467. * @param subMesh defines which submesh to check
  42468. * @param useInstances specifies that instances should be used
  42469. * @returns a boolean indicating that the submesh is ready or not
  42470. */
  42471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42472. /**
  42473. * Builds the material UBO layouts.
  42474. * Used internally during the effect preparation.
  42475. */
  42476. buildUniformLayout(): void;
  42477. /**
  42478. * Unbinds the material from the mesh
  42479. */
  42480. unbind(): void;
  42481. /**
  42482. * Binds the submesh to this material by preparing the effect and shader to draw
  42483. * @param world defines the world transformation matrix
  42484. * @param mesh defines the mesh containing the submesh
  42485. * @param subMesh defines the submesh to bind the material to
  42486. */
  42487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42488. /**
  42489. * Get the list of animatables in the material.
  42490. * @returns the list of animatables object used in the material
  42491. */
  42492. getAnimatables(): IAnimatable[];
  42493. /**
  42494. * Gets the active textures from the material
  42495. * @returns an array of textures
  42496. */
  42497. getActiveTextures(): BaseTexture[];
  42498. /**
  42499. * Specifies if the material uses a texture
  42500. * @param texture defines the texture to check against the material
  42501. * @returns a boolean specifying if the material uses the texture
  42502. */
  42503. hasTexture(texture: BaseTexture): boolean;
  42504. /**
  42505. * Disposes the material
  42506. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42507. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42508. */
  42509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42510. /**
  42511. * Makes a duplicate of the material, and gives it a new name
  42512. * @param name defines the new name for the duplicated material
  42513. * @returns the cloned material
  42514. */
  42515. clone(name: string): StandardMaterial;
  42516. /**
  42517. * Serializes this material in a JSON representation
  42518. * @returns the serialized material object
  42519. */
  42520. serialize(): any;
  42521. /**
  42522. * Creates a standard material from parsed material data
  42523. * @param source defines the JSON representation of the material
  42524. * @param scene defines the hosting scene
  42525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42526. * @returns a new standard material
  42527. */
  42528. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42529. /**
  42530. * Are diffuse textures enabled in the application.
  42531. */
  42532. static DiffuseTextureEnabled: boolean;
  42533. /**
  42534. * Are ambient textures enabled in the application.
  42535. */
  42536. static AmbientTextureEnabled: boolean;
  42537. /**
  42538. * Are opacity textures enabled in the application.
  42539. */
  42540. static OpacityTextureEnabled: boolean;
  42541. /**
  42542. * Are reflection textures enabled in the application.
  42543. */
  42544. static ReflectionTextureEnabled: boolean;
  42545. /**
  42546. * Are emissive textures enabled in the application.
  42547. */
  42548. static EmissiveTextureEnabled: boolean;
  42549. /**
  42550. * Are specular textures enabled in the application.
  42551. */
  42552. static SpecularTextureEnabled: boolean;
  42553. /**
  42554. * Are bump textures enabled in the application.
  42555. */
  42556. static BumpTextureEnabled: boolean;
  42557. /**
  42558. * Are lightmap textures enabled in the application.
  42559. */
  42560. static LightmapTextureEnabled: boolean;
  42561. /**
  42562. * Are refraction textures enabled in the application.
  42563. */
  42564. static RefractionTextureEnabled: boolean;
  42565. /**
  42566. * Are color grading textures enabled in the application.
  42567. */
  42568. static ColorGradingTextureEnabled: boolean;
  42569. /**
  42570. * Are fresnels enabled in the application.
  42571. */
  42572. static FresnelEnabled: boolean;
  42573. }
  42574. }
  42575. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42576. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42578. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42579. /** @hidden */
  42580. export var imageProcessingPixelShader: {
  42581. name: string;
  42582. shader: string;
  42583. };
  42584. }
  42585. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42586. import { Nullable } from "babylonjs/types";
  42587. import { Color4 } from "babylonjs/Maths/math.color";
  42588. import { Camera } from "babylonjs/Cameras/camera";
  42589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42590. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42591. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42593. import { Engine } from "babylonjs/Engines/engine";
  42594. import "babylonjs/Shaders/imageProcessing.fragment";
  42595. import "babylonjs/Shaders/postprocess.vertex";
  42596. /**
  42597. * ImageProcessingPostProcess
  42598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42599. */
  42600. export class ImageProcessingPostProcess extends PostProcess {
  42601. /**
  42602. * Default configuration related to image processing available in the PBR Material.
  42603. */
  42604. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42605. /**
  42606. * Gets the image processing configuration used either in this material.
  42607. */
  42608. /**
  42609. * Sets the Default image processing configuration used either in the this material.
  42610. *
  42611. * If sets to null, the scene one is in use.
  42612. */
  42613. imageProcessingConfiguration: ImageProcessingConfiguration;
  42614. /**
  42615. * Keep track of the image processing observer to allow dispose and replace.
  42616. */
  42617. private _imageProcessingObserver;
  42618. /**
  42619. * Attaches a new image processing configuration to the PBR Material.
  42620. * @param configuration
  42621. */
  42622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42623. /**
  42624. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42625. */
  42626. /**
  42627. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42628. */
  42629. colorCurves: Nullable<ColorCurves>;
  42630. /**
  42631. * Gets wether the color curves effect is enabled.
  42632. */
  42633. /**
  42634. * Sets wether the color curves effect is enabled.
  42635. */
  42636. colorCurvesEnabled: boolean;
  42637. /**
  42638. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42639. */
  42640. /**
  42641. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42642. */
  42643. colorGradingTexture: Nullable<BaseTexture>;
  42644. /**
  42645. * Gets wether the color grading effect is enabled.
  42646. */
  42647. /**
  42648. * Gets wether the color grading effect is enabled.
  42649. */
  42650. colorGradingEnabled: boolean;
  42651. /**
  42652. * Gets exposure used in the effect.
  42653. */
  42654. /**
  42655. * Sets exposure used in the effect.
  42656. */
  42657. exposure: number;
  42658. /**
  42659. * Gets wether tonemapping is enabled or not.
  42660. */
  42661. /**
  42662. * Sets wether tonemapping is enabled or not
  42663. */
  42664. toneMappingEnabled: boolean;
  42665. /**
  42666. * Gets the type of tone mapping effect.
  42667. */
  42668. /**
  42669. * Sets the type of tone mapping effect.
  42670. */
  42671. toneMappingType: number;
  42672. /**
  42673. * Gets contrast used in the effect.
  42674. */
  42675. /**
  42676. * Sets contrast used in the effect.
  42677. */
  42678. contrast: number;
  42679. /**
  42680. * Gets Vignette stretch size.
  42681. */
  42682. /**
  42683. * Sets Vignette stretch size.
  42684. */
  42685. vignetteStretch: number;
  42686. /**
  42687. * Gets Vignette centre X Offset.
  42688. */
  42689. /**
  42690. * Sets Vignette centre X Offset.
  42691. */
  42692. vignetteCentreX: number;
  42693. /**
  42694. * Gets Vignette centre Y Offset.
  42695. */
  42696. /**
  42697. * Sets Vignette centre Y Offset.
  42698. */
  42699. vignetteCentreY: number;
  42700. /**
  42701. * Gets Vignette weight or intensity of the vignette effect.
  42702. */
  42703. /**
  42704. * Sets Vignette weight or intensity of the vignette effect.
  42705. */
  42706. vignetteWeight: number;
  42707. /**
  42708. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42709. * if vignetteEnabled is set to true.
  42710. */
  42711. /**
  42712. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42713. * if vignetteEnabled is set to true.
  42714. */
  42715. vignetteColor: Color4;
  42716. /**
  42717. * Gets Camera field of view used by the Vignette effect.
  42718. */
  42719. /**
  42720. * Sets Camera field of view used by the Vignette effect.
  42721. */
  42722. vignetteCameraFov: number;
  42723. /**
  42724. * Gets the vignette blend mode allowing different kind of effect.
  42725. */
  42726. /**
  42727. * Sets the vignette blend mode allowing different kind of effect.
  42728. */
  42729. vignetteBlendMode: number;
  42730. /**
  42731. * Gets wether the vignette effect is enabled.
  42732. */
  42733. /**
  42734. * Sets wether the vignette effect is enabled.
  42735. */
  42736. vignetteEnabled: boolean;
  42737. private _fromLinearSpace;
  42738. /**
  42739. * Gets wether the input of the processing is in Gamma or Linear Space.
  42740. */
  42741. /**
  42742. * Sets wether the input of the processing is in Gamma or Linear Space.
  42743. */
  42744. fromLinearSpace: boolean;
  42745. /**
  42746. * Defines cache preventing GC.
  42747. */
  42748. private _defines;
  42749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42750. /**
  42751. * "ImageProcessingPostProcess"
  42752. * @returns "ImageProcessingPostProcess"
  42753. */
  42754. getClassName(): string;
  42755. protected _updateParameters(): void;
  42756. dispose(camera?: Camera): void;
  42757. }
  42758. }
  42759. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42760. import { Scene } from "babylonjs/scene";
  42761. import { Color3 } from "babylonjs/Maths/math.color";
  42762. import { Mesh } from "babylonjs/Meshes/mesh";
  42763. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42764. import { Nullable } from "babylonjs/types";
  42765. /**
  42766. * Class containing static functions to help procedurally build meshes
  42767. */
  42768. export class GroundBuilder {
  42769. /**
  42770. * Creates a ground mesh
  42771. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42772. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42774. * @param name defines the name of the mesh
  42775. * @param options defines the options used to create the mesh
  42776. * @param scene defines the hosting scene
  42777. * @returns the ground mesh
  42778. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42779. */
  42780. static CreateGround(name: string, options: {
  42781. width?: number;
  42782. height?: number;
  42783. subdivisions?: number;
  42784. subdivisionsX?: number;
  42785. subdivisionsY?: number;
  42786. updatable?: boolean;
  42787. }, scene: any): Mesh;
  42788. /**
  42789. * Creates a tiled ground mesh
  42790. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42791. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42792. * * 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
  42793. * * 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
  42794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42795. * @param name defines the name of the mesh
  42796. * @param options defines the options used to create the mesh
  42797. * @param scene defines the hosting scene
  42798. * @returns the tiled ground mesh
  42799. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42800. */
  42801. static CreateTiledGround(name: string, options: {
  42802. xmin: number;
  42803. zmin: number;
  42804. xmax: number;
  42805. zmax: number;
  42806. subdivisions?: {
  42807. w: number;
  42808. h: number;
  42809. };
  42810. precision?: {
  42811. w: number;
  42812. h: number;
  42813. };
  42814. updatable?: boolean;
  42815. }, scene?: Nullable<Scene>): Mesh;
  42816. /**
  42817. * Creates a ground mesh from a height map
  42818. * * The parameter `url` sets the URL of the height map image resource.
  42819. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42820. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42821. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42822. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42823. * * 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.
  42824. * * 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).
  42825. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42827. * @param name defines the name of the mesh
  42828. * @param url defines the url to the height map
  42829. * @param options defines the options used to create the mesh
  42830. * @param scene defines the hosting scene
  42831. * @returns the ground mesh
  42832. * @see https://doc.babylonjs.com/babylon101/height_map
  42833. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42834. */
  42835. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42836. width?: number;
  42837. height?: number;
  42838. subdivisions?: number;
  42839. minHeight?: number;
  42840. maxHeight?: number;
  42841. colorFilter?: Color3;
  42842. alphaFilter?: number;
  42843. updatable?: boolean;
  42844. onReady?: (mesh: GroundMesh) => void;
  42845. }, scene?: Nullable<Scene>): GroundMesh;
  42846. }
  42847. }
  42848. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42849. import { Vector4 } from "babylonjs/Maths/math.vector";
  42850. import { Mesh } from "babylonjs/Meshes/mesh";
  42851. /**
  42852. * Class containing static functions to help procedurally build meshes
  42853. */
  42854. export class TorusBuilder {
  42855. /**
  42856. * Creates a torus mesh
  42857. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42858. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42859. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42863. * @param name defines the name of the mesh
  42864. * @param options defines the options used to create the mesh
  42865. * @param scene defines the hosting scene
  42866. * @returns the torus mesh
  42867. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42868. */
  42869. static CreateTorus(name: string, options: {
  42870. diameter?: number;
  42871. thickness?: number;
  42872. tessellation?: number;
  42873. updatable?: boolean;
  42874. sideOrientation?: number;
  42875. frontUVs?: Vector4;
  42876. backUVs?: Vector4;
  42877. }, scene: any): Mesh;
  42878. }
  42879. }
  42880. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42881. import { Vector4 } from "babylonjs/Maths/math.vector";
  42882. import { Color4 } from "babylonjs/Maths/math.color";
  42883. import { Mesh } from "babylonjs/Meshes/mesh";
  42884. /**
  42885. * Class containing static functions to help procedurally build meshes
  42886. */
  42887. export class CylinderBuilder {
  42888. /**
  42889. * Creates a cylinder or a cone mesh
  42890. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42891. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42892. * * 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.
  42893. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42894. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42895. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42896. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42897. * * 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).
  42898. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42899. * * 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).
  42900. * * 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
  42901. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42902. * * 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
  42903. * * 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.
  42904. * * If `enclose` is false, a ring surface is one element.
  42905. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42906. * * 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
  42907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42910. * @param name defines the name of the mesh
  42911. * @param options defines the options used to create the mesh
  42912. * @param scene defines the hosting scene
  42913. * @returns the cylinder mesh
  42914. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42915. */
  42916. static CreateCylinder(name: string, options: {
  42917. height?: number;
  42918. diameterTop?: number;
  42919. diameterBottom?: number;
  42920. diameter?: number;
  42921. tessellation?: number;
  42922. subdivisions?: number;
  42923. arc?: number;
  42924. faceColors?: Color4[];
  42925. faceUV?: Vector4[];
  42926. updatable?: boolean;
  42927. hasRings?: boolean;
  42928. enclose?: boolean;
  42929. cap?: number;
  42930. sideOrientation?: number;
  42931. frontUVs?: Vector4;
  42932. backUVs?: Vector4;
  42933. }, scene: any): Mesh;
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42937. import { Observable } from "babylonjs/Misc/observable";
  42938. import { Nullable } from "babylonjs/types";
  42939. import { Camera } from "babylonjs/Cameras/camera";
  42940. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42941. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42942. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42943. import { Scene } from "babylonjs/scene";
  42944. import { Vector3 } from "babylonjs/Maths/math.vector";
  42945. import { Color3 } from "babylonjs/Maths/math.color";
  42946. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42948. import { Mesh } from "babylonjs/Meshes/mesh";
  42949. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42950. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42951. import "babylonjs/Meshes/Builders/groundBuilder";
  42952. import "babylonjs/Meshes/Builders/torusBuilder";
  42953. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42954. import "babylonjs/Gamepads/gamepadSceneComponent";
  42955. import "babylonjs/Animations/animatable";
  42956. /**
  42957. * Options to modify the vr teleportation behavior.
  42958. */
  42959. export interface VRTeleportationOptions {
  42960. /**
  42961. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42962. */
  42963. floorMeshName?: string;
  42964. /**
  42965. * A list of meshes to be used as the teleportation floor. (default: empty)
  42966. */
  42967. floorMeshes?: Mesh[];
  42968. }
  42969. /**
  42970. * Options to modify the vr experience helper's behavior.
  42971. */
  42972. export interface VRExperienceHelperOptions extends WebVROptions {
  42973. /**
  42974. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42975. */
  42976. createDeviceOrientationCamera?: boolean;
  42977. /**
  42978. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42979. */
  42980. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42981. /**
  42982. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42983. */
  42984. laserToggle?: boolean;
  42985. /**
  42986. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42987. */
  42988. floorMeshes?: Mesh[];
  42989. /**
  42990. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42991. */
  42992. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42993. }
  42994. /**
  42995. * Event containing information after VR has been entered
  42996. */
  42997. export class OnAfterEnteringVRObservableEvent {
  42998. /**
  42999. * If entering vr was successful
  43000. */
  43001. success: boolean;
  43002. }
  43003. /**
  43004. * Helps to quickly add VR support to an existing scene.
  43005. * See http://doc.babylonjs.com/how_to/webvr_helper
  43006. */
  43007. export class VRExperienceHelper {
  43008. /** Options to modify the vr experience helper's behavior. */
  43009. webVROptions: VRExperienceHelperOptions;
  43010. private _scene;
  43011. private _position;
  43012. private _btnVR;
  43013. private _btnVRDisplayed;
  43014. private _webVRsupported;
  43015. private _webVRready;
  43016. private _webVRrequesting;
  43017. private _webVRpresenting;
  43018. private _hasEnteredVR;
  43019. private _fullscreenVRpresenting;
  43020. private _inputElement;
  43021. private _webVRCamera;
  43022. private _vrDeviceOrientationCamera;
  43023. private _deviceOrientationCamera;
  43024. private _existingCamera;
  43025. private _onKeyDown;
  43026. private _onVrDisplayPresentChange;
  43027. private _onVRDisplayChanged;
  43028. private _onVRRequestPresentStart;
  43029. private _onVRRequestPresentComplete;
  43030. /**
  43031. * 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)
  43032. */
  43033. enableGazeEvenWhenNoPointerLock: boolean;
  43034. /**
  43035. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43036. */
  43037. exitVROnDoubleTap: boolean;
  43038. /**
  43039. * Observable raised right before entering VR.
  43040. */
  43041. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43042. /**
  43043. * Observable raised when entering VR has completed.
  43044. */
  43045. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43046. /**
  43047. * Observable raised when exiting VR.
  43048. */
  43049. onExitingVRObservable: Observable<VRExperienceHelper>;
  43050. /**
  43051. * Observable raised when controller mesh is loaded.
  43052. */
  43053. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43054. /** Return this.onEnteringVRObservable
  43055. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43056. */
  43057. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43058. /** Return this.onExitingVRObservable
  43059. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43060. */
  43061. readonly onExitingVR: Observable<VRExperienceHelper>;
  43062. /** Return this.onControllerMeshLoadedObservable
  43063. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43064. */
  43065. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43066. private _rayLength;
  43067. private _useCustomVRButton;
  43068. private _teleportationRequested;
  43069. private _teleportActive;
  43070. private _floorMeshName;
  43071. private _floorMeshesCollection;
  43072. private _rotationAllowed;
  43073. private _teleportBackwardsVector;
  43074. private _teleportationTarget;
  43075. private _isDefaultTeleportationTarget;
  43076. private _postProcessMove;
  43077. private _teleportationFillColor;
  43078. private _teleportationBorderColor;
  43079. private _rotationAngle;
  43080. private _haloCenter;
  43081. private _cameraGazer;
  43082. private _padSensibilityUp;
  43083. private _padSensibilityDown;
  43084. private _leftController;
  43085. private _rightController;
  43086. /**
  43087. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43088. */
  43089. onNewMeshSelected: Observable<AbstractMesh>;
  43090. /**
  43091. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43092. * This observable will provide the mesh and the controller used to select the mesh
  43093. */
  43094. onMeshSelectedWithController: Observable<{
  43095. mesh: AbstractMesh;
  43096. controller: WebVRController;
  43097. }>;
  43098. /**
  43099. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43100. */
  43101. onNewMeshPicked: Observable<PickingInfo>;
  43102. private _circleEase;
  43103. /**
  43104. * Observable raised before camera teleportation
  43105. */
  43106. onBeforeCameraTeleport: Observable<Vector3>;
  43107. /**
  43108. * Observable raised after camera teleportation
  43109. */
  43110. onAfterCameraTeleport: Observable<Vector3>;
  43111. /**
  43112. * Observable raised when current selected mesh gets unselected
  43113. */
  43114. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43115. private _raySelectionPredicate;
  43116. /**
  43117. * To be optionaly changed by user to define custom ray selection
  43118. */
  43119. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43120. /**
  43121. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43122. */
  43123. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43124. /**
  43125. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43126. */
  43127. teleportationEnabled: boolean;
  43128. private _defaultHeight;
  43129. private _teleportationInitialized;
  43130. private _interactionsEnabled;
  43131. private _interactionsRequested;
  43132. private _displayGaze;
  43133. private _displayLaserPointer;
  43134. /**
  43135. * The mesh used to display where the user is going to teleport.
  43136. */
  43137. /**
  43138. * Sets the mesh to be used to display where the user is going to teleport.
  43139. */
  43140. teleportationTarget: Mesh;
  43141. /**
  43142. * 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
  43143. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43144. * See http://doc.babylonjs.com/resources/baking_transformations
  43145. */
  43146. gazeTrackerMesh: Mesh;
  43147. /**
  43148. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43149. */
  43150. updateGazeTrackerScale: boolean;
  43151. /**
  43152. * If the gaze trackers color should be updated when selecting meshes
  43153. */
  43154. updateGazeTrackerColor: boolean;
  43155. /**
  43156. * If the controller laser color should be updated when selecting meshes
  43157. */
  43158. updateControllerLaserColor: boolean;
  43159. /**
  43160. * The gaze tracking mesh corresponding to the left controller
  43161. */
  43162. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43163. /**
  43164. * The gaze tracking mesh corresponding to the right controller
  43165. */
  43166. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43167. /**
  43168. * If the ray of the gaze should be displayed.
  43169. */
  43170. /**
  43171. * Sets if the ray of the gaze should be displayed.
  43172. */
  43173. displayGaze: boolean;
  43174. /**
  43175. * If the ray of the LaserPointer should be displayed.
  43176. */
  43177. /**
  43178. * Sets if the ray of the LaserPointer should be displayed.
  43179. */
  43180. displayLaserPointer: boolean;
  43181. /**
  43182. * The deviceOrientationCamera used as the camera when not in VR.
  43183. */
  43184. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43185. /**
  43186. * Based on the current WebVR support, returns the current VR camera used.
  43187. */
  43188. readonly currentVRCamera: Nullable<Camera>;
  43189. /**
  43190. * The webVRCamera which is used when in VR.
  43191. */
  43192. readonly webVRCamera: WebVRFreeCamera;
  43193. /**
  43194. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43195. */
  43196. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43197. /**
  43198. * The html button that is used to trigger entering into VR.
  43199. */
  43200. readonly vrButton: Nullable<HTMLButtonElement>;
  43201. private readonly _teleportationRequestInitiated;
  43202. /**
  43203. * Defines wether or not Pointer lock should be requested when switching to
  43204. * full screen.
  43205. */
  43206. requestPointerLockOnFullScreen: boolean;
  43207. /**
  43208. * Instantiates a VRExperienceHelper.
  43209. * Helps to quickly add VR support to an existing scene.
  43210. * @param scene The scene the VRExperienceHelper belongs to.
  43211. * @param webVROptions Options to modify the vr experience helper's behavior.
  43212. */
  43213. constructor(scene: Scene,
  43214. /** Options to modify the vr experience helper's behavior. */
  43215. webVROptions?: VRExperienceHelperOptions);
  43216. private _onDefaultMeshLoaded;
  43217. private _onResize;
  43218. private _onFullscreenChange;
  43219. /**
  43220. * Gets a value indicating if we are currently in VR mode.
  43221. */
  43222. readonly isInVRMode: boolean;
  43223. private onVrDisplayPresentChange;
  43224. private onVRDisplayChanged;
  43225. private moveButtonToBottomRight;
  43226. private displayVRButton;
  43227. private updateButtonVisibility;
  43228. private _cachedAngularSensibility;
  43229. /**
  43230. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43231. * Otherwise, will use the fullscreen API.
  43232. */
  43233. enterVR(): void;
  43234. /**
  43235. * Attempt to exit VR, or fullscreen.
  43236. */
  43237. exitVR(): void;
  43238. /**
  43239. * The position of the vr experience helper.
  43240. */
  43241. /**
  43242. * Sets the position of the vr experience helper.
  43243. */
  43244. position: Vector3;
  43245. /**
  43246. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43247. */
  43248. enableInteractions(): void;
  43249. private readonly _noControllerIsActive;
  43250. private beforeRender;
  43251. private _isTeleportationFloor;
  43252. /**
  43253. * Adds a floor mesh to be used for teleportation.
  43254. * @param floorMesh the mesh to be used for teleportation.
  43255. */
  43256. addFloorMesh(floorMesh: Mesh): void;
  43257. /**
  43258. * Removes a floor mesh from being used for teleportation.
  43259. * @param floorMesh the mesh to be removed.
  43260. */
  43261. removeFloorMesh(floorMesh: Mesh): void;
  43262. /**
  43263. * Enables interactions and teleportation using the VR controllers and gaze.
  43264. * @param vrTeleportationOptions options to modify teleportation behavior.
  43265. */
  43266. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43267. private _onNewGamepadConnected;
  43268. private _tryEnableInteractionOnController;
  43269. private _onNewGamepadDisconnected;
  43270. private _enableInteractionOnController;
  43271. private _checkTeleportWithRay;
  43272. private _checkRotate;
  43273. private _checkTeleportBackwards;
  43274. private _enableTeleportationOnController;
  43275. private _createTeleportationCircles;
  43276. private _displayTeleportationTarget;
  43277. private _hideTeleportationTarget;
  43278. private _rotateCamera;
  43279. private _moveTeleportationSelectorTo;
  43280. private _workingVector;
  43281. private _workingQuaternion;
  43282. private _workingMatrix;
  43283. /**
  43284. * Teleports the users feet to the desired location
  43285. * @param location The location where the user's feet should be placed
  43286. */
  43287. teleportCamera(location: Vector3): void;
  43288. private _convertNormalToDirectionOfRay;
  43289. private _castRayAndSelectObject;
  43290. private _notifySelectedMeshUnselected;
  43291. /**
  43292. * Sets the color of the laser ray from the vr controllers.
  43293. * @param color new color for the ray.
  43294. */
  43295. changeLaserColor(color: Color3): void;
  43296. /**
  43297. * Sets the color of the ray from the vr headsets gaze.
  43298. * @param color new color for the ray.
  43299. */
  43300. changeGazeColor(color: Color3): void;
  43301. /**
  43302. * Exits VR and disposes of the vr experience helper
  43303. */
  43304. dispose(): void;
  43305. /**
  43306. * Gets the name of the VRExperienceHelper class
  43307. * @returns "VRExperienceHelper"
  43308. */
  43309. getClassName(): string;
  43310. }
  43311. }
  43312. declare module "babylonjs/Cameras/VR/index" {
  43313. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43314. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43315. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43316. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43317. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43318. export * from "babylonjs/Cameras/VR/webVRCamera";
  43319. }
  43320. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43321. import { Nullable } from "babylonjs/types";
  43322. import { IDisposable } from "babylonjs/scene";
  43323. /**
  43324. * States of the webXR experience
  43325. */
  43326. export enum WebXRState {
  43327. /**
  43328. * Transitioning to being in XR mode
  43329. */
  43330. ENTERING_XR = 0,
  43331. /**
  43332. * Transitioning to non XR mode
  43333. */
  43334. EXITING_XR = 1,
  43335. /**
  43336. * In XR mode and presenting
  43337. */
  43338. IN_XR = 2,
  43339. /**
  43340. * Not entered XR mode
  43341. */
  43342. NOT_IN_XR = 3
  43343. }
  43344. /**
  43345. * Abstraction of the XR render target
  43346. */
  43347. export interface WebXRRenderTarget extends IDisposable {
  43348. /**
  43349. * xrpresent context of the canvas which can be used to display/mirror xr content
  43350. */
  43351. canvasContext: WebGLRenderingContext;
  43352. /**
  43353. * xr layer for the canvas
  43354. */
  43355. xrLayer: Nullable<XRWebGLLayer>;
  43356. /**
  43357. * Initializes the xr layer for the session
  43358. * @param xrSession xr session
  43359. * @returns a promise that will resolve once the XR Layer has been created
  43360. */
  43361. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43362. }
  43363. }
  43364. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43365. import { Nullable } from "babylonjs/types";
  43366. import { Observable } from "babylonjs/Misc/observable";
  43367. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43368. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43369. /**
  43370. * COnfiguration object for WebXR output canvas
  43371. */
  43372. export class WebXRManagedOutputCanvasOptions {
  43373. /**
  43374. * Options for this XR Layer output
  43375. */
  43376. canvasOptions: XRWebGLLayerOptions;
  43377. /**
  43378. * CSS styling for a newly created canvas (if not provided)
  43379. */
  43380. newCanvasCssStyle?: string;
  43381. /**
  43382. * Get the default values of the configuration object
  43383. * @returns default values of this configuration object
  43384. */
  43385. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43386. }
  43387. /**
  43388. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43389. */
  43390. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43391. private configuration;
  43392. private _engine;
  43393. private _canvas;
  43394. /**
  43395. * xrpresent context of the canvas which can be used to display/mirror xr content
  43396. */
  43397. canvasContext: WebGLRenderingContext;
  43398. /**
  43399. * xr layer for the canvas
  43400. */
  43401. xrLayer: Nullable<XRWebGLLayer>;
  43402. /**
  43403. * Initializes the xr layer for the session
  43404. * @param xrSession xr session
  43405. * @returns a promise that will resolve once the XR Layer has been created
  43406. */
  43407. initializeXRLayerAsync(xrSession: any): any;
  43408. /**
  43409. * Initializes the canvas to be added/removed upon entering/exiting xr
  43410. * @param engine the Babylon engine
  43411. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43412. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43413. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43414. */
  43415. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43416. /**
  43417. * Disposes of the object
  43418. */
  43419. dispose(): void;
  43420. private _setManagedOutputCanvas;
  43421. private _addCanvas;
  43422. private _removeCanvas;
  43423. }
  43424. }
  43425. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43426. import { Observable } from "babylonjs/Misc/observable";
  43427. import { Nullable } from "babylonjs/types";
  43428. import { IDisposable, Scene } from "babylonjs/scene";
  43429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43430. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43431. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43432. /**
  43433. * Manages an XRSession to work with Babylon's engine
  43434. * @see https://doc.babylonjs.com/how_to/webxr
  43435. */
  43436. export class WebXRSessionManager implements IDisposable {
  43437. private scene;
  43438. /**
  43439. * Fires every time a new xrFrame arrives which can be used to update the camera
  43440. */
  43441. onXRFrameObservable: Observable<any>;
  43442. /**
  43443. * Fires when the xr session is ended either by the device or manually done
  43444. */
  43445. onXRSessionEnded: Observable<any>;
  43446. /**
  43447. * Underlying xr session
  43448. */
  43449. session: XRSession;
  43450. /**
  43451. * Type of reference space used when creating the session
  43452. */
  43453. referenceSpace: XRReferenceSpace;
  43454. /**
  43455. * Current XR frame
  43456. */
  43457. currentFrame: Nullable<XRFrame>;
  43458. private _xrNavigator;
  43459. private baseLayer;
  43460. private _rttProvider;
  43461. private _sessionEnded;
  43462. /**
  43463. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43464. * @param scene The scene which the session should be created for
  43465. */
  43466. constructor(scene: Scene);
  43467. /**
  43468. * Initializes the manager
  43469. * After initialization enterXR can be called to start an XR session
  43470. * @returns Promise which resolves after it is initialized
  43471. */
  43472. initializeAsync(): Promise<void>;
  43473. /**
  43474. * Initializes an xr session
  43475. * @param xrSessionMode mode to initialize
  43476. * @param optionalFeatures defines optional values to pass to the session builder
  43477. * @returns a promise which will resolve once the session has been initialized
  43478. */
  43479. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43480. /**
  43481. * Sets the reference space on the xr session
  43482. * @param referenceSpace space to set
  43483. * @returns a promise that will resolve once the reference space has been set
  43484. */
  43485. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43486. /**
  43487. * Updates the render state of the session
  43488. * @param state state to set
  43489. * @returns a promise that resolves once the render state has been updated
  43490. */
  43491. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43492. /**
  43493. * Starts rendering to the xr layer
  43494. * @returns a promise that will resolve once rendering has started
  43495. */
  43496. startRenderingToXRAsync(): Promise<void>;
  43497. /**
  43498. * Gets the correct render target texture to be rendered this frame for this eye
  43499. * @param eye the eye for which to get the render target
  43500. * @returns the render target for the specified eye
  43501. */
  43502. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43503. /**
  43504. * Stops the xrSession and restores the renderloop
  43505. * @returns Promise which resolves after it exits XR
  43506. */
  43507. exitXRAsync(): Promise<void>;
  43508. /**
  43509. * Checks if a session would be supported for the creation options specified
  43510. * @param sessionMode session mode to check if supported eg. immersive-vr
  43511. * @returns true if supported
  43512. */
  43513. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43514. /**
  43515. * Creates a WebXRRenderTarget object for the XR session
  43516. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43517. * @param options optional options to provide when creating a new render target
  43518. * @returns a WebXR render target to which the session can render
  43519. */
  43520. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43521. /**
  43522. * @hidden
  43523. * Converts the render layer of xrSession to a render target
  43524. * @param session session to create render target for
  43525. * @param scene scene the new render target should be created for
  43526. */
  43527. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43528. /**
  43529. * Disposes of the session manager
  43530. */
  43531. dispose(): void;
  43532. }
  43533. }
  43534. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43535. import { Scene } from "babylonjs/scene";
  43536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43537. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43538. /**
  43539. * WebXR Camera which holds the views for the xrSession
  43540. * @see https://doc.babylonjs.com/how_to/webxr
  43541. */
  43542. export class WebXRCamera extends FreeCamera {
  43543. private static _TmpMatrix;
  43544. /**
  43545. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43546. * @param name the name of the camera
  43547. * @param scene the scene to add the camera to
  43548. */
  43549. constructor(name: string, scene: Scene);
  43550. private _updateNumberOfRigCameras;
  43551. /** @hidden */
  43552. _updateForDualEyeDebugging(): void;
  43553. /**
  43554. * Updates the cameras position from the current pose information of the XR session
  43555. * @param xrSessionManager the session containing pose information
  43556. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43557. */
  43558. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43559. }
  43560. }
  43561. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43562. import { Observable } from "babylonjs/Misc/observable";
  43563. import { IDisposable, Scene } from "babylonjs/scene";
  43564. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43566. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43567. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43568. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43569. /**
  43570. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43571. * @see https://doc.babylonjs.com/how_to/webxr
  43572. */
  43573. export class WebXRExperienceHelper implements IDisposable {
  43574. private scene;
  43575. /**
  43576. * 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
  43577. */
  43578. container: AbstractMesh;
  43579. /**
  43580. * Camera used to render xr content
  43581. */
  43582. camera: WebXRCamera;
  43583. /**
  43584. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43585. */
  43586. state: WebXRState;
  43587. private _setState;
  43588. private static _TmpVector;
  43589. /**
  43590. * Fires when the state of the experience helper has changed
  43591. */
  43592. onStateChangedObservable: Observable<WebXRState>;
  43593. /** Session manager used to keep track of xr session */
  43594. sessionManager: WebXRSessionManager;
  43595. private _nonVRCamera;
  43596. private _originalSceneAutoClear;
  43597. private _supported;
  43598. /**
  43599. * Creates the experience helper
  43600. * @param scene the scene to attach the experience helper to
  43601. * @returns a promise for the experience helper
  43602. */
  43603. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43604. /**
  43605. * Creates a WebXRExperienceHelper
  43606. * @param scene The scene the helper should be created in
  43607. */
  43608. private constructor();
  43609. /**
  43610. * Exits XR mode and returns the scene to its original state
  43611. * @returns promise that resolves after xr mode has exited
  43612. */
  43613. exitXRAsync(): Promise<void>;
  43614. /**
  43615. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43616. * @param sessionMode options for the XR session
  43617. * @param referenceSpaceType frame of reference of the XR session
  43618. * @param renderTarget the output canvas that will be used to enter XR mode
  43619. * @returns promise that resolves after xr mode has entered
  43620. */
  43621. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43622. /**
  43623. * Updates the global position of the camera by moving the camera's container
  43624. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43625. * @param position The desired global position of the camera
  43626. */
  43627. setPositionOfCameraUsingContainer(position: Vector3): void;
  43628. /**
  43629. * Rotates the xr camera by rotating the camera's container around the camera's position
  43630. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43631. * @param rotation the desired quaternion rotation to apply to the camera
  43632. */
  43633. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43634. /**
  43635. * Disposes of the experience helper
  43636. */
  43637. dispose(): void;
  43638. }
  43639. }
  43640. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43641. import { Nullable } from "babylonjs/types";
  43642. import { Observable } from "babylonjs/Misc/observable";
  43643. import { IDisposable, Scene } from "babylonjs/scene";
  43644. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43645. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43646. /**
  43647. * Button which can be used to enter a different mode of XR
  43648. */
  43649. export class WebXREnterExitUIButton {
  43650. /** button element */
  43651. element: HTMLElement;
  43652. /** XR initialization options for the button */
  43653. sessionMode: XRSessionMode;
  43654. /** Reference space type */
  43655. referenceSpaceType: XRReferenceSpaceType;
  43656. /**
  43657. * Creates a WebXREnterExitUIButton
  43658. * @param element button element
  43659. * @param sessionMode XR initialization session mode
  43660. * @param referenceSpaceType the type of reference space to be used
  43661. */
  43662. constructor(
  43663. /** button element */
  43664. element: HTMLElement,
  43665. /** XR initialization options for the button */
  43666. sessionMode: XRSessionMode,
  43667. /** Reference space type */
  43668. referenceSpaceType: XRReferenceSpaceType);
  43669. /**
  43670. * Overwritable function which can be used to update the button's visuals when the state changes
  43671. * @param activeButton the current active button in the UI
  43672. */
  43673. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43674. }
  43675. /**
  43676. * Options to create the webXR UI
  43677. */
  43678. export class WebXREnterExitUIOptions {
  43679. /**
  43680. * Context to enter xr with
  43681. */
  43682. renderTarget?: Nullable<WebXRRenderTarget>;
  43683. /**
  43684. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43685. */
  43686. customButtons?: Array<WebXREnterExitUIButton>;
  43687. }
  43688. /**
  43689. * UI to allow the user to enter/exit XR mode
  43690. */
  43691. export class WebXREnterExitUI implements IDisposable {
  43692. private scene;
  43693. private _overlay;
  43694. private _buttons;
  43695. private _activeButton;
  43696. /**
  43697. * Fired every time the active button is changed.
  43698. *
  43699. * When xr is entered via a button that launches xr that button will be the callback parameter
  43700. *
  43701. * When exiting xr the callback parameter will be null)
  43702. */
  43703. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43704. /**
  43705. * Creates UI to allow the user to enter/exit XR mode
  43706. * @param scene the scene to add the ui to
  43707. * @param helper the xr experience helper to enter/exit xr with
  43708. * @param options options to configure the UI
  43709. * @returns the created ui
  43710. */
  43711. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43712. private constructor();
  43713. private _updateButtons;
  43714. /**
  43715. * Disposes of the object
  43716. */
  43717. dispose(): void;
  43718. }
  43719. }
  43720. declare module "babylonjs/Cameras/XR/webXRController" {
  43721. import { Nullable } from "babylonjs/types";
  43722. import { Observable } from "babylonjs/Misc/observable";
  43723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43724. import { Ray } from "babylonjs/Culling/ray";
  43725. import { Scene } from "babylonjs/scene";
  43726. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43727. /**
  43728. * Represents an XR input
  43729. */
  43730. export class WebXRController {
  43731. private scene;
  43732. /** The underlying input source for the controller */
  43733. inputSource: XRInputSource;
  43734. private parentContainer;
  43735. /**
  43736. * 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
  43737. */
  43738. grip?: AbstractMesh;
  43739. /**
  43740. * Pointer which can be used to select objects or attach a visible laser to
  43741. */
  43742. pointer: AbstractMesh;
  43743. private _gamepadMode;
  43744. /**
  43745. * If available, this is the gamepad object related to this controller.
  43746. * Using this object it is possible to get click events and trackpad changes of the
  43747. * webxr controller that is currently being used.
  43748. */
  43749. gamepadController?: WebVRController;
  43750. /**
  43751. * Event that fires when the controller is removed/disposed
  43752. */
  43753. onDisposeObservable: Observable<{}>;
  43754. private _tmpMatrix;
  43755. private _tmpQuaternion;
  43756. private _tmpVector;
  43757. /**
  43758. * Creates the controller
  43759. * @see https://doc.babylonjs.com/how_to/webxr
  43760. * @param scene the scene which the controller should be associated to
  43761. * @param inputSource the underlying input source for the controller
  43762. * @param parentContainer parent that the controller meshes should be children of
  43763. */
  43764. constructor(scene: Scene,
  43765. /** The underlying input source for the controller */
  43766. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43767. /**
  43768. * Updates the controller pose based on the given XRFrame
  43769. * @param xrFrame xr frame to update the pose with
  43770. * @param referenceSpace reference space to use
  43771. */
  43772. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43773. /**
  43774. * Gets a world space ray coming from the controller
  43775. * @param result the resulting ray
  43776. */
  43777. getWorldPointerRayToRef(result: Ray): void;
  43778. /**
  43779. * Get the scene associated with this controller
  43780. * @returns the scene object
  43781. */
  43782. getScene(): Scene;
  43783. /**
  43784. * Disposes of the object
  43785. */
  43786. dispose(): void;
  43787. }
  43788. }
  43789. declare module "babylonjs/Cameras/XR/webXRInput" {
  43790. import { Observable } from "babylonjs/Misc/observable";
  43791. import { IDisposable } from "babylonjs/scene";
  43792. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43793. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43794. /**
  43795. * XR input used to track XR inputs such as controllers/rays
  43796. */
  43797. export class WebXRInput implements IDisposable {
  43798. /**
  43799. * Base experience the input listens to
  43800. */
  43801. baseExperience: WebXRExperienceHelper;
  43802. /**
  43803. * XR controllers being tracked
  43804. */
  43805. controllers: Array<WebXRController>;
  43806. private _frameObserver;
  43807. private _stateObserver;
  43808. /**
  43809. * Event when a controller has been connected/added
  43810. */
  43811. onControllerAddedObservable: Observable<WebXRController>;
  43812. /**
  43813. * Event when a controller has been removed/disconnected
  43814. */
  43815. onControllerRemovedObservable: Observable<WebXRController>;
  43816. /**
  43817. * Initializes the WebXRInput
  43818. * @param baseExperience experience helper which the input should be created for
  43819. */
  43820. constructor(
  43821. /**
  43822. * Base experience the input listens to
  43823. */
  43824. baseExperience: WebXRExperienceHelper);
  43825. private _onInputSourcesChange;
  43826. private _addAndRemoveControllers;
  43827. /**
  43828. * Disposes of the object
  43829. */
  43830. dispose(): void;
  43831. }
  43832. }
  43833. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43835. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43836. /**
  43837. * Enables teleportation
  43838. */
  43839. export class WebXRControllerTeleportation {
  43840. private _teleportationFillColor;
  43841. private _teleportationBorderColor;
  43842. private _tmpRay;
  43843. private _tmpVector;
  43844. /**
  43845. * Creates a WebXRControllerTeleportation
  43846. * @param input input manager to add teleportation to
  43847. * @param floorMeshes floormeshes which can be teleported to
  43848. */
  43849. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43850. }
  43851. }
  43852. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43853. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43854. /**
  43855. * Handles pointer input automatically for the pointer of XR controllers
  43856. */
  43857. export class WebXRControllerPointerSelection {
  43858. private static _idCounter;
  43859. private _tmpRay;
  43860. /**
  43861. * Creates a WebXRControllerPointerSelection
  43862. * @param input input manager to setup pointer selection
  43863. */
  43864. constructor(input: WebXRInput);
  43865. private _convertNormalToDirectionOfRay;
  43866. private _updatePointerDistance;
  43867. }
  43868. }
  43869. declare module "babylonjs/Loading/sceneLoader" {
  43870. import { Observable } from "babylonjs/Misc/observable";
  43871. import { Nullable } from "babylonjs/types";
  43872. import { Scene } from "babylonjs/scene";
  43873. import { Engine } from "babylonjs/Engines/engine";
  43874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43875. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43876. import { AssetContainer } from "babylonjs/assetContainer";
  43877. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43878. import { Skeleton } from "babylonjs/Bones/skeleton";
  43879. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43880. import { WebRequest } from "babylonjs/Misc/webRequest";
  43881. /**
  43882. * Class used to represent data loading progression
  43883. */
  43884. export class SceneLoaderProgressEvent {
  43885. /** defines if data length to load can be evaluated */
  43886. readonly lengthComputable: boolean;
  43887. /** defines the loaded data length */
  43888. readonly loaded: number;
  43889. /** defines the data length to load */
  43890. readonly total: number;
  43891. /**
  43892. * Create a new progress event
  43893. * @param lengthComputable defines if data length to load can be evaluated
  43894. * @param loaded defines the loaded data length
  43895. * @param total defines the data length to load
  43896. */
  43897. constructor(
  43898. /** defines if data length to load can be evaluated */
  43899. lengthComputable: boolean,
  43900. /** defines the loaded data length */
  43901. loaded: number,
  43902. /** defines the data length to load */
  43903. total: number);
  43904. /**
  43905. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43906. * @param event defines the source event
  43907. * @returns a new SceneLoaderProgressEvent
  43908. */
  43909. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43910. }
  43911. /**
  43912. * Interface used by SceneLoader plugins to define supported file extensions
  43913. */
  43914. export interface ISceneLoaderPluginExtensions {
  43915. /**
  43916. * Defines the list of supported extensions
  43917. */
  43918. [extension: string]: {
  43919. isBinary: boolean;
  43920. };
  43921. }
  43922. /**
  43923. * Interface used by SceneLoader plugin factory
  43924. */
  43925. export interface ISceneLoaderPluginFactory {
  43926. /**
  43927. * Defines the name of the factory
  43928. */
  43929. name: string;
  43930. /**
  43931. * Function called to create a new plugin
  43932. * @return the new plugin
  43933. */
  43934. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43935. /**
  43936. * The callback that returns true if the data can be directly loaded.
  43937. * @param data string containing the file data
  43938. * @returns if the data can be loaded directly
  43939. */
  43940. canDirectLoad?(data: string): boolean;
  43941. }
  43942. /**
  43943. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43944. */
  43945. export interface ISceneLoaderPluginBase {
  43946. /**
  43947. * The friendly name of this plugin.
  43948. */
  43949. name: string;
  43950. /**
  43951. * The file extensions supported by this plugin.
  43952. */
  43953. extensions: string | ISceneLoaderPluginExtensions;
  43954. /**
  43955. * The callback called when loading from a url.
  43956. * @param scene scene loading this url
  43957. * @param url url to load
  43958. * @param onSuccess callback called when the file successfully loads
  43959. * @param onProgress callback called while file is loading (if the server supports this mode)
  43960. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43961. * @param onError callback called when the file fails to load
  43962. * @returns a file request object
  43963. */
  43964. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43965. /**
  43966. * The callback called when loading from a file object.
  43967. * @param scene scene loading this file
  43968. * @param file defines the file to load
  43969. * @param onSuccess defines the callback to call when data is loaded
  43970. * @param onProgress defines the callback to call during loading process
  43971. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43972. * @param onError defines the callback to call when an error occurs
  43973. * @returns a file request object
  43974. */
  43975. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43976. /**
  43977. * The callback that returns true if the data can be directly loaded.
  43978. * @param data string containing the file data
  43979. * @returns if the data can be loaded directly
  43980. */
  43981. canDirectLoad?(data: string): boolean;
  43982. /**
  43983. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43984. * @param scene scene loading this data
  43985. * @param data string containing the data
  43986. * @returns data to pass to the plugin
  43987. */
  43988. directLoad?(scene: Scene, data: string): any;
  43989. /**
  43990. * The callback that allows custom handling of the root url based on the response url.
  43991. * @param rootUrl the original root url
  43992. * @param responseURL the response url if available
  43993. * @returns the new root url
  43994. */
  43995. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43996. }
  43997. /**
  43998. * Interface used to define a SceneLoader plugin
  43999. */
  44000. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44001. /**
  44002. * Import meshes into a scene.
  44003. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44004. * @param scene The scene to import into
  44005. * @param data The data to import
  44006. * @param rootUrl The root url for scene and resources
  44007. * @param meshes The meshes array to import into
  44008. * @param particleSystems The particle systems array to import into
  44009. * @param skeletons The skeletons array to import into
  44010. * @param onError The callback when import fails
  44011. * @returns True if successful or false otherwise
  44012. */
  44013. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44014. /**
  44015. * Load into a scene.
  44016. * @param scene The scene to load into
  44017. * @param data The data to import
  44018. * @param rootUrl The root url for scene and resources
  44019. * @param onError The callback when import fails
  44020. * @returns True if successful or false otherwise
  44021. */
  44022. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44023. /**
  44024. * Load into an asset container.
  44025. * @param scene The scene to load into
  44026. * @param data The data to import
  44027. * @param rootUrl The root url for scene and resources
  44028. * @param onError The callback when import fails
  44029. * @returns The loaded asset container
  44030. */
  44031. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44032. }
  44033. /**
  44034. * Interface used to define an async SceneLoader plugin
  44035. */
  44036. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44037. /**
  44038. * Import meshes into a scene.
  44039. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44040. * @param scene The scene to import into
  44041. * @param data The data to import
  44042. * @param rootUrl The root url for scene and resources
  44043. * @param onProgress The callback when the load progresses
  44044. * @param fileName Defines the name of the file to load
  44045. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44046. */
  44047. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44048. meshes: AbstractMesh[];
  44049. particleSystems: IParticleSystem[];
  44050. skeletons: Skeleton[];
  44051. animationGroups: AnimationGroup[];
  44052. }>;
  44053. /**
  44054. * Load into a scene.
  44055. * @param scene The scene to load into
  44056. * @param data The data to import
  44057. * @param rootUrl The root url for scene and resources
  44058. * @param onProgress The callback when the load progresses
  44059. * @param fileName Defines the name of the file to load
  44060. * @returns Nothing
  44061. */
  44062. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44063. /**
  44064. * Load into an asset container.
  44065. * @param scene The scene to load into
  44066. * @param data The data to import
  44067. * @param rootUrl The root url for scene and resources
  44068. * @param onProgress The callback when the load progresses
  44069. * @param fileName Defines the name of the file to load
  44070. * @returns The loaded asset container
  44071. */
  44072. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44073. }
  44074. /**
  44075. * Class used to load scene from various file formats using registered plugins
  44076. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44077. */
  44078. export class SceneLoader {
  44079. /**
  44080. * No logging while loading
  44081. */
  44082. static readonly NO_LOGGING: number;
  44083. /**
  44084. * Minimal logging while loading
  44085. */
  44086. static readonly MINIMAL_LOGGING: number;
  44087. /**
  44088. * Summary logging while loading
  44089. */
  44090. static readonly SUMMARY_LOGGING: number;
  44091. /**
  44092. * Detailled logging while loading
  44093. */
  44094. static readonly DETAILED_LOGGING: number;
  44095. /**
  44096. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44097. */
  44098. static ForceFullSceneLoadingForIncremental: boolean;
  44099. /**
  44100. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44101. */
  44102. static ShowLoadingScreen: boolean;
  44103. /**
  44104. * Defines the current logging level (while loading the scene)
  44105. * @ignorenaming
  44106. */
  44107. static loggingLevel: number;
  44108. /**
  44109. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44110. */
  44111. static CleanBoneMatrixWeights: boolean;
  44112. /**
  44113. * Event raised when a plugin is used to load a scene
  44114. */
  44115. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44116. private static _registeredPlugins;
  44117. private static _getDefaultPlugin;
  44118. private static _getPluginForExtension;
  44119. private static _getPluginForDirectLoad;
  44120. private static _getPluginForFilename;
  44121. private static _getDirectLoad;
  44122. private static _loadData;
  44123. private static _getFileInfo;
  44124. /**
  44125. * Gets a plugin that can load the given extension
  44126. * @param extension defines the extension to load
  44127. * @returns a plugin or null if none works
  44128. */
  44129. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44130. /**
  44131. * Gets a boolean indicating that the given extension can be loaded
  44132. * @param extension defines the extension to load
  44133. * @returns true if the extension is supported
  44134. */
  44135. static IsPluginForExtensionAvailable(extension: string): boolean;
  44136. /**
  44137. * Adds a new plugin to the list of registered plugins
  44138. * @param plugin defines the plugin to add
  44139. */
  44140. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44141. /**
  44142. * Import meshes into a scene
  44143. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44144. * @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)
  44145. * @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)
  44146. * @param scene the instance of BABYLON.Scene to append to
  44147. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44148. * @param onProgress a callback with a progress event for each file being loaded
  44149. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44150. * @param pluginExtension the extension used to determine the plugin
  44151. * @returns The loaded plugin
  44152. */
  44153. 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>;
  44154. /**
  44155. * Import meshes into a scene
  44156. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44157. * @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)
  44158. * @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)
  44159. * @param scene the instance of BABYLON.Scene to append to
  44160. * @param onProgress a callback with a progress event for each file being loaded
  44161. * @param pluginExtension the extension used to determine the plugin
  44162. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44163. */
  44164. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44165. meshes: AbstractMesh[];
  44166. particleSystems: IParticleSystem[];
  44167. skeletons: Skeleton[];
  44168. animationGroups: AnimationGroup[];
  44169. }>;
  44170. /**
  44171. * Load a scene
  44172. * @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)
  44173. * @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)
  44174. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44175. * @param onSuccess a callback with the scene when import succeeds
  44176. * @param onProgress a callback with a progress event for each file being loaded
  44177. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44178. * @param pluginExtension the extension used to determine the plugin
  44179. * @returns The loaded plugin
  44180. */
  44181. 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>;
  44182. /**
  44183. * Load a scene
  44184. * @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)
  44185. * @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)
  44186. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44187. * @param onProgress a callback with a progress event for each file being loaded
  44188. * @param pluginExtension the extension used to determine the plugin
  44189. * @returns The loaded scene
  44190. */
  44191. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44192. /**
  44193. * Append a scene
  44194. * @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)
  44195. * @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)
  44196. * @param scene is the instance of BABYLON.Scene to append to
  44197. * @param onSuccess a callback with the scene when import succeeds
  44198. * @param onProgress a callback with a progress event for each file being loaded
  44199. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44200. * @param pluginExtension the extension used to determine the plugin
  44201. * @returns The loaded plugin
  44202. */
  44203. 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>;
  44204. /**
  44205. * Append a scene
  44206. * @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)
  44207. * @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)
  44208. * @param scene is the instance of BABYLON.Scene to append to
  44209. * @param onProgress a callback with a progress event for each file being loaded
  44210. * @param pluginExtension the extension used to determine the plugin
  44211. * @returns The given scene
  44212. */
  44213. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44214. /**
  44215. * Load a scene into an asset container
  44216. * @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)
  44217. * @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)
  44218. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44219. * @param onSuccess a callback with the scene when import succeeds
  44220. * @param onProgress a callback with a progress event for each file being loaded
  44221. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44222. * @param pluginExtension the extension used to determine the plugin
  44223. * @returns The loaded plugin
  44224. */
  44225. 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>;
  44226. /**
  44227. * Load a scene into an asset container
  44228. * @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)
  44229. * @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)
  44230. * @param scene is the instance of Scene to append to
  44231. * @param onProgress a callback with a progress event for each file being loaded
  44232. * @param pluginExtension the extension used to determine the plugin
  44233. * @returns The loaded asset container
  44234. */
  44235. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44236. }
  44237. }
  44238. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44239. import { Scene } from "babylonjs/scene";
  44240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44241. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44242. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44243. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44244. /**
  44245. * Generic Controller
  44246. */
  44247. export class GenericController extends WebVRController {
  44248. /**
  44249. * Base Url for the controller model.
  44250. */
  44251. static readonly MODEL_BASE_URL: string;
  44252. /**
  44253. * File name for the controller model.
  44254. */
  44255. static readonly MODEL_FILENAME: string;
  44256. /**
  44257. * Creates a new GenericController from a gamepad
  44258. * @param vrGamepad the gamepad that the controller should be created from
  44259. */
  44260. constructor(vrGamepad: any);
  44261. /**
  44262. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44263. * @param scene scene in which to add meshes
  44264. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44265. */
  44266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44267. /**
  44268. * Called once for each button that changed state since the last frame
  44269. * @param buttonIdx Which button index changed
  44270. * @param state New state of the button
  44271. * @param changes Which properties on the state changed since last frame
  44272. */
  44273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44274. }
  44275. }
  44276. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44277. import { Observable } from "babylonjs/Misc/observable";
  44278. import { Scene } from "babylonjs/scene";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { Ray } from "babylonjs/Culling/ray";
  44281. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44282. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44283. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44284. /**
  44285. * Defines the WindowsMotionController object that the state of the windows motion controller
  44286. */
  44287. export class WindowsMotionController extends WebVRController {
  44288. /**
  44289. * The base url used to load the left and right controller models
  44290. */
  44291. static MODEL_BASE_URL: string;
  44292. /**
  44293. * The name of the left controller model file
  44294. */
  44295. static MODEL_LEFT_FILENAME: string;
  44296. /**
  44297. * The name of the right controller model file
  44298. */
  44299. static MODEL_RIGHT_FILENAME: string;
  44300. /**
  44301. * The controller name prefix for this controller type
  44302. */
  44303. static readonly GAMEPAD_ID_PREFIX: string;
  44304. /**
  44305. * The controller id pattern for this controller type
  44306. */
  44307. private static readonly GAMEPAD_ID_PATTERN;
  44308. private _loadedMeshInfo;
  44309. private readonly _mapping;
  44310. /**
  44311. * Fired when the trackpad on this controller is clicked
  44312. */
  44313. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44314. /**
  44315. * Fired when the trackpad on this controller is modified
  44316. */
  44317. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44318. /**
  44319. * The current x and y values of this controller's trackpad
  44320. */
  44321. trackpad: StickValues;
  44322. /**
  44323. * Creates a new WindowsMotionController from a gamepad
  44324. * @param vrGamepad the gamepad that the controller should be created from
  44325. */
  44326. constructor(vrGamepad: any);
  44327. /**
  44328. * Fired when the trigger on this controller is modified
  44329. */
  44330. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44331. /**
  44332. * Fired when the menu button on this controller is modified
  44333. */
  44334. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44335. /**
  44336. * Fired when the grip button on this controller is modified
  44337. */
  44338. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44339. /**
  44340. * Fired when the thumbstick button on this controller is modified
  44341. */
  44342. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44343. /**
  44344. * Fired when the touchpad button on this controller is modified
  44345. */
  44346. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44347. /**
  44348. * Fired when the touchpad values on this controller are modified
  44349. */
  44350. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44351. private _updateTrackpad;
  44352. /**
  44353. * Called once per frame by the engine.
  44354. */
  44355. update(): void;
  44356. /**
  44357. * Called once for each button that changed state since the last frame
  44358. * @param buttonIdx Which button index changed
  44359. * @param state New state of the button
  44360. * @param changes Which properties on the state changed since last frame
  44361. */
  44362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44363. /**
  44364. * Moves the buttons on the controller mesh based on their current state
  44365. * @param buttonName the name of the button to move
  44366. * @param buttonValue the value of the button which determines the buttons new position
  44367. */
  44368. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44369. /**
  44370. * Moves the axis on the controller mesh based on its current state
  44371. * @param axis the index of the axis
  44372. * @param axisValue the value of the axis which determines the meshes new position
  44373. * @hidden
  44374. */
  44375. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44376. /**
  44377. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44378. * @param scene scene in which to add meshes
  44379. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44380. */
  44381. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44382. /**
  44383. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44384. * can be transformed by button presses and axes values, based on this._mapping.
  44385. *
  44386. * @param scene scene in which the meshes exist
  44387. * @param meshes list of meshes that make up the controller model to process
  44388. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44389. */
  44390. private processModel;
  44391. private createMeshInfo;
  44392. /**
  44393. * Gets the ray of the controller in the direction the controller is pointing
  44394. * @param length the length the resulting ray should be
  44395. * @returns a ray in the direction the controller is pointing
  44396. */
  44397. getForwardRay(length?: number): Ray;
  44398. /**
  44399. * Disposes of the controller
  44400. */
  44401. dispose(): void;
  44402. }
  44403. }
  44404. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44405. import { Observable } from "babylonjs/Misc/observable";
  44406. import { Scene } from "babylonjs/scene";
  44407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44408. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44409. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44410. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44411. /**
  44412. * Oculus Touch Controller
  44413. */
  44414. export class OculusTouchController extends WebVRController {
  44415. /**
  44416. * Base Url for the controller model.
  44417. */
  44418. static MODEL_BASE_URL: string;
  44419. /**
  44420. * File name for the left controller model.
  44421. */
  44422. static MODEL_LEFT_FILENAME: string;
  44423. /**
  44424. * File name for the right controller model.
  44425. */
  44426. static MODEL_RIGHT_FILENAME: string;
  44427. /**
  44428. * Base Url for the Quest controller model.
  44429. */
  44430. static QUEST_MODEL_BASE_URL: string;
  44431. /**
  44432. * @hidden
  44433. * If the controllers are running on a device that needs the updated Quest controller models
  44434. */
  44435. static _IsQuest: boolean;
  44436. /**
  44437. * Fired when the secondary trigger on this controller is modified
  44438. */
  44439. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44440. /**
  44441. * Fired when the thumb rest on this controller is modified
  44442. */
  44443. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44444. /**
  44445. * Creates a new OculusTouchController from a gamepad
  44446. * @param vrGamepad the gamepad that the controller should be created from
  44447. */
  44448. constructor(vrGamepad: any);
  44449. /**
  44450. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44451. * @param scene scene in which to add meshes
  44452. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44453. */
  44454. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44455. /**
  44456. * Fired when the A button on this controller is modified
  44457. */
  44458. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44459. /**
  44460. * Fired when the B button on this controller is modified
  44461. */
  44462. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44463. /**
  44464. * Fired when the X button on this controller is modified
  44465. */
  44466. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44467. /**
  44468. * Fired when the Y button on this controller is modified
  44469. */
  44470. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44471. /**
  44472. * Called once for each button that changed state since the last frame
  44473. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44474. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44475. * 2) secondary trigger (same)
  44476. * 3) A (right) X (left), touch, pressed = value
  44477. * 4) B / Y
  44478. * 5) thumb rest
  44479. * @param buttonIdx Which button index changed
  44480. * @param state New state of the button
  44481. * @param changes Which properties on the state changed since last frame
  44482. */
  44483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44484. }
  44485. }
  44486. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44487. import { Scene } from "babylonjs/scene";
  44488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44489. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44490. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44491. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44492. import { Observable } from "babylonjs/Misc/observable";
  44493. /**
  44494. * Vive Controller
  44495. */
  44496. export class ViveController extends WebVRController {
  44497. /**
  44498. * Base Url for the controller model.
  44499. */
  44500. static MODEL_BASE_URL: string;
  44501. /**
  44502. * File name for the controller model.
  44503. */
  44504. static MODEL_FILENAME: string;
  44505. /**
  44506. * Creates a new ViveController from a gamepad
  44507. * @param vrGamepad the gamepad that the controller should be created from
  44508. */
  44509. constructor(vrGamepad: any);
  44510. /**
  44511. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44512. * @param scene scene in which to add meshes
  44513. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44514. */
  44515. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44516. /**
  44517. * Fired when the left button on this controller is modified
  44518. */
  44519. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44520. /**
  44521. * Fired when the right button on this controller is modified
  44522. */
  44523. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44524. /**
  44525. * Fired when the menu button on this controller is modified
  44526. */
  44527. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44528. /**
  44529. * Called once for each button that changed state since the last frame
  44530. * Vive mapping:
  44531. * 0: touchpad
  44532. * 1: trigger
  44533. * 2: left AND right buttons
  44534. * 3: menu button
  44535. * @param buttonIdx Which button index changed
  44536. * @param state New state of the button
  44537. * @param changes Which properties on the state changed since last frame
  44538. */
  44539. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44540. }
  44541. }
  44542. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44543. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44544. /**
  44545. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44546. */
  44547. export class WebXRControllerModelLoader {
  44548. /**
  44549. * Creates the WebXRControllerModelLoader
  44550. * @param input xr input that creates the controllers
  44551. */
  44552. constructor(input: WebXRInput);
  44553. }
  44554. }
  44555. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44556. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44557. import { Scene } from "babylonjs/scene";
  44558. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44559. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44560. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44561. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44562. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44563. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44565. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44566. /**
  44567. * Options for the default xr helper
  44568. */
  44569. export class WebXRDefaultExperienceOptions {
  44570. /**
  44571. * Floor meshes that should be used for teleporting
  44572. */
  44573. floorMeshes: Array<AbstractMesh>;
  44574. /**
  44575. * Enable or disable default UI to enter XR
  44576. */
  44577. disableDefaultUI: boolean;
  44578. /**
  44579. * optional configuration for the output canvas
  44580. */
  44581. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44582. }
  44583. /**
  44584. * Default experience which provides a similar setup to the previous webVRExperience
  44585. */
  44586. export class WebXRDefaultExperience {
  44587. /**
  44588. * Base experience
  44589. */
  44590. baseExperience: WebXRExperienceHelper;
  44591. /**
  44592. * Input experience extension
  44593. */
  44594. input: WebXRInput;
  44595. /**
  44596. * Loads the controller models
  44597. */
  44598. controllerModelLoader: WebXRControllerModelLoader;
  44599. /**
  44600. * Enables laser pointer and selection
  44601. */
  44602. pointerSelection: WebXRControllerPointerSelection;
  44603. /**
  44604. * Enables teleportation
  44605. */
  44606. teleportation: WebXRControllerTeleportation;
  44607. /**
  44608. * Enables ui for enetering/exiting xr
  44609. */
  44610. enterExitUI: WebXREnterExitUI;
  44611. /**
  44612. * Default target xr should render to
  44613. */
  44614. renderTarget: WebXRRenderTarget;
  44615. /**
  44616. * Creates the default xr experience
  44617. * @param scene scene
  44618. * @param options options for basic configuration
  44619. * @returns resulting WebXRDefaultExperience
  44620. */
  44621. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44622. private constructor();
  44623. /**
  44624. * DIsposes of the experience helper
  44625. */
  44626. dispose(): void;
  44627. }
  44628. }
  44629. declare module "babylonjs/Cameras/XR/index" {
  44630. export * from "babylonjs/Cameras/XR/webXRCamera";
  44631. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44632. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44633. export * from "babylonjs/Cameras/XR/webXRInput";
  44634. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44635. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44636. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44637. export * from "babylonjs/Cameras/XR/webXRController";
  44638. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44639. export * from "babylonjs/Cameras/XR/webXRTypes";
  44640. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44641. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44642. }
  44643. declare module "babylonjs/Cameras/RigModes/index" {
  44644. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44645. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44646. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44647. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44648. }
  44649. declare module "babylonjs/Cameras/index" {
  44650. export * from "babylonjs/Cameras/Inputs/index";
  44651. export * from "babylonjs/Cameras/cameraInputsManager";
  44652. export * from "babylonjs/Cameras/camera";
  44653. export * from "babylonjs/Cameras/targetCamera";
  44654. export * from "babylonjs/Cameras/freeCamera";
  44655. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44656. export * from "babylonjs/Cameras/touchCamera";
  44657. export * from "babylonjs/Cameras/arcRotateCamera";
  44658. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44659. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44660. export * from "babylonjs/Cameras/flyCamera";
  44661. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44662. export * from "babylonjs/Cameras/followCamera";
  44663. export * from "babylonjs/Cameras/followCameraInputsManager";
  44664. export * from "babylonjs/Cameras/gamepadCamera";
  44665. export * from "babylonjs/Cameras/Stereoscopic/index";
  44666. export * from "babylonjs/Cameras/universalCamera";
  44667. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44668. export * from "babylonjs/Cameras/VR/index";
  44669. export * from "babylonjs/Cameras/XR/index";
  44670. export * from "babylonjs/Cameras/RigModes/index";
  44671. }
  44672. declare module "babylonjs/Collisions/index" {
  44673. export * from "babylonjs/Collisions/collider";
  44674. export * from "babylonjs/Collisions/collisionCoordinator";
  44675. export * from "babylonjs/Collisions/pickingInfo";
  44676. export * from "babylonjs/Collisions/intersectionInfo";
  44677. export * from "babylonjs/Collisions/meshCollisionData";
  44678. }
  44679. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44680. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44681. import { Vector3 } from "babylonjs/Maths/math.vector";
  44682. import { Ray } from "babylonjs/Culling/ray";
  44683. import { Plane } from "babylonjs/Maths/math.plane";
  44684. /**
  44685. * Contains an array of blocks representing the octree
  44686. */
  44687. export interface IOctreeContainer<T> {
  44688. /**
  44689. * Blocks within the octree
  44690. */
  44691. blocks: Array<OctreeBlock<T>>;
  44692. }
  44693. /**
  44694. * Class used to store a cell in an octree
  44695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44696. */
  44697. export class OctreeBlock<T> {
  44698. /**
  44699. * Gets the content of the current block
  44700. */
  44701. entries: T[];
  44702. /**
  44703. * Gets the list of block children
  44704. */
  44705. blocks: Array<OctreeBlock<T>>;
  44706. private _depth;
  44707. private _maxDepth;
  44708. private _capacity;
  44709. private _minPoint;
  44710. private _maxPoint;
  44711. private _boundingVectors;
  44712. private _creationFunc;
  44713. /**
  44714. * Creates a new block
  44715. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44716. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44717. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44718. * @param depth defines the current depth of this block in the octree
  44719. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44720. * @param creationFunc defines a callback to call when an element is added to the block
  44721. */
  44722. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44723. /**
  44724. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44725. */
  44726. readonly capacity: number;
  44727. /**
  44728. * Gets the minimum vector (in world space) of the block's bounding box
  44729. */
  44730. readonly minPoint: Vector3;
  44731. /**
  44732. * Gets the maximum vector (in world space) of the block's bounding box
  44733. */
  44734. readonly maxPoint: Vector3;
  44735. /**
  44736. * Add a new element to this block
  44737. * @param entry defines the element to add
  44738. */
  44739. addEntry(entry: T): void;
  44740. /**
  44741. * Remove an element from this block
  44742. * @param entry defines the element to remove
  44743. */
  44744. removeEntry(entry: T): void;
  44745. /**
  44746. * Add an array of elements to this block
  44747. * @param entries defines the array of elements to add
  44748. */
  44749. addEntries(entries: T[]): void;
  44750. /**
  44751. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44752. * @param frustumPlanes defines the frustum planes to test
  44753. * @param selection defines the array to store current content if selection is positive
  44754. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44755. */
  44756. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44757. /**
  44758. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44759. * @param sphereCenter defines the bounding sphere center
  44760. * @param sphereRadius defines the bounding sphere radius
  44761. * @param selection defines the array to store current content if selection is positive
  44762. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44763. */
  44764. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44765. /**
  44766. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44767. * @param ray defines the ray to test with
  44768. * @param selection defines the array to store current content if selection is positive
  44769. */
  44770. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44771. /**
  44772. * Subdivide the content into child blocks (this block will then be empty)
  44773. */
  44774. createInnerBlocks(): void;
  44775. /**
  44776. * @hidden
  44777. */
  44778. 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;
  44779. }
  44780. }
  44781. declare module "babylonjs/Culling/Octrees/octree" {
  44782. import { SmartArray } from "babylonjs/Misc/smartArray";
  44783. import { Vector3 } from "babylonjs/Maths/math.vector";
  44784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44786. import { Ray } from "babylonjs/Culling/ray";
  44787. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44788. import { Plane } from "babylonjs/Maths/math.plane";
  44789. /**
  44790. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44791. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44792. */
  44793. export class Octree<T> {
  44794. /** 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.) */
  44795. maxDepth: number;
  44796. /**
  44797. * Blocks within the octree containing objects
  44798. */
  44799. blocks: Array<OctreeBlock<T>>;
  44800. /**
  44801. * Content stored in the octree
  44802. */
  44803. dynamicContent: T[];
  44804. private _maxBlockCapacity;
  44805. private _selectionContent;
  44806. private _creationFunc;
  44807. /**
  44808. * Creates a octree
  44809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44810. * @param creationFunc function to be used to instatiate the octree
  44811. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44812. * @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.)
  44813. */
  44814. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44815. /** 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.) */
  44816. maxDepth?: number);
  44817. /**
  44818. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44819. * @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);
  44820. * @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);
  44821. * @param entries meshes to be added to the octree blocks
  44822. */
  44823. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44824. /**
  44825. * Adds a mesh to the octree
  44826. * @param entry Mesh to add to the octree
  44827. */
  44828. addMesh(entry: T): void;
  44829. /**
  44830. * Remove an element from the octree
  44831. * @param entry defines the element to remove
  44832. */
  44833. removeMesh(entry: T): void;
  44834. /**
  44835. * Selects an array of meshes within the frustum
  44836. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44837. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44838. * @returns array of meshes within the frustum
  44839. */
  44840. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44841. /**
  44842. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44843. * @param sphereCenter defines the bounding sphere center
  44844. * @param sphereRadius defines the bounding sphere radius
  44845. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44846. * @returns an array of objects that intersect the sphere
  44847. */
  44848. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44849. /**
  44850. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44851. * @param ray defines the ray to test with
  44852. * @returns array of intersected objects
  44853. */
  44854. intersectsRay(ray: Ray): SmartArray<T>;
  44855. /**
  44856. * Adds a mesh into the octree block if it intersects the block
  44857. */
  44858. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44859. /**
  44860. * Adds a submesh into the octree block if it intersects the block
  44861. */
  44862. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44863. }
  44864. }
  44865. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44866. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44867. import { Scene } from "babylonjs/scene";
  44868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44870. import { Ray } from "babylonjs/Culling/ray";
  44871. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44872. import { Collider } from "babylonjs/Collisions/collider";
  44873. module "babylonjs/scene" {
  44874. interface Scene {
  44875. /**
  44876. * @hidden
  44877. * Backing Filed
  44878. */
  44879. _selectionOctree: Octree<AbstractMesh>;
  44880. /**
  44881. * Gets the octree used to boost mesh selection (picking)
  44882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44883. */
  44884. selectionOctree: Octree<AbstractMesh>;
  44885. /**
  44886. * Creates or updates the octree used to boost selection (picking)
  44887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44888. * @param maxCapacity defines the maximum capacity per leaf
  44889. * @param maxDepth defines the maximum depth of the octree
  44890. * @returns an octree of AbstractMesh
  44891. */
  44892. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44893. }
  44894. }
  44895. module "babylonjs/Meshes/abstractMesh" {
  44896. interface AbstractMesh {
  44897. /**
  44898. * @hidden
  44899. * Backing Field
  44900. */
  44901. _submeshesOctree: Octree<SubMesh>;
  44902. /**
  44903. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44905. * @param maxCapacity defines the maximum size of each block (64 by default)
  44906. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44907. * @returns the new octree
  44908. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44910. */
  44911. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44912. }
  44913. }
  44914. /**
  44915. * Defines the octree scene component responsible to manage any octrees
  44916. * in a given scene.
  44917. */
  44918. export class OctreeSceneComponent {
  44919. /**
  44920. * The component name help to identify the component in the list of scene components.
  44921. */
  44922. readonly name: string;
  44923. /**
  44924. * The scene the component belongs to.
  44925. */
  44926. scene: Scene;
  44927. /**
  44928. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44929. */
  44930. readonly checksIsEnabled: boolean;
  44931. /**
  44932. * Creates a new instance of the component for the given scene
  44933. * @param scene Defines the scene to register the component in
  44934. */
  44935. constructor(scene: Scene);
  44936. /**
  44937. * Registers the component in a given scene
  44938. */
  44939. register(): void;
  44940. /**
  44941. * Return the list of active meshes
  44942. * @returns the list of active meshes
  44943. */
  44944. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44945. /**
  44946. * Return the list of active sub meshes
  44947. * @param mesh The mesh to get the candidates sub meshes from
  44948. * @returns the list of active sub meshes
  44949. */
  44950. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44951. private _tempRay;
  44952. /**
  44953. * Return the list of sub meshes intersecting with a given local ray
  44954. * @param mesh defines the mesh to find the submesh for
  44955. * @param localRay defines the ray in local space
  44956. * @returns the list of intersecting sub meshes
  44957. */
  44958. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44959. /**
  44960. * Return the list of sub meshes colliding with a collider
  44961. * @param mesh defines the mesh to find the submesh for
  44962. * @param collider defines the collider to evaluate the collision against
  44963. * @returns the list of colliding sub meshes
  44964. */
  44965. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44966. /**
  44967. * Rebuilds the elements related to this component in case of
  44968. * context lost for instance.
  44969. */
  44970. rebuild(): void;
  44971. /**
  44972. * Disposes the component and the associated ressources.
  44973. */
  44974. dispose(): void;
  44975. }
  44976. }
  44977. declare module "babylonjs/Culling/Octrees/index" {
  44978. export * from "babylonjs/Culling/Octrees/octree";
  44979. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44980. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44981. }
  44982. declare module "babylonjs/Culling/index" {
  44983. export * from "babylonjs/Culling/boundingBox";
  44984. export * from "babylonjs/Culling/boundingInfo";
  44985. export * from "babylonjs/Culling/boundingSphere";
  44986. export * from "babylonjs/Culling/Octrees/index";
  44987. export * from "babylonjs/Culling/ray";
  44988. }
  44989. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44990. import { IDisposable, Scene } from "babylonjs/scene";
  44991. import { Nullable } from "babylonjs/types";
  44992. import { Observable } from "babylonjs/Misc/observable";
  44993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44994. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44995. import { Camera } from "babylonjs/Cameras/camera";
  44996. /**
  44997. * Renders a layer on top of an existing scene
  44998. */
  44999. export class UtilityLayerRenderer implements IDisposable {
  45000. /** the original scene that will be rendered on top of */
  45001. originalScene: Scene;
  45002. private _pointerCaptures;
  45003. private _lastPointerEvents;
  45004. private static _DefaultUtilityLayer;
  45005. private static _DefaultKeepDepthUtilityLayer;
  45006. private _sharedGizmoLight;
  45007. private _renderCamera;
  45008. /**
  45009. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45010. * @returns the camera that is used when rendering the utility layer
  45011. */
  45012. getRenderCamera(): Nullable<Camera>;
  45013. /**
  45014. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45015. * @param cam the camera that should be used when rendering the utility layer
  45016. */
  45017. setRenderCamera(cam: Nullable<Camera>): void;
  45018. /**
  45019. * @hidden
  45020. * Light which used by gizmos to get light shading
  45021. */
  45022. _getSharedGizmoLight(): HemisphericLight;
  45023. /**
  45024. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45025. */
  45026. pickUtilitySceneFirst: boolean;
  45027. /**
  45028. * 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)
  45029. */
  45030. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45031. /**
  45032. * 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)
  45033. */
  45034. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45035. /**
  45036. * The scene that is rendered on top of the original scene
  45037. */
  45038. utilityLayerScene: Scene;
  45039. /**
  45040. * If the utility layer should automatically be rendered on top of existing scene
  45041. */
  45042. shouldRender: boolean;
  45043. /**
  45044. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45045. */
  45046. onlyCheckPointerDownEvents: boolean;
  45047. /**
  45048. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45049. */
  45050. processAllEvents: boolean;
  45051. /**
  45052. * Observable raised when the pointer move from the utility layer scene to the main scene
  45053. */
  45054. onPointerOutObservable: Observable<number>;
  45055. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45056. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45057. private _afterRenderObserver;
  45058. private _sceneDisposeObserver;
  45059. private _originalPointerObserver;
  45060. /**
  45061. * Instantiates a UtilityLayerRenderer
  45062. * @param originalScene the original scene that will be rendered on top of
  45063. * @param handleEvents boolean indicating if the utility layer should handle events
  45064. */
  45065. constructor(
  45066. /** the original scene that will be rendered on top of */
  45067. originalScene: Scene, handleEvents?: boolean);
  45068. private _notifyObservers;
  45069. /**
  45070. * Renders the utility layers scene on top of the original scene
  45071. */
  45072. render(): void;
  45073. /**
  45074. * Disposes of the renderer
  45075. */
  45076. dispose(): void;
  45077. private _updateCamera;
  45078. }
  45079. }
  45080. declare module "babylonjs/Gizmos/gizmo" {
  45081. import { Nullable } from "babylonjs/types";
  45082. import { IDisposable } from "babylonjs/scene";
  45083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45084. import { Mesh } from "babylonjs/Meshes/mesh";
  45085. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45086. /**
  45087. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45088. */
  45089. export class Gizmo implements IDisposable {
  45090. /** The utility layer the gizmo will be added to */
  45091. gizmoLayer: UtilityLayerRenderer;
  45092. /**
  45093. * The root mesh of the gizmo
  45094. */
  45095. _rootMesh: Mesh;
  45096. private _attachedMesh;
  45097. /**
  45098. * Ratio for the scale of the gizmo (Default: 1)
  45099. */
  45100. scaleRatio: number;
  45101. /**
  45102. * If a custom mesh has been set (Default: false)
  45103. */
  45104. protected _customMeshSet: boolean;
  45105. /**
  45106. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45107. * * When set, interactions will be enabled
  45108. */
  45109. attachedMesh: Nullable<AbstractMesh>;
  45110. /**
  45111. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45112. * @param mesh The mesh to replace the default mesh of the gizmo
  45113. */
  45114. setCustomMesh(mesh: Mesh): void;
  45115. /**
  45116. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45117. */
  45118. updateGizmoRotationToMatchAttachedMesh: boolean;
  45119. /**
  45120. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45121. */
  45122. updateGizmoPositionToMatchAttachedMesh: boolean;
  45123. /**
  45124. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45125. */
  45126. updateScale: boolean;
  45127. protected _interactionsEnabled: boolean;
  45128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45129. private _beforeRenderObserver;
  45130. private _tempVector;
  45131. /**
  45132. * Creates a gizmo
  45133. * @param gizmoLayer The utility layer the gizmo will be added to
  45134. */
  45135. constructor(
  45136. /** The utility layer the gizmo will be added to */
  45137. gizmoLayer?: UtilityLayerRenderer);
  45138. /**
  45139. * Updates the gizmo to match the attached mesh's position/rotation
  45140. */
  45141. protected _update(): void;
  45142. /**
  45143. * Disposes of the gizmo
  45144. */
  45145. dispose(): void;
  45146. }
  45147. }
  45148. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45149. import { Observable } from "babylonjs/Misc/observable";
  45150. import { Nullable } from "babylonjs/types";
  45151. import { Vector3 } from "babylonjs/Maths/math.vector";
  45152. import { Color3 } from "babylonjs/Maths/math.color";
  45153. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45155. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45156. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45157. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45158. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45159. import { Scene } from "babylonjs/scene";
  45160. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45161. /**
  45162. * Single plane drag gizmo
  45163. */
  45164. export class PlaneDragGizmo extends Gizmo {
  45165. /**
  45166. * Drag behavior responsible for the gizmos dragging interactions
  45167. */
  45168. dragBehavior: PointerDragBehavior;
  45169. private _pointerObserver;
  45170. /**
  45171. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45172. */
  45173. snapDistance: number;
  45174. /**
  45175. * Event that fires each time the gizmo snaps to a new location.
  45176. * * snapDistance is the the change in distance
  45177. */
  45178. onSnapObservable: Observable<{
  45179. snapDistance: number;
  45180. }>;
  45181. private _plane;
  45182. private _coloredMaterial;
  45183. private _hoverMaterial;
  45184. private _isEnabled;
  45185. private _parent;
  45186. /** @hidden */
  45187. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45188. /** @hidden */
  45189. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45190. /**
  45191. * Creates a PlaneDragGizmo
  45192. * @param gizmoLayer The utility layer the gizmo will be added to
  45193. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45194. * @param color The color of the gizmo
  45195. */
  45196. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45197. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45198. /**
  45199. * If the gizmo is enabled
  45200. */
  45201. isEnabled: boolean;
  45202. /**
  45203. * Disposes of the gizmo
  45204. */
  45205. dispose(): void;
  45206. }
  45207. }
  45208. declare module "babylonjs/Gizmos/positionGizmo" {
  45209. import { Observable } from "babylonjs/Misc/observable";
  45210. import { Nullable } from "babylonjs/types";
  45211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45212. import { Mesh } from "babylonjs/Meshes/mesh";
  45213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45214. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45215. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45217. /**
  45218. * Gizmo that enables dragging a mesh along 3 axis
  45219. */
  45220. export class PositionGizmo extends Gizmo {
  45221. /**
  45222. * Internal gizmo used for interactions on the x axis
  45223. */
  45224. xGizmo: AxisDragGizmo;
  45225. /**
  45226. * Internal gizmo used for interactions on the y axis
  45227. */
  45228. yGizmo: AxisDragGizmo;
  45229. /**
  45230. * Internal gizmo used for interactions on the z axis
  45231. */
  45232. zGizmo: AxisDragGizmo;
  45233. /**
  45234. * Internal gizmo used for interactions on the yz plane
  45235. */
  45236. xPlaneGizmo: PlaneDragGizmo;
  45237. /**
  45238. * Internal gizmo used for interactions on the xz plane
  45239. */
  45240. yPlaneGizmo: PlaneDragGizmo;
  45241. /**
  45242. * Internal gizmo used for interactions on the xy plane
  45243. */
  45244. zPlaneGizmo: PlaneDragGizmo;
  45245. /**
  45246. * private variables
  45247. */
  45248. private _meshAttached;
  45249. private _updateGizmoRotationToMatchAttachedMesh;
  45250. private _snapDistance;
  45251. private _scaleRatio;
  45252. /** Fires an event when any of it's sub gizmos are dragged */
  45253. onDragStartObservable: Observable<unknown>;
  45254. /** Fires an event when any of it's sub gizmos are released from dragging */
  45255. onDragEndObservable: Observable<unknown>;
  45256. /**
  45257. * If set to true, planar drag is enabled
  45258. */
  45259. private _planarGizmoEnabled;
  45260. attachedMesh: Nullable<AbstractMesh>;
  45261. /**
  45262. * Creates a PositionGizmo
  45263. * @param gizmoLayer The utility layer the gizmo will be added to
  45264. */
  45265. constructor(gizmoLayer?: UtilityLayerRenderer);
  45266. /**
  45267. * If the planar drag gizmo is enabled
  45268. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45269. */
  45270. planarGizmoEnabled: boolean;
  45271. updateGizmoRotationToMatchAttachedMesh: boolean;
  45272. /**
  45273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45274. */
  45275. snapDistance: number;
  45276. /**
  45277. * Ratio for the scale of the gizmo (Default: 1)
  45278. */
  45279. scaleRatio: number;
  45280. /**
  45281. * Disposes of the gizmo
  45282. */
  45283. dispose(): void;
  45284. /**
  45285. * CustomMeshes are not supported by this gizmo
  45286. * @param mesh The mesh to replace the default mesh of the gizmo
  45287. */
  45288. setCustomMesh(mesh: Mesh): void;
  45289. }
  45290. }
  45291. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45292. import { Observable } from "babylonjs/Misc/observable";
  45293. import { Nullable } from "babylonjs/types";
  45294. import { Vector3 } from "babylonjs/Maths/math.vector";
  45295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45297. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45298. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45299. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45300. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45301. import { Scene } from "babylonjs/scene";
  45302. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45303. import { Color3 } from "babylonjs/Maths/math.color";
  45304. /**
  45305. * Single axis drag gizmo
  45306. */
  45307. export class AxisDragGizmo extends Gizmo {
  45308. /**
  45309. * Drag behavior responsible for the gizmos dragging interactions
  45310. */
  45311. dragBehavior: PointerDragBehavior;
  45312. private _pointerObserver;
  45313. /**
  45314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45315. */
  45316. snapDistance: number;
  45317. /**
  45318. * Event that fires each time the gizmo snaps to a new location.
  45319. * * snapDistance is the the change in distance
  45320. */
  45321. onSnapObservable: Observable<{
  45322. snapDistance: number;
  45323. }>;
  45324. private _isEnabled;
  45325. private _parent;
  45326. private _arrow;
  45327. private _coloredMaterial;
  45328. private _hoverMaterial;
  45329. /** @hidden */
  45330. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45331. /** @hidden */
  45332. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45333. /**
  45334. * Creates an AxisDragGizmo
  45335. * @param gizmoLayer The utility layer the gizmo will be added to
  45336. * @param dragAxis The axis which the gizmo will be able to drag on
  45337. * @param color The color of the gizmo
  45338. */
  45339. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45341. /**
  45342. * If the gizmo is enabled
  45343. */
  45344. isEnabled: boolean;
  45345. /**
  45346. * Disposes of the gizmo
  45347. */
  45348. dispose(): void;
  45349. }
  45350. }
  45351. declare module "babylonjs/Debug/axesViewer" {
  45352. import { Vector3 } from "babylonjs/Maths/math.vector";
  45353. import { Nullable } from "babylonjs/types";
  45354. import { Scene } from "babylonjs/scene";
  45355. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45356. /**
  45357. * The Axes viewer will show 3 axes in a specific point in space
  45358. */
  45359. export class AxesViewer {
  45360. private _xAxis;
  45361. private _yAxis;
  45362. private _zAxis;
  45363. private _scaleLinesFactor;
  45364. private _instanced;
  45365. /**
  45366. * Gets the hosting scene
  45367. */
  45368. scene: Scene;
  45369. /**
  45370. * Gets or sets a number used to scale line length
  45371. */
  45372. scaleLines: number;
  45373. /** Gets the node hierarchy used to render x-axis */
  45374. readonly xAxis: TransformNode;
  45375. /** Gets the node hierarchy used to render y-axis */
  45376. readonly yAxis: TransformNode;
  45377. /** Gets the node hierarchy used to render z-axis */
  45378. readonly zAxis: TransformNode;
  45379. /**
  45380. * Creates a new AxesViewer
  45381. * @param scene defines the hosting scene
  45382. * @param scaleLines defines a number used to scale line length (1 by default)
  45383. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45384. * @param xAxis defines the node hierarchy used to render the x-axis
  45385. * @param yAxis defines the node hierarchy used to render the y-axis
  45386. * @param zAxis defines the node hierarchy used to render the z-axis
  45387. */
  45388. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45389. /**
  45390. * Force the viewer to update
  45391. * @param position defines the position of the viewer
  45392. * @param xaxis defines the x axis of the viewer
  45393. * @param yaxis defines the y axis of the viewer
  45394. * @param zaxis defines the z axis of the viewer
  45395. */
  45396. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45397. /**
  45398. * Creates an instance of this axes viewer.
  45399. * @returns a new axes viewer with instanced meshes
  45400. */
  45401. createInstance(): AxesViewer;
  45402. /** Releases resources */
  45403. dispose(): void;
  45404. private static _SetRenderingGroupId;
  45405. }
  45406. }
  45407. declare module "babylonjs/Debug/boneAxesViewer" {
  45408. import { Nullable } from "babylonjs/types";
  45409. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45410. import { Vector3 } from "babylonjs/Maths/math.vector";
  45411. import { Mesh } from "babylonjs/Meshes/mesh";
  45412. import { Bone } from "babylonjs/Bones/bone";
  45413. import { Scene } from "babylonjs/scene";
  45414. /**
  45415. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45416. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45417. */
  45418. export class BoneAxesViewer extends AxesViewer {
  45419. /**
  45420. * Gets or sets the target mesh where to display the axes viewer
  45421. */
  45422. mesh: Nullable<Mesh>;
  45423. /**
  45424. * Gets or sets the target bone where to display the axes viewer
  45425. */
  45426. bone: Nullable<Bone>;
  45427. /** Gets current position */
  45428. pos: Vector3;
  45429. /** Gets direction of X axis */
  45430. xaxis: Vector3;
  45431. /** Gets direction of Y axis */
  45432. yaxis: Vector3;
  45433. /** Gets direction of Z axis */
  45434. zaxis: Vector3;
  45435. /**
  45436. * Creates a new BoneAxesViewer
  45437. * @param scene defines the hosting scene
  45438. * @param bone defines the target bone
  45439. * @param mesh defines the target mesh
  45440. * @param scaleLines defines a scaling factor for line length (1 by default)
  45441. */
  45442. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45443. /**
  45444. * Force the viewer to update
  45445. */
  45446. update(): void;
  45447. /** Releases resources */
  45448. dispose(): void;
  45449. }
  45450. }
  45451. declare module "babylonjs/Debug/debugLayer" {
  45452. import { Scene } from "babylonjs/scene";
  45453. /**
  45454. * Interface used to define scene explorer extensibility option
  45455. */
  45456. export interface IExplorerExtensibilityOption {
  45457. /**
  45458. * Define the option label
  45459. */
  45460. label: string;
  45461. /**
  45462. * Defines the action to execute on click
  45463. */
  45464. action: (entity: any) => void;
  45465. }
  45466. /**
  45467. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45468. */
  45469. export interface IExplorerExtensibilityGroup {
  45470. /**
  45471. * Defines a predicate to test if a given type mut be extended
  45472. */
  45473. predicate: (entity: any) => boolean;
  45474. /**
  45475. * Gets the list of options added to a type
  45476. */
  45477. entries: IExplorerExtensibilityOption[];
  45478. }
  45479. /**
  45480. * Interface used to define the options to use to create the Inspector
  45481. */
  45482. export interface IInspectorOptions {
  45483. /**
  45484. * Display in overlay mode (default: false)
  45485. */
  45486. overlay?: boolean;
  45487. /**
  45488. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45489. */
  45490. globalRoot?: HTMLElement;
  45491. /**
  45492. * Display the Scene explorer
  45493. */
  45494. showExplorer?: boolean;
  45495. /**
  45496. * Display the property inspector
  45497. */
  45498. showInspector?: boolean;
  45499. /**
  45500. * Display in embed mode (both panes on the right)
  45501. */
  45502. embedMode?: boolean;
  45503. /**
  45504. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45505. */
  45506. handleResize?: boolean;
  45507. /**
  45508. * Allow the panes to popup (default: true)
  45509. */
  45510. enablePopup?: boolean;
  45511. /**
  45512. * Allow the panes to be closed by users (default: true)
  45513. */
  45514. enableClose?: boolean;
  45515. /**
  45516. * Optional list of extensibility entries
  45517. */
  45518. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45519. /**
  45520. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45521. */
  45522. inspectorURL?: string;
  45523. }
  45524. module "babylonjs/scene" {
  45525. interface Scene {
  45526. /**
  45527. * @hidden
  45528. * Backing field
  45529. */
  45530. _debugLayer: DebugLayer;
  45531. /**
  45532. * Gets the debug layer (aka Inspector) associated with the scene
  45533. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45534. */
  45535. debugLayer: DebugLayer;
  45536. }
  45537. }
  45538. /**
  45539. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45540. * what is happening in your scene
  45541. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45542. */
  45543. export class DebugLayer {
  45544. /**
  45545. * Define the url to get the inspector script from.
  45546. * By default it uses the babylonjs CDN.
  45547. * @ignoreNaming
  45548. */
  45549. static InspectorURL: string;
  45550. private _scene;
  45551. private BJSINSPECTOR;
  45552. private _onPropertyChangedObservable?;
  45553. /**
  45554. * Observable triggered when a property is changed through the inspector.
  45555. */
  45556. readonly onPropertyChangedObservable: any;
  45557. /**
  45558. * Instantiates a new debug layer.
  45559. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45560. * what is happening in your scene
  45561. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45562. * @param scene Defines the scene to inspect
  45563. */
  45564. constructor(scene: Scene);
  45565. /** Creates the inspector window. */
  45566. private _createInspector;
  45567. /**
  45568. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45569. * @param entity defines the entity to select
  45570. * @param lineContainerTitle defines the specific block to highlight
  45571. */
  45572. select(entity: any, lineContainerTitle?: string): void;
  45573. /** Get the inspector from bundle or global */
  45574. private _getGlobalInspector;
  45575. /**
  45576. * Get if the inspector is visible or not.
  45577. * @returns true if visible otherwise, false
  45578. */
  45579. isVisible(): boolean;
  45580. /**
  45581. * Hide the inspector and close its window.
  45582. */
  45583. hide(): void;
  45584. /**
  45585. * Launch the debugLayer.
  45586. * @param config Define the configuration of the inspector
  45587. * @return a promise fulfilled when the debug layer is visible
  45588. */
  45589. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45590. }
  45591. }
  45592. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45593. import { Nullable } from "babylonjs/types";
  45594. import { Scene } from "babylonjs/scene";
  45595. import { Vector4 } from "babylonjs/Maths/math.vector";
  45596. import { Color4 } from "babylonjs/Maths/math.color";
  45597. import { Mesh } from "babylonjs/Meshes/mesh";
  45598. /**
  45599. * Class containing static functions to help procedurally build meshes
  45600. */
  45601. export class BoxBuilder {
  45602. /**
  45603. * Creates a box mesh
  45604. * * The parameter `size` sets the size (float) of each box side (default 1)
  45605. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45606. * * 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)
  45607. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45611. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45612. * @param name defines the name of the mesh
  45613. * @param options defines the options used to create the mesh
  45614. * @param scene defines the hosting scene
  45615. * @returns the box mesh
  45616. */
  45617. static CreateBox(name: string, options: {
  45618. size?: number;
  45619. width?: number;
  45620. height?: number;
  45621. depth?: number;
  45622. faceUV?: Vector4[];
  45623. faceColors?: Color4[];
  45624. sideOrientation?: number;
  45625. frontUVs?: Vector4;
  45626. backUVs?: Vector4;
  45627. wrap?: boolean;
  45628. topBaseAt?: number;
  45629. bottomBaseAt?: number;
  45630. updatable?: boolean;
  45631. }, scene?: Nullable<Scene>): Mesh;
  45632. }
  45633. }
  45634. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45635. import { Vector4 } from "babylonjs/Maths/math.vector";
  45636. import { Mesh } from "babylonjs/Meshes/mesh";
  45637. import { Scene } from "babylonjs/scene";
  45638. import { Nullable } from "babylonjs/types";
  45639. /**
  45640. * Class containing static functions to help procedurally build meshes
  45641. */
  45642. export class SphereBuilder {
  45643. /**
  45644. * Creates a sphere mesh
  45645. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45646. * * 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`)
  45647. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45648. * * 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
  45649. * * 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)
  45650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45653. * @param name defines the name of the mesh
  45654. * @param options defines the options used to create the mesh
  45655. * @param scene defines the hosting scene
  45656. * @returns the sphere mesh
  45657. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45658. */
  45659. static CreateSphere(name: string, options: {
  45660. segments?: number;
  45661. diameter?: number;
  45662. diameterX?: number;
  45663. diameterY?: number;
  45664. diameterZ?: number;
  45665. arc?: number;
  45666. slice?: number;
  45667. sideOrientation?: number;
  45668. frontUVs?: Vector4;
  45669. backUVs?: Vector4;
  45670. updatable?: boolean;
  45671. }, scene?: Nullable<Scene>): Mesh;
  45672. }
  45673. }
  45674. declare module "babylonjs/Debug/physicsViewer" {
  45675. import { Nullable } from "babylonjs/types";
  45676. import { Scene } from "babylonjs/scene";
  45677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45678. import { Mesh } from "babylonjs/Meshes/mesh";
  45679. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45680. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45681. /**
  45682. * Used to show the physics impostor around the specific mesh
  45683. */
  45684. export class PhysicsViewer {
  45685. /** @hidden */
  45686. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45687. /** @hidden */
  45688. protected _meshes: Array<Nullable<AbstractMesh>>;
  45689. /** @hidden */
  45690. protected _scene: Nullable<Scene>;
  45691. /** @hidden */
  45692. protected _numMeshes: number;
  45693. /** @hidden */
  45694. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45695. private _renderFunction;
  45696. private _utilityLayer;
  45697. private _debugBoxMesh;
  45698. private _debugSphereMesh;
  45699. private _debugCylinderMesh;
  45700. private _debugMaterial;
  45701. private _debugMeshMeshes;
  45702. /**
  45703. * Creates a new PhysicsViewer
  45704. * @param scene defines the hosting scene
  45705. */
  45706. constructor(scene: Scene);
  45707. /** @hidden */
  45708. protected _updateDebugMeshes(): void;
  45709. /**
  45710. * Renders a specified physic impostor
  45711. * @param impostor defines the impostor to render
  45712. * @param targetMesh defines the mesh represented by the impostor
  45713. * @returns the new debug mesh used to render the impostor
  45714. */
  45715. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45716. /**
  45717. * Hides a specified physic impostor
  45718. * @param impostor defines the impostor to hide
  45719. */
  45720. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45721. private _getDebugMaterial;
  45722. private _getDebugBoxMesh;
  45723. private _getDebugSphereMesh;
  45724. private _getDebugCylinderMesh;
  45725. private _getDebugMeshMesh;
  45726. private _getDebugMesh;
  45727. /** Releases all resources */
  45728. dispose(): void;
  45729. }
  45730. }
  45731. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45732. import { Vector3 } from "babylonjs/Maths/math.vector";
  45733. import { Color4 } from "babylonjs/Maths/math.color";
  45734. import { Nullable } from "babylonjs/types";
  45735. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45736. import { Scene } from "babylonjs/scene";
  45737. /**
  45738. * Class containing static functions to help procedurally build meshes
  45739. */
  45740. export class LinesBuilder {
  45741. /**
  45742. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45743. * * 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
  45744. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45745. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45746. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45747. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45748. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45749. * * 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
  45750. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45753. * @param name defines the name of the new line system
  45754. * @param options defines the options used to create the line system
  45755. * @param scene defines the hosting scene
  45756. * @returns a new line system mesh
  45757. */
  45758. static CreateLineSystem(name: string, options: {
  45759. lines: Vector3[][];
  45760. updatable?: boolean;
  45761. instance?: Nullable<LinesMesh>;
  45762. colors?: Nullable<Color4[][]>;
  45763. useVertexAlpha?: boolean;
  45764. }, scene: Nullable<Scene>): LinesMesh;
  45765. /**
  45766. * Creates a line mesh
  45767. * 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
  45768. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45769. * * The parameter `points` is an array successive Vector3
  45770. * * 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
  45771. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45772. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45773. * * When updating an instance, remember that only point positions can change, not the number of points
  45774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45776. * @param name defines the name of the new line system
  45777. * @param options defines the options used to create the line system
  45778. * @param scene defines the hosting scene
  45779. * @returns a new line mesh
  45780. */
  45781. static CreateLines(name: string, options: {
  45782. points: Vector3[];
  45783. updatable?: boolean;
  45784. instance?: Nullable<LinesMesh>;
  45785. colors?: Color4[];
  45786. useVertexAlpha?: boolean;
  45787. }, scene?: Nullable<Scene>): LinesMesh;
  45788. /**
  45789. * Creates a dashed line mesh
  45790. * * 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
  45791. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45792. * * The parameter `points` is an array successive Vector3
  45793. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45794. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45795. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45796. * * 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
  45797. * * When updating an instance, remember that only point positions can change, not the number of points
  45798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45799. * @param name defines the name of the mesh
  45800. * @param options defines the options used to create the mesh
  45801. * @param scene defines the hosting scene
  45802. * @returns the dashed line mesh
  45803. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45804. */
  45805. static CreateDashedLines(name: string, options: {
  45806. points: Vector3[];
  45807. dashSize?: number;
  45808. gapSize?: number;
  45809. dashNb?: number;
  45810. updatable?: boolean;
  45811. instance?: LinesMesh;
  45812. }, scene?: Nullable<Scene>): LinesMesh;
  45813. }
  45814. }
  45815. declare module "babylonjs/Debug/rayHelper" {
  45816. import { Nullable } from "babylonjs/types";
  45817. import { Ray } from "babylonjs/Culling/ray";
  45818. import { Vector3 } from "babylonjs/Maths/math.vector";
  45819. import { Color3 } from "babylonjs/Maths/math.color";
  45820. import { Scene } from "babylonjs/scene";
  45821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45822. import "babylonjs/Meshes/Builders/linesBuilder";
  45823. /**
  45824. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45825. * in order to better appreciate the issue one might have.
  45826. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45827. */
  45828. export class RayHelper {
  45829. /**
  45830. * Defines the ray we are currently tryin to visualize.
  45831. */
  45832. ray: Nullable<Ray>;
  45833. private _renderPoints;
  45834. private _renderLine;
  45835. private _renderFunction;
  45836. private _scene;
  45837. private _updateToMeshFunction;
  45838. private _attachedToMesh;
  45839. private _meshSpaceDirection;
  45840. private _meshSpaceOrigin;
  45841. /**
  45842. * Helper function to create a colored helper in a scene in one line.
  45843. * @param ray Defines the ray we are currently tryin to visualize
  45844. * @param scene Defines the scene the ray is used in
  45845. * @param color Defines the color we want to see the ray in
  45846. * @returns The newly created ray helper.
  45847. */
  45848. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45849. /**
  45850. * Instantiate a new ray helper.
  45851. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45852. * in order to better appreciate the issue one might have.
  45853. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45854. * @param ray Defines the ray we are currently tryin to visualize
  45855. */
  45856. constructor(ray: Ray);
  45857. /**
  45858. * Shows the ray we are willing to debug.
  45859. * @param scene Defines the scene the ray needs to be rendered in
  45860. * @param color Defines the color the ray needs to be rendered in
  45861. */
  45862. show(scene: Scene, color?: Color3): void;
  45863. /**
  45864. * Hides the ray we are debugging.
  45865. */
  45866. hide(): void;
  45867. private _render;
  45868. /**
  45869. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45870. * @param mesh Defines the mesh we want the helper attached to
  45871. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45872. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45873. * @param length Defines the length of the ray
  45874. */
  45875. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45876. /**
  45877. * Detach the ray helper from the mesh it has previously been attached to.
  45878. */
  45879. detachFromMesh(): void;
  45880. private _updateToMesh;
  45881. /**
  45882. * Dispose the helper and release its associated resources.
  45883. */
  45884. dispose(): void;
  45885. }
  45886. }
  45887. declare module "babylonjs/Debug/skeletonViewer" {
  45888. import { Color3 } from "babylonjs/Maths/math.color";
  45889. import { Scene } from "babylonjs/scene";
  45890. import { Nullable } from "babylonjs/types";
  45891. import { Skeleton } from "babylonjs/Bones/skeleton";
  45892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45893. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45894. /**
  45895. * Class used to render a debug view of a given skeleton
  45896. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45897. */
  45898. export class SkeletonViewer {
  45899. /** defines the skeleton to render */
  45900. skeleton: Skeleton;
  45901. /** defines the mesh attached to the skeleton */
  45902. mesh: AbstractMesh;
  45903. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45904. autoUpdateBonesMatrices: boolean;
  45905. /** defines the rendering group id to use with the viewer */
  45906. renderingGroupId: number;
  45907. /** Gets or sets the color used to render the skeleton */
  45908. color: Color3;
  45909. private _scene;
  45910. private _debugLines;
  45911. private _debugMesh;
  45912. private _isEnabled;
  45913. private _renderFunction;
  45914. private _utilityLayer;
  45915. /**
  45916. * Returns the mesh used to render the bones
  45917. */
  45918. readonly debugMesh: Nullable<LinesMesh>;
  45919. /**
  45920. * Creates a new SkeletonViewer
  45921. * @param skeleton defines the skeleton to render
  45922. * @param mesh defines the mesh attached to the skeleton
  45923. * @param scene defines the hosting scene
  45924. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45925. * @param renderingGroupId defines the rendering group id to use with the viewer
  45926. */
  45927. constructor(
  45928. /** defines the skeleton to render */
  45929. skeleton: Skeleton,
  45930. /** defines the mesh attached to the skeleton */
  45931. mesh: AbstractMesh, scene: Scene,
  45932. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45933. autoUpdateBonesMatrices?: boolean,
  45934. /** defines the rendering group id to use with the viewer */
  45935. renderingGroupId?: number);
  45936. /** Gets or sets a boolean indicating if the viewer is enabled */
  45937. isEnabled: boolean;
  45938. private _getBonePosition;
  45939. private _getLinesForBonesWithLength;
  45940. private _getLinesForBonesNoLength;
  45941. /** Update the viewer to sync with current skeleton state */
  45942. update(): void;
  45943. /** Release associated resources */
  45944. dispose(): void;
  45945. }
  45946. }
  45947. declare module "babylonjs/Debug/index" {
  45948. export * from "babylonjs/Debug/axesViewer";
  45949. export * from "babylonjs/Debug/boneAxesViewer";
  45950. export * from "babylonjs/Debug/debugLayer";
  45951. export * from "babylonjs/Debug/physicsViewer";
  45952. export * from "babylonjs/Debug/rayHelper";
  45953. export * from "babylonjs/Debug/skeletonViewer";
  45954. }
  45955. declare module "babylonjs/Engines/nullEngine" {
  45956. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45957. import { Scene } from "babylonjs/scene";
  45958. import { Engine } from "babylonjs/Engines/engine";
  45959. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45960. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45962. import { Effect } from "babylonjs/Materials/effect";
  45963. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45964. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45965. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45966. /**
  45967. * Options to create the null engine
  45968. */
  45969. export class NullEngineOptions {
  45970. /**
  45971. * Render width (Default: 512)
  45972. */
  45973. renderWidth: number;
  45974. /**
  45975. * Render height (Default: 256)
  45976. */
  45977. renderHeight: number;
  45978. /**
  45979. * Texture size (Default: 512)
  45980. */
  45981. textureSize: number;
  45982. /**
  45983. * If delta time between frames should be constant
  45984. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45985. */
  45986. deterministicLockstep: boolean;
  45987. /**
  45988. * Maximum about of steps between frames (Default: 4)
  45989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45990. */
  45991. lockstepMaxSteps: number;
  45992. }
  45993. /**
  45994. * The null engine class provides support for headless version of babylon.js.
  45995. * This can be used in server side scenario or for testing purposes
  45996. */
  45997. export class NullEngine extends Engine {
  45998. private _options;
  45999. /**
  46000. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46002. * @returns true if engine is in deterministic lock step mode
  46003. */
  46004. isDeterministicLockStep(): boolean;
  46005. /**
  46006. * Gets the max steps when engine is running in deterministic lock step
  46007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46008. * @returns the max steps
  46009. */
  46010. getLockstepMaxSteps(): number;
  46011. /**
  46012. * Gets the current hardware scaling level.
  46013. * By default the hardware scaling level is computed from the window device ratio.
  46014. * 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.
  46015. * @returns a number indicating the current hardware scaling level
  46016. */
  46017. getHardwareScalingLevel(): number;
  46018. constructor(options?: NullEngineOptions);
  46019. /**
  46020. * Creates a vertex buffer
  46021. * @param vertices the data for the vertex buffer
  46022. * @returns the new WebGL static buffer
  46023. */
  46024. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46025. /**
  46026. * Creates a new index buffer
  46027. * @param indices defines the content of the index buffer
  46028. * @param updatable defines if the index buffer must be updatable
  46029. * @returns a new webGL buffer
  46030. */
  46031. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46032. /**
  46033. * Clear the current render buffer or the current render target (if any is set up)
  46034. * @param color defines the color to use
  46035. * @param backBuffer defines if the back buffer must be cleared
  46036. * @param depth defines if the depth buffer must be cleared
  46037. * @param stencil defines if the stencil buffer must be cleared
  46038. */
  46039. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46040. /**
  46041. * Gets the current render width
  46042. * @param useScreen defines if screen size must be used (or the current render target if any)
  46043. * @returns a number defining the current render width
  46044. */
  46045. getRenderWidth(useScreen?: boolean): number;
  46046. /**
  46047. * Gets the current render height
  46048. * @param useScreen defines if screen size must be used (or the current render target if any)
  46049. * @returns a number defining the current render height
  46050. */
  46051. getRenderHeight(useScreen?: boolean): number;
  46052. /**
  46053. * Set the WebGL's viewport
  46054. * @param viewport defines the viewport element to be used
  46055. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46056. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46057. */
  46058. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46059. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46060. /**
  46061. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46062. * @param pipelineContext defines the pipeline context to use
  46063. * @param uniformsNames defines the list of uniform names
  46064. * @returns an array of webGL uniform locations
  46065. */
  46066. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46067. /**
  46068. * Gets the lsit of active attributes for a given webGL program
  46069. * @param pipelineContext defines the pipeline context to use
  46070. * @param attributesNames defines the list of attribute names to get
  46071. * @returns an array of indices indicating the offset of each attribute
  46072. */
  46073. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46074. /**
  46075. * Binds an effect to the webGL context
  46076. * @param effect defines the effect to bind
  46077. */
  46078. bindSamplers(effect: Effect): void;
  46079. /**
  46080. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46081. * @param effect defines the effect to activate
  46082. */
  46083. enableEffect(effect: Effect): void;
  46084. /**
  46085. * Set various states to the webGL context
  46086. * @param culling defines backface culling state
  46087. * @param zOffset defines the value to apply to zOffset (0 by default)
  46088. * @param force defines if states must be applied even if cache is up to date
  46089. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46090. */
  46091. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46092. /**
  46093. * Set the value of an uniform to an array of int32
  46094. * @param uniform defines the webGL uniform location where to store the value
  46095. * @param array defines the array of int32 to store
  46096. */
  46097. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46098. /**
  46099. * Set the value of an uniform to an array of int32 (stored as vec2)
  46100. * @param uniform defines the webGL uniform location where to store the value
  46101. * @param array defines the array of int32 to store
  46102. */
  46103. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46104. /**
  46105. * Set the value of an uniform to an array of int32 (stored as vec3)
  46106. * @param uniform defines the webGL uniform location where to store the value
  46107. * @param array defines the array of int32 to store
  46108. */
  46109. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46110. /**
  46111. * Set the value of an uniform to an array of int32 (stored as vec4)
  46112. * @param uniform defines the webGL uniform location where to store the value
  46113. * @param array defines the array of int32 to store
  46114. */
  46115. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46116. /**
  46117. * Set the value of an uniform to an array of float32
  46118. * @param uniform defines the webGL uniform location where to store the value
  46119. * @param array defines the array of float32 to store
  46120. */
  46121. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46122. /**
  46123. * Set the value of an uniform to an array of float32 (stored as vec2)
  46124. * @param uniform defines the webGL uniform location where to store the value
  46125. * @param array defines the array of float32 to store
  46126. */
  46127. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46128. /**
  46129. * Set the value of an uniform to an array of float32 (stored as vec3)
  46130. * @param uniform defines the webGL uniform location where to store the value
  46131. * @param array defines the array of float32 to store
  46132. */
  46133. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46134. /**
  46135. * Set the value of an uniform to an array of float32 (stored as vec4)
  46136. * @param uniform defines the webGL uniform location where to store the value
  46137. * @param array defines the array of float32 to store
  46138. */
  46139. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46140. /**
  46141. * Set the value of an uniform to an array of number
  46142. * @param uniform defines the webGL uniform location where to store the value
  46143. * @param array defines the array of number to store
  46144. */
  46145. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46146. /**
  46147. * Set the value of an uniform to an array of number (stored as vec2)
  46148. * @param uniform defines the webGL uniform location where to store the value
  46149. * @param array defines the array of number to store
  46150. */
  46151. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46152. /**
  46153. * Set the value of an uniform to an array of number (stored as vec3)
  46154. * @param uniform defines the webGL uniform location where to store the value
  46155. * @param array defines the array of number to store
  46156. */
  46157. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46158. /**
  46159. * Set the value of an uniform to an array of number (stored as vec4)
  46160. * @param uniform defines the webGL uniform location where to store the value
  46161. * @param array defines the array of number to store
  46162. */
  46163. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46164. /**
  46165. * Set the value of an uniform to an array of float32 (stored as matrices)
  46166. * @param uniform defines the webGL uniform location where to store the value
  46167. * @param matrices defines the array of float32 to store
  46168. */
  46169. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46170. /**
  46171. * Set the value of an uniform to a matrix (3x3)
  46172. * @param uniform defines the webGL uniform location where to store the value
  46173. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46174. */
  46175. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46176. /**
  46177. * Set the value of an uniform to a matrix (2x2)
  46178. * @param uniform defines the webGL uniform location where to store the value
  46179. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46180. */
  46181. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46182. /**
  46183. * Set the value of an uniform to a number (float)
  46184. * @param uniform defines the webGL uniform location where to store the value
  46185. * @param value defines the float number to store
  46186. */
  46187. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46188. /**
  46189. * Set the value of an uniform to a vec2
  46190. * @param uniform defines the webGL uniform location where to store the value
  46191. * @param x defines the 1st component of the value
  46192. * @param y defines the 2nd component of the value
  46193. */
  46194. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46195. /**
  46196. * Set the value of an uniform to a vec3
  46197. * @param uniform defines the webGL uniform location where to store the value
  46198. * @param x defines the 1st component of the value
  46199. * @param y defines the 2nd component of the value
  46200. * @param z defines the 3rd component of the value
  46201. */
  46202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46203. /**
  46204. * Set the value of an uniform to a boolean
  46205. * @param uniform defines the webGL uniform location where to store the value
  46206. * @param bool defines the boolean to store
  46207. */
  46208. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46209. /**
  46210. * Set the value of an uniform to a vec4
  46211. * @param uniform defines the webGL uniform location where to store the value
  46212. * @param x defines the 1st component of the value
  46213. * @param y defines the 2nd component of the value
  46214. * @param z defines the 3rd component of the value
  46215. * @param w defines the 4th component of the value
  46216. */
  46217. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46218. /**
  46219. * Sets the current alpha mode
  46220. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46221. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46223. */
  46224. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46225. /**
  46226. * Bind webGl buffers directly to the webGL context
  46227. * @param vertexBuffers defines the vertex buffer to bind
  46228. * @param indexBuffer defines the index buffer to bind
  46229. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46230. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46231. * @param effect defines the effect associated with the vertex buffer
  46232. */
  46233. bindBuffers(vertexBuffers: {
  46234. [key: string]: VertexBuffer;
  46235. }, indexBuffer: DataBuffer, effect: Effect): void;
  46236. /**
  46237. * Force the entire cache to be cleared
  46238. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46239. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46240. */
  46241. wipeCaches(bruteForce?: boolean): void;
  46242. /**
  46243. * Send a draw order
  46244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46245. * @param indexStart defines the starting index
  46246. * @param indexCount defines the number of index to draw
  46247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46248. */
  46249. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46250. /**
  46251. * Draw a list of indexed primitives
  46252. * @param fillMode defines the primitive to use
  46253. * @param indexStart defines the starting index
  46254. * @param indexCount defines the number of index to draw
  46255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46256. */
  46257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46258. /**
  46259. * Draw a list of unindexed primitives
  46260. * @param fillMode defines the primitive to use
  46261. * @param verticesStart defines the index of first vertex to draw
  46262. * @param verticesCount defines the count of vertices to draw
  46263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46264. */
  46265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46266. /** @hidden */
  46267. _createTexture(): WebGLTexture;
  46268. /** @hidden */
  46269. _releaseTexture(texture: InternalTexture): void;
  46270. /**
  46271. * Usually called from Texture.ts.
  46272. * Passed information to create a WebGLTexture
  46273. * @param urlArg defines a value which contains one of the following:
  46274. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46275. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46276. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46277. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46278. * @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)
  46279. * @param scene needed for loading to the correct scene
  46280. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46281. * @param onLoad optional callback to be called upon successful completion
  46282. * @param onError optional callback to be called upon failure
  46283. * @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
  46284. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46285. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46286. * @param forcedExtension defines the extension to use to pick the right loader
  46287. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46288. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46289. */
  46290. 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;
  46291. /**
  46292. * Creates a new render target texture
  46293. * @param size defines the size of the texture
  46294. * @param options defines the options used to create the texture
  46295. * @returns a new render target texture stored in an InternalTexture
  46296. */
  46297. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46298. /**
  46299. * Update the sampling mode of a given texture
  46300. * @param samplingMode defines the required sampling mode
  46301. * @param texture defines the texture to update
  46302. */
  46303. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46304. /**
  46305. * Binds the frame buffer to the specified texture.
  46306. * @param texture The texture to render to or null for the default canvas
  46307. * @param faceIndex The face of the texture to render to in case of cube texture
  46308. * @param requiredWidth The width of the target to render to
  46309. * @param requiredHeight The height of the target to render to
  46310. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46311. * @param depthStencilTexture The depth stencil texture to use to render
  46312. * @param lodLevel defines le lod level to bind to the frame buffer
  46313. */
  46314. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46315. /**
  46316. * Unbind the current render target texture from the webGL context
  46317. * @param texture defines the render target texture to unbind
  46318. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46319. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46320. */
  46321. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46322. /**
  46323. * Creates a dynamic vertex buffer
  46324. * @param vertices the data for the dynamic vertex buffer
  46325. * @returns the new WebGL dynamic buffer
  46326. */
  46327. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46328. /**
  46329. * Update the content of a dynamic texture
  46330. * @param texture defines the texture to update
  46331. * @param canvas defines the canvas containing the source
  46332. * @param invertY defines if data must be stored with Y axis inverted
  46333. * @param premulAlpha defines if alpha is stored as premultiplied
  46334. * @param format defines the format of the data
  46335. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46336. */
  46337. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46338. /**
  46339. * Gets a boolean indicating if all created effects are ready
  46340. * @returns true if all effects are ready
  46341. */
  46342. areAllEffectsReady(): boolean;
  46343. /**
  46344. * @hidden
  46345. * Get the current error code of the webGL context
  46346. * @returns the error code
  46347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46348. */
  46349. getError(): number;
  46350. /** @hidden */
  46351. _getUnpackAlignement(): number;
  46352. /** @hidden */
  46353. _unpackFlipY(value: boolean): void;
  46354. /**
  46355. * Update a dynamic index buffer
  46356. * @param indexBuffer defines the target index buffer
  46357. * @param indices defines the data to update
  46358. * @param offset defines the offset in the target index buffer where update should start
  46359. */
  46360. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46361. /**
  46362. * Updates a dynamic vertex buffer.
  46363. * @param vertexBuffer the vertex buffer to update
  46364. * @param vertices the data used to update the vertex buffer
  46365. * @param byteOffset the byte offset of the data (optional)
  46366. * @param byteLength the byte length of the data (optional)
  46367. */
  46368. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46369. /** @hidden */
  46370. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46371. /** @hidden */
  46372. _bindTexture(channel: number, texture: InternalTexture): void;
  46373. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46374. /**
  46375. * 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
  46376. */
  46377. releaseEffects(): void;
  46378. displayLoadingUI(): void;
  46379. hideLoadingUI(): void;
  46380. /** @hidden */
  46381. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46382. /** @hidden */
  46383. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46384. /** @hidden */
  46385. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46386. /** @hidden */
  46387. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46388. }
  46389. }
  46390. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46391. import { Nullable, int } from "babylonjs/types";
  46392. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46393. /** @hidden */
  46394. export class _OcclusionDataStorage {
  46395. /** @hidden */
  46396. occlusionInternalRetryCounter: number;
  46397. /** @hidden */
  46398. isOcclusionQueryInProgress: boolean;
  46399. /** @hidden */
  46400. isOccluded: boolean;
  46401. /** @hidden */
  46402. occlusionRetryCount: number;
  46403. /** @hidden */
  46404. occlusionType: number;
  46405. /** @hidden */
  46406. occlusionQueryAlgorithmType: number;
  46407. }
  46408. module "babylonjs/Engines/engine" {
  46409. interface Engine {
  46410. /**
  46411. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46412. * @return the new query
  46413. */
  46414. createQuery(): WebGLQuery;
  46415. /**
  46416. * Delete and release a webGL query
  46417. * @param query defines the query to delete
  46418. * @return the current engine
  46419. */
  46420. deleteQuery(query: WebGLQuery): Engine;
  46421. /**
  46422. * Check if a given query has resolved and got its value
  46423. * @param query defines the query to check
  46424. * @returns true if the query got its value
  46425. */
  46426. isQueryResultAvailable(query: WebGLQuery): boolean;
  46427. /**
  46428. * Gets the value of a given query
  46429. * @param query defines the query to check
  46430. * @returns the value of the query
  46431. */
  46432. getQueryResult(query: WebGLQuery): number;
  46433. /**
  46434. * Initiates an occlusion query
  46435. * @param algorithmType defines the algorithm to use
  46436. * @param query defines the query to use
  46437. * @returns the current engine
  46438. * @see http://doc.babylonjs.com/features/occlusionquery
  46439. */
  46440. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46441. /**
  46442. * Ends an occlusion query
  46443. * @see http://doc.babylonjs.com/features/occlusionquery
  46444. * @param algorithmType defines the algorithm to use
  46445. * @returns the current engine
  46446. */
  46447. endOcclusionQuery(algorithmType: number): Engine;
  46448. /**
  46449. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46450. * Please note that only one query can be issued at a time
  46451. * @returns a time token used to track the time span
  46452. */
  46453. startTimeQuery(): Nullable<_TimeToken>;
  46454. /**
  46455. * Ends a time query
  46456. * @param token defines the token used to measure the time span
  46457. * @returns the time spent (in ns)
  46458. */
  46459. endTimeQuery(token: _TimeToken): int;
  46460. /** @hidden */
  46461. _currentNonTimestampToken: Nullable<_TimeToken>;
  46462. /** @hidden */
  46463. _createTimeQuery(): WebGLQuery;
  46464. /** @hidden */
  46465. _deleteTimeQuery(query: WebGLQuery): void;
  46466. /** @hidden */
  46467. _getGlAlgorithmType(algorithmType: number): number;
  46468. /** @hidden */
  46469. _getTimeQueryResult(query: WebGLQuery): any;
  46470. /** @hidden */
  46471. _getTimeQueryAvailability(query: WebGLQuery): any;
  46472. }
  46473. }
  46474. module "babylonjs/Meshes/abstractMesh" {
  46475. interface AbstractMesh {
  46476. /**
  46477. * Backing filed
  46478. * @hidden
  46479. */
  46480. __occlusionDataStorage: _OcclusionDataStorage;
  46481. /**
  46482. * Access property
  46483. * @hidden
  46484. */
  46485. _occlusionDataStorage: _OcclusionDataStorage;
  46486. /**
  46487. * 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.
  46488. * The default value is -1 which means don't break the query and wait till the result
  46489. * @see http://doc.babylonjs.com/features/occlusionquery
  46490. */
  46491. occlusionRetryCount: number;
  46492. /**
  46493. * 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:
  46494. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46495. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46496. * * 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.
  46497. * @see http://doc.babylonjs.com/features/occlusionquery
  46498. */
  46499. occlusionType: number;
  46500. /**
  46501. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46502. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46503. * * 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.
  46504. * @see http://doc.babylonjs.com/features/occlusionquery
  46505. */
  46506. occlusionQueryAlgorithmType: number;
  46507. /**
  46508. * 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
  46509. * @see http://doc.babylonjs.com/features/occlusionquery
  46510. */
  46511. isOccluded: boolean;
  46512. /**
  46513. * Flag to check the progress status of the query
  46514. * @see http://doc.babylonjs.com/features/occlusionquery
  46515. */
  46516. isOcclusionQueryInProgress: boolean;
  46517. }
  46518. }
  46519. }
  46520. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46521. import { Nullable } from "babylonjs/types";
  46522. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46523. /** @hidden */
  46524. export var _forceTransformFeedbackToBundle: boolean;
  46525. module "babylonjs/Engines/engine" {
  46526. interface Engine {
  46527. /**
  46528. * Creates a webGL transform feedback object
  46529. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46530. * @returns the webGL transform feedback object
  46531. */
  46532. createTransformFeedback(): WebGLTransformFeedback;
  46533. /**
  46534. * Delete a webGL transform feedback object
  46535. * @param value defines the webGL transform feedback object to delete
  46536. */
  46537. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46538. /**
  46539. * Bind a webGL transform feedback object to the webgl context
  46540. * @param value defines the webGL transform feedback object to bind
  46541. */
  46542. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46543. /**
  46544. * Begins a transform feedback operation
  46545. * @param usePoints defines if points or triangles must be used
  46546. */
  46547. beginTransformFeedback(usePoints: boolean): void;
  46548. /**
  46549. * Ends a transform feedback operation
  46550. */
  46551. endTransformFeedback(): void;
  46552. /**
  46553. * Specify the varyings to use with transform feedback
  46554. * @param program defines the associated webGL program
  46555. * @param value defines the list of strings representing the varying names
  46556. */
  46557. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46558. /**
  46559. * Bind a webGL buffer for a transform feedback operation
  46560. * @param value defines the webGL buffer to bind
  46561. */
  46562. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46563. }
  46564. }
  46565. }
  46566. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46567. import { Scene } from "babylonjs/scene";
  46568. import { Engine } from "babylonjs/Engines/engine";
  46569. import { Texture } from "babylonjs/Materials/Textures/texture";
  46570. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46571. import "babylonjs/Engines/Extensions/engine.multiRender";
  46572. /**
  46573. * Creation options of the multi render target texture.
  46574. */
  46575. export interface IMultiRenderTargetOptions {
  46576. /**
  46577. * Define if the texture needs to create mip maps after render.
  46578. */
  46579. generateMipMaps?: boolean;
  46580. /**
  46581. * Define the types of all the draw buffers we want to create
  46582. */
  46583. types?: number[];
  46584. /**
  46585. * Define the sampling modes of all the draw buffers we want to create
  46586. */
  46587. samplingModes?: number[];
  46588. /**
  46589. * Define if a depth buffer is required
  46590. */
  46591. generateDepthBuffer?: boolean;
  46592. /**
  46593. * Define if a stencil buffer is required
  46594. */
  46595. generateStencilBuffer?: boolean;
  46596. /**
  46597. * Define if a depth texture is required instead of a depth buffer
  46598. */
  46599. generateDepthTexture?: boolean;
  46600. /**
  46601. * Define the number of desired draw buffers
  46602. */
  46603. textureCount?: number;
  46604. /**
  46605. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46606. */
  46607. doNotChangeAspectRatio?: boolean;
  46608. /**
  46609. * Define the default type of the buffers we are creating
  46610. */
  46611. defaultType?: number;
  46612. }
  46613. /**
  46614. * A multi render target, like a render target provides the ability to render to a texture.
  46615. * Unlike the render target, it can render to several draw buffers in one draw.
  46616. * This is specially interesting in deferred rendering or for any effects requiring more than
  46617. * just one color from a single pass.
  46618. */
  46619. export class MultiRenderTarget extends RenderTargetTexture {
  46620. private _internalTextures;
  46621. private _textures;
  46622. private _multiRenderTargetOptions;
  46623. /**
  46624. * Get if draw buffers are currently supported by the used hardware and browser.
  46625. */
  46626. readonly isSupported: boolean;
  46627. /**
  46628. * Get the list of textures generated by the multi render target.
  46629. */
  46630. readonly textures: Texture[];
  46631. /**
  46632. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46633. */
  46634. readonly depthTexture: Texture;
  46635. /**
  46636. * Set the wrapping mode on U of all the textures we are rendering to.
  46637. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46638. */
  46639. wrapU: number;
  46640. /**
  46641. * Set the wrapping mode on V of all the textures we are rendering to.
  46642. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46643. */
  46644. wrapV: number;
  46645. /**
  46646. * Instantiate a new multi render target texture.
  46647. * A multi render target, like a render target provides the ability to render to a texture.
  46648. * Unlike the render target, it can render to several draw buffers in one draw.
  46649. * This is specially interesting in deferred rendering or for any effects requiring more than
  46650. * just one color from a single pass.
  46651. * @param name Define the name of the texture
  46652. * @param size Define the size of the buffers to render to
  46653. * @param count Define the number of target we are rendering into
  46654. * @param scene Define the scene the texture belongs to
  46655. * @param options Define the options used to create the multi render target
  46656. */
  46657. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46658. /** @hidden */
  46659. _rebuild(): void;
  46660. private _createInternalTextures;
  46661. private _createTextures;
  46662. /**
  46663. * Define the number of samples used if MSAA is enabled.
  46664. */
  46665. samples: number;
  46666. /**
  46667. * Resize all the textures in the multi render target.
  46668. * Be carrefull as it will recreate all the data in the new texture.
  46669. * @param size Define the new size
  46670. */
  46671. resize(size: any): void;
  46672. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46673. /**
  46674. * Dispose the render targets and their associated resources
  46675. */
  46676. dispose(): void;
  46677. /**
  46678. * Release all the underlying texture used as draw buffers.
  46679. */
  46680. releaseInternalTextures(): void;
  46681. }
  46682. }
  46683. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46685. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46686. import { Nullable } from "babylonjs/types";
  46687. module "babylonjs/Engines/thinEngine" {
  46688. interface ThinEngine {
  46689. /**
  46690. * Unbind a list of render target textures from the webGL context
  46691. * This is used only when drawBuffer extension or webGL2 are active
  46692. * @param textures defines the render target textures to unbind
  46693. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46694. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46695. */
  46696. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46697. /**
  46698. * Create a multi render target texture
  46699. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46700. * @param size defines the size of the texture
  46701. * @param options defines the creation options
  46702. * @returns the cube texture as an InternalTexture
  46703. */
  46704. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46705. /**
  46706. * Update the sample count for a given multiple render target texture
  46707. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46708. * @param textures defines the textures to update
  46709. * @param samples defines the sample count to set
  46710. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46711. */
  46712. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46713. }
  46714. }
  46715. }
  46716. declare module "babylonjs/Engines/Extensions/engine.views" {
  46717. import { Camera } from "babylonjs/Cameras/camera";
  46718. import { Nullable } from "babylonjs/types";
  46719. /**
  46720. * Class used to define an additional view for the engine
  46721. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46722. */
  46723. export class EngineView {
  46724. /** Defines the canvas where to render the view */
  46725. target: HTMLCanvasElement;
  46726. /** Defines an optional camera used to render the view (will use active camera else) */
  46727. camera?: Camera;
  46728. }
  46729. module "babylonjs/Engines/engine" {
  46730. interface Engine {
  46731. /**
  46732. * Gets or sets the HTML element to use for attaching events
  46733. */
  46734. inputElement: Nullable<HTMLElement>;
  46735. /**
  46736. * Gets the current engine view
  46737. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46738. */
  46739. activeView: Nullable<EngineView>;
  46740. /** Gets or sets the list of views */
  46741. views: EngineView[];
  46742. /**
  46743. * Register a new child canvas
  46744. * @param canvas defines the canvas to register
  46745. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46746. * @returns the associated view
  46747. */
  46748. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46749. /**
  46750. * Remove a registered child canvas
  46751. * @param canvas defines the canvas to remove
  46752. * @returns the current engine
  46753. */
  46754. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46755. }
  46756. }
  46757. }
  46758. declare module "babylonjs/Engines/Extensions/index" {
  46759. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46760. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46761. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46762. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46763. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46764. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46765. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46766. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46767. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46768. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46769. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46770. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46771. export * from "babylonjs/Engines/Extensions/engine.views";
  46772. }
  46773. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46774. import { Nullable } from "babylonjs/types";
  46775. /**
  46776. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46777. */
  46778. export interface CubeMapInfo {
  46779. /**
  46780. * The pixel array for the front face.
  46781. * This is stored in format, left to right, up to down format.
  46782. */
  46783. front: Nullable<ArrayBufferView>;
  46784. /**
  46785. * The pixel array for the back face.
  46786. * This is stored in format, left to right, up to down format.
  46787. */
  46788. back: Nullable<ArrayBufferView>;
  46789. /**
  46790. * The pixel array for the left face.
  46791. * This is stored in format, left to right, up to down format.
  46792. */
  46793. left: Nullable<ArrayBufferView>;
  46794. /**
  46795. * The pixel array for the right face.
  46796. * This is stored in format, left to right, up to down format.
  46797. */
  46798. right: Nullable<ArrayBufferView>;
  46799. /**
  46800. * The pixel array for the up face.
  46801. * This is stored in format, left to right, up to down format.
  46802. */
  46803. up: Nullable<ArrayBufferView>;
  46804. /**
  46805. * The pixel array for the down face.
  46806. * This is stored in format, left to right, up to down format.
  46807. */
  46808. down: Nullable<ArrayBufferView>;
  46809. /**
  46810. * The size of the cubemap stored.
  46811. *
  46812. * Each faces will be size * size pixels.
  46813. */
  46814. size: number;
  46815. /**
  46816. * The format of the texture.
  46817. *
  46818. * RGBA, RGB.
  46819. */
  46820. format: number;
  46821. /**
  46822. * The type of the texture data.
  46823. *
  46824. * UNSIGNED_INT, FLOAT.
  46825. */
  46826. type: number;
  46827. /**
  46828. * Specifies whether the texture is in gamma space.
  46829. */
  46830. gammaSpace: boolean;
  46831. }
  46832. /**
  46833. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46834. */
  46835. export class PanoramaToCubeMapTools {
  46836. private static FACE_FRONT;
  46837. private static FACE_BACK;
  46838. private static FACE_RIGHT;
  46839. private static FACE_LEFT;
  46840. private static FACE_DOWN;
  46841. private static FACE_UP;
  46842. /**
  46843. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46844. *
  46845. * @param float32Array The source data.
  46846. * @param inputWidth The width of the input panorama.
  46847. * @param inputHeight The height of the input panorama.
  46848. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46849. * @return The cubemap data
  46850. */
  46851. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46852. private static CreateCubemapTexture;
  46853. private static CalcProjectionSpherical;
  46854. }
  46855. }
  46856. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46857. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46859. import { Nullable } from "babylonjs/types";
  46860. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46861. /**
  46862. * Helper class dealing with the extraction of spherical polynomial dataArray
  46863. * from a cube map.
  46864. */
  46865. export class CubeMapToSphericalPolynomialTools {
  46866. private static FileFaces;
  46867. /**
  46868. * Converts a texture to the according Spherical Polynomial data.
  46869. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46870. *
  46871. * @param texture The texture to extract the information from.
  46872. * @return The Spherical Polynomial data.
  46873. */
  46874. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46875. /**
  46876. * Converts a cubemap to the according Spherical Polynomial data.
  46877. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46878. *
  46879. * @param cubeInfo The Cube map to extract the information from.
  46880. * @return The Spherical Polynomial data.
  46881. */
  46882. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46883. }
  46884. }
  46885. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46886. import { Nullable } from "babylonjs/types";
  46887. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46888. module "babylonjs/Materials/Textures/baseTexture" {
  46889. interface BaseTexture {
  46890. /**
  46891. * Get the polynomial representation of the texture data.
  46892. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46893. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46894. */
  46895. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46896. }
  46897. }
  46898. }
  46899. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46900. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46901. /** @hidden */
  46902. export var rgbdEncodePixelShader: {
  46903. name: string;
  46904. shader: string;
  46905. };
  46906. }
  46907. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46908. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46909. /** @hidden */
  46910. export var rgbdDecodePixelShader: {
  46911. name: string;
  46912. shader: string;
  46913. };
  46914. }
  46915. declare module "babylonjs/Misc/environmentTextureTools" {
  46916. import { Nullable } from "babylonjs/types";
  46917. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46918. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46919. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46921. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46922. import "babylonjs/Shaders/rgbdEncode.fragment";
  46923. import "babylonjs/Shaders/rgbdDecode.fragment";
  46924. /**
  46925. * Raw texture data and descriptor sufficient for WebGL texture upload
  46926. */
  46927. export interface EnvironmentTextureInfo {
  46928. /**
  46929. * Version of the environment map
  46930. */
  46931. version: number;
  46932. /**
  46933. * Width of image
  46934. */
  46935. width: number;
  46936. /**
  46937. * Irradiance information stored in the file.
  46938. */
  46939. irradiance: any;
  46940. /**
  46941. * Specular information stored in the file.
  46942. */
  46943. specular: any;
  46944. }
  46945. /**
  46946. * Defines One Image in the file. It requires only the position in the file
  46947. * as well as the length.
  46948. */
  46949. interface BufferImageData {
  46950. /**
  46951. * Length of the image data.
  46952. */
  46953. length: number;
  46954. /**
  46955. * Position of the data from the null terminator delimiting the end of the JSON.
  46956. */
  46957. position: number;
  46958. }
  46959. /**
  46960. * Defines the specular data enclosed in the file.
  46961. * This corresponds to the version 1 of the data.
  46962. */
  46963. export interface EnvironmentTextureSpecularInfoV1 {
  46964. /**
  46965. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46966. */
  46967. specularDataPosition?: number;
  46968. /**
  46969. * This contains all the images data needed to reconstruct the cubemap.
  46970. */
  46971. mipmaps: Array<BufferImageData>;
  46972. /**
  46973. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46974. */
  46975. lodGenerationScale: number;
  46976. }
  46977. /**
  46978. * Sets of helpers addressing the serialization and deserialization of environment texture
  46979. * stored in a BabylonJS env file.
  46980. * Those files are usually stored as .env files.
  46981. */
  46982. export class EnvironmentTextureTools {
  46983. /**
  46984. * Magic number identifying the env file.
  46985. */
  46986. private static _MagicBytes;
  46987. /**
  46988. * Gets the environment info from an env file.
  46989. * @param data The array buffer containing the .env bytes.
  46990. * @returns the environment file info (the json header) if successfully parsed.
  46991. */
  46992. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46993. /**
  46994. * Creates an environment texture from a loaded cube texture.
  46995. * @param texture defines the cube texture to convert in env file
  46996. * @return a promise containing the environment data if succesfull.
  46997. */
  46998. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46999. /**
  47000. * Creates a JSON representation of the spherical data.
  47001. * @param texture defines the texture containing the polynomials
  47002. * @return the JSON representation of the spherical info
  47003. */
  47004. private static _CreateEnvTextureIrradiance;
  47005. /**
  47006. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47007. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47008. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47009. * @return the views described by info providing access to the underlying buffer
  47010. */
  47011. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47012. /**
  47013. * Uploads the texture info contained in the env file to the GPU.
  47014. * @param texture defines the internal texture to upload to
  47015. * @param arrayBuffer defines the buffer cotaining the data to load
  47016. * @param info defines the texture info retrieved through the GetEnvInfo method
  47017. * @returns a promise
  47018. */
  47019. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47020. private static _OnImageReadyAsync;
  47021. /**
  47022. * Uploads the levels of image data to the GPU.
  47023. * @param texture defines the internal texture to upload to
  47024. * @param imageData defines the array buffer views of image data [mipmap][face]
  47025. * @returns a promise
  47026. */
  47027. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47028. /**
  47029. * Uploads spherical polynomials information to the texture.
  47030. * @param texture defines the texture we are trying to upload the information to
  47031. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47032. */
  47033. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47034. /** @hidden */
  47035. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47036. }
  47037. }
  47038. declare module "babylonjs/Maths/math.vertexFormat" {
  47039. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47040. /**
  47041. * Contains position and normal vectors for a vertex
  47042. */
  47043. export class PositionNormalVertex {
  47044. /** the position of the vertex (defaut: 0,0,0) */
  47045. position: Vector3;
  47046. /** the normal of the vertex (defaut: 0,1,0) */
  47047. normal: Vector3;
  47048. /**
  47049. * Creates a PositionNormalVertex
  47050. * @param position the position of the vertex (defaut: 0,0,0)
  47051. * @param normal the normal of the vertex (defaut: 0,1,0)
  47052. */
  47053. constructor(
  47054. /** the position of the vertex (defaut: 0,0,0) */
  47055. position?: Vector3,
  47056. /** the normal of the vertex (defaut: 0,1,0) */
  47057. normal?: Vector3);
  47058. /**
  47059. * Clones the PositionNormalVertex
  47060. * @returns the cloned PositionNormalVertex
  47061. */
  47062. clone(): PositionNormalVertex;
  47063. }
  47064. /**
  47065. * Contains position, normal and uv vectors for a vertex
  47066. */
  47067. export class PositionNormalTextureVertex {
  47068. /** the position of the vertex (defaut: 0,0,0) */
  47069. position: Vector3;
  47070. /** the normal of the vertex (defaut: 0,1,0) */
  47071. normal: Vector3;
  47072. /** the uv of the vertex (default: 0,0) */
  47073. uv: Vector2;
  47074. /**
  47075. * Creates a PositionNormalTextureVertex
  47076. * @param position the position of the vertex (defaut: 0,0,0)
  47077. * @param normal the normal of the vertex (defaut: 0,1,0)
  47078. * @param uv the uv of the vertex (default: 0,0)
  47079. */
  47080. constructor(
  47081. /** the position of the vertex (defaut: 0,0,0) */
  47082. position?: Vector3,
  47083. /** the normal of the vertex (defaut: 0,1,0) */
  47084. normal?: Vector3,
  47085. /** the uv of the vertex (default: 0,0) */
  47086. uv?: Vector2);
  47087. /**
  47088. * Clones the PositionNormalTextureVertex
  47089. * @returns the cloned PositionNormalTextureVertex
  47090. */
  47091. clone(): PositionNormalTextureVertex;
  47092. }
  47093. }
  47094. declare module "babylonjs/Maths/math" {
  47095. export * from "babylonjs/Maths/math.axis";
  47096. export * from "babylonjs/Maths/math.color";
  47097. export * from "babylonjs/Maths/math.constants";
  47098. export * from "babylonjs/Maths/math.frustum";
  47099. export * from "babylonjs/Maths/math.path";
  47100. export * from "babylonjs/Maths/math.plane";
  47101. export * from "babylonjs/Maths/math.size";
  47102. export * from "babylonjs/Maths/math.vector";
  47103. export * from "babylonjs/Maths/math.vertexFormat";
  47104. export * from "babylonjs/Maths/math.viewport";
  47105. }
  47106. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47107. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47108. /** @hidden */
  47109. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47110. private _genericAttributeLocation;
  47111. private _varyingLocationCount;
  47112. private _varyingLocationMap;
  47113. private _replacements;
  47114. private _textureCount;
  47115. private _uniforms;
  47116. lineProcessor(line: string): string;
  47117. attributeProcessor(attribute: string): string;
  47118. varyingProcessor(varying: string, isFragment: boolean): string;
  47119. uniformProcessor(uniform: string): string;
  47120. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47121. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47122. }
  47123. }
  47124. declare module "babylonjs/Engines/nativeEngine" {
  47125. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47126. import { Engine } from "babylonjs/Engines/engine";
  47127. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47130. import { Effect } from "babylonjs/Materials/effect";
  47131. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47132. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47133. import { IColor4Like } from "babylonjs/Maths/math.like";
  47134. import { Scene } from "babylonjs/scene";
  47135. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47136. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47137. /**
  47138. * Container for accessors for natively-stored mesh data buffers.
  47139. */
  47140. class NativeDataBuffer extends DataBuffer {
  47141. /**
  47142. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47143. */
  47144. nativeIndexBuffer?: any;
  47145. /**
  47146. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47147. */
  47148. nativeVertexBuffer?: any;
  47149. }
  47150. /** @hidden */
  47151. class NativeTexture extends InternalTexture {
  47152. getInternalTexture(): InternalTexture;
  47153. getViewCount(): number;
  47154. }
  47155. /** @hidden */
  47156. export class NativeEngine extends Engine {
  47157. private readonly _native;
  47158. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47159. private readonly INVALID_HANDLE;
  47160. getHardwareScalingLevel(): number;
  47161. constructor();
  47162. /**
  47163. * Can be used to override the current requestAnimationFrame requester.
  47164. * @hidden
  47165. */
  47166. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47167. /**
  47168. * Override default engine behavior.
  47169. * @param color
  47170. * @param backBuffer
  47171. * @param depth
  47172. * @param stencil
  47173. */
  47174. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47175. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47176. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47177. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47178. recordVertexArrayObject(vertexBuffers: {
  47179. [key: string]: VertexBuffer;
  47180. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47181. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47182. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47183. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47184. /**
  47185. * Draw a list of indexed primitives
  47186. * @param fillMode defines the primitive to use
  47187. * @param indexStart defines the starting index
  47188. * @param indexCount defines the number of index to draw
  47189. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47190. */
  47191. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47192. /**
  47193. * Draw a list of unindexed primitives
  47194. * @param fillMode defines the primitive to use
  47195. * @param verticesStart defines the index of first vertex to draw
  47196. * @param verticesCount defines the count of vertices to draw
  47197. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47198. */
  47199. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47200. createPipelineContext(): IPipelineContext;
  47201. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47202. /** @hidden */
  47203. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47204. /** @hidden */
  47205. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47206. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47207. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47208. protected _setProgram(program: WebGLProgram): void;
  47209. _releaseEffect(effect: Effect): void;
  47210. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47211. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47212. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47213. bindSamplers(effect: Effect): void;
  47214. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47215. getRenderWidth(useScreen?: boolean): number;
  47216. getRenderHeight(useScreen?: boolean): number;
  47217. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47218. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47219. /**
  47220. * Set the z offset to apply to current rendering
  47221. * @param value defines the offset to apply
  47222. */
  47223. setZOffset(value: number): void;
  47224. /**
  47225. * Gets the current value of the zOffset
  47226. * @returns the current zOffset state
  47227. */
  47228. getZOffset(): number;
  47229. /**
  47230. * Enable or disable depth buffering
  47231. * @param enable defines the state to set
  47232. */
  47233. setDepthBuffer(enable: boolean): void;
  47234. /**
  47235. * Gets a boolean indicating if depth writing is enabled
  47236. * @returns the current depth writing state
  47237. */
  47238. getDepthWrite(): boolean;
  47239. /**
  47240. * Enable or disable depth writing
  47241. * @param enable defines the state to set
  47242. */
  47243. setDepthWrite(enable: boolean): void;
  47244. /**
  47245. * Enable or disable color writing
  47246. * @param enable defines the state to set
  47247. */
  47248. setColorWrite(enable: boolean): void;
  47249. /**
  47250. * Gets a boolean indicating if color writing is enabled
  47251. * @returns the current color writing state
  47252. */
  47253. getColorWrite(): boolean;
  47254. /**
  47255. * Sets alpha constants used by some alpha blending modes
  47256. * @param r defines the red component
  47257. * @param g defines the green component
  47258. * @param b defines the blue component
  47259. * @param a defines the alpha component
  47260. */
  47261. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47262. /**
  47263. * Sets the current alpha mode
  47264. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47265. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47267. */
  47268. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47269. /**
  47270. * Gets the current alpha mode
  47271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47272. * @returns the current alpha mode
  47273. */
  47274. getAlphaMode(): number;
  47275. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47276. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47277. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47278. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47279. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47280. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47281. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47282. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47283. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47284. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47285. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47286. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47287. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47288. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47289. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47290. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47291. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47292. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47293. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47294. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47295. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47296. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47297. wipeCaches(bruteForce?: boolean): void;
  47298. _createTexture(): WebGLTexture;
  47299. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47300. /**
  47301. * Usually called from BABYLON.Texture.ts.
  47302. * Passed information to create a WebGLTexture
  47303. * @param urlArg defines a value which contains one of the following:
  47304. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47305. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47306. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47308. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47309. * @param scene needed for loading to the correct scene
  47310. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47311. * @param onLoad optional callback to be called upon successful completion
  47312. * @param onError optional callback to be called upon failure
  47313. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47314. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47315. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47316. * @param forcedExtension defines the extension to use to pick the right loader
  47317. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47318. */
  47319. 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;
  47320. /**
  47321. * Creates a cube texture
  47322. * @param rootUrl defines the url where the files to load is located
  47323. * @param scene defines the current scene
  47324. * @param files defines the list of files to load (1 per face)
  47325. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47326. * @param onLoad defines an optional callback raised when the texture is loaded
  47327. * @param onError defines an optional callback raised if there is an issue to load the texture
  47328. * @param format defines the format of the data
  47329. * @param forcedExtension defines the extension to use to pick the right loader
  47330. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47331. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47332. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47333. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47334. * @returns the cube texture as an InternalTexture
  47335. */
  47336. 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;
  47337. private _getSamplingFilter;
  47338. private static _GetNativeTextureFormat;
  47339. createRenderTargetTexture(size: number | {
  47340. width: number;
  47341. height: number;
  47342. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47343. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47344. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47345. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47346. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47347. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47348. /**
  47349. * Updates a dynamic vertex buffer.
  47350. * @param vertexBuffer the vertex buffer to update
  47351. * @param data the data used to update the vertex buffer
  47352. * @param byteOffset the byte offset of the data (optional)
  47353. * @param byteLength the byte length of the data (optional)
  47354. */
  47355. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47356. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47357. private _updateAnisotropicLevel;
  47358. private _getAddressMode;
  47359. /** @hidden */
  47360. _bindTexture(channel: number, texture: InternalTexture): void;
  47361. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47362. releaseEffects(): void;
  47363. /** @hidden */
  47364. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47365. /** @hidden */
  47366. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47367. /** @hidden */
  47368. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47369. /** @hidden */
  47370. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47371. }
  47372. }
  47373. declare module "babylonjs/Engines/index" {
  47374. export * from "babylonjs/Engines/constants";
  47375. export * from "babylonjs/Engines/engineCapabilities";
  47376. export * from "babylonjs/Engines/instancingAttributeInfo";
  47377. export * from "babylonjs/Engines/thinEngine";
  47378. export * from "babylonjs/Engines/engine";
  47379. export * from "babylonjs/Engines/engineStore";
  47380. export * from "babylonjs/Engines/nullEngine";
  47381. export * from "babylonjs/Engines/Extensions/index";
  47382. export * from "babylonjs/Engines/IPipelineContext";
  47383. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47384. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47385. export * from "babylonjs/Engines/nativeEngine";
  47386. }
  47387. declare module "babylonjs/Events/clipboardEvents" {
  47388. /**
  47389. * Gather the list of clipboard event types as constants.
  47390. */
  47391. export class ClipboardEventTypes {
  47392. /**
  47393. * The clipboard event is fired when a copy command is active (pressed).
  47394. */
  47395. static readonly COPY: number;
  47396. /**
  47397. * The clipboard event is fired when a cut command is active (pressed).
  47398. */
  47399. static readonly CUT: number;
  47400. /**
  47401. * The clipboard event is fired when a paste command is active (pressed).
  47402. */
  47403. static readonly PASTE: number;
  47404. }
  47405. /**
  47406. * This class is used to store clipboard related info for the onClipboardObservable event.
  47407. */
  47408. export class ClipboardInfo {
  47409. /**
  47410. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47411. */
  47412. type: number;
  47413. /**
  47414. * Defines the related dom event
  47415. */
  47416. event: ClipboardEvent;
  47417. /**
  47418. *Creates an instance of ClipboardInfo.
  47419. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47420. * @param event Defines the related dom event
  47421. */
  47422. constructor(
  47423. /**
  47424. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47425. */
  47426. type: number,
  47427. /**
  47428. * Defines the related dom event
  47429. */
  47430. event: ClipboardEvent);
  47431. /**
  47432. * Get the clipboard event's type from the keycode.
  47433. * @param keyCode Defines the keyCode for the current keyboard event.
  47434. * @return {number}
  47435. */
  47436. static GetTypeFromCharacter(keyCode: number): number;
  47437. }
  47438. }
  47439. declare module "babylonjs/Events/index" {
  47440. export * from "babylonjs/Events/keyboardEvents";
  47441. export * from "babylonjs/Events/pointerEvents";
  47442. export * from "babylonjs/Events/clipboardEvents";
  47443. }
  47444. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47445. import { Scene } from "babylonjs/scene";
  47446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47447. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47448. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47449. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47450. /**
  47451. * Google Daydream controller
  47452. */
  47453. export class DaydreamController extends WebVRController {
  47454. /**
  47455. * Base Url for the controller model.
  47456. */
  47457. static MODEL_BASE_URL: string;
  47458. /**
  47459. * File name for the controller model.
  47460. */
  47461. static MODEL_FILENAME: string;
  47462. /**
  47463. * Gamepad Id prefix used to identify Daydream Controller.
  47464. */
  47465. static readonly GAMEPAD_ID_PREFIX: string;
  47466. /**
  47467. * Creates a new DaydreamController from a gamepad
  47468. * @param vrGamepad the gamepad that the controller should be created from
  47469. */
  47470. constructor(vrGamepad: any);
  47471. /**
  47472. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47473. * @param scene scene in which to add meshes
  47474. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47475. */
  47476. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47477. /**
  47478. * Called once for each button that changed state since the last frame
  47479. * @param buttonIdx Which button index changed
  47480. * @param state New state of the button
  47481. * @param changes Which properties on the state changed since last frame
  47482. */
  47483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47484. }
  47485. }
  47486. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47487. import { Scene } from "babylonjs/scene";
  47488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47489. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47490. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47491. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47492. /**
  47493. * Gear VR Controller
  47494. */
  47495. export class GearVRController extends WebVRController {
  47496. /**
  47497. * Base Url for the controller model.
  47498. */
  47499. static MODEL_BASE_URL: string;
  47500. /**
  47501. * File name for the controller model.
  47502. */
  47503. static MODEL_FILENAME: string;
  47504. /**
  47505. * Gamepad Id prefix used to identify this controller.
  47506. */
  47507. static readonly GAMEPAD_ID_PREFIX: string;
  47508. private readonly _buttonIndexToObservableNameMap;
  47509. /**
  47510. * Creates a new GearVRController from a gamepad
  47511. * @param vrGamepad the gamepad that the controller should be created from
  47512. */
  47513. constructor(vrGamepad: any);
  47514. /**
  47515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47516. * @param scene scene in which to add meshes
  47517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47518. */
  47519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47520. /**
  47521. * Called once for each button that changed state since the last frame
  47522. * @param buttonIdx Which button index changed
  47523. * @param state New state of the button
  47524. * @param changes Which properties on the state changed since last frame
  47525. */
  47526. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47527. }
  47528. }
  47529. declare module "babylonjs/Gamepads/Controllers/index" {
  47530. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47531. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47532. export * from "babylonjs/Gamepads/Controllers/genericController";
  47533. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47534. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47535. export * from "babylonjs/Gamepads/Controllers/viveController";
  47536. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47537. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47538. }
  47539. declare module "babylonjs/Gamepads/index" {
  47540. export * from "babylonjs/Gamepads/Controllers/index";
  47541. export * from "babylonjs/Gamepads/gamepad";
  47542. export * from "babylonjs/Gamepads/gamepadManager";
  47543. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47544. export * from "babylonjs/Gamepads/xboxGamepad";
  47545. export * from "babylonjs/Gamepads/dualShockGamepad";
  47546. }
  47547. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47548. import { Scene } from "babylonjs/scene";
  47549. import { Vector4 } from "babylonjs/Maths/math.vector";
  47550. import { Color4 } from "babylonjs/Maths/math.color";
  47551. import { Mesh } from "babylonjs/Meshes/mesh";
  47552. import { Nullable } from "babylonjs/types";
  47553. /**
  47554. * Class containing static functions to help procedurally build meshes
  47555. */
  47556. export class PolyhedronBuilder {
  47557. /**
  47558. * Creates a polyhedron mesh
  47559. * * 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
  47560. * * The parameter `size` (positive float, default 1) sets the polygon size
  47561. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47562. * * 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`
  47563. * * 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
  47564. * * 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)`)
  47565. * * 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
  47566. * * 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
  47567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47570. * @param name defines the name of the mesh
  47571. * @param options defines the options used to create the mesh
  47572. * @param scene defines the hosting scene
  47573. * @returns the polyhedron mesh
  47574. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47575. */
  47576. static CreatePolyhedron(name: string, options: {
  47577. type?: number;
  47578. size?: number;
  47579. sizeX?: number;
  47580. sizeY?: number;
  47581. sizeZ?: number;
  47582. custom?: any;
  47583. faceUV?: Vector4[];
  47584. faceColors?: Color4[];
  47585. flat?: boolean;
  47586. updatable?: boolean;
  47587. sideOrientation?: number;
  47588. frontUVs?: Vector4;
  47589. backUVs?: Vector4;
  47590. }, scene?: Nullable<Scene>): Mesh;
  47591. }
  47592. }
  47593. declare module "babylonjs/Gizmos/scaleGizmo" {
  47594. import { Observable } from "babylonjs/Misc/observable";
  47595. import { Nullable } from "babylonjs/types";
  47596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47597. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47598. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47600. /**
  47601. * Gizmo that enables scaling a mesh along 3 axis
  47602. */
  47603. export class ScaleGizmo extends Gizmo {
  47604. /**
  47605. * Internal gizmo used for interactions on the x axis
  47606. */
  47607. xGizmo: AxisScaleGizmo;
  47608. /**
  47609. * Internal gizmo used for interactions on the y axis
  47610. */
  47611. yGizmo: AxisScaleGizmo;
  47612. /**
  47613. * Internal gizmo used for interactions on the z axis
  47614. */
  47615. zGizmo: AxisScaleGizmo;
  47616. /**
  47617. * Internal gizmo used to scale all axis equally
  47618. */
  47619. uniformScaleGizmo: AxisScaleGizmo;
  47620. private _meshAttached;
  47621. private _updateGizmoRotationToMatchAttachedMesh;
  47622. private _snapDistance;
  47623. private _scaleRatio;
  47624. private _uniformScalingMesh;
  47625. private _octahedron;
  47626. /** Fires an event when any of it's sub gizmos are dragged */
  47627. onDragStartObservable: Observable<unknown>;
  47628. /** Fires an event when any of it's sub gizmos are released from dragging */
  47629. onDragEndObservable: Observable<unknown>;
  47630. attachedMesh: Nullable<AbstractMesh>;
  47631. /**
  47632. * Creates a ScaleGizmo
  47633. * @param gizmoLayer The utility layer the gizmo will be added to
  47634. */
  47635. constructor(gizmoLayer?: UtilityLayerRenderer);
  47636. updateGizmoRotationToMatchAttachedMesh: boolean;
  47637. /**
  47638. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47639. */
  47640. snapDistance: number;
  47641. /**
  47642. * Ratio for the scale of the gizmo (Default: 1)
  47643. */
  47644. scaleRatio: number;
  47645. /**
  47646. * Disposes of the gizmo
  47647. */
  47648. dispose(): void;
  47649. }
  47650. }
  47651. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47652. import { Observable } from "babylonjs/Misc/observable";
  47653. import { Nullable } from "babylonjs/types";
  47654. import { Vector3 } from "babylonjs/Maths/math.vector";
  47655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47656. import { Mesh } from "babylonjs/Meshes/mesh";
  47657. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47658. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47659. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47660. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47661. import { Color3 } from "babylonjs/Maths/math.color";
  47662. /**
  47663. * Single axis scale gizmo
  47664. */
  47665. export class AxisScaleGizmo extends Gizmo {
  47666. /**
  47667. * Drag behavior responsible for the gizmos dragging interactions
  47668. */
  47669. dragBehavior: PointerDragBehavior;
  47670. private _pointerObserver;
  47671. /**
  47672. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47673. */
  47674. snapDistance: number;
  47675. /**
  47676. * Event that fires each time the gizmo snaps to a new location.
  47677. * * snapDistance is the the change in distance
  47678. */
  47679. onSnapObservable: Observable<{
  47680. snapDistance: number;
  47681. }>;
  47682. /**
  47683. * If the scaling operation should be done on all axis (default: false)
  47684. */
  47685. uniformScaling: boolean;
  47686. private _isEnabled;
  47687. private _parent;
  47688. private _arrow;
  47689. private _coloredMaterial;
  47690. private _hoverMaterial;
  47691. /**
  47692. * Creates an AxisScaleGizmo
  47693. * @param gizmoLayer The utility layer the gizmo will be added to
  47694. * @param dragAxis The axis which the gizmo will be able to scale on
  47695. * @param color The color of the gizmo
  47696. */
  47697. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47699. /**
  47700. * If the gizmo is enabled
  47701. */
  47702. isEnabled: boolean;
  47703. /**
  47704. * Disposes of the gizmo
  47705. */
  47706. dispose(): void;
  47707. /**
  47708. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47709. * @param mesh The mesh to replace the default mesh of the gizmo
  47710. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47711. */
  47712. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47713. }
  47714. }
  47715. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47716. import { Observable } from "babylonjs/Misc/observable";
  47717. import { Nullable } from "babylonjs/types";
  47718. import { Vector3 } from "babylonjs/Maths/math.vector";
  47719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47720. import { Mesh } from "babylonjs/Meshes/mesh";
  47721. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47722. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47723. import { Color3 } from "babylonjs/Maths/math.color";
  47724. import "babylonjs/Meshes/Builders/boxBuilder";
  47725. /**
  47726. * Bounding box gizmo
  47727. */
  47728. export class BoundingBoxGizmo extends Gizmo {
  47729. private _lineBoundingBox;
  47730. private _rotateSpheresParent;
  47731. private _scaleBoxesParent;
  47732. private _boundingDimensions;
  47733. private _renderObserver;
  47734. private _pointerObserver;
  47735. private _scaleDragSpeed;
  47736. private _tmpQuaternion;
  47737. private _tmpVector;
  47738. private _tmpRotationMatrix;
  47739. /**
  47740. * 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)
  47741. */
  47742. ignoreChildren: boolean;
  47743. /**
  47744. * 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)
  47745. */
  47746. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47747. /**
  47748. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47749. */
  47750. rotationSphereSize: number;
  47751. /**
  47752. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47753. */
  47754. scaleBoxSize: number;
  47755. /**
  47756. * 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)
  47757. */
  47758. fixedDragMeshScreenSize: boolean;
  47759. /**
  47760. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47761. */
  47762. fixedDragMeshScreenSizeDistanceFactor: number;
  47763. /**
  47764. * Fired when a rotation sphere or scale box is dragged
  47765. */
  47766. onDragStartObservable: Observable<{}>;
  47767. /**
  47768. * Fired when a scale box is dragged
  47769. */
  47770. onScaleBoxDragObservable: Observable<{}>;
  47771. /**
  47772. * Fired when a scale box drag is ended
  47773. */
  47774. onScaleBoxDragEndObservable: Observable<{}>;
  47775. /**
  47776. * Fired when a rotation sphere is dragged
  47777. */
  47778. onRotationSphereDragObservable: Observable<{}>;
  47779. /**
  47780. * Fired when a rotation sphere drag is ended
  47781. */
  47782. onRotationSphereDragEndObservable: Observable<{}>;
  47783. /**
  47784. * 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)
  47785. */
  47786. scalePivot: Nullable<Vector3>;
  47787. /**
  47788. * Mesh used as a pivot to rotate the attached mesh
  47789. */
  47790. private _anchorMesh;
  47791. private _existingMeshScale;
  47792. private _dragMesh;
  47793. private pointerDragBehavior;
  47794. private coloredMaterial;
  47795. private hoverColoredMaterial;
  47796. /**
  47797. * Sets the color of the bounding box gizmo
  47798. * @param color the color to set
  47799. */
  47800. setColor(color: Color3): void;
  47801. /**
  47802. * Creates an BoundingBoxGizmo
  47803. * @param gizmoLayer The utility layer the gizmo will be added to
  47804. * @param color The color of the gizmo
  47805. */
  47806. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47807. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47808. private _selectNode;
  47809. /**
  47810. * Updates the bounding box information for the Gizmo
  47811. */
  47812. updateBoundingBox(): void;
  47813. private _updateRotationSpheres;
  47814. private _updateScaleBoxes;
  47815. /**
  47816. * Enables rotation on the specified axis and disables rotation on the others
  47817. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47818. */
  47819. setEnabledRotationAxis(axis: string): void;
  47820. /**
  47821. * Enables/disables scaling
  47822. * @param enable if scaling should be enabled
  47823. */
  47824. setEnabledScaling(enable: boolean): void;
  47825. private _updateDummy;
  47826. /**
  47827. * Enables a pointer drag behavior on the bounding box of the gizmo
  47828. */
  47829. enableDragBehavior(): void;
  47830. /**
  47831. * Disposes of the gizmo
  47832. */
  47833. dispose(): void;
  47834. /**
  47835. * 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)
  47836. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47837. * @returns the bounding box mesh with the passed in mesh as a child
  47838. */
  47839. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47840. /**
  47841. * CustomMeshes are not supported by this gizmo
  47842. * @param mesh The mesh to replace the default mesh of the gizmo
  47843. */
  47844. setCustomMesh(mesh: Mesh): void;
  47845. }
  47846. }
  47847. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47848. import { Observable } from "babylonjs/Misc/observable";
  47849. import { Nullable } from "babylonjs/types";
  47850. import { Vector3 } from "babylonjs/Maths/math.vector";
  47851. import { Color3 } from "babylonjs/Maths/math.color";
  47852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47853. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47854. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47855. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47856. import "babylonjs/Meshes/Builders/linesBuilder";
  47857. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47858. /**
  47859. * Single plane rotation gizmo
  47860. */
  47861. export class PlaneRotationGizmo extends Gizmo {
  47862. /**
  47863. * Drag behavior responsible for the gizmos dragging interactions
  47864. */
  47865. dragBehavior: PointerDragBehavior;
  47866. private _pointerObserver;
  47867. /**
  47868. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47869. */
  47870. snapDistance: number;
  47871. /**
  47872. * Event that fires each time the gizmo snaps to a new location.
  47873. * * snapDistance is the the change in distance
  47874. */
  47875. onSnapObservable: Observable<{
  47876. snapDistance: number;
  47877. }>;
  47878. private _isEnabled;
  47879. private _parent;
  47880. /**
  47881. * Creates a PlaneRotationGizmo
  47882. * @param gizmoLayer The utility layer the gizmo will be added to
  47883. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47884. * @param color The color of the gizmo
  47885. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47886. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47887. */
  47888. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47889. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47890. /**
  47891. * If the gizmo is enabled
  47892. */
  47893. isEnabled: boolean;
  47894. /**
  47895. * Disposes of the gizmo
  47896. */
  47897. dispose(): void;
  47898. }
  47899. }
  47900. declare module "babylonjs/Gizmos/rotationGizmo" {
  47901. import { Observable } from "babylonjs/Misc/observable";
  47902. import { Nullable } from "babylonjs/types";
  47903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47904. import { Mesh } from "babylonjs/Meshes/mesh";
  47905. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47906. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47907. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47908. /**
  47909. * Gizmo that enables rotating a mesh along 3 axis
  47910. */
  47911. export class RotationGizmo extends Gizmo {
  47912. /**
  47913. * Internal gizmo used for interactions on the x axis
  47914. */
  47915. xGizmo: PlaneRotationGizmo;
  47916. /**
  47917. * Internal gizmo used for interactions on the y axis
  47918. */
  47919. yGizmo: PlaneRotationGizmo;
  47920. /**
  47921. * Internal gizmo used for interactions on the z axis
  47922. */
  47923. zGizmo: PlaneRotationGizmo;
  47924. /** Fires an event when any of it's sub gizmos are dragged */
  47925. onDragStartObservable: Observable<unknown>;
  47926. /** Fires an event when any of it's sub gizmos are released from dragging */
  47927. onDragEndObservable: Observable<unknown>;
  47928. private _meshAttached;
  47929. attachedMesh: Nullable<AbstractMesh>;
  47930. /**
  47931. * Creates a RotationGizmo
  47932. * @param gizmoLayer The utility layer the gizmo will be added to
  47933. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47934. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47935. */
  47936. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47937. updateGizmoRotationToMatchAttachedMesh: boolean;
  47938. /**
  47939. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47940. */
  47941. snapDistance: number;
  47942. /**
  47943. * Ratio for the scale of the gizmo (Default: 1)
  47944. */
  47945. scaleRatio: number;
  47946. /**
  47947. * Disposes of the gizmo
  47948. */
  47949. dispose(): void;
  47950. /**
  47951. * CustomMeshes are not supported by this gizmo
  47952. * @param mesh The mesh to replace the default mesh of the gizmo
  47953. */
  47954. setCustomMesh(mesh: Mesh): void;
  47955. }
  47956. }
  47957. declare module "babylonjs/Gizmos/gizmoManager" {
  47958. import { Observable } from "babylonjs/Misc/observable";
  47959. import { Nullable } from "babylonjs/types";
  47960. import { Scene, IDisposable } from "babylonjs/scene";
  47961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47962. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47963. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47964. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47965. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47966. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47967. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47968. /**
  47969. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47970. */
  47971. export class GizmoManager implements IDisposable {
  47972. private scene;
  47973. /**
  47974. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47975. */
  47976. gizmos: {
  47977. positionGizmo: Nullable<PositionGizmo>;
  47978. rotationGizmo: Nullable<RotationGizmo>;
  47979. scaleGizmo: Nullable<ScaleGizmo>;
  47980. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47981. };
  47982. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47983. clearGizmoOnEmptyPointerEvent: boolean;
  47984. /** Fires an event when the manager is attached to a mesh */
  47985. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47986. private _gizmosEnabled;
  47987. private _pointerObserver;
  47988. private _attachedMesh;
  47989. private _boundingBoxColor;
  47990. private _defaultUtilityLayer;
  47991. private _defaultKeepDepthUtilityLayer;
  47992. /**
  47993. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47994. */
  47995. boundingBoxDragBehavior: SixDofDragBehavior;
  47996. /**
  47997. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47998. */
  47999. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48000. /**
  48001. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48002. */
  48003. usePointerToAttachGizmos: boolean;
  48004. /**
  48005. * Utility layer that the bounding box gizmo belongs to
  48006. */
  48007. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48008. /**
  48009. * Utility layer that all gizmos besides bounding box belong to
  48010. */
  48011. readonly utilityLayer: UtilityLayerRenderer;
  48012. /**
  48013. * Instatiates a gizmo manager
  48014. * @param scene the scene to overlay the gizmos on top of
  48015. */
  48016. constructor(scene: Scene);
  48017. /**
  48018. * Attaches a set of gizmos to the specified mesh
  48019. * @param mesh The mesh the gizmo's should be attached to
  48020. */
  48021. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48022. /**
  48023. * If the position gizmo is enabled
  48024. */
  48025. positionGizmoEnabled: boolean;
  48026. /**
  48027. * If the rotation gizmo is enabled
  48028. */
  48029. rotationGizmoEnabled: boolean;
  48030. /**
  48031. * If the scale gizmo is enabled
  48032. */
  48033. scaleGizmoEnabled: boolean;
  48034. /**
  48035. * If the boundingBox gizmo is enabled
  48036. */
  48037. boundingBoxGizmoEnabled: boolean;
  48038. /**
  48039. * Disposes of the gizmo manager
  48040. */
  48041. dispose(): void;
  48042. }
  48043. }
  48044. declare module "babylonjs/Lights/directionalLight" {
  48045. import { Camera } from "babylonjs/Cameras/camera";
  48046. import { Scene } from "babylonjs/scene";
  48047. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48049. import { Light } from "babylonjs/Lights/light";
  48050. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48051. import { Effect } from "babylonjs/Materials/effect";
  48052. /**
  48053. * A directional light is defined by a direction (what a surprise!).
  48054. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48055. * 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.
  48056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48057. */
  48058. export class DirectionalLight extends ShadowLight {
  48059. private _shadowFrustumSize;
  48060. /**
  48061. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48062. */
  48063. /**
  48064. * Specifies a fix frustum size for the shadow generation.
  48065. */
  48066. shadowFrustumSize: number;
  48067. private _shadowOrthoScale;
  48068. /**
  48069. * Gets the shadow projection scale against the optimal computed one.
  48070. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48071. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48072. */
  48073. /**
  48074. * Sets the shadow projection scale against the optimal computed one.
  48075. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48076. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48077. */
  48078. shadowOrthoScale: number;
  48079. /**
  48080. * Automatically compute the projection matrix to best fit (including all the casters)
  48081. * on each frame.
  48082. */
  48083. autoUpdateExtends: boolean;
  48084. private _orthoLeft;
  48085. private _orthoRight;
  48086. private _orthoTop;
  48087. private _orthoBottom;
  48088. /**
  48089. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48090. * The directional light is emitted from everywhere in the given direction.
  48091. * It can cast shadows.
  48092. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48093. * @param name The friendly name of the light
  48094. * @param direction The direction of the light
  48095. * @param scene The scene the light belongs to
  48096. */
  48097. constructor(name: string, direction: Vector3, scene: Scene);
  48098. /**
  48099. * Returns the string "DirectionalLight".
  48100. * @return The class name
  48101. */
  48102. getClassName(): string;
  48103. /**
  48104. * Returns the integer 1.
  48105. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48106. */
  48107. getTypeID(): number;
  48108. /**
  48109. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48110. * Returns the DirectionalLight Shadow projection matrix.
  48111. */
  48112. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48113. /**
  48114. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48115. * Returns the DirectionalLight Shadow projection matrix.
  48116. */
  48117. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48118. /**
  48119. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48120. * Returns the DirectionalLight Shadow projection matrix.
  48121. */
  48122. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48123. protected _buildUniformLayout(): void;
  48124. /**
  48125. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48126. * @param effect The effect to update
  48127. * @param lightIndex The index of the light in the effect to update
  48128. * @returns The directional light
  48129. */
  48130. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48131. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48132. /**
  48133. * Gets the minZ used for shadow according to both the scene and the light.
  48134. *
  48135. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48136. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48137. * @param activeCamera The camera we are returning the min for
  48138. * @returns the depth min z
  48139. */
  48140. getDepthMinZ(activeCamera: Camera): number;
  48141. /**
  48142. * Gets the maxZ used for shadow according to both the scene and the light.
  48143. *
  48144. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48145. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48146. * @param activeCamera The camera we are returning the max for
  48147. * @returns the depth max z
  48148. */
  48149. getDepthMaxZ(activeCamera: Camera): number;
  48150. /**
  48151. * Prepares the list of defines specific to the light type.
  48152. * @param defines the list of defines
  48153. * @param lightIndex defines the index of the light for the effect
  48154. */
  48155. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48156. }
  48157. }
  48158. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48159. import { Mesh } from "babylonjs/Meshes/mesh";
  48160. /**
  48161. * Class containing static functions to help procedurally build meshes
  48162. */
  48163. export class HemisphereBuilder {
  48164. /**
  48165. * Creates a hemisphere mesh
  48166. * @param name defines the name of the mesh
  48167. * @param options defines the options used to create the mesh
  48168. * @param scene defines the hosting scene
  48169. * @returns the hemisphere mesh
  48170. */
  48171. static CreateHemisphere(name: string, options: {
  48172. segments?: number;
  48173. diameter?: number;
  48174. sideOrientation?: number;
  48175. }, scene: any): Mesh;
  48176. }
  48177. }
  48178. declare module "babylonjs/Lights/spotLight" {
  48179. import { Nullable } from "babylonjs/types";
  48180. import { Scene } from "babylonjs/scene";
  48181. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48183. import { Effect } from "babylonjs/Materials/effect";
  48184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48185. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48186. /**
  48187. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48188. * These values define a cone of light starting from the position, emitting toward the direction.
  48189. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48190. * and the exponent defines the speed of the decay of the light with distance (reach).
  48191. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48192. */
  48193. export class SpotLight extends ShadowLight {
  48194. private _angle;
  48195. private _innerAngle;
  48196. private _cosHalfAngle;
  48197. private _lightAngleScale;
  48198. private _lightAngleOffset;
  48199. /**
  48200. * Gets the cone angle of the spot light in Radians.
  48201. */
  48202. /**
  48203. * Sets the cone angle of the spot light in Radians.
  48204. */
  48205. angle: number;
  48206. /**
  48207. * Only used in gltf falloff mode, this defines the angle where
  48208. * the directional falloff will start before cutting at angle which could be seen
  48209. * as outer angle.
  48210. */
  48211. /**
  48212. * Only used in gltf falloff mode, this defines the angle where
  48213. * the directional falloff will start before cutting at angle which could be seen
  48214. * as outer angle.
  48215. */
  48216. innerAngle: number;
  48217. private _shadowAngleScale;
  48218. /**
  48219. * Allows scaling the angle of the light for shadow generation only.
  48220. */
  48221. /**
  48222. * Allows scaling the angle of the light for shadow generation only.
  48223. */
  48224. shadowAngleScale: number;
  48225. /**
  48226. * The light decay speed with the distance from the emission spot.
  48227. */
  48228. exponent: number;
  48229. private _projectionTextureMatrix;
  48230. /**
  48231. * Allows reading the projecton texture
  48232. */
  48233. readonly projectionTextureMatrix: Matrix;
  48234. protected _projectionTextureLightNear: number;
  48235. /**
  48236. * Gets the near clip of the Spotlight for texture projection.
  48237. */
  48238. /**
  48239. * Sets the near clip of the Spotlight for texture projection.
  48240. */
  48241. projectionTextureLightNear: number;
  48242. protected _projectionTextureLightFar: number;
  48243. /**
  48244. * Gets the far clip of the Spotlight for texture projection.
  48245. */
  48246. /**
  48247. * Sets the far clip of the Spotlight for texture projection.
  48248. */
  48249. projectionTextureLightFar: number;
  48250. protected _projectionTextureUpDirection: Vector3;
  48251. /**
  48252. * Gets the Up vector of the Spotlight for texture projection.
  48253. */
  48254. /**
  48255. * Sets the Up vector of the Spotlight for texture projection.
  48256. */
  48257. projectionTextureUpDirection: Vector3;
  48258. private _projectionTexture;
  48259. /**
  48260. * Gets the projection texture of the light.
  48261. */
  48262. /**
  48263. * Sets the projection texture of the light.
  48264. */
  48265. projectionTexture: Nullable<BaseTexture>;
  48266. private _projectionTextureViewLightDirty;
  48267. private _projectionTextureProjectionLightDirty;
  48268. private _projectionTextureDirty;
  48269. private _projectionTextureViewTargetVector;
  48270. private _projectionTextureViewLightMatrix;
  48271. private _projectionTextureProjectionLightMatrix;
  48272. private _projectionTextureScalingMatrix;
  48273. /**
  48274. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48275. * It can cast shadows.
  48276. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48277. * @param name The light friendly name
  48278. * @param position The position of the spot light in the scene
  48279. * @param direction The direction of the light in the scene
  48280. * @param angle The cone angle of the light in Radians
  48281. * @param exponent The light decay speed with the distance from the emission spot
  48282. * @param scene The scene the lights belongs to
  48283. */
  48284. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48285. /**
  48286. * Returns the string "SpotLight".
  48287. * @returns the class name
  48288. */
  48289. getClassName(): string;
  48290. /**
  48291. * Returns the integer 2.
  48292. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48293. */
  48294. getTypeID(): number;
  48295. /**
  48296. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48297. */
  48298. protected _setDirection(value: Vector3): void;
  48299. /**
  48300. * Overrides the position setter to recompute the projection texture view light Matrix.
  48301. */
  48302. protected _setPosition(value: Vector3): void;
  48303. /**
  48304. * 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.
  48305. * Returns the SpotLight.
  48306. */
  48307. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48308. protected _computeProjectionTextureViewLightMatrix(): void;
  48309. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48310. /**
  48311. * Main function for light texture projection matrix computing.
  48312. */
  48313. protected _computeProjectionTextureMatrix(): void;
  48314. protected _buildUniformLayout(): void;
  48315. private _computeAngleValues;
  48316. /**
  48317. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48318. * @param effect The effect to update
  48319. * @param lightIndex The index of the light in the effect to update
  48320. * @returns The spot light
  48321. */
  48322. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48323. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48324. /**
  48325. * Disposes the light and the associated resources.
  48326. */
  48327. dispose(): void;
  48328. /**
  48329. * Prepares the list of defines specific to the light type.
  48330. * @param defines the list of defines
  48331. * @param lightIndex defines the index of the light for the effect
  48332. */
  48333. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48334. }
  48335. }
  48336. declare module "babylonjs/Gizmos/lightGizmo" {
  48337. import { Nullable } from "babylonjs/types";
  48338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48339. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48340. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48341. import { Light } from "babylonjs/Lights/light";
  48342. /**
  48343. * Gizmo that enables viewing a light
  48344. */
  48345. export class LightGizmo extends Gizmo {
  48346. private _lightMesh;
  48347. private _material;
  48348. private cachedPosition;
  48349. private cachedForward;
  48350. /**
  48351. * Creates a LightGizmo
  48352. * @param gizmoLayer The utility layer the gizmo will be added to
  48353. */
  48354. constructor(gizmoLayer?: UtilityLayerRenderer);
  48355. private _light;
  48356. /**
  48357. * The light that the gizmo is attached to
  48358. */
  48359. light: Nullable<Light>;
  48360. /**
  48361. * Gets the material used to render the light gizmo
  48362. */
  48363. readonly material: StandardMaterial;
  48364. /**
  48365. * @hidden
  48366. * Updates the gizmo to match the attached mesh's position/rotation
  48367. */
  48368. protected _update(): void;
  48369. private static _Scale;
  48370. /**
  48371. * Creates the lines for a light mesh
  48372. */
  48373. private static _createLightLines;
  48374. /**
  48375. * Disposes of the light gizmo
  48376. */
  48377. dispose(): void;
  48378. private static _CreateHemisphericLightMesh;
  48379. private static _CreatePointLightMesh;
  48380. private static _CreateSpotLightMesh;
  48381. private static _CreateDirectionalLightMesh;
  48382. }
  48383. }
  48384. declare module "babylonjs/Gizmos/index" {
  48385. export * from "babylonjs/Gizmos/axisDragGizmo";
  48386. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48387. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48388. export * from "babylonjs/Gizmos/gizmo";
  48389. export * from "babylonjs/Gizmos/gizmoManager";
  48390. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48391. export * from "babylonjs/Gizmos/positionGizmo";
  48392. export * from "babylonjs/Gizmos/rotationGizmo";
  48393. export * from "babylonjs/Gizmos/scaleGizmo";
  48394. export * from "babylonjs/Gizmos/lightGizmo";
  48395. export * from "babylonjs/Gizmos/planeDragGizmo";
  48396. }
  48397. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48398. /** @hidden */
  48399. export var backgroundFragmentDeclaration: {
  48400. name: string;
  48401. shader: string;
  48402. };
  48403. }
  48404. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48405. /** @hidden */
  48406. export var backgroundUboDeclaration: {
  48407. name: string;
  48408. shader: string;
  48409. };
  48410. }
  48411. declare module "babylonjs/Shaders/background.fragment" {
  48412. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48413. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48414. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48415. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48416. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48417. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48418. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48419. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48420. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48421. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48423. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48425. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48426. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48427. /** @hidden */
  48428. export var backgroundPixelShader: {
  48429. name: string;
  48430. shader: string;
  48431. };
  48432. }
  48433. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48434. /** @hidden */
  48435. export var backgroundVertexDeclaration: {
  48436. name: string;
  48437. shader: string;
  48438. };
  48439. }
  48440. declare module "babylonjs/Shaders/background.vertex" {
  48441. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48442. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48444. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48445. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48446. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48447. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48448. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48449. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48450. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48451. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48452. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48453. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48454. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48455. /** @hidden */
  48456. export var backgroundVertexShader: {
  48457. name: string;
  48458. shader: string;
  48459. };
  48460. }
  48461. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48462. import { Nullable, int, float } from "babylonjs/types";
  48463. import { Scene } from "babylonjs/scene";
  48464. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48467. import { Mesh } from "babylonjs/Meshes/mesh";
  48468. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48469. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48470. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48472. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48473. import { Color3 } from "babylonjs/Maths/math.color";
  48474. import "babylonjs/Shaders/background.fragment";
  48475. import "babylonjs/Shaders/background.vertex";
  48476. /**
  48477. * Background material used to create an efficient environement around your scene.
  48478. */
  48479. export class BackgroundMaterial extends PushMaterial {
  48480. /**
  48481. * Standard reflectance value at parallel view angle.
  48482. */
  48483. static StandardReflectance0: number;
  48484. /**
  48485. * Standard reflectance value at grazing angle.
  48486. */
  48487. static StandardReflectance90: number;
  48488. protected _primaryColor: Color3;
  48489. /**
  48490. * Key light Color (multiply against the environement texture)
  48491. */
  48492. primaryColor: Color3;
  48493. protected __perceptualColor: Nullable<Color3>;
  48494. /**
  48495. * Experimental Internal Use Only.
  48496. *
  48497. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48498. * This acts as a helper to set the primary color to a more "human friendly" value.
  48499. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48500. * output color as close as possible from the chosen value.
  48501. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48502. * part of lighting setup.)
  48503. */
  48504. _perceptualColor: Nullable<Color3>;
  48505. protected _primaryColorShadowLevel: float;
  48506. /**
  48507. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48508. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48509. */
  48510. primaryColorShadowLevel: float;
  48511. protected _primaryColorHighlightLevel: float;
  48512. /**
  48513. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48514. * The primary color is used at the level chosen to define what the white area would look.
  48515. */
  48516. primaryColorHighlightLevel: float;
  48517. protected _reflectionTexture: Nullable<BaseTexture>;
  48518. /**
  48519. * Reflection Texture used in the material.
  48520. * Should be author in a specific way for the best result (refer to the documentation).
  48521. */
  48522. reflectionTexture: Nullable<BaseTexture>;
  48523. protected _reflectionBlur: float;
  48524. /**
  48525. * Reflection Texture level of blur.
  48526. *
  48527. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48528. * texture twice.
  48529. */
  48530. reflectionBlur: float;
  48531. protected _diffuseTexture: Nullable<BaseTexture>;
  48532. /**
  48533. * Diffuse Texture used in the material.
  48534. * Should be author in a specific way for the best result (refer to the documentation).
  48535. */
  48536. diffuseTexture: Nullable<BaseTexture>;
  48537. protected _shadowLights: Nullable<IShadowLight[]>;
  48538. /**
  48539. * Specify the list of lights casting shadow on the material.
  48540. * All scene shadow lights will be included if null.
  48541. */
  48542. shadowLights: Nullable<IShadowLight[]>;
  48543. protected _shadowLevel: float;
  48544. /**
  48545. * Helps adjusting the shadow to a softer level if required.
  48546. * 0 means black shadows and 1 means no shadows.
  48547. */
  48548. shadowLevel: float;
  48549. protected _sceneCenter: Vector3;
  48550. /**
  48551. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48552. * It is usually zero but might be interesting to modify according to your setup.
  48553. */
  48554. sceneCenter: Vector3;
  48555. protected _opacityFresnel: boolean;
  48556. /**
  48557. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48558. * This helps ensuring a nice transition when the camera goes under the ground.
  48559. */
  48560. opacityFresnel: boolean;
  48561. protected _reflectionFresnel: boolean;
  48562. /**
  48563. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48564. * This helps adding a mirror texture on the ground.
  48565. */
  48566. reflectionFresnel: boolean;
  48567. protected _reflectionFalloffDistance: number;
  48568. /**
  48569. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48570. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48571. */
  48572. reflectionFalloffDistance: number;
  48573. protected _reflectionAmount: number;
  48574. /**
  48575. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48576. */
  48577. reflectionAmount: number;
  48578. protected _reflectionReflectance0: number;
  48579. /**
  48580. * This specifies the weight of the reflection at grazing angle.
  48581. */
  48582. reflectionReflectance0: number;
  48583. protected _reflectionReflectance90: number;
  48584. /**
  48585. * This specifies the weight of the reflection at a perpendicular point of view.
  48586. */
  48587. reflectionReflectance90: number;
  48588. /**
  48589. * Sets the reflection reflectance fresnel values according to the default standard
  48590. * empirically know to work well :-)
  48591. */
  48592. reflectionStandardFresnelWeight: number;
  48593. protected _useRGBColor: boolean;
  48594. /**
  48595. * Helps to directly use the maps channels instead of their level.
  48596. */
  48597. useRGBColor: boolean;
  48598. protected _enableNoise: boolean;
  48599. /**
  48600. * This helps reducing the banding effect that could occur on the background.
  48601. */
  48602. enableNoise: boolean;
  48603. /**
  48604. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48605. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48606. * Recommended to be keep at 1.0 except for special cases.
  48607. */
  48608. fovMultiplier: number;
  48609. private _fovMultiplier;
  48610. /**
  48611. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48612. */
  48613. useEquirectangularFOV: boolean;
  48614. private _maxSimultaneousLights;
  48615. /**
  48616. * Number of Simultaneous lights allowed on the material.
  48617. */
  48618. maxSimultaneousLights: int;
  48619. /**
  48620. * Default configuration related to image processing available in the Background Material.
  48621. */
  48622. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48623. /**
  48624. * Keep track of the image processing observer to allow dispose and replace.
  48625. */
  48626. private _imageProcessingObserver;
  48627. /**
  48628. * Attaches a new image processing configuration to the PBR Material.
  48629. * @param configuration (if null the scene configuration will be use)
  48630. */
  48631. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48632. /**
  48633. * Gets the image processing configuration used either in this material.
  48634. */
  48635. /**
  48636. * Sets the Default image processing configuration used either in the this material.
  48637. *
  48638. * If sets to null, the scene one is in use.
  48639. */
  48640. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48641. /**
  48642. * Gets wether the color curves effect is enabled.
  48643. */
  48644. /**
  48645. * Sets wether the color curves effect is enabled.
  48646. */
  48647. cameraColorCurvesEnabled: boolean;
  48648. /**
  48649. * Gets wether the color grading effect is enabled.
  48650. */
  48651. /**
  48652. * Gets wether the color grading effect is enabled.
  48653. */
  48654. cameraColorGradingEnabled: boolean;
  48655. /**
  48656. * Gets wether tonemapping is enabled or not.
  48657. */
  48658. /**
  48659. * Sets wether tonemapping is enabled or not
  48660. */
  48661. cameraToneMappingEnabled: boolean;
  48662. /**
  48663. * The camera exposure used on this material.
  48664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48665. * This corresponds to a photographic exposure.
  48666. */
  48667. /**
  48668. * The camera exposure used on this material.
  48669. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48670. * This corresponds to a photographic exposure.
  48671. */
  48672. cameraExposure: float;
  48673. /**
  48674. * Gets The camera contrast used on this material.
  48675. */
  48676. /**
  48677. * Sets The camera contrast used on this material.
  48678. */
  48679. cameraContrast: float;
  48680. /**
  48681. * Gets the Color Grading 2D Lookup Texture.
  48682. */
  48683. /**
  48684. * Sets the Color Grading 2D Lookup Texture.
  48685. */
  48686. cameraColorGradingTexture: Nullable<BaseTexture>;
  48687. /**
  48688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48690. * 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;
  48691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48692. */
  48693. /**
  48694. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48695. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48696. * 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;
  48697. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48698. */
  48699. cameraColorCurves: Nullable<ColorCurves>;
  48700. /**
  48701. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48702. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48703. */
  48704. switchToBGR: boolean;
  48705. private _renderTargets;
  48706. private _reflectionControls;
  48707. private _white;
  48708. private _primaryShadowColor;
  48709. private _primaryHighlightColor;
  48710. /**
  48711. * Instantiates a Background Material in the given scene
  48712. * @param name The friendly name of the material
  48713. * @param scene The scene to add the material to
  48714. */
  48715. constructor(name: string, scene: Scene);
  48716. /**
  48717. * Gets a boolean indicating that current material needs to register RTT
  48718. */
  48719. readonly hasRenderTargetTextures: boolean;
  48720. /**
  48721. * The entire material has been created in order to prevent overdraw.
  48722. * @returns false
  48723. */
  48724. needAlphaTesting(): boolean;
  48725. /**
  48726. * The entire material has been created in order to prevent overdraw.
  48727. * @returns true if blending is enable
  48728. */
  48729. needAlphaBlending(): boolean;
  48730. /**
  48731. * Checks wether the material is ready to be rendered for a given mesh.
  48732. * @param mesh The mesh to render
  48733. * @param subMesh The submesh to check against
  48734. * @param useInstances Specify wether or not the material is used with instances
  48735. * @returns true if all the dependencies are ready (Textures, Effects...)
  48736. */
  48737. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48738. /**
  48739. * Compute the primary color according to the chosen perceptual color.
  48740. */
  48741. private _computePrimaryColorFromPerceptualColor;
  48742. /**
  48743. * Compute the highlights and shadow colors according to their chosen levels.
  48744. */
  48745. private _computePrimaryColors;
  48746. /**
  48747. * Build the uniform buffer used in the material.
  48748. */
  48749. buildUniformLayout(): void;
  48750. /**
  48751. * Unbind the material.
  48752. */
  48753. unbind(): void;
  48754. /**
  48755. * Bind only the world matrix to the material.
  48756. * @param world The world matrix to bind.
  48757. */
  48758. bindOnlyWorldMatrix(world: Matrix): void;
  48759. /**
  48760. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48761. * @param world The world matrix to bind.
  48762. * @param subMesh The submesh to bind for.
  48763. */
  48764. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48765. /**
  48766. * Checks to see if a texture is used in the material.
  48767. * @param texture - Base texture to use.
  48768. * @returns - Boolean specifying if a texture is used in the material.
  48769. */
  48770. hasTexture(texture: BaseTexture): boolean;
  48771. /**
  48772. * Dispose the material.
  48773. * @param forceDisposeEffect Force disposal of the associated effect.
  48774. * @param forceDisposeTextures Force disposal of the associated textures.
  48775. */
  48776. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48777. /**
  48778. * Clones the material.
  48779. * @param name The cloned name.
  48780. * @returns The cloned material.
  48781. */
  48782. clone(name: string): BackgroundMaterial;
  48783. /**
  48784. * Serializes the current material to its JSON representation.
  48785. * @returns The JSON representation.
  48786. */
  48787. serialize(): any;
  48788. /**
  48789. * Gets the class name of the material
  48790. * @returns "BackgroundMaterial"
  48791. */
  48792. getClassName(): string;
  48793. /**
  48794. * Parse a JSON input to create back a background material.
  48795. * @param source The JSON data to parse
  48796. * @param scene The scene to create the parsed material in
  48797. * @param rootUrl The root url of the assets the material depends upon
  48798. * @returns the instantiated BackgroundMaterial.
  48799. */
  48800. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48801. }
  48802. }
  48803. declare module "babylonjs/Helpers/environmentHelper" {
  48804. import { Observable } from "babylonjs/Misc/observable";
  48805. import { Nullable } from "babylonjs/types";
  48806. import { Scene } from "babylonjs/scene";
  48807. import { Vector3 } from "babylonjs/Maths/math.vector";
  48808. import { Color3 } from "babylonjs/Maths/math.color";
  48809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48810. import { Mesh } from "babylonjs/Meshes/mesh";
  48811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48812. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48813. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48814. import "babylonjs/Meshes/Builders/planeBuilder";
  48815. import "babylonjs/Meshes/Builders/boxBuilder";
  48816. /**
  48817. * Represents the different options available during the creation of
  48818. * a Environment helper.
  48819. *
  48820. * This can control the default ground, skybox and image processing setup of your scene.
  48821. */
  48822. export interface IEnvironmentHelperOptions {
  48823. /**
  48824. * Specifies wether or not to create a ground.
  48825. * True by default.
  48826. */
  48827. createGround: boolean;
  48828. /**
  48829. * Specifies the ground size.
  48830. * 15 by default.
  48831. */
  48832. groundSize: number;
  48833. /**
  48834. * The texture used on the ground for the main color.
  48835. * Comes from the BabylonJS CDN by default.
  48836. *
  48837. * Remarks: Can be either a texture or a url.
  48838. */
  48839. groundTexture: string | BaseTexture;
  48840. /**
  48841. * The color mixed in the ground texture by default.
  48842. * BabylonJS clearColor by default.
  48843. */
  48844. groundColor: Color3;
  48845. /**
  48846. * Specifies the ground opacity.
  48847. * 1 by default.
  48848. */
  48849. groundOpacity: number;
  48850. /**
  48851. * Enables the ground to receive shadows.
  48852. * True by default.
  48853. */
  48854. enableGroundShadow: boolean;
  48855. /**
  48856. * Helps preventing the shadow to be fully black on the ground.
  48857. * 0.5 by default.
  48858. */
  48859. groundShadowLevel: number;
  48860. /**
  48861. * Creates a mirror texture attach to the ground.
  48862. * false by default.
  48863. */
  48864. enableGroundMirror: boolean;
  48865. /**
  48866. * Specifies the ground mirror size ratio.
  48867. * 0.3 by default as the default kernel is 64.
  48868. */
  48869. groundMirrorSizeRatio: number;
  48870. /**
  48871. * Specifies the ground mirror blur kernel size.
  48872. * 64 by default.
  48873. */
  48874. groundMirrorBlurKernel: number;
  48875. /**
  48876. * Specifies the ground mirror visibility amount.
  48877. * 1 by default
  48878. */
  48879. groundMirrorAmount: number;
  48880. /**
  48881. * Specifies the ground mirror reflectance weight.
  48882. * This uses the standard weight of the background material to setup the fresnel effect
  48883. * of the mirror.
  48884. * 1 by default.
  48885. */
  48886. groundMirrorFresnelWeight: number;
  48887. /**
  48888. * Specifies the ground mirror Falloff distance.
  48889. * This can helps reducing the size of the reflection.
  48890. * 0 by Default.
  48891. */
  48892. groundMirrorFallOffDistance: number;
  48893. /**
  48894. * Specifies the ground mirror texture type.
  48895. * Unsigned Int by Default.
  48896. */
  48897. groundMirrorTextureType: number;
  48898. /**
  48899. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48900. * the shown objects.
  48901. */
  48902. groundYBias: number;
  48903. /**
  48904. * Specifies wether or not to create a skybox.
  48905. * True by default.
  48906. */
  48907. createSkybox: boolean;
  48908. /**
  48909. * Specifies the skybox size.
  48910. * 20 by default.
  48911. */
  48912. skyboxSize: number;
  48913. /**
  48914. * The texture used on the skybox for the main color.
  48915. * Comes from the BabylonJS CDN by default.
  48916. *
  48917. * Remarks: Can be either a texture or a url.
  48918. */
  48919. skyboxTexture: string | BaseTexture;
  48920. /**
  48921. * The color mixed in the skybox texture by default.
  48922. * BabylonJS clearColor by default.
  48923. */
  48924. skyboxColor: Color3;
  48925. /**
  48926. * The background rotation around the Y axis of the scene.
  48927. * This helps aligning the key lights of your scene with the background.
  48928. * 0 by default.
  48929. */
  48930. backgroundYRotation: number;
  48931. /**
  48932. * Compute automatically the size of the elements to best fit with the scene.
  48933. */
  48934. sizeAuto: boolean;
  48935. /**
  48936. * Default position of the rootMesh if autoSize is not true.
  48937. */
  48938. rootPosition: Vector3;
  48939. /**
  48940. * Sets up the image processing in the scene.
  48941. * true by default.
  48942. */
  48943. setupImageProcessing: boolean;
  48944. /**
  48945. * The texture used as your environment texture in the scene.
  48946. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48947. *
  48948. * Remarks: Can be either a texture or a url.
  48949. */
  48950. environmentTexture: string | BaseTexture;
  48951. /**
  48952. * The value of the exposure to apply to the scene.
  48953. * 0.6 by default if setupImageProcessing is true.
  48954. */
  48955. cameraExposure: number;
  48956. /**
  48957. * The value of the contrast to apply to the scene.
  48958. * 1.6 by default if setupImageProcessing is true.
  48959. */
  48960. cameraContrast: number;
  48961. /**
  48962. * Specifies wether or not tonemapping should be enabled in the scene.
  48963. * true by default if setupImageProcessing is true.
  48964. */
  48965. toneMappingEnabled: boolean;
  48966. }
  48967. /**
  48968. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48969. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48970. * It also helps with the default setup of your imageProcessing configuration.
  48971. */
  48972. export class EnvironmentHelper {
  48973. /**
  48974. * Default ground texture URL.
  48975. */
  48976. private static _groundTextureCDNUrl;
  48977. /**
  48978. * Default skybox texture URL.
  48979. */
  48980. private static _skyboxTextureCDNUrl;
  48981. /**
  48982. * Default environment texture URL.
  48983. */
  48984. private static _environmentTextureCDNUrl;
  48985. /**
  48986. * Creates the default options for the helper.
  48987. */
  48988. private static _getDefaultOptions;
  48989. private _rootMesh;
  48990. /**
  48991. * Gets the root mesh created by the helper.
  48992. */
  48993. readonly rootMesh: Mesh;
  48994. private _skybox;
  48995. /**
  48996. * Gets the skybox created by the helper.
  48997. */
  48998. readonly skybox: Nullable<Mesh>;
  48999. private _skyboxTexture;
  49000. /**
  49001. * Gets the skybox texture created by the helper.
  49002. */
  49003. readonly skyboxTexture: Nullable<BaseTexture>;
  49004. private _skyboxMaterial;
  49005. /**
  49006. * Gets the skybox material created by the helper.
  49007. */
  49008. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49009. private _ground;
  49010. /**
  49011. * Gets the ground mesh created by the helper.
  49012. */
  49013. readonly ground: Nullable<Mesh>;
  49014. private _groundTexture;
  49015. /**
  49016. * Gets the ground texture created by the helper.
  49017. */
  49018. readonly groundTexture: Nullable<BaseTexture>;
  49019. private _groundMirror;
  49020. /**
  49021. * Gets the ground mirror created by the helper.
  49022. */
  49023. readonly groundMirror: Nullable<MirrorTexture>;
  49024. /**
  49025. * Gets the ground mirror render list to helps pushing the meshes
  49026. * you wish in the ground reflection.
  49027. */
  49028. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49029. private _groundMaterial;
  49030. /**
  49031. * Gets the ground material created by the helper.
  49032. */
  49033. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49034. /**
  49035. * Stores the creation options.
  49036. */
  49037. private readonly _scene;
  49038. private _options;
  49039. /**
  49040. * This observable will be notified with any error during the creation of the environment,
  49041. * mainly texture creation errors.
  49042. */
  49043. onErrorObservable: Observable<{
  49044. message?: string;
  49045. exception?: any;
  49046. }>;
  49047. /**
  49048. * constructor
  49049. * @param options Defines the options we want to customize the helper
  49050. * @param scene The scene to add the material to
  49051. */
  49052. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49053. /**
  49054. * Updates the background according to the new options
  49055. * @param options
  49056. */
  49057. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49058. /**
  49059. * Sets the primary color of all the available elements.
  49060. * @param color the main color to affect to the ground and the background
  49061. */
  49062. setMainColor(color: Color3): void;
  49063. /**
  49064. * Setup the image processing according to the specified options.
  49065. */
  49066. private _setupImageProcessing;
  49067. /**
  49068. * Setup the environment texture according to the specified options.
  49069. */
  49070. private _setupEnvironmentTexture;
  49071. /**
  49072. * Setup the background according to the specified options.
  49073. */
  49074. private _setupBackground;
  49075. /**
  49076. * Get the scene sizes according to the setup.
  49077. */
  49078. private _getSceneSize;
  49079. /**
  49080. * Setup the ground according to the specified options.
  49081. */
  49082. private _setupGround;
  49083. /**
  49084. * Setup the ground material according to the specified options.
  49085. */
  49086. private _setupGroundMaterial;
  49087. /**
  49088. * Setup the ground diffuse texture according to the specified options.
  49089. */
  49090. private _setupGroundDiffuseTexture;
  49091. /**
  49092. * Setup the ground mirror texture according to the specified options.
  49093. */
  49094. private _setupGroundMirrorTexture;
  49095. /**
  49096. * Setup the ground to receive the mirror texture.
  49097. */
  49098. private _setupMirrorInGroundMaterial;
  49099. /**
  49100. * Setup the skybox according to the specified options.
  49101. */
  49102. private _setupSkybox;
  49103. /**
  49104. * Setup the skybox material according to the specified options.
  49105. */
  49106. private _setupSkyboxMaterial;
  49107. /**
  49108. * Setup the skybox reflection texture according to the specified options.
  49109. */
  49110. private _setupSkyboxReflectionTexture;
  49111. private _errorHandler;
  49112. /**
  49113. * Dispose all the elements created by the Helper.
  49114. */
  49115. dispose(): void;
  49116. }
  49117. }
  49118. declare module "babylonjs/Helpers/photoDome" {
  49119. import { Observable } from "babylonjs/Misc/observable";
  49120. import { Nullable } from "babylonjs/types";
  49121. import { Scene } from "babylonjs/scene";
  49122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49123. import { Mesh } from "babylonjs/Meshes/mesh";
  49124. import { Texture } from "babylonjs/Materials/Textures/texture";
  49125. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49126. import "babylonjs/Meshes/Builders/sphereBuilder";
  49127. /**
  49128. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49129. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49130. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49131. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49132. */
  49133. export class PhotoDome extends TransformNode {
  49134. /**
  49135. * Define the image as a Monoscopic panoramic 360 image.
  49136. */
  49137. static readonly MODE_MONOSCOPIC: number;
  49138. /**
  49139. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49140. */
  49141. static readonly MODE_TOPBOTTOM: number;
  49142. /**
  49143. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49144. */
  49145. static readonly MODE_SIDEBYSIDE: number;
  49146. private _useDirectMapping;
  49147. /**
  49148. * The texture being displayed on the sphere
  49149. */
  49150. protected _photoTexture: Texture;
  49151. /**
  49152. * Gets or sets the texture being displayed on the sphere
  49153. */
  49154. photoTexture: Texture;
  49155. /**
  49156. * Observable raised when an error occured while loading the 360 image
  49157. */
  49158. onLoadErrorObservable: Observable<string>;
  49159. /**
  49160. * The skybox material
  49161. */
  49162. protected _material: BackgroundMaterial;
  49163. /**
  49164. * The surface used for the skybox
  49165. */
  49166. protected _mesh: Mesh;
  49167. /**
  49168. * Gets the mesh used for the skybox.
  49169. */
  49170. readonly mesh: Mesh;
  49171. /**
  49172. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49173. * Also see the options.resolution property.
  49174. */
  49175. fovMultiplier: number;
  49176. private _imageMode;
  49177. /**
  49178. * Gets or set the current video mode for the video. It can be:
  49179. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49180. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49181. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49182. */
  49183. imageMode: number;
  49184. /**
  49185. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49186. * @param name Element's name, child elements will append suffixes for their own names.
  49187. * @param urlsOfPhoto defines the url of the photo to display
  49188. * @param options defines an object containing optional or exposed sub element properties
  49189. * @param onError defines a callback called when an error occured while loading the texture
  49190. */
  49191. constructor(name: string, urlOfPhoto: string, options: {
  49192. resolution?: number;
  49193. size?: number;
  49194. useDirectMapping?: boolean;
  49195. faceForward?: boolean;
  49196. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49197. private _onBeforeCameraRenderObserver;
  49198. private _changeImageMode;
  49199. /**
  49200. * Releases resources associated with this node.
  49201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49203. */
  49204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49205. }
  49206. }
  49207. declare module "babylonjs/Misc/rgbdTextureTools" {
  49208. import "babylonjs/Shaders/rgbdDecode.fragment";
  49209. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49210. import { Texture } from "babylonjs/Materials/Textures/texture";
  49211. /**
  49212. * Class used to host RGBD texture specific utilities
  49213. */
  49214. export class RGBDTextureTools {
  49215. /**
  49216. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49217. * @param texture the texture to expand.
  49218. */
  49219. static ExpandRGBDTexture(texture: Texture): void;
  49220. }
  49221. }
  49222. declare module "babylonjs/Misc/brdfTextureTools" {
  49223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49224. import { Scene } from "babylonjs/scene";
  49225. /**
  49226. * Class used to host texture specific utilities
  49227. */
  49228. export class BRDFTextureTools {
  49229. /**
  49230. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49231. * @param scene defines the hosting scene
  49232. * @returns the environment BRDF texture
  49233. */
  49234. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49235. private static _environmentBRDFBase64Texture;
  49236. }
  49237. }
  49238. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49239. import { Nullable } from "babylonjs/types";
  49240. import { Color3 } from "babylonjs/Maths/math.color";
  49241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49242. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49243. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49244. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49245. import { Engine } from "babylonjs/Engines/engine";
  49246. import { Scene } from "babylonjs/scene";
  49247. /**
  49248. * @hidden
  49249. */
  49250. export interface IMaterialClearCoatDefines {
  49251. CLEARCOAT: boolean;
  49252. CLEARCOAT_DEFAULTIOR: boolean;
  49253. CLEARCOAT_TEXTURE: boolean;
  49254. CLEARCOAT_TEXTUREDIRECTUV: number;
  49255. CLEARCOAT_BUMP: boolean;
  49256. CLEARCOAT_BUMPDIRECTUV: number;
  49257. CLEARCOAT_TINT: boolean;
  49258. CLEARCOAT_TINT_TEXTURE: boolean;
  49259. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49260. /** @hidden */
  49261. _areTexturesDirty: boolean;
  49262. }
  49263. /**
  49264. * Define the code related to the clear coat parameters of the pbr material.
  49265. */
  49266. export class PBRClearCoatConfiguration {
  49267. /**
  49268. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49269. * The default fits with a polyurethane material.
  49270. */
  49271. private static readonly _DefaultIndexOfRefraction;
  49272. private _isEnabled;
  49273. /**
  49274. * Defines if the clear coat is enabled in the material.
  49275. */
  49276. isEnabled: boolean;
  49277. /**
  49278. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49279. */
  49280. intensity: number;
  49281. /**
  49282. * Defines the clear coat layer roughness.
  49283. */
  49284. roughness: number;
  49285. private _indexOfRefraction;
  49286. /**
  49287. * Defines the index of refraction of the clear coat.
  49288. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49289. * The default fits with a polyurethane material.
  49290. * Changing the default value is more performance intensive.
  49291. */
  49292. indexOfRefraction: number;
  49293. private _texture;
  49294. /**
  49295. * Stores the clear coat values in a texture.
  49296. */
  49297. texture: Nullable<BaseTexture>;
  49298. private _bumpTexture;
  49299. /**
  49300. * Define the clear coat specific bump texture.
  49301. */
  49302. bumpTexture: Nullable<BaseTexture>;
  49303. private _isTintEnabled;
  49304. /**
  49305. * Defines if the clear coat tint is enabled in the material.
  49306. */
  49307. isTintEnabled: boolean;
  49308. /**
  49309. * Defines the clear coat tint of the material.
  49310. * This is only use if tint is enabled
  49311. */
  49312. tintColor: Color3;
  49313. /**
  49314. * Defines the distance at which the tint color should be found in the
  49315. * clear coat media.
  49316. * This is only use if tint is enabled
  49317. */
  49318. tintColorAtDistance: number;
  49319. /**
  49320. * Defines the clear coat layer thickness.
  49321. * This is only use if tint is enabled
  49322. */
  49323. tintThickness: number;
  49324. private _tintTexture;
  49325. /**
  49326. * Stores the clear tint values in a texture.
  49327. * rgb is tint
  49328. * a is a thickness factor
  49329. */
  49330. tintTexture: Nullable<BaseTexture>;
  49331. /** @hidden */
  49332. private _internalMarkAllSubMeshesAsTexturesDirty;
  49333. /** @hidden */
  49334. _markAllSubMeshesAsTexturesDirty(): void;
  49335. /**
  49336. * Instantiate a new istance of clear coat configuration.
  49337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49338. */
  49339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49340. /**
  49341. * Gets wehter the submesh is ready to be used or not.
  49342. * @param defines the list of "defines" to update.
  49343. * @param scene defines the scene the material belongs to.
  49344. * @param engine defines the engine the material belongs to.
  49345. * @param disableBumpMap defines wether the material disables bump or not.
  49346. * @returns - boolean indicating that the submesh is ready or not.
  49347. */
  49348. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49349. /**
  49350. * Checks to see if a texture is used in the material.
  49351. * @param defines the list of "defines" to update.
  49352. * @param scene defines the scene to the material belongs to.
  49353. */
  49354. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49355. /**
  49356. * Binds the material data.
  49357. * @param uniformBuffer defines the Uniform buffer to fill in.
  49358. * @param scene defines the scene the material belongs to.
  49359. * @param engine defines the engine the material belongs to.
  49360. * @param disableBumpMap defines wether the material disables bump or not.
  49361. * @param isFrozen defines wether the material is frozen or not.
  49362. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49363. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49364. */
  49365. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49366. /**
  49367. * Checks to see if a texture is used in the material.
  49368. * @param texture - Base texture to use.
  49369. * @returns - Boolean specifying if a texture is used in the material.
  49370. */
  49371. hasTexture(texture: BaseTexture): boolean;
  49372. /**
  49373. * Returns an array of the actively used textures.
  49374. * @param activeTextures Array of BaseTextures
  49375. */
  49376. getActiveTextures(activeTextures: BaseTexture[]): void;
  49377. /**
  49378. * Returns the animatable textures.
  49379. * @param animatables Array of animatable textures.
  49380. */
  49381. getAnimatables(animatables: IAnimatable[]): void;
  49382. /**
  49383. * Disposes the resources of the material.
  49384. * @param forceDisposeTextures - Forces the disposal of all textures.
  49385. */
  49386. dispose(forceDisposeTextures?: boolean): void;
  49387. /**
  49388. * Get the current class name of the texture useful for serialization or dynamic coding.
  49389. * @returns "PBRClearCoatConfiguration"
  49390. */
  49391. getClassName(): string;
  49392. /**
  49393. * Add fallbacks to the effect fallbacks list.
  49394. * @param defines defines the Base texture to use.
  49395. * @param fallbacks defines the current fallback list.
  49396. * @param currentRank defines the current fallback rank.
  49397. * @returns the new fallback rank.
  49398. */
  49399. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49400. /**
  49401. * Add the required uniforms to the current list.
  49402. * @param uniforms defines the current uniform list.
  49403. */
  49404. static AddUniforms(uniforms: string[]): void;
  49405. /**
  49406. * Add the required samplers to the current list.
  49407. * @param samplers defines the current sampler list.
  49408. */
  49409. static AddSamplers(samplers: string[]): void;
  49410. /**
  49411. * Add the required uniforms to the current buffer.
  49412. * @param uniformBuffer defines the current uniform buffer.
  49413. */
  49414. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49415. /**
  49416. * Makes a duplicate of the current configuration into another one.
  49417. * @param clearCoatConfiguration define the config where to copy the info
  49418. */
  49419. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49420. /**
  49421. * Serializes this clear coat configuration.
  49422. * @returns - An object with the serialized config.
  49423. */
  49424. serialize(): any;
  49425. /**
  49426. * Parses a anisotropy Configuration from a serialized object.
  49427. * @param source - Serialized object.
  49428. * @param scene Defines the scene we are parsing for
  49429. * @param rootUrl Defines the rootUrl to load from
  49430. */
  49431. parse(source: any, scene: Scene, rootUrl: string): void;
  49432. }
  49433. }
  49434. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49435. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49437. import { Vector2 } from "babylonjs/Maths/math.vector";
  49438. import { Scene } from "babylonjs/scene";
  49439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49440. import { Nullable } from "babylonjs/types";
  49441. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49443. /**
  49444. * @hidden
  49445. */
  49446. export interface IMaterialAnisotropicDefines {
  49447. ANISOTROPIC: boolean;
  49448. ANISOTROPIC_TEXTURE: boolean;
  49449. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49450. MAINUV1: boolean;
  49451. _areTexturesDirty: boolean;
  49452. _needUVs: boolean;
  49453. }
  49454. /**
  49455. * Define the code related to the anisotropic parameters of the pbr material.
  49456. */
  49457. export class PBRAnisotropicConfiguration {
  49458. private _isEnabled;
  49459. /**
  49460. * Defines if the anisotropy is enabled in the material.
  49461. */
  49462. isEnabled: boolean;
  49463. /**
  49464. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49465. */
  49466. intensity: number;
  49467. /**
  49468. * Defines if the effect is along the tangents, bitangents or in between.
  49469. * By default, the effect is "strectching" the highlights along the tangents.
  49470. */
  49471. direction: Vector2;
  49472. private _texture;
  49473. /**
  49474. * Stores the anisotropy values in a texture.
  49475. * rg is direction (like normal from -1 to 1)
  49476. * b is a intensity
  49477. */
  49478. texture: Nullable<BaseTexture>;
  49479. /** @hidden */
  49480. private _internalMarkAllSubMeshesAsTexturesDirty;
  49481. /** @hidden */
  49482. _markAllSubMeshesAsTexturesDirty(): void;
  49483. /**
  49484. * Instantiate a new istance of anisotropy configuration.
  49485. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49486. */
  49487. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49488. /**
  49489. * Specifies that the submesh is ready to be used.
  49490. * @param defines the list of "defines" to update.
  49491. * @param scene defines the scene the material belongs to.
  49492. * @returns - boolean indicating that the submesh is ready or not.
  49493. */
  49494. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49495. /**
  49496. * Checks to see if a texture is used in the material.
  49497. * @param defines the list of "defines" to update.
  49498. * @param mesh the mesh we are preparing the defines for.
  49499. * @param scene defines the scene the material belongs to.
  49500. */
  49501. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49502. /**
  49503. * Binds the material data.
  49504. * @param uniformBuffer defines the Uniform buffer to fill in.
  49505. * @param scene defines the scene the material belongs to.
  49506. * @param isFrozen defines wether the material is frozen or not.
  49507. */
  49508. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49509. /**
  49510. * Checks to see if a texture is used in the material.
  49511. * @param texture - Base texture to use.
  49512. * @returns - Boolean specifying if a texture is used in the material.
  49513. */
  49514. hasTexture(texture: BaseTexture): boolean;
  49515. /**
  49516. * Returns an array of the actively used textures.
  49517. * @param activeTextures Array of BaseTextures
  49518. */
  49519. getActiveTextures(activeTextures: BaseTexture[]): void;
  49520. /**
  49521. * Returns the animatable textures.
  49522. * @param animatables Array of animatable textures.
  49523. */
  49524. getAnimatables(animatables: IAnimatable[]): void;
  49525. /**
  49526. * Disposes the resources of the material.
  49527. * @param forceDisposeTextures - Forces the disposal of all textures.
  49528. */
  49529. dispose(forceDisposeTextures?: boolean): void;
  49530. /**
  49531. * Get the current class name of the texture useful for serialization or dynamic coding.
  49532. * @returns "PBRAnisotropicConfiguration"
  49533. */
  49534. getClassName(): string;
  49535. /**
  49536. * Add fallbacks to the effect fallbacks list.
  49537. * @param defines defines the Base texture to use.
  49538. * @param fallbacks defines the current fallback list.
  49539. * @param currentRank defines the current fallback rank.
  49540. * @returns the new fallback rank.
  49541. */
  49542. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49543. /**
  49544. * Add the required uniforms to the current list.
  49545. * @param uniforms defines the current uniform list.
  49546. */
  49547. static AddUniforms(uniforms: string[]): void;
  49548. /**
  49549. * Add the required uniforms to the current buffer.
  49550. * @param uniformBuffer defines the current uniform buffer.
  49551. */
  49552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49553. /**
  49554. * Add the required samplers to the current list.
  49555. * @param samplers defines the current sampler list.
  49556. */
  49557. static AddSamplers(samplers: string[]): void;
  49558. /**
  49559. * Makes a duplicate of the current configuration into another one.
  49560. * @param anisotropicConfiguration define the config where to copy the info
  49561. */
  49562. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49563. /**
  49564. * Serializes this anisotropy configuration.
  49565. * @returns - An object with the serialized config.
  49566. */
  49567. serialize(): any;
  49568. /**
  49569. * Parses a anisotropy Configuration from a serialized object.
  49570. * @param source - Serialized object.
  49571. * @param scene Defines the scene we are parsing for
  49572. * @param rootUrl Defines the rootUrl to load from
  49573. */
  49574. parse(source: any, scene: Scene, rootUrl: string): void;
  49575. }
  49576. }
  49577. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49578. import { Scene } from "babylonjs/scene";
  49579. /**
  49580. * @hidden
  49581. */
  49582. export interface IMaterialBRDFDefines {
  49583. BRDF_V_HEIGHT_CORRELATED: boolean;
  49584. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49585. SPHERICAL_HARMONICS: boolean;
  49586. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49587. /** @hidden */
  49588. _areMiscDirty: boolean;
  49589. }
  49590. /**
  49591. * Define the code related to the BRDF parameters of the pbr material.
  49592. */
  49593. export class PBRBRDFConfiguration {
  49594. /**
  49595. * Default value used for the energy conservation.
  49596. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49597. */
  49598. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49599. /**
  49600. * Default value used for the Smith Visibility Height Correlated mode.
  49601. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49602. */
  49603. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49604. /**
  49605. * Default value used for the IBL diffuse part.
  49606. * This can help switching back to the polynomials mode globally which is a tiny bit
  49607. * less GPU intensive at the drawback of a lower quality.
  49608. */
  49609. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49610. /**
  49611. * Default value used for activating energy conservation for the specular workflow.
  49612. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49613. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49614. */
  49615. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49616. private _useEnergyConservation;
  49617. /**
  49618. * Defines if the material uses energy conservation.
  49619. */
  49620. useEnergyConservation: boolean;
  49621. private _useSmithVisibilityHeightCorrelated;
  49622. /**
  49623. * LEGACY Mode set to false
  49624. * Defines if the material uses height smith correlated visibility term.
  49625. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49626. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49627. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49628. * Not relying on height correlated will also disable energy conservation.
  49629. */
  49630. useSmithVisibilityHeightCorrelated: boolean;
  49631. private _useSphericalHarmonics;
  49632. /**
  49633. * LEGACY Mode set to false
  49634. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49635. * diffuse part of the IBL.
  49636. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49637. * to the ground truth.
  49638. */
  49639. useSphericalHarmonics: boolean;
  49640. private _useSpecularGlossinessInputEnergyConservation;
  49641. /**
  49642. * Defines if the material uses energy conservation, when the specular workflow is active.
  49643. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49644. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49645. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49646. */
  49647. useSpecularGlossinessInputEnergyConservation: boolean;
  49648. /** @hidden */
  49649. private _internalMarkAllSubMeshesAsMiscDirty;
  49650. /** @hidden */
  49651. _markAllSubMeshesAsMiscDirty(): void;
  49652. /**
  49653. * Instantiate a new istance of clear coat configuration.
  49654. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49655. */
  49656. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49657. /**
  49658. * Checks to see if a texture is used in the material.
  49659. * @param defines the list of "defines" to update.
  49660. */
  49661. prepareDefines(defines: IMaterialBRDFDefines): void;
  49662. /**
  49663. * Get the current class name of the texture useful for serialization or dynamic coding.
  49664. * @returns "PBRClearCoatConfiguration"
  49665. */
  49666. getClassName(): string;
  49667. /**
  49668. * Makes a duplicate of the current configuration into another one.
  49669. * @param brdfConfiguration define the config where to copy the info
  49670. */
  49671. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49672. /**
  49673. * Serializes this BRDF configuration.
  49674. * @returns - An object with the serialized config.
  49675. */
  49676. serialize(): any;
  49677. /**
  49678. * Parses a anisotropy Configuration from a serialized object.
  49679. * @param source - Serialized object.
  49680. * @param scene Defines the scene we are parsing for
  49681. * @param rootUrl Defines the rootUrl to load from
  49682. */
  49683. parse(source: any, scene: Scene, rootUrl: string): void;
  49684. }
  49685. }
  49686. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49687. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49688. import { Color3 } from "babylonjs/Maths/math.color";
  49689. import { Scene } from "babylonjs/scene";
  49690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49691. import { Nullable } from "babylonjs/types";
  49692. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49693. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49694. /**
  49695. * @hidden
  49696. */
  49697. export interface IMaterialSheenDefines {
  49698. SHEEN: boolean;
  49699. SHEEN_TEXTURE: boolean;
  49700. SHEEN_TEXTUREDIRECTUV: number;
  49701. SHEEN_LINKWITHALBEDO: boolean;
  49702. /** @hidden */
  49703. _areTexturesDirty: boolean;
  49704. }
  49705. /**
  49706. * Define the code related to the Sheen parameters of the pbr material.
  49707. */
  49708. export class PBRSheenConfiguration {
  49709. private _isEnabled;
  49710. /**
  49711. * Defines if the material uses sheen.
  49712. */
  49713. isEnabled: boolean;
  49714. private _linkSheenWithAlbedo;
  49715. /**
  49716. * Defines if the sheen is linked to the sheen color.
  49717. */
  49718. linkSheenWithAlbedo: boolean;
  49719. /**
  49720. * Defines the sheen intensity.
  49721. */
  49722. intensity: number;
  49723. /**
  49724. * Defines the sheen color.
  49725. */
  49726. color: Color3;
  49727. private _texture;
  49728. /**
  49729. * Stores the sheen tint values in a texture.
  49730. * rgb is tint
  49731. * a is a intensity
  49732. */
  49733. texture: Nullable<BaseTexture>;
  49734. /** @hidden */
  49735. private _internalMarkAllSubMeshesAsTexturesDirty;
  49736. /** @hidden */
  49737. _markAllSubMeshesAsTexturesDirty(): void;
  49738. /**
  49739. * Instantiate a new istance of clear coat configuration.
  49740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49741. */
  49742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49743. /**
  49744. * Specifies that the submesh is ready to be used.
  49745. * @param defines the list of "defines" to update.
  49746. * @param scene defines the scene the material belongs to.
  49747. * @returns - boolean indicating that the submesh is ready or not.
  49748. */
  49749. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49750. /**
  49751. * Checks to see if a texture is used in the material.
  49752. * @param defines the list of "defines" to update.
  49753. * @param scene defines the scene the material belongs to.
  49754. */
  49755. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49756. /**
  49757. * Binds the material data.
  49758. * @param uniformBuffer defines the Uniform buffer to fill in.
  49759. * @param scene defines the scene the material belongs to.
  49760. * @param isFrozen defines wether the material is frozen or not.
  49761. */
  49762. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49763. /**
  49764. * Checks to see if a texture is used in the material.
  49765. * @param texture - Base texture to use.
  49766. * @returns - Boolean specifying if a texture is used in the material.
  49767. */
  49768. hasTexture(texture: BaseTexture): boolean;
  49769. /**
  49770. * Returns an array of the actively used textures.
  49771. * @param activeTextures Array of BaseTextures
  49772. */
  49773. getActiveTextures(activeTextures: BaseTexture[]): void;
  49774. /**
  49775. * Returns the animatable textures.
  49776. * @param animatables Array of animatable textures.
  49777. */
  49778. getAnimatables(animatables: IAnimatable[]): void;
  49779. /**
  49780. * Disposes the resources of the material.
  49781. * @param forceDisposeTextures - Forces the disposal of all textures.
  49782. */
  49783. dispose(forceDisposeTextures?: boolean): void;
  49784. /**
  49785. * Get the current class name of the texture useful for serialization or dynamic coding.
  49786. * @returns "PBRSheenConfiguration"
  49787. */
  49788. getClassName(): string;
  49789. /**
  49790. * Add fallbacks to the effect fallbacks list.
  49791. * @param defines defines the Base texture to use.
  49792. * @param fallbacks defines the current fallback list.
  49793. * @param currentRank defines the current fallback rank.
  49794. * @returns the new fallback rank.
  49795. */
  49796. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49797. /**
  49798. * Add the required uniforms to the current list.
  49799. * @param uniforms defines the current uniform list.
  49800. */
  49801. static AddUniforms(uniforms: string[]): void;
  49802. /**
  49803. * Add the required uniforms to the current buffer.
  49804. * @param uniformBuffer defines the current uniform buffer.
  49805. */
  49806. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49807. /**
  49808. * Add the required samplers to the current list.
  49809. * @param samplers defines the current sampler list.
  49810. */
  49811. static AddSamplers(samplers: string[]): void;
  49812. /**
  49813. * Makes a duplicate of the current configuration into another one.
  49814. * @param sheenConfiguration define the config where to copy the info
  49815. */
  49816. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49817. /**
  49818. * Serializes this BRDF configuration.
  49819. * @returns - An object with the serialized config.
  49820. */
  49821. serialize(): any;
  49822. /**
  49823. * Parses a anisotropy Configuration from a serialized object.
  49824. * @param source - Serialized object.
  49825. * @param scene Defines the scene we are parsing for
  49826. * @param rootUrl Defines the rootUrl to load from
  49827. */
  49828. parse(source: any, scene: Scene, rootUrl: string): void;
  49829. }
  49830. }
  49831. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49832. import { Nullable } from "babylonjs/types";
  49833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49834. import { Color3 } from "babylonjs/Maths/math.color";
  49835. import { SmartArray } from "babylonjs/Misc/smartArray";
  49836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49838. import { Effect } from "babylonjs/Materials/effect";
  49839. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49840. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49841. import { Engine } from "babylonjs/Engines/engine";
  49842. import { Scene } from "babylonjs/scene";
  49843. /**
  49844. * @hidden
  49845. */
  49846. export interface IMaterialSubSurfaceDefines {
  49847. SUBSURFACE: boolean;
  49848. SS_REFRACTION: boolean;
  49849. SS_TRANSLUCENCY: boolean;
  49850. SS_SCATERRING: boolean;
  49851. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49852. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49853. SS_REFRACTIONMAP_3D: boolean;
  49854. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49855. SS_LODINREFRACTIONALPHA: boolean;
  49856. SS_GAMMAREFRACTION: boolean;
  49857. SS_RGBDREFRACTION: boolean;
  49858. SS_LINEARSPECULARREFRACTION: boolean;
  49859. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49860. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49861. /** @hidden */
  49862. _areTexturesDirty: boolean;
  49863. }
  49864. /**
  49865. * Define the code related to the sub surface parameters of the pbr material.
  49866. */
  49867. export class PBRSubSurfaceConfiguration {
  49868. private _isRefractionEnabled;
  49869. /**
  49870. * Defines if the refraction is enabled in the material.
  49871. */
  49872. isRefractionEnabled: boolean;
  49873. private _isTranslucencyEnabled;
  49874. /**
  49875. * Defines if the translucency is enabled in the material.
  49876. */
  49877. isTranslucencyEnabled: boolean;
  49878. private _isScatteringEnabled;
  49879. /**
  49880. * Defines the refraction intensity of the material.
  49881. * The refraction when enabled replaces the Diffuse part of the material.
  49882. * The intensity helps transitionning between diffuse and refraction.
  49883. */
  49884. refractionIntensity: number;
  49885. /**
  49886. * Defines the translucency intensity of the material.
  49887. * When translucency has been enabled, this defines how much of the "translucency"
  49888. * is addded to the diffuse part of the material.
  49889. */
  49890. translucencyIntensity: number;
  49891. /**
  49892. * Defines the scattering intensity of the material.
  49893. * When scattering has been enabled, this defines how much of the "scattered light"
  49894. * is addded to the diffuse part of the material.
  49895. */
  49896. scatteringIntensity: number;
  49897. private _thicknessTexture;
  49898. /**
  49899. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49900. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49901. * 0 would mean minimumThickness
  49902. * 1 would mean maximumThickness
  49903. * The other channels might be use as a mask to vary the different effects intensity.
  49904. */
  49905. thicknessTexture: Nullable<BaseTexture>;
  49906. private _refractionTexture;
  49907. /**
  49908. * Defines the texture to use for refraction.
  49909. */
  49910. refractionTexture: Nullable<BaseTexture>;
  49911. private _indexOfRefraction;
  49912. /**
  49913. * Defines the index of refraction used in the material.
  49914. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49915. */
  49916. indexOfRefraction: number;
  49917. private _invertRefractionY;
  49918. /**
  49919. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49920. */
  49921. invertRefractionY: boolean;
  49922. private _linkRefractionWithTransparency;
  49923. /**
  49924. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49925. * Materials half opaque for instance using refraction could benefit from this control.
  49926. */
  49927. linkRefractionWithTransparency: boolean;
  49928. /**
  49929. * Defines the minimum thickness stored in the thickness map.
  49930. * If no thickness map is defined, this value will be used to simulate thickness.
  49931. */
  49932. minimumThickness: number;
  49933. /**
  49934. * Defines the maximum thickness stored in the thickness map.
  49935. */
  49936. maximumThickness: number;
  49937. /**
  49938. * Defines the volume tint of the material.
  49939. * This is used for both translucency and scattering.
  49940. */
  49941. tintColor: Color3;
  49942. /**
  49943. * Defines the distance at which the tint color should be found in the media.
  49944. * This is used for refraction only.
  49945. */
  49946. tintColorAtDistance: number;
  49947. /**
  49948. * Defines how far each channel transmit through the media.
  49949. * It is defined as a color to simplify it selection.
  49950. */
  49951. diffusionDistance: Color3;
  49952. private _useMaskFromThicknessTexture;
  49953. /**
  49954. * Stores the intensity of the different subsurface effects in the thickness texture.
  49955. * * the green channel is the translucency intensity.
  49956. * * the blue channel is the scattering intensity.
  49957. * * the alpha channel is the refraction intensity.
  49958. */
  49959. useMaskFromThicknessTexture: boolean;
  49960. /** @hidden */
  49961. private _internalMarkAllSubMeshesAsTexturesDirty;
  49962. /** @hidden */
  49963. _markAllSubMeshesAsTexturesDirty(): void;
  49964. /**
  49965. * Instantiate a new istance of sub surface configuration.
  49966. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49967. */
  49968. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49969. /**
  49970. * Gets wehter the submesh is ready to be used or not.
  49971. * @param defines the list of "defines" to update.
  49972. * @param scene defines the scene the material belongs to.
  49973. * @returns - boolean indicating that the submesh is ready or not.
  49974. */
  49975. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49976. /**
  49977. * Checks to see if a texture is used in the material.
  49978. * @param defines the list of "defines" to update.
  49979. * @param scene defines the scene to the material belongs to.
  49980. */
  49981. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49982. /**
  49983. * Binds the material data.
  49984. * @param uniformBuffer defines the Uniform buffer to fill in.
  49985. * @param scene defines the scene the material belongs to.
  49986. * @param engine defines the engine the material belongs to.
  49987. * @param isFrozen defines wether the material is frozen or not.
  49988. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49989. */
  49990. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49991. /**
  49992. * Unbinds the material from the mesh.
  49993. * @param activeEffect defines the effect that should be unbound from.
  49994. * @returns true if unbound, otherwise false
  49995. */
  49996. unbind(activeEffect: Effect): boolean;
  49997. /**
  49998. * Returns the texture used for refraction or null if none is used.
  49999. * @param scene defines the scene the material belongs to.
  50000. * @returns - Refraction texture if present. If no refraction texture and refraction
  50001. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50002. */
  50003. private _getRefractionTexture;
  50004. /**
  50005. * Returns true if alpha blending should be disabled.
  50006. */
  50007. readonly disableAlphaBlending: boolean;
  50008. /**
  50009. * Fills the list of render target textures.
  50010. * @param renderTargets the list of render targets to update
  50011. */
  50012. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50013. /**
  50014. * Checks to see if a texture is used in the material.
  50015. * @param texture - Base texture to use.
  50016. * @returns - Boolean specifying if a texture is used in the material.
  50017. */
  50018. hasTexture(texture: BaseTexture): boolean;
  50019. /**
  50020. * Gets a boolean indicating that current material needs to register RTT
  50021. * @returns true if this uses a render target otherwise false.
  50022. */
  50023. hasRenderTargetTextures(): boolean;
  50024. /**
  50025. * Returns an array of the actively used textures.
  50026. * @param activeTextures Array of BaseTextures
  50027. */
  50028. getActiveTextures(activeTextures: BaseTexture[]): void;
  50029. /**
  50030. * Returns the animatable textures.
  50031. * @param animatables Array of animatable textures.
  50032. */
  50033. getAnimatables(animatables: IAnimatable[]): void;
  50034. /**
  50035. * Disposes the resources of the material.
  50036. * @param forceDisposeTextures - Forces the disposal of all textures.
  50037. */
  50038. dispose(forceDisposeTextures?: boolean): void;
  50039. /**
  50040. * Get the current class name of the texture useful for serialization or dynamic coding.
  50041. * @returns "PBRSubSurfaceConfiguration"
  50042. */
  50043. getClassName(): string;
  50044. /**
  50045. * Add fallbacks to the effect fallbacks list.
  50046. * @param defines defines the Base texture to use.
  50047. * @param fallbacks defines the current fallback list.
  50048. * @param currentRank defines the current fallback rank.
  50049. * @returns the new fallback rank.
  50050. */
  50051. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50052. /**
  50053. * Add the required uniforms to the current list.
  50054. * @param uniforms defines the current uniform list.
  50055. */
  50056. static AddUniforms(uniforms: string[]): void;
  50057. /**
  50058. * Add the required samplers to the current list.
  50059. * @param samplers defines the current sampler list.
  50060. */
  50061. static AddSamplers(samplers: string[]): void;
  50062. /**
  50063. * Add the required uniforms to the current buffer.
  50064. * @param uniformBuffer defines the current uniform buffer.
  50065. */
  50066. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50067. /**
  50068. * Makes a duplicate of the current configuration into another one.
  50069. * @param configuration define the config where to copy the info
  50070. */
  50071. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50072. /**
  50073. * Serializes this Sub Surface configuration.
  50074. * @returns - An object with the serialized config.
  50075. */
  50076. serialize(): any;
  50077. /**
  50078. * Parses a anisotropy Configuration from a serialized object.
  50079. * @param source - Serialized object.
  50080. * @param scene Defines the scene we are parsing for
  50081. * @param rootUrl Defines the rootUrl to load from
  50082. */
  50083. parse(source: any, scene: Scene, rootUrl: string): void;
  50084. }
  50085. }
  50086. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50087. /** @hidden */
  50088. export var pbrFragmentDeclaration: {
  50089. name: string;
  50090. shader: string;
  50091. };
  50092. }
  50093. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50094. /** @hidden */
  50095. export var pbrUboDeclaration: {
  50096. name: string;
  50097. shader: string;
  50098. };
  50099. }
  50100. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50101. /** @hidden */
  50102. export var pbrFragmentExtraDeclaration: {
  50103. name: string;
  50104. shader: string;
  50105. };
  50106. }
  50107. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50108. /** @hidden */
  50109. export var pbrFragmentSamplersDeclaration: {
  50110. name: string;
  50111. shader: string;
  50112. };
  50113. }
  50114. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50115. /** @hidden */
  50116. export var pbrHelperFunctions: {
  50117. name: string;
  50118. shader: string;
  50119. };
  50120. }
  50121. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50122. /** @hidden */
  50123. export var harmonicsFunctions: {
  50124. name: string;
  50125. shader: string;
  50126. };
  50127. }
  50128. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50129. /** @hidden */
  50130. export var pbrDirectLightingSetupFunctions: {
  50131. name: string;
  50132. shader: string;
  50133. };
  50134. }
  50135. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50136. /** @hidden */
  50137. export var pbrDirectLightingFalloffFunctions: {
  50138. name: string;
  50139. shader: string;
  50140. };
  50141. }
  50142. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50143. /** @hidden */
  50144. export var pbrBRDFFunctions: {
  50145. name: string;
  50146. shader: string;
  50147. };
  50148. }
  50149. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50150. /** @hidden */
  50151. export var pbrDirectLightingFunctions: {
  50152. name: string;
  50153. shader: string;
  50154. };
  50155. }
  50156. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50157. /** @hidden */
  50158. export var pbrIBLFunctions: {
  50159. name: string;
  50160. shader: string;
  50161. };
  50162. }
  50163. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50164. /** @hidden */
  50165. export var pbrDebug: {
  50166. name: string;
  50167. shader: string;
  50168. };
  50169. }
  50170. declare module "babylonjs/Shaders/pbr.fragment" {
  50171. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50172. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50173. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50174. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50175. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50176. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50177. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50178. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50179. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50180. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50181. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50182. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50183. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50184. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50185. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50186. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50187. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50188. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50189. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50190. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50191. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50192. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50193. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50194. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50195. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50196. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50197. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50198. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50199. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50200. /** @hidden */
  50201. export var pbrPixelShader: {
  50202. name: string;
  50203. shader: string;
  50204. };
  50205. }
  50206. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50207. /** @hidden */
  50208. export var pbrVertexDeclaration: {
  50209. name: string;
  50210. shader: string;
  50211. };
  50212. }
  50213. declare module "babylonjs/Shaders/pbr.vertex" {
  50214. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50215. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50216. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50217. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50218. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50219. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50220. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50222. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50223. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50224. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50227. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50229. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50230. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50231. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50232. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50233. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50234. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50235. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50236. /** @hidden */
  50237. export var pbrVertexShader: {
  50238. name: string;
  50239. shader: string;
  50240. };
  50241. }
  50242. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50243. import { Nullable } from "babylonjs/types";
  50244. import { Scene } from "babylonjs/scene";
  50245. import { Matrix } from "babylonjs/Maths/math.vector";
  50246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50248. import { Mesh } from "babylonjs/Meshes/mesh";
  50249. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50250. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50251. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50252. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50253. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50254. import { Color3 } from "babylonjs/Maths/math.color";
  50255. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50256. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50257. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50258. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50261. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50262. import "babylonjs/Shaders/pbr.fragment";
  50263. import "babylonjs/Shaders/pbr.vertex";
  50264. /**
  50265. * Manages the defines for the PBR Material.
  50266. * @hidden
  50267. */
  50268. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50269. PBR: boolean;
  50270. MAINUV1: boolean;
  50271. MAINUV2: boolean;
  50272. UV1: boolean;
  50273. UV2: boolean;
  50274. ALBEDO: boolean;
  50275. ALBEDODIRECTUV: number;
  50276. VERTEXCOLOR: boolean;
  50277. AMBIENT: boolean;
  50278. AMBIENTDIRECTUV: number;
  50279. AMBIENTINGRAYSCALE: boolean;
  50280. OPACITY: boolean;
  50281. VERTEXALPHA: boolean;
  50282. OPACITYDIRECTUV: number;
  50283. OPACITYRGB: boolean;
  50284. ALPHATEST: boolean;
  50285. DEPTHPREPASS: boolean;
  50286. ALPHABLEND: boolean;
  50287. ALPHAFROMALBEDO: boolean;
  50288. ALPHATESTVALUE: string;
  50289. SPECULAROVERALPHA: boolean;
  50290. RADIANCEOVERALPHA: boolean;
  50291. ALPHAFRESNEL: boolean;
  50292. LINEARALPHAFRESNEL: boolean;
  50293. PREMULTIPLYALPHA: boolean;
  50294. EMISSIVE: boolean;
  50295. EMISSIVEDIRECTUV: number;
  50296. REFLECTIVITY: boolean;
  50297. REFLECTIVITYDIRECTUV: number;
  50298. SPECULARTERM: boolean;
  50299. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50300. MICROSURFACEAUTOMATIC: boolean;
  50301. LODBASEDMICROSFURACE: boolean;
  50302. MICROSURFACEMAP: boolean;
  50303. MICROSURFACEMAPDIRECTUV: number;
  50304. METALLICWORKFLOW: boolean;
  50305. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50306. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50307. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50308. AOSTOREINMETALMAPRED: boolean;
  50309. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50310. ENVIRONMENTBRDF: boolean;
  50311. ENVIRONMENTBRDF_RGBD: boolean;
  50312. NORMAL: boolean;
  50313. TANGENT: boolean;
  50314. BUMP: boolean;
  50315. BUMPDIRECTUV: number;
  50316. OBJECTSPACE_NORMALMAP: boolean;
  50317. PARALLAX: boolean;
  50318. PARALLAXOCCLUSION: boolean;
  50319. NORMALXYSCALE: boolean;
  50320. LIGHTMAP: boolean;
  50321. LIGHTMAPDIRECTUV: number;
  50322. USELIGHTMAPASSHADOWMAP: boolean;
  50323. GAMMALIGHTMAP: boolean;
  50324. RGBDLIGHTMAP: boolean;
  50325. REFLECTION: boolean;
  50326. REFLECTIONMAP_3D: boolean;
  50327. REFLECTIONMAP_SPHERICAL: boolean;
  50328. REFLECTIONMAP_PLANAR: boolean;
  50329. REFLECTIONMAP_CUBIC: boolean;
  50330. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50331. REFLECTIONMAP_PROJECTION: boolean;
  50332. REFLECTIONMAP_SKYBOX: boolean;
  50333. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50334. REFLECTIONMAP_EXPLICIT: boolean;
  50335. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50336. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50337. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50338. INVERTCUBICMAP: boolean;
  50339. USESPHERICALFROMREFLECTIONMAP: boolean;
  50340. USEIRRADIANCEMAP: boolean;
  50341. SPHERICAL_HARMONICS: boolean;
  50342. USESPHERICALINVERTEX: boolean;
  50343. REFLECTIONMAP_OPPOSITEZ: boolean;
  50344. LODINREFLECTIONALPHA: boolean;
  50345. GAMMAREFLECTION: boolean;
  50346. RGBDREFLECTION: boolean;
  50347. LINEARSPECULARREFLECTION: boolean;
  50348. RADIANCEOCCLUSION: boolean;
  50349. HORIZONOCCLUSION: boolean;
  50350. INSTANCES: boolean;
  50351. NUM_BONE_INFLUENCERS: number;
  50352. BonesPerMesh: number;
  50353. BONETEXTURE: boolean;
  50354. NONUNIFORMSCALING: boolean;
  50355. MORPHTARGETS: boolean;
  50356. MORPHTARGETS_NORMAL: boolean;
  50357. MORPHTARGETS_TANGENT: boolean;
  50358. MORPHTARGETS_UV: boolean;
  50359. NUM_MORPH_INFLUENCERS: number;
  50360. IMAGEPROCESSING: boolean;
  50361. VIGNETTE: boolean;
  50362. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50363. VIGNETTEBLENDMODEOPAQUE: boolean;
  50364. TONEMAPPING: boolean;
  50365. TONEMAPPING_ACES: boolean;
  50366. CONTRAST: boolean;
  50367. COLORCURVES: boolean;
  50368. COLORGRADING: boolean;
  50369. COLORGRADING3D: boolean;
  50370. SAMPLER3DGREENDEPTH: boolean;
  50371. SAMPLER3DBGRMAP: boolean;
  50372. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50373. EXPOSURE: boolean;
  50374. MULTIVIEW: boolean;
  50375. USEPHYSICALLIGHTFALLOFF: boolean;
  50376. USEGLTFLIGHTFALLOFF: boolean;
  50377. TWOSIDEDLIGHTING: boolean;
  50378. SHADOWFLOAT: boolean;
  50379. CLIPPLANE: boolean;
  50380. CLIPPLANE2: boolean;
  50381. CLIPPLANE3: boolean;
  50382. CLIPPLANE4: boolean;
  50383. POINTSIZE: boolean;
  50384. FOG: boolean;
  50385. LOGARITHMICDEPTH: boolean;
  50386. FORCENORMALFORWARD: boolean;
  50387. SPECULARAA: boolean;
  50388. CLEARCOAT: boolean;
  50389. CLEARCOAT_DEFAULTIOR: boolean;
  50390. CLEARCOAT_TEXTURE: boolean;
  50391. CLEARCOAT_TEXTUREDIRECTUV: number;
  50392. CLEARCOAT_BUMP: boolean;
  50393. CLEARCOAT_BUMPDIRECTUV: number;
  50394. CLEARCOAT_TINT: boolean;
  50395. CLEARCOAT_TINT_TEXTURE: boolean;
  50396. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50397. ANISOTROPIC: boolean;
  50398. ANISOTROPIC_TEXTURE: boolean;
  50399. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50400. BRDF_V_HEIGHT_CORRELATED: boolean;
  50401. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50402. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50403. SHEEN: boolean;
  50404. SHEEN_TEXTURE: boolean;
  50405. SHEEN_TEXTUREDIRECTUV: number;
  50406. SHEEN_LINKWITHALBEDO: boolean;
  50407. SUBSURFACE: boolean;
  50408. SS_REFRACTION: boolean;
  50409. SS_TRANSLUCENCY: boolean;
  50410. SS_SCATERRING: boolean;
  50411. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50412. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50413. SS_REFRACTIONMAP_3D: boolean;
  50414. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50415. SS_LODINREFRACTIONALPHA: boolean;
  50416. SS_GAMMAREFRACTION: boolean;
  50417. SS_RGBDREFRACTION: boolean;
  50418. SS_LINEARSPECULARREFRACTION: boolean;
  50419. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50420. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50421. UNLIT: boolean;
  50422. DEBUGMODE: number;
  50423. /**
  50424. * Initializes the PBR Material defines.
  50425. */
  50426. constructor();
  50427. /**
  50428. * Resets the PBR Material defines.
  50429. */
  50430. reset(): void;
  50431. }
  50432. /**
  50433. * The Physically based material base class of BJS.
  50434. *
  50435. * This offers the main features of a standard PBR material.
  50436. * For more information, please refer to the documentation :
  50437. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50438. */
  50439. export abstract class PBRBaseMaterial extends PushMaterial {
  50440. /**
  50441. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50442. */
  50443. static readonly PBRMATERIAL_OPAQUE: number;
  50444. /**
  50445. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50446. */
  50447. static readonly PBRMATERIAL_ALPHATEST: number;
  50448. /**
  50449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50450. */
  50451. static readonly PBRMATERIAL_ALPHABLEND: number;
  50452. /**
  50453. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50454. * They are also discarded below the alpha cutoff threshold to improve performances.
  50455. */
  50456. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50457. /**
  50458. * Defines the default value of how much AO map is occluding the analytical lights
  50459. * (point spot...).
  50460. */
  50461. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50462. /**
  50463. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50464. */
  50465. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50466. /**
  50467. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50468. * to enhance interoperability with other engines.
  50469. */
  50470. static readonly LIGHTFALLOFF_GLTF: number;
  50471. /**
  50472. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50473. * to enhance interoperability with other materials.
  50474. */
  50475. static readonly LIGHTFALLOFF_STANDARD: number;
  50476. /**
  50477. * Intensity of the direct lights e.g. the four lights available in your scene.
  50478. * This impacts both the direct diffuse and specular highlights.
  50479. */
  50480. protected _directIntensity: number;
  50481. /**
  50482. * Intensity of the emissive part of the material.
  50483. * This helps controlling the emissive effect without modifying the emissive color.
  50484. */
  50485. protected _emissiveIntensity: number;
  50486. /**
  50487. * Intensity of the environment e.g. how much the environment will light the object
  50488. * either through harmonics for rough material or through the refelction for shiny ones.
  50489. */
  50490. protected _environmentIntensity: number;
  50491. /**
  50492. * This is a special control allowing the reduction of the specular highlights coming from the
  50493. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50494. */
  50495. protected _specularIntensity: number;
  50496. /**
  50497. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50498. */
  50499. private _lightingInfos;
  50500. /**
  50501. * Debug Control allowing disabling the bump map on this material.
  50502. */
  50503. protected _disableBumpMap: boolean;
  50504. /**
  50505. * AKA Diffuse Texture in standard nomenclature.
  50506. */
  50507. protected _albedoTexture: Nullable<BaseTexture>;
  50508. /**
  50509. * AKA Occlusion Texture in other nomenclature.
  50510. */
  50511. protected _ambientTexture: Nullable<BaseTexture>;
  50512. /**
  50513. * AKA Occlusion Texture Intensity in other nomenclature.
  50514. */
  50515. protected _ambientTextureStrength: number;
  50516. /**
  50517. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50518. * 1 means it completely occludes it
  50519. * 0 mean it has no impact
  50520. */
  50521. protected _ambientTextureImpactOnAnalyticalLights: number;
  50522. /**
  50523. * Stores the alpha values in a texture.
  50524. */
  50525. protected _opacityTexture: Nullable<BaseTexture>;
  50526. /**
  50527. * Stores the reflection values in a texture.
  50528. */
  50529. protected _reflectionTexture: Nullable<BaseTexture>;
  50530. /**
  50531. * Stores the emissive values in a texture.
  50532. */
  50533. protected _emissiveTexture: Nullable<BaseTexture>;
  50534. /**
  50535. * AKA Specular texture in other nomenclature.
  50536. */
  50537. protected _reflectivityTexture: Nullable<BaseTexture>;
  50538. /**
  50539. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50540. */
  50541. protected _metallicTexture: Nullable<BaseTexture>;
  50542. /**
  50543. * Specifies the metallic scalar of the metallic/roughness workflow.
  50544. * Can also be used to scale the metalness values of the metallic texture.
  50545. */
  50546. protected _metallic: Nullable<number>;
  50547. /**
  50548. * Specifies the roughness scalar of the metallic/roughness workflow.
  50549. * Can also be used to scale the roughness values of the metallic texture.
  50550. */
  50551. protected _roughness: Nullable<number>;
  50552. /**
  50553. * Specifies the an F0 factor to help configuring the material F0.
  50554. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50555. * to 0.5 the previously hard coded value stays the same.
  50556. * Can also be used to scale the F0 values of the metallic texture.
  50557. */
  50558. protected _metallicF0Factor: number;
  50559. /**
  50560. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50561. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50562. * your expectation as it multiplies with the texture data.
  50563. */
  50564. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50565. /**
  50566. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50567. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50568. */
  50569. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50570. /**
  50571. * Stores surface normal data used to displace a mesh in a texture.
  50572. */
  50573. protected _bumpTexture: Nullable<BaseTexture>;
  50574. /**
  50575. * Stores the pre-calculated light information of a mesh in a texture.
  50576. */
  50577. protected _lightmapTexture: Nullable<BaseTexture>;
  50578. /**
  50579. * The color of a material in ambient lighting.
  50580. */
  50581. protected _ambientColor: Color3;
  50582. /**
  50583. * AKA Diffuse Color in other nomenclature.
  50584. */
  50585. protected _albedoColor: Color3;
  50586. /**
  50587. * AKA Specular Color in other nomenclature.
  50588. */
  50589. protected _reflectivityColor: Color3;
  50590. /**
  50591. * The color applied when light is reflected from a material.
  50592. */
  50593. protected _reflectionColor: Color3;
  50594. /**
  50595. * The color applied when light is emitted from a material.
  50596. */
  50597. protected _emissiveColor: Color3;
  50598. /**
  50599. * AKA Glossiness in other nomenclature.
  50600. */
  50601. protected _microSurface: number;
  50602. /**
  50603. * Specifies that the material will use the light map as a show map.
  50604. */
  50605. protected _useLightmapAsShadowmap: boolean;
  50606. /**
  50607. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50608. * makes the reflect vector face the model (under horizon).
  50609. */
  50610. protected _useHorizonOcclusion: boolean;
  50611. /**
  50612. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50613. * too much the area relying on ambient texture to define their ambient occlusion.
  50614. */
  50615. protected _useRadianceOcclusion: boolean;
  50616. /**
  50617. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50618. */
  50619. protected _useAlphaFromAlbedoTexture: boolean;
  50620. /**
  50621. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50622. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50623. */
  50624. protected _useSpecularOverAlpha: boolean;
  50625. /**
  50626. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50627. */
  50628. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50629. /**
  50630. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50631. */
  50632. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50633. /**
  50634. * Specifies if the metallic texture contains the roughness information in its green channel.
  50635. */
  50636. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50637. /**
  50638. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50639. */
  50640. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50641. /**
  50642. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50643. */
  50644. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50645. /**
  50646. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50647. */
  50648. protected _useAmbientInGrayScale: boolean;
  50649. /**
  50650. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50651. * The material will try to infer what glossiness each pixel should be.
  50652. */
  50653. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50654. /**
  50655. * Defines the falloff type used in this material.
  50656. * It by default is Physical.
  50657. */
  50658. protected _lightFalloff: number;
  50659. /**
  50660. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50661. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50662. */
  50663. protected _useRadianceOverAlpha: boolean;
  50664. /**
  50665. * Allows using an object space normal map (instead of tangent space).
  50666. */
  50667. protected _useObjectSpaceNormalMap: boolean;
  50668. /**
  50669. * Allows using the bump map in parallax mode.
  50670. */
  50671. protected _useParallax: boolean;
  50672. /**
  50673. * Allows using the bump map in parallax occlusion mode.
  50674. */
  50675. protected _useParallaxOcclusion: boolean;
  50676. /**
  50677. * Controls the scale bias of the parallax mode.
  50678. */
  50679. protected _parallaxScaleBias: number;
  50680. /**
  50681. * If sets to true, disables all the lights affecting the material.
  50682. */
  50683. protected _disableLighting: boolean;
  50684. /**
  50685. * Number of Simultaneous lights allowed on the material.
  50686. */
  50687. protected _maxSimultaneousLights: number;
  50688. /**
  50689. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50690. */
  50691. protected _invertNormalMapX: boolean;
  50692. /**
  50693. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50694. */
  50695. protected _invertNormalMapY: boolean;
  50696. /**
  50697. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50698. */
  50699. protected _twoSidedLighting: boolean;
  50700. /**
  50701. * Defines the alpha limits in alpha test mode.
  50702. */
  50703. protected _alphaCutOff: number;
  50704. /**
  50705. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50706. */
  50707. protected _forceAlphaTest: boolean;
  50708. /**
  50709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50710. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50711. */
  50712. protected _useAlphaFresnel: boolean;
  50713. /**
  50714. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50715. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50716. */
  50717. protected _useLinearAlphaFresnel: boolean;
  50718. /**
  50719. * The transparency mode of the material.
  50720. */
  50721. protected _transparencyMode: Nullable<number>;
  50722. /**
  50723. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50724. * from cos thetav and roughness:
  50725. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50726. */
  50727. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50728. /**
  50729. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50730. */
  50731. protected _forceIrradianceInFragment: boolean;
  50732. /**
  50733. * Force normal to face away from face.
  50734. */
  50735. protected _forceNormalForward: boolean;
  50736. /**
  50737. * Enables specular anti aliasing in the PBR shader.
  50738. * It will both interacts on the Geometry for analytical and IBL lighting.
  50739. * It also prefilter the roughness map based on the bump values.
  50740. */
  50741. protected _enableSpecularAntiAliasing: boolean;
  50742. /**
  50743. * Default configuration related to image processing available in the PBR Material.
  50744. */
  50745. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50746. /**
  50747. * Keep track of the image processing observer to allow dispose and replace.
  50748. */
  50749. private _imageProcessingObserver;
  50750. /**
  50751. * Attaches a new image processing configuration to the PBR Material.
  50752. * @param configuration
  50753. */
  50754. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50755. /**
  50756. * Stores the available render targets.
  50757. */
  50758. private _renderTargets;
  50759. /**
  50760. * Sets the global ambient color for the material used in lighting calculations.
  50761. */
  50762. private _globalAmbientColor;
  50763. /**
  50764. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50765. */
  50766. private _useLogarithmicDepth;
  50767. /**
  50768. * If set to true, no lighting calculations will be applied.
  50769. */
  50770. private _unlit;
  50771. private _debugMode;
  50772. /**
  50773. * @hidden
  50774. * This is reserved for the inspector.
  50775. * Defines the material debug mode.
  50776. * It helps seeing only some components of the material while troubleshooting.
  50777. */
  50778. debugMode: number;
  50779. /**
  50780. * @hidden
  50781. * This is reserved for the inspector.
  50782. * Specify from where on screen the debug mode should start.
  50783. * The value goes from -1 (full screen) to 1 (not visible)
  50784. * It helps with side by side comparison against the final render
  50785. * This defaults to -1
  50786. */
  50787. private debugLimit;
  50788. /**
  50789. * @hidden
  50790. * This is reserved for the inspector.
  50791. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50792. * You can use the factor to better multiply the final value.
  50793. */
  50794. private debugFactor;
  50795. /**
  50796. * Defines the clear coat layer parameters for the material.
  50797. */
  50798. readonly clearCoat: PBRClearCoatConfiguration;
  50799. /**
  50800. * Defines the anisotropic parameters for the material.
  50801. */
  50802. readonly anisotropy: PBRAnisotropicConfiguration;
  50803. /**
  50804. * Defines the BRDF parameters for the material.
  50805. */
  50806. readonly brdf: PBRBRDFConfiguration;
  50807. /**
  50808. * Defines the Sheen parameters for the material.
  50809. */
  50810. readonly sheen: PBRSheenConfiguration;
  50811. /**
  50812. * Defines the SubSurface parameters for the material.
  50813. */
  50814. readonly subSurface: PBRSubSurfaceConfiguration;
  50815. /**
  50816. * Custom callback helping to override the default shader used in the material.
  50817. */
  50818. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50819. protected _rebuildInParallel: boolean;
  50820. /**
  50821. * Instantiates a new PBRMaterial instance.
  50822. *
  50823. * @param name The material name
  50824. * @param scene The scene the material will be use in.
  50825. */
  50826. constructor(name: string, scene: Scene);
  50827. /**
  50828. * Gets a boolean indicating that current material needs to register RTT
  50829. */
  50830. readonly hasRenderTargetTextures: boolean;
  50831. /**
  50832. * Gets the name of the material class.
  50833. */
  50834. getClassName(): string;
  50835. /**
  50836. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50837. */
  50838. /**
  50839. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50840. */
  50841. useLogarithmicDepth: boolean;
  50842. /**
  50843. * Gets the current transparency mode.
  50844. */
  50845. /**
  50846. * Sets the transparency mode of the material.
  50847. *
  50848. * | Value | Type | Description |
  50849. * | ----- | ----------------------------------- | ----------- |
  50850. * | 0 | OPAQUE | |
  50851. * | 1 | ALPHATEST | |
  50852. * | 2 | ALPHABLEND | |
  50853. * | 3 | ALPHATESTANDBLEND | |
  50854. *
  50855. */
  50856. transparencyMode: Nullable<number>;
  50857. /**
  50858. * Returns true if alpha blending should be disabled.
  50859. */
  50860. private readonly _disableAlphaBlending;
  50861. /**
  50862. * Specifies whether or not this material should be rendered in alpha blend mode.
  50863. */
  50864. needAlphaBlending(): boolean;
  50865. /**
  50866. * Specifies if the mesh will require alpha blending.
  50867. * @param mesh - BJS mesh.
  50868. */
  50869. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50870. /**
  50871. * Specifies whether or not this material should be rendered in alpha test mode.
  50872. */
  50873. needAlphaTesting(): boolean;
  50874. /**
  50875. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50876. */
  50877. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50878. /**
  50879. * Gets the texture used for the alpha test.
  50880. */
  50881. getAlphaTestTexture(): Nullable<BaseTexture>;
  50882. /**
  50883. * Specifies that the submesh is ready to be used.
  50884. * @param mesh - BJS mesh.
  50885. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50886. * @param useInstances - Specifies that instances should be used.
  50887. * @returns - boolean indicating that the submesh is ready or not.
  50888. */
  50889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50890. /**
  50891. * Specifies if the material uses metallic roughness workflow.
  50892. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50893. */
  50894. isMetallicWorkflow(): boolean;
  50895. private _prepareEffect;
  50896. private _prepareDefines;
  50897. /**
  50898. * Force shader compilation
  50899. */
  50900. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50901. /**
  50902. * Initializes the uniform buffer layout for the shader.
  50903. */
  50904. buildUniformLayout(): void;
  50905. /**
  50906. * Unbinds the material from the mesh
  50907. */
  50908. unbind(): void;
  50909. /**
  50910. * Binds the submesh data.
  50911. * @param world - The world matrix.
  50912. * @param mesh - The BJS mesh.
  50913. * @param subMesh - A submesh of the BJS mesh.
  50914. */
  50915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50916. /**
  50917. * Returns the animatable textures.
  50918. * @returns - Array of animatable textures.
  50919. */
  50920. getAnimatables(): IAnimatable[];
  50921. /**
  50922. * Returns the texture used for reflections.
  50923. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50924. */
  50925. private _getReflectionTexture;
  50926. /**
  50927. * Returns an array of the actively used textures.
  50928. * @returns - Array of BaseTextures
  50929. */
  50930. getActiveTextures(): BaseTexture[];
  50931. /**
  50932. * Checks to see if a texture is used in the material.
  50933. * @param texture - Base texture to use.
  50934. * @returns - Boolean specifying if a texture is used in the material.
  50935. */
  50936. hasTexture(texture: BaseTexture): boolean;
  50937. /**
  50938. * Disposes the resources of the material.
  50939. * @param forceDisposeEffect - Forces the disposal of effects.
  50940. * @param forceDisposeTextures - Forces the disposal of all textures.
  50941. */
  50942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50943. }
  50944. }
  50945. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50946. import { Nullable } from "babylonjs/types";
  50947. import { Scene } from "babylonjs/scene";
  50948. import { Color3 } from "babylonjs/Maths/math.color";
  50949. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50950. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50952. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50953. /**
  50954. * The Physically based material of BJS.
  50955. *
  50956. * This offers the main features of a standard PBR material.
  50957. * For more information, please refer to the documentation :
  50958. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50959. */
  50960. export class PBRMaterial extends PBRBaseMaterial {
  50961. /**
  50962. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50963. */
  50964. static readonly PBRMATERIAL_OPAQUE: number;
  50965. /**
  50966. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50967. */
  50968. static readonly PBRMATERIAL_ALPHATEST: number;
  50969. /**
  50970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50971. */
  50972. static readonly PBRMATERIAL_ALPHABLEND: number;
  50973. /**
  50974. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50975. * They are also discarded below the alpha cutoff threshold to improve performances.
  50976. */
  50977. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50978. /**
  50979. * Defines the default value of how much AO map is occluding the analytical lights
  50980. * (point spot...).
  50981. */
  50982. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50983. /**
  50984. * Intensity of the direct lights e.g. the four lights available in your scene.
  50985. * This impacts both the direct diffuse and specular highlights.
  50986. */
  50987. directIntensity: number;
  50988. /**
  50989. * Intensity of the emissive part of the material.
  50990. * This helps controlling the emissive effect without modifying the emissive color.
  50991. */
  50992. emissiveIntensity: number;
  50993. /**
  50994. * Intensity of the environment e.g. how much the environment will light the object
  50995. * either through harmonics for rough material or through the refelction for shiny ones.
  50996. */
  50997. environmentIntensity: number;
  50998. /**
  50999. * This is a special control allowing the reduction of the specular highlights coming from the
  51000. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51001. */
  51002. specularIntensity: number;
  51003. /**
  51004. * Debug Control allowing disabling the bump map on this material.
  51005. */
  51006. disableBumpMap: boolean;
  51007. /**
  51008. * AKA Diffuse Texture in standard nomenclature.
  51009. */
  51010. albedoTexture: BaseTexture;
  51011. /**
  51012. * AKA Occlusion Texture in other nomenclature.
  51013. */
  51014. ambientTexture: BaseTexture;
  51015. /**
  51016. * AKA Occlusion Texture Intensity in other nomenclature.
  51017. */
  51018. ambientTextureStrength: number;
  51019. /**
  51020. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51021. * 1 means it completely occludes it
  51022. * 0 mean it has no impact
  51023. */
  51024. ambientTextureImpactOnAnalyticalLights: number;
  51025. /**
  51026. * Stores the alpha values in a texture.
  51027. */
  51028. opacityTexture: BaseTexture;
  51029. /**
  51030. * Stores the reflection values in a texture.
  51031. */
  51032. reflectionTexture: Nullable<BaseTexture>;
  51033. /**
  51034. * Stores the emissive values in a texture.
  51035. */
  51036. emissiveTexture: BaseTexture;
  51037. /**
  51038. * AKA Specular texture in other nomenclature.
  51039. */
  51040. reflectivityTexture: BaseTexture;
  51041. /**
  51042. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51043. */
  51044. metallicTexture: BaseTexture;
  51045. /**
  51046. * Specifies the metallic scalar of the metallic/roughness workflow.
  51047. * Can also be used to scale the metalness values of the metallic texture.
  51048. */
  51049. metallic: Nullable<number>;
  51050. /**
  51051. * Specifies the roughness scalar of the metallic/roughness workflow.
  51052. * Can also be used to scale the roughness values of the metallic texture.
  51053. */
  51054. roughness: Nullable<number>;
  51055. /**
  51056. * Specifies the an F0 factor to help configuring the material F0.
  51057. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51058. * to 0.5 the previously hard coded value stays the same.
  51059. * Can also be used to scale the F0 values of the metallic texture.
  51060. */
  51061. metallicF0Factor: number;
  51062. /**
  51063. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51064. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51065. * your expectation as it multiplies with the texture data.
  51066. */
  51067. useMetallicF0FactorFromMetallicTexture: boolean;
  51068. /**
  51069. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51070. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51071. */
  51072. microSurfaceTexture: BaseTexture;
  51073. /**
  51074. * Stores surface normal data used to displace a mesh in a texture.
  51075. */
  51076. bumpTexture: BaseTexture;
  51077. /**
  51078. * Stores the pre-calculated light information of a mesh in a texture.
  51079. */
  51080. lightmapTexture: BaseTexture;
  51081. /**
  51082. * Stores the refracted light information in a texture.
  51083. */
  51084. refractionTexture: Nullable<BaseTexture>;
  51085. /**
  51086. * The color of a material in ambient lighting.
  51087. */
  51088. ambientColor: Color3;
  51089. /**
  51090. * AKA Diffuse Color in other nomenclature.
  51091. */
  51092. albedoColor: Color3;
  51093. /**
  51094. * AKA Specular Color in other nomenclature.
  51095. */
  51096. reflectivityColor: Color3;
  51097. /**
  51098. * The color reflected from the material.
  51099. */
  51100. reflectionColor: Color3;
  51101. /**
  51102. * The color emitted from the material.
  51103. */
  51104. emissiveColor: Color3;
  51105. /**
  51106. * AKA Glossiness in other nomenclature.
  51107. */
  51108. microSurface: number;
  51109. /**
  51110. * source material index of refraction (IOR)' / 'destination material IOR.
  51111. */
  51112. indexOfRefraction: number;
  51113. /**
  51114. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51115. */
  51116. invertRefractionY: boolean;
  51117. /**
  51118. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51119. * Materials half opaque for instance using refraction could benefit from this control.
  51120. */
  51121. linkRefractionWithTransparency: boolean;
  51122. /**
  51123. * If true, the light map contains occlusion information instead of lighting info.
  51124. */
  51125. useLightmapAsShadowmap: boolean;
  51126. /**
  51127. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51128. */
  51129. useAlphaFromAlbedoTexture: boolean;
  51130. /**
  51131. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51132. */
  51133. forceAlphaTest: boolean;
  51134. /**
  51135. * Defines the alpha limits in alpha test mode.
  51136. */
  51137. alphaCutOff: number;
  51138. /**
  51139. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51140. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51141. */
  51142. useSpecularOverAlpha: boolean;
  51143. /**
  51144. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51145. */
  51146. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51147. /**
  51148. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51149. */
  51150. useRoughnessFromMetallicTextureAlpha: boolean;
  51151. /**
  51152. * Specifies if the metallic texture contains the roughness information in its green channel.
  51153. */
  51154. useRoughnessFromMetallicTextureGreen: boolean;
  51155. /**
  51156. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51157. */
  51158. useMetallnessFromMetallicTextureBlue: boolean;
  51159. /**
  51160. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51161. */
  51162. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51163. /**
  51164. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51165. */
  51166. useAmbientInGrayScale: boolean;
  51167. /**
  51168. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51169. * The material will try to infer what glossiness each pixel should be.
  51170. */
  51171. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51172. /**
  51173. * BJS is using an harcoded light falloff based on a manually sets up range.
  51174. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51175. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51176. */
  51177. /**
  51178. * BJS is using an harcoded light falloff based on a manually sets up range.
  51179. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51180. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51181. */
  51182. usePhysicalLightFalloff: boolean;
  51183. /**
  51184. * In order to support the falloff compatibility with gltf, a special mode has been added
  51185. * to reproduce the gltf light falloff.
  51186. */
  51187. /**
  51188. * In order to support the falloff compatibility with gltf, a special mode has been added
  51189. * to reproduce the gltf light falloff.
  51190. */
  51191. useGLTFLightFalloff: boolean;
  51192. /**
  51193. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51194. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51195. */
  51196. useRadianceOverAlpha: boolean;
  51197. /**
  51198. * Allows using an object space normal map (instead of tangent space).
  51199. */
  51200. useObjectSpaceNormalMap: boolean;
  51201. /**
  51202. * Allows using the bump map in parallax mode.
  51203. */
  51204. useParallax: boolean;
  51205. /**
  51206. * Allows using the bump map in parallax occlusion mode.
  51207. */
  51208. useParallaxOcclusion: boolean;
  51209. /**
  51210. * Controls the scale bias of the parallax mode.
  51211. */
  51212. parallaxScaleBias: number;
  51213. /**
  51214. * If sets to true, disables all the lights affecting the material.
  51215. */
  51216. disableLighting: boolean;
  51217. /**
  51218. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51219. */
  51220. forceIrradianceInFragment: boolean;
  51221. /**
  51222. * Number of Simultaneous lights allowed on the material.
  51223. */
  51224. maxSimultaneousLights: number;
  51225. /**
  51226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51227. */
  51228. invertNormalMapX: boolean;
  51229. /**
  51230. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51231. */
  51232. invertNormalMapY: boolean;
  51233. /**
  51234. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51235. */
  51236. twoSidedLighting: boolean;
  51237. /**
  51238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51239. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51240. */
  51241. useAlphaFresnel: boolean;
  51242. /**
  51243. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51244. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51245. */
  51246. useLinearAlphaFresnel: boolean;
  51247. /**
  51248. * Let user defines the brdf lookup texture used for IBL.
  51249. * A default 8bit version is embedded but you could point at :
  51250. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51251. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51252. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51253. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51254. */
  51255. environmentBRDFTexture: Nullable<BaseTexture>;
  51256. /**
  51257. * Force normal to face away from face.
  51258. */
  51259. forceNormalForward: boolean;
  51260. /**
  51261. * Enables specular anti aliasing in the PBR shader.
  51262. * It will both interacts on the Geometry for analytical and IBL lighting.
  51263. * It also prefilter the roughness map based on the bump values.
  51264. */
  51265. enableSpecularAntiAliasing: boolean;
  51266. /**
  51267. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51268. * makes the reflect vector face the model (under horizon).
  51269. */
  51270. useHorizonOcclusion: boolean;
  51271. /**
  51272. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51273. * too much the area relying on ambient texture to define their ambient occlusion.
  51274. */
  51275. useRadianceOcclusion: boolean;
  51276. /**
  51277. * If set to true, no lighting calculations will be applied.
  51278. */
  51279. unlit: boolean;
  51280. /**
  51281. * Gets the image processing configuration used either in this material.
  51282. */
  51283. /**
  51284. * Sets the Default image processing configuration used either in the this material.
  51285. *
  51286. * If sets to null, the scene one is in use.
  51287. */
  51288. imageProcessingConfiguration: ImageProcessingConfiguration;
  51289. /**
  51290. * Gets wether the color curves effect is enabled.
  51291. */
  51292. /**
  51293. * Sets wether the color curves effect is enabled.
  51294. */
  51295. cameraColorCurvesEnabled: boolean;
  51296. /**
  51297. * Gets wether the color grading effect is enabled.
  51298. */
  51299. /**
  51300. * Gets wether the color grading effect is enabled.
  51301. */
  51302. cameraColorGradingEnabled: boolean;
  51303. /**
  51304. * Gets wether tonemapping is enabled or not.
  51305. */
  51306. /**
  51307. * Sets wether tonemapping is enabled or not
  51308. */
  51309. cameraToneMappingEnabled: boolean;
  51310. /**
  51311. * The camera exposure used on this material.
  51312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51313. * This corresponds to a photographic exposure.
  51314. */
  51315. /**
  51316. * The camera exposure used on this material.
  51317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51318. * This corresponds to a photographic exposure.
  51319. */
  51320. cameraExposure: number;
  51321. /**
  51322. * Gets The camera contrast used on this material.
  51323. */
  51324. /**
  51325. * Sets The camera contrast used on this material.
  51326. */
  51327. cameraContrast: number;
  51328. /**
  51329. * Gets the Color Grading 2D Lookup Texture.
  51330. */
  51331. /**
  51332. * Sets the Color Grading 2D Lookup Texture.
  51333. */
  51334. cameraColorGradingTexture: Nullable<BaseTexture>;
  51335. /**
  51336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51338. * 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;
  51339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51340. */
  51341. /**
  51342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51344. * 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;
  51345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51346. */
  51347. cameraColorCurves: Nullable<ColorCurves>;
  51348. /**
  51349. * Instantiates a new PBRMaterial instance.
  51350. *
  51351. * @param name The material name
  51352. * @param scene The scene the material will be use in.
  51353. */
  51354. constructor(name: string, scene: Scene);
  51355. /**
  51356. * Returns the name of this material class.
  51357. */
  51358. getClassName(): string;
  51359. /**
  51360. * Makes a duplicate of the current material.
  51361. * @param name - name to use for the new material.
  51362. */
  51363. clone(name: string): PBRMaterial;
  51364. /**
  51365. * Serializes this PBR Material.
  51366. * @returns - An object with the serialized material.
  51367. */
  51368. serialize(): any;
  51369. /**
  51370. * Parses a PBR Material from a serialized object.
  51371. * @param source - Serialized object.
  51372. * @param scene - BJS scene instance.
  51373. * @param rootUrl - url for the scene object
  51374. * @returns - PBRMaterial
  51375. */
  51376. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51377. }
  51378. }
  51379. declare module "babylonjs/Misc/dds" {
  51380. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51382. import { Nullable } from "babylonjs/types";
  51383. import { Scene } from "babylonjs/scene";
  51384. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51385. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51386. /**
  51387. * Direct draw surface info
  51388. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51389. */
  51390. export interface DDSInfo {
  51391. /**
  51392. * Width of the texture
  51393. */
  51394. width: number;
  51395. /**
  51396. * Width of the texture
  51397. */
  51398. height: number;
  51399. /**
  51400. * Number of Mipmaps for the texture
  51401. * @see https://en.wikipedia.org/wiki/Mipmap
  51402. */
  51403. mipmapCount: number;
  51404. /**
  51405. * If the textures format is a known fourCC format
  51406. * @see https://www.fourcc.org/
  51407. */
  51408. isFourCC: boolean;
  51409. /**
  51410. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51411. */
  51412. isRGB: boolean;
  51413. /**
  51414. * If the texture is a lumincance format
  51415. */
  51416. isLuminance: boolean;
  51417. /**
  51418. * If this is a cube texture
  51419. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51420. */
  51421. isCube: boolean;
  51422. /**
  51423. * If the texture is a compressed format eg. FOURCC_DXT1
  51424. */
  51425. isCompressed: boolean;
  51426. /**
  51427. * The dxgiFormat of the texture
  51428. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51429. */
  51430. dxgiFormat: number;
  51431. /**
  51432. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51433. */
  51434. textureType: number;
  51435. /**
  51436. * Sphericle polynomial created for the dds texture
  51437. */
  51438. sphericalPolynomial?: SphericalPolynomial;
  51439. }
  51440. /**
  51441. * Class used to provide DDS decompression tools
  51442. */
  51443. export class DDSTools {
  51444. /**
  51445. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51446. */
  51447. static StoreLODInAlphaChannel: boolean;
  51448. /**
  51449. * Gets DDS information from an array buffer
  51450. * @param arrayBuffer defines the array buffer to read data from
  51451. * @returns the DDS information
  51452. */
  51453. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51454. private static _FloatView;
  51455. private static _Int32View;
  51456. private static _ToHalfFloat;
  51457. private static _FromHalfFloat;
  51458. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51459. private static _GetHalfFloatRGBAArrayBuffer;
  51460. private static _GetFloatRGBAArrayBuffer;
  51461. private static _GetFloatAsUIntRGBAArrayBuffer;
  51462. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51463. private static _GetRGBAArrayBuffer;
  51464. private static _ExtractLongWordOrder;
  51465. private static _GetRGBArrayBuffer;
  51466. private static _GetLuminanceArrayBuffer;
  51467. /**
  51468. * Uploads DDS Levels to a Babylon Texture
  51469. * @hidden
  51470. */
  51471. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51472. }
  51473. module "babylonjs/Engines/thinEngine" {
  51474. interface ThinEngine {
  51475. /**
  51476. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51477. * @param rootUrl defines the url where the file to load is located
  51478. * @param scene defines the current scene
  51479. * @param lodScale defines scale to apply to the mip map selection
  51480. * @param lodOffset defines offset to apply to the mip map selection
  51481. * @param onLoad defines an optional callback raised when the texture is loaded
  51482. * @param onError defines an optional callback raised if there is an issue to load the texture
  51483. * @param format defines the format of the data
  51484. * @param forcedExtension defines the extension to use to pick the right loader
  51485. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51486. * @returns the cube texture as an InternalTexture
  51487. */
  51488. 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;
  51489. }
  51490. }
  51491. }
  51492. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51493. import { Nullable } from "babylonjs/types";
  51494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51495. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51496. /**
  51497. * Implementation of the DDS Texture Loader.
  51498. * @hidden
  51499. */
  51500. export class _DDSTextureLoader implements IInternalTextureLoader {
  51501. /**
  51502. * Defines wether the loader supports cascade loading the different faces.
  51503. */
  51504. readonly supportCascades: boolean;
  51505. /**
  51506. * This returns if the loader support the current file information.
  51507. * @param extension defines the file extension of the file being loaded
  51508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51509. * @param fallback defines the fallback internal texture if any
  51510. * @param isBase64 defines whether the texture is encoded as a base64
  51511. * @param isBuffer defines whether the texture data are stored as a buffer
  51512. * @returns true if the loader can load the specified file
  51513. */
  51514. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51515. /**
  51516. * Transform the url before loading if required.
  51517. * @param rootUrl the url of the texture
  51518. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51519. * @returns the transformed texture
  51520. */
  51521. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51522. /**
  51523. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51524. * @param rootUrl the url of the texture
  51525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51526. * @returns the fallback texture
  51527. */
  51528. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51529. /**
  51530. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51531. * @param data contains the texture data
  51532. * @param texture defines the BabylonJS internal texture
  51533. * @param createPolynomials will be true if polynomials have been requested
  51534. * @param onLoad defines the callback to trigger once the texture is ready
  51535. * @param onError defines the callback to trigger in case of error
  51536. */
  51537. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51538. /**
  51539. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51540. * @param data contains the texture data
  51541. * @param texture defines the BabylonJS internal texture
  51542. * @param callback defines the method to call once ready to upload
  51543. */
  51544. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51545. }
  51546. }
  51547. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51548. import { Nullable } from "babylonjs/types";
  51549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51550. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51551. /**
  51552. * Implementation of the ENV Texture Loader.
  51553. * @hidden
  51554. */
  51555. export class _ENVTextureLoader implements IInternalTextureLoader {
  51556. /**
  51557. * Defines wether the loader supports cascade loading the different faces.
  51558. */
  51559. readonly supportCascades: boolean;
  51560. /**
  51561. * This returns if the loader support the current file information.
  51562. * @param extension defines the file extension of the file being loaded
  51563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51564. * @param fallback defines the fallback internal texture if any
  51565. * @param isBase64 defines whether the texture is encoded as a base64
  51566. * @param isBuffer defines whether the texture data are stored as a buffer
  51567. * @returns true if the loader can load the specified file
  51568. */
  51569. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51570. /**
  51571. * Transform the url before loading if required.
  51572. * @param rootUrl the url of the texture
  51573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51574. * @returns the transformed texture
  51575. */
  51576. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51577. /**
  51578. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51579. * @param rootUrl the url of the texture
  51580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51581. * @returns the fallback texture
  51582. */
  51583. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51584. /**
  51585. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51586. * @param data contains the texture data
  51587. * @param texture defines the BabylonJS internal texture
  51588. * @param createPolynomials will be true if polynomials have been requested
  51589. * @param onLoad defines the callback to trigger once the texture is ready
  51590. * @param onError defines the callback to trigger in case of error
  51591. */
  51592. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51593. /**
  51594. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51595. * @param data contains the texture data
  51596. * @param texture defines the BabylonJS internal texture
  51597. * @param callback defines the method to call once ready to upload
  51598. */
  51599. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51600. }
  51601. }
  51602. declare module "babylonjs/Misc/khronosTextureContainer" {
  51603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51604. /**
  51605. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51606. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51607. */
  51608. export class KhronosTextureContainer {
  51609. /** contents of the KTX container file */
  51610. arrayBuffer: any;
  51611. private static HEADER_LEN;
  51612. private static COMPRESSED_2D;
  51613. private static COMPRESSED_3D;
  51614. private static TEX_2D;
  51615. private static TEX_3D;
  51616. /**
  51617. * Gets the openGL type
  51618. */
  51619. glType: number;
  51620. /**
  51621. * Gets the openGL type size
  51622. */
  51623. glTypeSize: number;
  51624. /**
  51625. * Gets the openGL format
  51626. */
  51627. glFormat: number;
  51628. /**
  51629. * Gets the openGL internal format
  51630. */
  51631. glInternalFormat: number;
  51632. /**
  51633. * Gets the base internal format
  51634. */
  51635. glBaseInternalFormat: number;
  51636. /**
  51637. * Gets image width in pixel
  51638. */
  51639. pixelWidth: number;
  51640. /**
  51641. * Gets image height in pixel
  51642. */
  51643. pixelHeight: number;
  51644. /**
  51645. * Gets image depth in pixels
  51646. */
  51647. pixelDepth: number;
  51648. /**
  51649. * Gets the number of array elements
  51650. */
  51651. numberOfArrayElements: number;
  51652. /**
  51653. * Gets the number of faces
  51654. */
  51655. numberOfFaces: number;
  51656. /**
  51657. * Gets the number of mipmap levels
  51658. */
  51659. numberOfMipmapLevels: number;
  51660. /**
  51661. * Gets the bytes of key value data
  51662. */
  51663. bytesOfKeyValueData: number;
  51664. /**
  51665. * Gets the load type
  51666. */
  51667. loadType: number;
  51668. /**
  51669. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51670. */
  51671. isInvalid: boolean;
  51672. /**
  51673. * Creates a new KhronosTextureContainer
  51674. * @param arrayBuffer contents of the KTX container file
  51675. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51676. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51677. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51678. */
  51679. constructor(
  51680. /** contents of the KTX container file */
  51681. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51682. /**
  51683. * Uploads KTX content to a Babylon Texture.
  51684. * It is assumed that the texture has already been created & is currently bound
  51685. * @hidden
  51686. */
  51687. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51688. private _upload2DCompressedLevels;
  51689. }
  51690. }
  51691. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51692. import { Nullable } from "babylonjs/types";
  51693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51694. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51695. /**
  51696. * Implementation of the KTX Texture Loader.
  51697. * @hidden
  51698. */
  51699. export class _KTXTextureLoader implements IInternalTextureLoader {
  51700. /**
  51701. * Defines wether the loader supports cascade loading the different faces.
  51702. */
  51703. readonly supportCascades: boolean;
  51704. /**
  51705. * This returns if the loader support the current file information.
  51706. * @param extension defines the file extension of the file being loaded
  51707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51708. * @param fallback defines the fallback internal texture if any
  51709. * @param isBase64 defines whether the texture is encoded as a base64
  51710. * @param isBuffer defines whether the texture data are stored as a buffer
  51711. * @returns true if the loader can load the specified file
  51712. */
  51713. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51714. /**
  51715. * Transform the url before loading if required.
  51716. * @param rootUrl the url of the texture
  51717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51718. * @returns the transformed texture
  51719. */
  51720. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51721. /**
  51722. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51723. * @param rootUrl the url of the texture
  51724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51725. * @returns the fallback texture
  51726. */
  51727. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51728. /**
  51729. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51730. * @param data contains the texture data
  51731. * @param texture defines the BabylonJS internal texture
  51732. * @param createPolynomials will be true if polynomials have been requested
  51733. * @param onLoad defines the callback to trigger once the texture is ready
  51734. * @param onError defines the callback to trigger in case of error
  51735. */
  51736. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51737. /**
  51738. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51739. * @param data contains the texture data
  51740. * @param texture defines the BabylonJS internal texture
  51741. * @param callback defines the method to call once ready to upload
  51742. */
  51743. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51744. }
  51745. }
  51746. declare module "babylonjs/Helpers/sceneHelpers" {
  51747. import { Nullable } from "babylonjs/types";
  51748. import { Mesh } from "babylonjs/Meshes/mesh";
  51749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51750. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51751. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51752. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51753. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51754. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51755. import "babylonjs/Meshes/Builders/boxBuilder";
  51756. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51757. /** @hidden */
  51758. export var _forceSceneHelpersToBundle: boolean;
  51759. module "babylonjs/scene" {
  51760. interface Scene {
  51761. /**
  51762. * Creates a default light for the scene.
  51763. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51764. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51765. */
  51766. createDefaultLight(replace?: boolean): void;
  51767. /**
  51768. * Creates a default camera for the scene.
  51769. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51770. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51771. * @param replace has default false, when true replaces the active camera in the scene
  51772. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51773. */
  51774. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51775. /**
  51776. * Creates a default camera and a default light.
  51777. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51778. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51779. * @param replace has the default false, when true replaces the active camera/light in the scene
  51780. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51781. */
  51782. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51783. /**
  51784. * Creates a new sky box
  51785. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51786. * @param environmentTexture defines the texture to use as environment texture
  51787. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51788. * @param scale defines the overall scale of the skybox
  51789. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51790. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51791. * @returns a new mesh holding the sky box
  51792. */
  51793. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51794. /**
  51795. * Creates a new environment
  51796. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51797. * @param options defines the options you can use to configure the environment
  51798. * @returns the new EnvironmentHelper
  51799. */
  51800. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51801. /**
  51802. * Creates a new VREXperienceHelper
  51803. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51804. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51805. * @returns a new VREXperienceHelper
  51806. */
  51807. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51808. /**
  51809. * Creates a new WebXRDefaultExperience
  51810. * @see http://doc.babylonjs.com/how_to/webxr
  51811. * @param options experience options
  51812. * @returns a promise for a new WebXRDefaultExperience
  51813. */
  51814. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51815. }
  51816. }
  51817. }
  51818. declare module "babylonjs/Helpers/videoDome" {
  51819. import { Scene } from "babylonjs/scene";
  51820. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51821. import { Mesh } from "babylonjs/Meshes/mesh";
  51822. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51823. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51824. import "babylonjs/Meshes/Builders/sphereBuilder";
  51825. /**
  51826. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51827. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51828. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51829. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51830. */
  51831. export class VideoDome extends TransformNode {
  51832. /**
  51833. * Define the video source as a Monoscopic panoramic 360 video.
  51834. */
  51835. static readonly MODE_MONOSCOPIC: number;
  51836. /**
  51837. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51838. */
  51839. static readonly MODE_TOPBOTTOM: number;
  51840. /**
  51841. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51842. */
  51843. static readonly MODE_SIDEBYSIDE: number;
  51844. private _halfDome;
  51845. private _useDirectMapping;
  51846. /**
  51847. * The video texture being displayed on the sphere
  51848. */
  51849. protected _videoTexture: VideoTexture;
  51850. /**
  51851. * Gets the video texture being displayed on the sphere
  51852. */
  51853. readonly videoTexture: VideoTexture;
  51854. /**
  51855. * The skybox material
  51856. */
  51857. protected _material: BackgroundMaterial;
  51858. /**
  51859. * The surface used for the skybox
  51860. */
  51861. protected _mesh: Mesh;
  51862. /**
  51863. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51864. */
  51865. private _halfDomeMask;
  51866. /**
  51867. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51868. * Also see the options.resolution property.
  51869. */
  51870. fovMultiplier: number;
  51871. private _videoMode;
  51872. /**
  51873. * Gets or set the current video mode for the video. It can be:
  51874. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51875. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51876. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51877. */
  51878. videoMode: number;
  51879. /**
  51880. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51881. *
  51882. */
  51883. /**
  51884. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51885. */
  51886. halfDome: boolean;
  51887. /**
  51888. * Oberserver used in Stereoscopic VR Mode.
  51889. */
  51890. private _onBeforeCameraRenderObserver;
  51891. /**
  51892. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51893. * @param name Element's name, child elements will append suffixes for their own names.
  51894. * @param urlsOrVideo defines the url(s) or the video element to use
  51895. * @param options An object containing optional or exposed sub element properties
  51896. */
  51897. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51898. resolution?: number;
  51899. clickToPlay?: boolean;
  51900. autoPlay?: boolean;
  51901. loop?: boolean;
  51902. size?: number;
  51903. poster?: string;
  51904. faceForward?: boolean;
  51905. useDirectMapping?: boolean;
  51906. halfDomeMode?: boolean;
  51907. }, scene: Scene);
  51908. private _changeVideoMode;
  51909. /**
  51910. * Releases resources associated with this node.
  51911. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51912. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51913. */
  51914. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51915. }
  51916. }
  51917. declare module "babylonjs/Helpers/index" {
  51918. export * from "babylonjs/Helpers/environmentHelper";
  51919. export * from "babylonjs/Helpers/photoDome";
  51920. export * from "babylonjs/Helpers/sceneHelpers";
  51921. export * from "babylonjs/Helpers/videoDome";
  51922. }
  51923. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51924. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51925. import { IDisposable } from "babylonjs/scene";
  51926. import { Engine } from "babylonjs/Engines/engine";
  51927. /**
  51928. * This class can be used to get instrumentation data from a Babylon engine
  51929. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51930. */
  51931. export class EngineInstrumentation implements IDisposable {
  51932. /**
  51933. * Define the instrumented engine.
  51934. */
  51935. engine: Engine;
  51936. private _captureGPUFrameTime;
  51937. private _gpuFrameTimeToken;
  51938. private _gpuFrameTime;
  51939. private _captureShaderCompilationTime;
  51940. private _shaderCompilationTime;
  51941. private _onBeginFrameObserver;
  51942. private _onEndFrameObserver;
  51943. private _onBeforeShaderCompilationObserver;
  51944. private _onAfterShaderCompilationObserver;
  51945. /**
  51946. * Gets the perf counter used for GPU frame time
  51947. */
  51948. readonly gpuFrameTimeCounter: PerfCounter;
  51949. /**
  51950. * Gets the GPU frame time capture status
  51951. */
  51952. /**
  51953. * Enable or disable the GPU frame time capture
  51954. */
  51955. captureGPUFrameTime: boolean;
  51956. /**
  51957. * Gets the perf counter used for shader compilation time
  51958. */
  51959. readonly shaderCompilationTimeCounter: PerfCounter;
  51960. /**
  51961. * Gets the shader compilation time capture status
  51962. */
  51963. /**
  51964. * Enable or disable the shader compilation time capture
  51965. */
  51966. captureShaderCompilationTime: boolean;
  51967. /**
  51968. * Instantiates a new engine instrumentation.
  51969. * This class can be used to get instrumentation data from a Babylon engine
  51970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51971. * @param engine Defines the engine to instrument
  51972. */
  51973. constructor(
  51974. /**
  51975. * Define the instrumented engine.
  51976. */
  51977. engine: Engine);
  51978. /**
  51979. * Dispose and release associated resources.
  51980. */
  51981. dispose(): void;
  51982. }
  51983. }
  51984. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51985. import { Scene, IDisposable } from "babylonjs/scene";
  51986. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51987. /**
  51988. * This class can be used to get instrumentation data from a Babylon engine
  51989. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51990. */
  51991. export class SceneInstrumentation implements IDisposable {
  51992. /**
  51993. * Defines the scene to instrument
  51994. */
  51995. scene: Scene;
  51996. private _captureActiveMeshesEvaluationTime;
  51997. private _activeMeshesEvaluationTime;
  51998. private _captureRenderTargetsRenderTime;
  51999. private _renderTargetsRenderTime;
  52000. private _captureFrameTime;
  52001. private _frameTime;
  52002. private _captureRenderTime;
  52003. private _renderTime;
  52004. private _captureInterFrameTime;
  52005. private _interFrameTime;
  52006. private _captureParticlesRenderTime;
  52007. private _particlesRenderTime;
  52008. private _captureSpritesRenderTime;
  52009. private _spritesRenderTime;
  52010. private _capturePhysicsTime;
  52011. private _physicsTime;
  52012. private _captureAnimationsTime;
  52013. private _animationsTime;
  52014. private _captureCameraRenderTime;
  52015. private _cameraRenderTime;
  52016. private _onBeforeActiveMeshesEvaluationObserver;
  52017. private _onAfterActiveMeshesEvaluationObserver;
  52018. private _onBeforeRenderTargetsRenderObserver;
  52019. private _onAfterRenderTargetsRenderObserver;
  52020. private _onAfterRenderObserver;
  52021. private _onBeforeDrawPhaseObserver;
  52022. private _onAfterDrawPhaseObserver;
  52023. private _onBeforeAnimationsObserver;
  52024. private _onBeforeParticlesRenderingObserver;
  52025. private _onAfterParticlesRenderingObserver;
  52026. private _onBeforeSpritesRenderingObserver;
  52027. private _onAfterSpritesRenderingObserver;
  52028. private _onBeforePhysicsObserver;
  52029. private _onAfterPhysicsObserver;
  52030. private _onAfterAnimationsObserver;
  52031. private _onBeforeCameraRenderObserver;
  52032. private _onAfterCameraRenderObserver;
  52033. /**
  52034. * Gets the perf counter used for active meshes evaluation time
  52035. */
  52036. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52037. /**
  52038. * Gets the active meshes evaluation time capture status
  52039. */
  52040. /**
  52041. * Enable or disable the active meshes evaluation time capture
  52042. */
  52043. captureActiveMeshesEvaluationTime: boolean;
  52044. /**
  52045. * Gets the perf counter used for render targets render time
  52046. */
  52047. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52048. /**
  52049. * Gets the render targets render time capture status
  52050. */
  52051. /**
  52052. * Enable or disable the render targets render time capture
  52053. */
  52054. captureRenderTargetsRenderTime: boolean;
  52055. /**
  52056. * Gets the perf counter used for particles render time
  52057. */
  52058. readonly particlesRenderTimeCounter: PerfCounter;
  52059. /**
  52060. * Gets the particles render time capture status
  52061. */
  52062. /**
  52063. * Enable or disable the particles render time capture
  52064. */
  52065. captureParticlesRenderTime: boolean;
  52066. /**
  52067. * Gets the perf counter used for sprites render time
  52068. */
  52069. readonly spritesRenderTimeCounter: PerfCounter;
  52070. /**
  52071. * Gets the sprites render time capture status
  52072. */
  52073. /**
  52074. * Enable or disable the sprites render time capture
  52075. */
  52076. captureSpritesRenderTime: boolean;
  52077. /**
  52078. * Gets the perf counter used for physics time
  52079. */
  52080. readonly physicsTimeCounter: PerfCounter;
  52081. /**
  52082. * Gets the physics time capture status
  52083. */
  52084. /**
  52085. * Enable or disable the physics time capture
  52086. */
  52087. capturePhysicsTime: boolean;
  52088. /**
  52089. * Gets the perf counter used for animations time
  52090. */
  52091. readonly animationsTimeCounter: PerfCounter;
  52092. /**
  52093. * Gets the animations time capture status
  52094. */
  52095. /**
  52096. * Enable or disable the animations time capture
  52097. */
  52098. captureAnimationsTime: boolean;
  52099. /**
  52100. * Gets the perf counter used for frame time capture
  52101. */
  52102. readonly frameTimeCounter: PerfCounter;
  52103. /**
  52104. * Gets the frame time capture status
  52105. */
  52106. /**
  52107. * Enable or disable the frame time capture
  52108. */
  52109. captureFrameTime: boolean;
  52110. /**
  52111. * Gets the perf counter used for inter-frames time capture
  52112. */
  52113. readonly interFrameTimeCounter: PerfCounter;
  52114. /**
  52115. * Gets the inter-frames time capture status
  52116. */
  52117. /**
  52118. * Enable or disable the inter-frames time capture
  52119. */
  52120. captureInterFrameTime: boolean;
  52121. /**
  52122. * Gets the perf counter used for render time capture
  52123. */
  52124. readonly renderTimeCounter: PerfCounter;
  52125. /**
  52126. * Gets the render time capture status
  52127. */
  52128. /**
  52129. * Enable or disable the render time capture
  52130. */
  52131. captureRenderTime: boolean;
  52132. /**
  52133. * Gets the perf counter used for camera render time capture
  52134. */
  52135. readonly cameraRenderTimeCounter: PerfCounter;
  52136. /**
  52137. * Gets the camera render time capture status
  52138. */
  52139. /**
  52140. * Enable or disable the camera render time capture
  52141. */
  52142. captureCameraRenderTime: boolean;
  52143. /**
  52144. * Gets the perf counter used for draw calls
  52145. */
  52146. readonly drawCallsCounter: PerfCounter;
  52147. /**
  52148. * Instantiates a new scene instrumentation.
  52149. * This class can be used to get instrumentation data from a Babylon engine
  52150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52151. * @param scene Defines the scene to instrument
  52152. */
  52153. constructor(
  52154. /**
  52155. * Defines the scene to instrument
  52156. */
  52157. scene: Scene);
  52158. /**
  52159. * Dispose and release associated resources.
  52160. */
  52161. dispose(): void;
  52162. }
  52163. }
  52164. declare module "babylonjs/Instrumentation/index" {
  52165. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52166. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52167. export * from "babylonjs/Instrumentation/timeToken";
  52168. }
  52169. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52170. /** @hidden */
  52171. export var glowMapGenerationPixelShader: {
  52172. name: string;
  52173. shader: string;
  52174. };
  52175. }
  52176. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52177. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52178. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52179. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52180. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52181. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52182. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52183. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52184. /** @hidden */
  52185. export var glowMapGenerationVertexShader: {
  52186. name: string;
  52187. shader: string;
  52188. };
  52189. }
  52190. declare module "babylonjs/Layers/effectLayer" {
  52191. import { Observable } from "babylonjs/Misc/observable";
  52192. import { Nullable } from "babylonjs/types";
  52193. import { Camera } from "babylonjs/Cameras/camera";
  52194. import { Scene } from "babylonjs/scene";
  52195. import { ISize } from "babylonjs/Maths/math.size";
  52196. import { Color4 } from "babylonjs/Maths/math.color";
  52197. import { Engine } from "babylonjs/Engines/engine";
  52198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52200. import { Mesh } from "babylonjs/Meshes/mesh";
  52201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52203. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52204. import { Effect } from "babylonjs/Materials/effect";
  52205. import { Material } from "babylonjs/Materials/material";
  52206. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52207. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52208. /**
  52209. * Effect layer options. This helps customizing the behaviour
  52210. * of the effect layer.
  52211. */
  52212. export interface IEffectLayerOptions {
  52213. /**
  52214. * Multiplication factor apply to the canvas size to compute the render target size
  52215. * used to generated the objects (the smaller the faster).
  52216. */
  52217. mainTextureRatio: number;
  52218. /**
  52219. * Enforces a fixed size texture to ensure effect stability across devices.
  52220. */
  52221. mainTextureFixedSize?: number;
  52222. /**
  52223. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52224. */
  52225. alphaBlendingMode: number;
  52226. /**
  52227. * The camera attached to the layer.
  52228. */
  52229. camera: Nullable<Camera>;
  52230. /**
  52231. * The rendering group to draw the layer in.
  52232. */
  52233. renderingGroupId: number;
  52234. }
  52235. /**
  52236. * The effect layer Helps adding post process effect blended with the main pass.
  52237. *
  52238. * This can be for instance use to generate glow or higlight effects on the scene.
  52239. *
  52240. * The effect layer class can not be used directly and is intented to inherited from to be
  52241. * customized per effects.
  52242. */
  52243. export abstract class EffectLayer {
  52244. private _vertexBuffers;
  52245. private _indexBuffer;
  52246. private _cachedDefines;
  52247. private _effectLayerMapGenerationEffect;
  52248. private _effectLayerOptions;
  52249. private _mergeEffect;
  52250. protected _scene: Scene;
  52251. protected _engine: Engine;
  52252. protected _maxSize: number;
  52253. protected _mainTextureDesiredSize: ISize;
  52254. protected _mainTexture: RenderTargetTexture;
  52255. protected _shouldRender: boolean;
  52256. protected _postProcesses: PostProcess[];
  52257. protected _textures: BaseTexture[];
  52258. protected _emissiveTextureAndColor: {
  52259. texture: Nullable<BaseTexture>;
  52260. color: Color4;
  52261. };
  52262. /**
  52263. * The name of the layer
  52264. */
  52265. name: string;
  52266. /**
  52267. * The clear color of the texture used to generate the glow map.
  52268. */
  52269. neutralColor: Color4;
  52270. /**
  52271. * Specifies wether the highlight layer is enabled or not.
  52272. */
  52273. isEnabled: boolean;
  52274. /**
  52275. * Gets the camera attached to the layer.
  52276. */
  52277. readonly camera: Nullable<Camera>;
  52278. /**
  52279. * Gets the rendering group id the layer should render in.
  52280. */
  52281. renderingGroupId: number;
  52282. /**
  52283. * An event triggered when the effect layer has been disposed.
  52284. */
  52285. onDisposeObservable: Observable<EffectLayer>;
  52286. /**
  52287. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52288. */
  52289. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52290. /**
  52291. * An event triggered when the generated texture is being merged in the scene.
  52292. */
  52293. onBeforeComposeObservable: Observable<EffectLayer>;
  52294. /**
  52295. * An event triggered when the mesh is rendered into the effect render target.
  52296. */
  52297. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52298. /**
  52299. * An event triggered after the mesh has been rendered into the effect render target.
  52300. */
  52301. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52302. /**
  52303. * An event triggered when the generated texture has been merged in the scene.
  52304. */
  52305. onAfterComposeObservable: Observable<EffectLayer>;
  52306. /**
  52307. * An event triggered when the efffect layer changes its size.
  52308. */
  52309. onSizeChangedObservable: Observable<EffectLayer>;
  52310. /** @hidden */
  52311. static _SceneComponentInitialization: (scene: Scene) => void;
  52312. /**
  52313. * Instantiates a new effect Layer and references it in the scene.
  52314. * @param name The name of the layer
  52315. * @param scene The scene to use the layer in
  52316. */
  52317. constructor(
  52318. /** The Friendly of the effect in the scene */
  52319. name: string, scene: Scene);
  52320. /**
  52321. * Get the effect name of the layer.
  52322. * @return The effect name
  52323. */
  52324. abstract getEffectName(): string;
  52325. /**
  52326. * Checks for the readiness of the element composing the layer.
  52327. * @param subMesh the mesh to check for
  52328. * @param useInstances specify wether or not to use instances to render the mesh
  52329. * @return true if ready otherwise, false
  52330. */
  52331. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52332. /**
  52333. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52334. * @returns true if the effect requires stencil during the main canvas render pass.
  52335. */
  52336. abstract needStencil(): boolean;
  52337. /**
  52338. * Create the merge effect. This is the shader use to blit the information back
  52339. * to the main canvas at the end of the scene rendering.
  52340. * @returns The effect containing the shader used to merge the effect on the main canvas
  52341. */
  52342. protected abstract _createMergeEffect(): Effect;
  52343. /**
  52344. * Creates the render target textures and post processes used in the effect layer.
  52345. */
  52346. protected abstract _createTextureAndPostProcesses(): void;
  52347. /**
  52348. * Implementation specific of rendering the generating effect on the main canvas.
  52349. * @param effect The effect used to render through
  52350. */
  52351. protected abstract _internalRender(effect: Effect): void;
  52352. /**
  52353. * Sets the required values for both the emissive texture and and the main color.
  52354. */
  52355. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52356. /**
  52357. * Free any resources and references associated to a mesh.
  52358. * Internal use
  52359. * @param mesh The mesh to free.
  52360. */
  52361. abstract _disposeMesh(mesh: Mesh): void;
  52362. /**
  52363. * Serializes this layer (Glow or Highlight for example)
  52364. * @returns a serialized layer object
  52365. */
  52366. abstract serialize?(): any;
  52367. /**
  52368. * Initializes the effect layer with the required options.
  52369. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52370. */
  52371. protected _init(options: Partial<IEffectLayerOptions>): void;
  52372. /**
  52373. * Generates the index buffer of the full screen quad blending to the main canvas.
  52374. */
  52375. private _generateIndexBuffer;
  52376. /**
  52377. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52378. */
  52379. private _generateVertexBuffer;
  52380. /**
  52381. * Sets the main texture desired size which is the closest power of two
  52382. * of the engine canvas size.
  52383. */
  52384. private _setMainTextureSize;
  52385. /**
  52386. * Creates the main texture for the effect layer.
  52387. */
  52388. protected _createMainTexture(): void;
  52389. /**
  52390. * Adds specific effects defines.
  52391. * @param defines The defines to add specifics to.
  52392. */
  52393. protected _addCustomEffectDefines(defines: string[]): void;
  52394. /**
  52395. * Checks for the readiness of the element composing the layer.
  52396. * @param subMesh the mesh to check for
  52397. * @param useInstances specify wether or not to use instances to render the mesh
  52398. * @param emissiveTexture the associated emissive texture used to generate the glow
  52399. * @return true if ready otherwise, false
  52400. */
  52401. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52402. /**
  52403. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52404. */
  52405. render(): void;
  52406. /**
  52407. * Determine if a given mesh will be used in the current effect.
  52408. * @param mesh mesh to test
  52409. * @returns true if the mesh will be used
  52410. */
  52411. hasMesh(mesh: AbstractMesh): boolean;
  52412. /**
  52413. * Returns true if the layer contains information to display, otherwise false.
  52414. * @returns true if the glow layer should be rendered
  52415. */
  52416. shouldRender(): boolean;
  52417. /**
  52418. * Returns true if the mesh should render, otherwise false.
  52419. * @param mesh The mesh to render
  52420. * @returns true if it should render otherwise false
  52421. */
  52422. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52423. /**
  52424. * Returns true if the mesh can be rendered, otherwise false.
  52425. * @param mesh The mesh to render
  52426. * @param material The material used on the mesh
  52427. * @returns true if it can be rendered otherwise false
  52428. */
  52429. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52430. /**
  52431. * Returns true if the mesh should render, otherwise false.
  52432. * @param mesh The mesh to render
  52433. * @returns true if it should render otherwise false
  52434. */
  52435. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52436. /**
  52437. * Renders the submesh passed in parameter to the generation map.
  52438. */
  52439. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52440. /**
  52441. * Defines wether the current material of the mesh should be use to render the effect.
  52442. * @param mesh defines the current mesh to render
  52443. */
  52444. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52445. /**
  52446. * Rebuild the required buffers.
  52447. * @hidden Internal use only.
  52448. */
  52449. _rebuild(): void;
  52450. /**
  52451. * Dispose only the render target textures and post process.
  52452. */
  52453. private _disposeTextureAndPostProcesses;
  52454. /**
  52455. * Dispose the highlight layer and free resources.
  52456. */
  52457. dispose(): void;
  52458. /**
  52459. * Gets the class name of the effect layer
  52460. * @returns the string with the class name of the effect layer
  52461. */
  52462. getClassName(): string;
  52463. /**
  52464. * Creates an effect layer from parsed effect layer data
  52465. * @param parsedEffectLayer defines effect layer data
  52466. * @param scene defines the current scene
  52467. * @param rootUrl defines the root URL containing the effect layer information
  52468. * @returns a parsed effect Layer
  52469. */
  52470. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52471. }
  52472. }
  52473. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52474. import { Scene } from "babylonjs/scene";
  52475. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52476. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52477. import { AbstractScene } from "babylonjs/abstractScene";
  52478. module "babylonjs/abstractScene" {
  52479. interface AbstractScene {
  52480. /**
  52481. * The list of effect layers (highlights/glow) added to the scene
  52482. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52483. * @see http://doc.babylonjs.com/how_to/glow_layer
  52484. */
  52485. effectLayers: Array<EffectLayer>;
  52486. /**
  52487. * Removes the given effect layer from this scene.
  52488. * @param toRemove defines the effect layer to remove
  52489. * @returns the index of the removed effect layer
  52490. */
  52491. removeEffectLayer(toRemove: EffectLayer): number;
  52492. /**
  52493. * Adds the given effect layer to this scene
  52494. * @param newEffectLayer defines the effect layer to add
  52495. */
  52496. addEffectLayer(newEffectLayer: EffectLayer): void;
  52497. }
  52498. }
  52499. /**
  52500. * Defines the layer scene component responsible to manage any effect layers
  52501. * in a given scene.
  52502. */
  52503. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52504. /**
  52505. * The component name helpfull to identify the component in the list of scene components.
  52506. */
  52507. readonly name: string;
  52508. /**
  52509. * The scene the component belongs to.
  52510. */
  52511. scene: Scene;
  52512. private _engine;
  52513. private _renderEffects;
  52514. private _needStencil;
  52515. private _previousStencilState;
  52516. /**
  52517. * Creates a new instance of the component for the given scene
  52518. * @param scene Defines the scene to register the component in
  52519. */
  52520. constructor(scene: Scene);
  52521. /**
  52522. * Registers the component in a given scene
  52523. */
  52524. register(): void;
  52525. /**
  52526. * Rebuilds the elements related to this component in case of
  52527. * context lost for instance.
  52528. */
  52529. rebuild(): void;
  52530. /**
  52531. * Serializes the component data to the specified json object
  52532. * @param serializationObject The object to serialize to
  52533. */
  52534. serialize(serializationObject: any): void;
  52535. /**
  52536. * Adds all the elements from the container to the scene
  52537. * @param container the container holding the elements
  52538. */
  52539. addFromContainer(container: AbstractScene): void;
  52540. /**
  52541. * Removes all the elements in the container from the scene
  52542. * @param container contains the elements to remove
  52543. * @param dispose if the removed element should be disposed (default: false)
  52544. */
  52545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52546. /**
  52547. * Disposes the component and the associated ressources.
  52548. */
  52549. dispose(): void;
  52550. private _isReadyForMesh;
  52551. private _renderMainTexture;
  52552. private _setStencil;
  52553. private _setStencilBack;
  52554. private _draw;
  52555. private _drawCamera;
  52556. private _drawRenderingGroup;
  52557. }
  52558. }
  52559. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52560. /** @hidden */
  52561. export var glowMapMergePixelShader: {
  52562. name: string;
  52563. shader: string;
  52564. };
  52565. }
  52566. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52567. /** @hidden */
  52568. export var glowMapMergeVertexShader: {
  52569. name: string;
  52570. shader: string;
  52571. };
  52572. }
  52573. declare module "babylonjs/Layers/glowLayer" {
  52574. import { Nullable } from "babylonjs/types";
  52575. import { Camera } from "babylonjs/Cameras/camera";
  52576. import { Scene } from "babylonjs/scene";
  52577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52579. import { Mesh } from "babylonjs/Meshes/mesh";
  52580. import { Texture } from "babylonjs/Materials/Textures/texture";
  52581. import { Effect } from "babylonjs/Materials/effect";
  52582. import { Material } from "babylonjs/Materials/material";
  52583. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52584. import { Color4 } from "babylonjs/Maths/math.color";
  52585. import "babylonjs/Shaders/glowMapMerge.fragment";
  52586. import "babylonjs/Shaders/glowMapMerge.vertex";
  52587. import "babylonjs/Layers/effectLayerSceneComponent";
  52588. module "babylonjs/abstractScene" {
  52589. interface AbstractScene {
  52590. /**
  52591. * Return a the first highlight layer of the scene with a given name.
  52592. * @param name The name of the highlight layer to look for.
  52593. * @return The highlight layer if found otherwise null.
  52594. */
  52595. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52596. }
  52597. }
  52598. /**
  52599. * Glow layer options. This helps customizing the behaviour
  52600. * of the glow layer.
  52601. */
  52602. export interface IGlowLayerOptions {
  52603. /**
  52604. * Multiplication factor apply to the canvas size to compute the render target size
  52605. * used to generated the glowing objects (the smaller the faster).
  52606. */
  52607. mainTextureRatio: number;
  52608. /**
  52609. * Enforces a fixed size texture to ensure resize independant blur.
  52610. */
  52611. mainTextureFixedSize?: number;
  52612. /**
  52613. * How big is the kernel of the blur texture.
  52614. */
  52615. blurKernelSize: number;
  52616. /**
  52617. * The camera attached to the layer.
  52618. */
  52619. camera: Nullable<Camera>;
  52620. /**
  52621. * Enable MSAA by chosing the number of samples.
  52622. */
  52623. mainTextureSamples?: number;
  52624. /**
  52625. * The rendering group to draw the layer in.
  52626. */
  52627. renderingGroupId: number;
  52628. }
  52629. /**
  52630. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52631. *
  52632. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52633. *
  52634. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52635. */
  52636. export class GlowLayer extends EffectLayer {
  52637. /**
  52638. * Effect Name of the layer.
  52639. */
  52640. static readonly EffectName: string;
  52641. /**
  52642. * The default blur kernel size used for the glow.
  52643. */
  52644. static DefaultBlurKernelSize: number;
  52645. /**
  52646. * The default texture size ratio used for the glow.
  52647. */
  52648. static DefaultTextureRatio: number;
  52649. /**
  52650. * Sets the kernel size of the blur.
  52651. */
  52652. /**
  52653. * Gets the kernel size of the blur.
  52654. */
  52655. blurKernelSize: number;
  52656. /**
  52657. * Sets the glow intensity.
  52658. */
  52659. /**
  52660. * Gets the glow intensity.
  52661. */
  52662. intensity: number;
  52663. private _options;
  52664. private _intensity;
  52665. private _horizontalBlurPostprocess1;
  52666. private _verticalBlurPostprocess1;
  52667. private _horizontalBlurPostprocess2;
  52668. private _verticalBlurPostprocess2;
  52669. private _blurTexture1;
  52670. private _blurTexture2;
  52671. private _postProcesses1;
  52672. private _postProcesses2;
  52673. private _includedOnlyMeshes;
  52674. private _excludedMeshes;
  52675. private _meshesUsingTheirOwnMaterials;
  52676. /**
  52677. * Callback used to let the user override the color selection on a per mesh basis
  52678. */
  52679. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52680. /**
  52681. * Callback used to let the user override the texture selection on a per mesh basis
  52682. */
  52683. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52684. /**
  52685. * Instantiates a new glow Layer and references it to the scene.
  52686. * @param name The name of the layer
  52687. * @param scene The scene to use the layer in
  52688. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52689. */
  52690. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52691. /**
  52692. * Get the effect name of the layer.
  52693. * @return The effect name
  52694. */
  52695. getEffectName(): string;
  52696. /**
  52697. * Create the merge effect. This is the shader use to blit the information back
  52698. * to the main canvas at the end of the scene rendering.
  52699. */
  52700. protected _createMergeEffect(): Effect;
  52701. /**
  52702. * Creates the render target textures and post processes used in the glow layer.
  52703. */
  52704. protected _createTextureAndPostProcesses(): void;
  52705. /**
  52706. * Checks for the readiness of the element composing the layer.
  52707. * @param subMesh the mesh to check for
  52708. * @param useInstances specify wether or not to use instances to render the mesh
  52709. * @param emissiveTexture the associated emissive texture used to generate the glow
  52710. * @return true if ready otherwise, false
  52711. */
  52712. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52713. /**
  52714. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52715. */
  52716. needStencil(): boolean;
  52717. /**
  52718. * Returns true if the mesh can be rendered, otherwise false.
  52719. * @param mesh The mesh to render
  52720. * @param material The material used on the mesh
  52721. * @returns true if it can be rendered otherwise false
  52722. */
  52723. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52724. /**
  52725. * Implementation specific of rendering the generating effect on the main canvas.
  52726. * @param effect The effect used to render through
  52727. */
  52728. protected _internalRender(effect: Effect): void;
  52729. /**
  52730. * Sets the required values for both the emissive texture and and the main color.
  52731. */
  52732. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52733. /**
  52734. * Returns true if the mesh should render, otherwise false.
  52735. * @param mesh The mesh to render
  52736. * @returns true if it should render otherwise false
  52737. */
  52738. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52739. /**
  52740. * Adds specific effects defines.
  52741. * @param defines The defines to add specifics to.
  52742. */
  52743. protected _addCustomEffectDefines(defines: string[]): void;
  52744. /**
  52745. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52746. * @param mesh The mesh to exclude from the glow layer
  52747. */
  52748. addExcludedMesh(mesh: Mesh): void;
  52749. /**
  52750. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52751. * @param mesh The mesh to remove
  52752. */
  52753. removeExcludedMesh(mesh: Mesh): void;
  52754. /**
  52755. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52756. * @param mesh The mesh to include in the glow layer
  52757. */
  52758. addIncludedOnlyMesh(mesh: Mesh): void;
  52759. /**
  52760. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52761. * @param mesh The mesh to remove
  52762. */
  52763. removeIncludedOnlyMesh(mesh: Mesh): void;
  52764. /**
  52765. * Determine if a given mesh will be used in the glow layer
  52766. * @param mesh The mesh to test
  52767. * @returns true if the mesh will be highlighted by the current glow layer
  52768. */
  52769. hasMesh(mesh: AbstractMesh): boolean;
  52770. /**
  52771. * Defines wether the current material of the mesh should be use to render the effect.
  52772. * @param mesh defines the current mesh to render
  52773. */
  52774. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52775. /**
  52776. * Add a mesh to be rendered through its own material and not with emissive only.
  52777. * @param mesh The mesh for which we need to use its material
  52778. */
  52779. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52780. /**
  52781. * Remove a mesh from being rendered through its own material and not with emissive only.
  52782. * @param mesh The mesh for which we need to not use its material
  52783. */
  52784. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52785. /**
  52786. * Free any resources and references associated to a mesh.
  52787. * Internal use
  52788. * @param mesh The mesh to free.
  52789. * @hidden
  52790. */
  52791. _disposeMesh(mesh: Mesh): void;
  52792. /**
  52793. * Gets the class name of the effect layer
  52794. * @returns the string with the class name of the effect layer
  52795. */
  52796. getClassName(): string;
  52797. /**
  52798. * Serializes this glow layer
  52799. * @returns a serialized glow layer object
  52800. */
  52801. serialize(): any;
  52802. /**
  52803. * Creates a Glow Layer from parsed glow layer data
  52804. * @param parsedGlowLayer defines glow layer data
  52805. * @param scene defines the current scene
  52806. * @param rootUrl defines the root URL containing the glow layer information
  52807. * @returns a parsed Glow Layer
  52808. */
  52809. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52810. }
  52811. }
  52812. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52813. /** @hidden */
  52814. export var glowBlurPostProcessPixelShader: {
  52815. name: string;
  52816. shader: string;
  52817. };
  52818. }
  52819. declare module "babylonjs/Layers/highlightLayer" {
  52820. import { Observable } from "babylonjs/Misc/observable";
  52821. import { Nullable } from "babylonjs/types";
  52822. import { Camera } from "babylonjs/Cameras/camera";
  52823. import { Scene } from "babylonjs/scene";
  52824. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52826. import { Mesh } from "babylonjs/Meshes/mesh";
  52827. import { Effect } from "babylonjs/Materials/effect";
  52828. import { Material } from "babylonjs/Materials/material";
  52829. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52830. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52831. import "babylonjs/Shaders/glowMapMerge.fragment";
  52832. import "babylonjs/Shaders/glowMapMerge.vertex";
  52833. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52834. module "babylonjs/abstractScene" {
  52835. interface AbstractScene {
  52836. /**
  52837. * Return a the first highlight layer of the scene with a given name.
  52838. * @param name The name of the highlight layer to look for.
  52839. * @return The highlight layer if found otherwise null.
  52840. */
  52841. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52842. }
  52843. }
  52844. /**
  52845. * Highlight layer options. This helps customizing the behaviour
  52846. * of the highlight layer.
  52847. */
  52848. export interface IHighlightLayerOptions {
  52849. /**
  52850. * Multiplication factor apply to the canvas size to compute the render target size
  52851. * used to generated the glowing objects (the smaller the faster).
  52852. */
  52853. mainTextureRatio: number;
  52854. /**
  52855. * Enforces a fixed size texture to ensure resize independant blur.
  52856. */
  52857. mainTextureFixedSize?: number;
  52858. /**
  52859. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52860. * of the picture to blur (the smaller the faster).
  52861. */
  52862. blurTextureSizeRatio: number;
  52863. /**
  52864. * How big in texel of the blur texture is the vertical blur.
  52865. */
  52866. blurVerticalSize: number;
  52867. /**
  52868. * How big in texel of the blur texture is the horizontal blur.
  52869. */
  52870. blurHorizontalSize: number;
  52871. /**
  52872. * Alpha blending mode used to apply the blur. Default is combine.
  52873. */
  52874. alphaBlendingMode: number;
  52875. /**
  52876. * The camera attached to the layer.
  52877. */
  52878. camera: Nullable<Camera>;
  52879. /**
  52880. * Should we display highlight as a solid stroke?
  52881. */
  52882. isStroke?: boolean;
  52883. /**
  52884. * The rendering group to draw the layer in.
  52885. */
  52886. renderingGroupId: number;
  52887. }
  52888. /**
  52889. * The highlight layer Helps adding a glow effect around a mesh.
  52890. *
  52891. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52892. * glowy meshes to your scene.
  52893. *
  52894. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52895. */
  52896. export class HighlightLayer extends EffectLayer {
  52897. name: string;
  52898. /**
  52899. * Effect Name of the highlight layer.
  52900. */
  52901. static readonly EffectName: string;
  52902. /**
  52903. * The neutral color used during the preparation of the glow effect.
  52904. * This is black by default as the blend operation is a blend operation.
  52905. */
  52906. static NeutralColor: Color4;
  52907. /**
  52908. * Stencil value used for glowing meshes.
  52909. */
  52910. static GlowingMeshStencilReference: number;
  52911. /**
  52912. * Stencil value used for the other meshes in the scene.
  52913. */
  52914. static NormalMeshStencilReference: number;
  52915. /**
  52916. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52917. */
  52918. innerGlow: boolean;
  52919. /**
  52920. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52921. */
  52922. outerGlow: boolean;
  52923. /**
  52924. * Specifies the horizontal size of the blur.
  52925. */
  52926. /**
  52927. * Gets the horizontal size of the blur.
  52928. */
  52929. blurHorizontalSize: number;
  52930. /**
  52931. * Specifies the vertical size of the blur.
  52932. */
  52933. /**
  52934. * Gets the vertical size of the blur.
  52935. */
  52936. blurVerticalSize: number;
  52937. /**
  52938. * An event triggered when the highlight layer is being blurred.
  52939. */
  52940. onBeforeBlurObservable: Observable<HighlightLayer>;
  52941. /**
  52942. * An event triggered when the highlight layer has been blurred.
  52943. */
  52944. onAfterBlurObservable: Observable<HighlightLayer>;
  52945. private _instanceGlowingMeshStencilReference;
  52946. private _options;
  52947. private _downSamplePostprocess;
  52948. private _horizontalBlurPostprocess;
  52949. private _verticalBlurPostprocess;
  52950. private _blurTexture;
  52951. private _meshes;
  52952. private _excludedMeshes;
  52953. /**
  52954. * Instantiates a new highlight Layer and references it to the scene..
  52955. * @param name The name of the layer
  52956. * @param scene The scene to use the layer in
  52957. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52958. */
  52959. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52960. /**
  52961. * Get the effect name of the layer.
  52962. * @return The effect name
  52963. */
  52964. getEffectName(): string;
  52965. /**
  52966. * Create the merge effect. This is the shader use to blit the information back
  52967. * to the main canvas at the end of the scene rendering.
  52968. */
  52969. protected _createMergeEffect(): Effect;
  52970. /**
  52971. * Creates the render target textures and post processes used in the highlight layer.
  52972. */
  52973. protected _createTextureAndPostProcesses(): void;
  52974. /**
  52975. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52976. */
  52977. needStencil(): boolean;
  52978. /**
  52979. * Checks for the readiness of the element composing the layer.
  52980. * @param subMesh the mesh to check for
  52981. * @param useInstances specify wether or not to use instances to render the mesh
  52982. * @param emissiveTexture the associated emissive texture used to generate the glow
  52983. * @return true if ready otherwise, false
  52984. */
  52985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52986. /**
  52987. * Implementation specific of rendering the generating effect on the main canvas.
  52988. * @param effect The effect used to render through
  52989. */
  52990. protected _internalRender(effect: Effect): void;
  52991. /**
  52992. * Returns true if the layer contains information to display, otherwise false.
  52993. */
  52994. shouldRender(): boolean;
  52995. /**
  52996. * Returns true if the mesh should render, otherwise false.
  52997. * @param mesh The mesh to render
  52998. * @returns true if it should render otherwise false
  52999. */
  53000. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53001. /**
  53002. * Sets the required values for both the emissive texture and and the main color.
  53003. */
  53004. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53005. /**
  53006. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53007. * @param mesh The mesh to exclude from the highlight layer
  53008. */
  53009. addExcludedMesh(mesh: Mesh): void;
  53010. /**
  53011. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53012. * @param mesh The mesh to highlight
  53013. */
  53014. removeExcludedMesh(mesh: Mesh): void;
  53015. /**
  53016. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53017. * @param mesh mesh to test
  53018. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53019. */
  53020. hasMesh(mesh: AbstractMesh): boolean;
  53021. /**
  53022. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53023. * @param mesh The mesh to highlight
  53024. * @param color The color of the highlight
  53025. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53026. */
  53027. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53028. /**
  53029. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53030. * @param mesh The mesh to highlight
  53031. */
  53032. removeMesh(mesh: Mesh): void;
  53033. /**
  53034. * Force the stencil to the normal expected value for none glowing parts
  53035. */
  53036. private _defaultStencilReference;
  53037. /**
  53038. * Free any resources and references associated to a mesh.
  53039. * Internal use
  53040. * @param mesh The mesh to free.
  53041. * @hidden
  53042. */
  53043. _disposeMesh(mesh: Mesh): void;
  53044. /**
  53045. * Dispose the highlight layer and free resources.
  53046. */
  53047. dispose(): void;
  53048. /**
  53049. * Gets the class name of the effect layer
  53050. * @returns the string with the class name of the effect layer
  53051. */
  53052. getClassName(): string;
  53053. /**
  53054. * Serializes this Highlight layer
  53055. * @returns a serialized Highlight layer object
  53056. */
  53057. serialize(): any;
  53058. /**
  53059. * Creates a Highlight layer from parsed Highlight layer data
  53060. * @param parsedHightlightLayer defines the Highlight layer data
  53061. * @param scene defines the current scene
  53062. * @param rootUrl defines the root URL containing the Highlight layer information
  53063. * @returns a parsed Highlight layer
  53064. */
  53065. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53066. }
  53067. }
  53068. declare module "babylonjs/Layers/layerSceneComponent" {
  53069. import { Scene } from "babylonjs/scene";
  53070. import { ISceneComponent } from "babylonjs/sceneComponent";
  53071. import { Layer } from "babylonjs/Layers/layer";
  53072. import { AbstractScene } from "babylonjs/abstractScene";
  53073. module "babylonjs/abstractScene" {
  53074. interface AbstractScene {
  53075. /**
  53076. * The list of layers (background and foreground) of the scene
  53077. */
  53078. layers: Array<Layer>;
  53079. }
  53080. }
  53081. /**
  53082. * Defines the layer scene component responsible to manage any layers
  53083. * in a given scene.
  53084. */
  53085. export class LayerSceneComponent implements ISceneComponent {
  53086. /**
  53087. * The component name helpfull to identify the component in the list of scene components.
  53088. */
  53089. readonly name: string;
  53090. /**
  53091. * The scene the component belongs to.
  53092. */
  53093. scene: Scene;
  53094. private _engine;
  53095. /**
  53096. * Creates a new instance of the component for the given scene
  53097. * @param scene Defines the scene to register the component in
  53098. */
  53099. constructor(scene: Scene);
  53100. /**
  53101. * Registers the component in a given scene
  53102. */
  53103. register(): void;
  53104. /**
  53105. * Rebuilds the elements related to this component in case of
  53106. * context lost for instance.
  53107. */
  53108. rebuild(): void;
  53109. /**
  53110. * Disposes the component and the associated ressources.
  53111. */
  53112. dispose(): void;
  53113. private _draw;
  53114. private _drawCameraPredicate;
  53115. private _drawCameraBackground;
  53116. private _drawCameraForeground;
  53117. private _drawRenderTargetPredicate;
  53118. private _drawRenderTargetBackground;
  53119. private _drawRenderTargetForeground;
  53120. /**
  53121. * Adds all the elements from the container to the scene
  53122. * @param container the container holding the elements
  53123. */
  53124. addFromContainer(container: AbstractScene): void;
  53125. /**
  53126. * Removes all the elements in the container from the scene
  53127. * @param container contains the elements to remove
  53128. * @param dispose if the removed element should be disposed (default: false)
  53129. */
  53130. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53131. }
  53132. }
  53133. declare module "babylonjs/Shaders/layer.fragment" {
  53134. /** @hidden */
  53135. export var layerPixelShader: {
  53136. name: string;
  53137. shader: string;
  53138. };
  53139. }
  53140. declare module "babylonjs/Shaders/layer.vertex" {
  53141. /** @hidden */
  53142. export var layerVertexShader: {
  53143. name: string;
  53144. shader: string;
  53145. };
  53146. }
  53147. declare module "babylonjs/Layers/layer" {
  53148. import { Observable } from "babylonjs/Misc/observable";
  53149. import { Nullable } from "babylonjs/types";
  53150. import { Scene } from "babylonjs/scene";
  53151. import { Vector2 } from "babylonjs/Maths/math.vector";
  53152. import { Color4 } from "babylonjs/Maths/math.color";
  53153. import { Texture } from "babylonjs/Materials/Textures/texture";
  53154. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53155. import "babylonjs/Shaders/layer.fragment";
  53156. import "babylonjs/Shaders/layer.vertex";
  53157. /**
  53158. * This represents a full screen 2d layer.
  53159. * This can be useful to display a picture in the background of your scene for instance.
  53160. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53161. */
  53162. export class Layer {
  53163. /**
  53164. * Define the name of the layer.
  53165. */
  53166. name: string;
  53167. /**
  53168. * Define the texture the layer should display.
  53169. */
  53170. texture: Nullable<Texture>;
  53171. /**
  53172. * Is the layer in background or foreground.
  53173. */
  53174. isBackground: boolean;
  53175. /**
  53176. * Define the color of the layer (instead of texture).
  53177. */
  53178. color: Color4;
  53179. /**
  53180. * Define the scale of the layer in order to zoom in out of the texture.
  53181. */
  53182. scale: Vector2;
  53183. /**
  53184. * Define an offset for the layer in order to shift the texture.
  53185. */
  53186. offset: Vector2;
  53187. /**
  53188. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53189. */
  53190. alphaBlendingMode: number;
  53191. /**
  53192. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53193. * Alpha test will not mix with the background color in case of transparency.
  53194. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53195. */
  53196. alphaTest: boolean;
  53197. /**
  53198. * Define a mask to restrict the layer to only some of the scene cameras.
  53199. */
  53200. layerMask: number;
  53201. /**
  53202. * Define the list of render target the layer is visible into.
  53203. */
  53204. renderTargetTextures: RenderTargetTexture[];
  53205. /**
  53206. * Define if the layer is only used in renderTarget or if it also
  53207. * renders in the main frame buffer of the canvas.
  53208. */
  53209. renderOnlyInRenderTargetTextures: boolean;
  53210. private _scene;
  53211. private _vertexBuffers;
  53212. private _indexBuffer;
  53213. private _effect;
  53214. private _alphaTestEffect;
  53215. /**
  53216. * An event triggered when the layer is disposed.
  53217. */
  53218. onDisposeObservable: Observable<Layer>;
  53219. private _onDisposeObserver;
  53220. /**
  53221. * Back compatibility with callback before the onDisposeObservable existed.
  53222. * The set callback will be triggered when the layer has been disposed.
  53223. */
  53224. onDispose: () => void;
  53225. /**
  53226. * An event triggered before rendering the scene
  53227. */
  53228. onBeforeRenderObservable: Observable<Layer>;
  53229. private _onBeforeRenderObserver;
  53230. /**
  53231. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53232. * The set callback will be triggered just before rendering the layer.
  53233. */
  53234. onBeforeRender: () => void;
  53235. /**
  53236. * An event triggered after rendering the scene
  53237. */
  53238. onAfterRenderObservable: Observable<Layer>;
  53239. private _onAfterRenderObserver;
  53240. /**
  53241. * Back compatibility with callback before the onAfterRenderObservable existed.
  53242. * The set callback will be triggered just after rendering the layer.
  53243. */
  53244. onAfterRender: () => void;
  53245. /**
  53246. * Instantiates a new layer.
  53247. * This represents a full screen 2d layer.
  53248. * This can be useful to display a picture in the background of your scene for instance.
  53249. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53250. * @param name Define the name of the layer in the scene
  53251. * @param imgUrl Define the url of the texture to display in the layer
  53252. * @param scene Define the scene the layer belongs to
  53253. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53254. * @param color Defines a color for the layer
  53255. */
  53256. constructor(
  53257. /**
  53258. * Define the name of the layer.
  53259. */
  53260. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53261. private _createIndexBuffer;
  53262. /** @hidden */
  53263. _rebuild(): void;
  53264. /**
  53265. * Renders the layer in the scene.
  53266. */
  53267. render(): void;
  53268. /**
  53269. * Disposes and releases the associated ressources.
  53270. */
  53271. dispose(): void;
  53272. }
  53273. }
  53274. declare module "babylonjs/Layers/index" {
  53275. export * from "babylonjs/Layers/effectLayer";
  53276. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53277. export * from "babylonjs/Layers/glowLayer";
  53278. export * from "babylonjs/Layers/highlightLayer";
  53279. export * from "babylonjs/Layers/layer";
  53280. export * from "babylonjs/Layers/layerSceneComponent";
  53281. }
  53282. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53283. /** @hidden */
  53284. export var lensFlarePixelShader: {
  53285. name: string;
  53286. shader: string;
  53287. };
  53288. }
  53289. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53290. /** @hidden */
  53291. export var lensFlareVertexShader: {
  53292. name: string;
  53293. shader: string;
  53294. };
  53295. }
  53296. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53297. import { Scene } from "babylonjs/scene";
  53298. import { Vector3 } from "babylonjs/Maths/math.vector";
  53299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53300. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53301. import "babylonjs/Shaders/lensFlare.fragment";
  53302. import "babylonjs/Shaders/lensFlare.vertex";
  53303. import { Viewport } from "babylonjs/Maths/math.viewport";
  53304. /**
  53305. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53306. * It is usually composed of several `lensFlare`.
  53307. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53308. */
  53309. export class LensFlareSystem {
  53310. /**
  53311. * Define the name of the lens flare system
  53312. */
  53313. name: string;
  53314. /**
  53315. * List of lens flares used in this system.
  53316. */
  53317. lensFlares: LensFlare[];
  53318. /**
  53319. * Define a limit from the border the lens flare can be visible.
  53320. */
  53321. borderLimit: number;
  53322. /**
  53323. * Define a viewport border we do not want to see the lens flare in.
  53324. */
  53325. viewportBorder: number;
  53326. /**
  53327. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53328. */
  53329. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53330. /**
  53331. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53332. */
  53333. layerMask: number;
  53334. /**
  53335. * Define the id of the lens flare system in the scene.
  53336. * (equal to name by default)
  53337. */
  53338. id: string;
  53339. private _scene;
  53340. private _emitter;
  53341. private _vertexBuffers;
  53342. private _indexBuffer;
  53343. private _effect;
  53344. private _positionX;
  53345. private _positionY;
  53346. private _isEnabled;
  53347. /** @hidden */
  53348. static _SceneComponentInitialization: (scene: Scene) => void;
  53349. /**
  53350. * Instantiates a lens flare system.
  53351. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53352. * It is usually composed of several `lensFlare`.
  53353. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53354. * @param name Define the name of the lens flare system in the scene
  53355. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53356. * @param scene Define the scene the lens flare system belongs to
  53357. */
  53358. constructor(
  53359. /**
  53360. * Define the name of the lens flare system
  53361. */
  53362. name: string, emitter: any, scene: Scene);
  53363. /**
  53364. * Define if the lens flare system is enabled.
  53365. */
  53366. isEnabled: boolean;
  53367. /**
  53368. * Get the scene the effects belongs to.
  53369. * @returns the scene holding the lens flare system
  53370. */
  53371. getScene(): Scene;
  53372. /**
  53373. * Get the emitter of the lens flare system.
  53374. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53375. * @returns the emitter of the lens flare system
  53376. */
  53377. getEmitter(): any;
  53378. /**
  53379. * Set the emitter of the lens flare system.
  53380. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53381. * @param newEmitter Define the new emitter of the system
  53382. */
  53383. setEmitter(newEmitter: any): void;
  53384. /**
  53385. * Get the lens flare system emitter position.
  53386. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53387. * @returns the position
  53388. */
  53389. getEmitterPosition(): Vector3;
  53390. /**
  53391. * @hidden
  53392. */
  53393. computeEffectivePosition(globalViewport: Viewport): boolean;
  53394. /** @hidden */
  53395. _isVisible(): boolean;
  53396. /**
  53397. * @hidden
  53398. */
  53399. render(): boolean;
  53400. /**
  53401. * Dispose and release the lens flare with its associated resources.
  53402. */
  53403. dispose(): void;
  53404. /**
  53405. * Parse a lens flare system from a JSON repressentation
  53406. * @param parsedLensFlareSystem Define the JSON to parse
  53407. * @param scene Define the scene the parsed system should be instantiated in
  53408. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53409. * @returns the parsed system
  53410. */
  53411. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53412. /**
  53413. * Serialize the current Lens Flare System into a JSON representation.
  53414. * @returns the serialized JSON
  53415. */
  53416. serialize(): any;
  53417. }
  53418. }
  53419. declare module "babylonjs/LensFlares/lensFlare" {
  53420. import { Nullable } from "babylonjs/types";
  53421. import { Color3 } from "babylonjs/Maths/math.color";
  53422. import { Texture } from "babylonjs/Materials/Textures/texture";
  53423. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53424. /**
  53425. * This represents one of the lens effect in a `lensFlareSystem`.
  53426. * It controls one of the indiviual texture used in the effect.
  53427. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53428. */
  53429. export class LensFlare {
  53430. /**
  53431. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53432. */
  53433. size: number;
  53434. /**
  53435. * 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.
  53436. */
  53437. position: number;
  53438. /**
  53439. * Define the lens color.
  53440. */
  53441. color: Color3;
  53442. /**
  53443. * Define the lens texture.
  53444. */
  53445. texture: Nullable<Texture>;
  53446. /**
  53447. * Define the alpha mode to render this particular lens.
  53448. */
  53449. alphaMode: number;
  53450. private _system;
  53451. /**
  53452. * Creates a new Lens Flare.
  53453. * This represents one of the lens effect in a `lensFlareSystem`.
  53454. * It controls one of the indiviual texture used in the effect.
  53455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53456. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53457. * @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.
  53458. * @param color Define the lens color
  53459. * @param imgUrl Define the lens texture url
  53460. * @param system Define the `lensFlareSystem` this flare is part of
  53461. * @returns The newly created Lens Flare
  53462. */
  53463. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53464. /**
  53465. * Instantiates a new Lens Flare.
  53466. * This represents one of the lens effect in a `lensFlareSystem`.
  53467. * It controls one of the indiviual texture used in the effect.
  53468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53469. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53470. * @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.
  53471. * @param color Define the lens color
  53472. * @param imgUrl Define the lens texture url
  53473. * @param system Define the `lensFlareSystem` this flare is part of
  53474. */
  53475. constructor(
  53476. /**
  53477. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53478. */
  53479. size: number,
  53480. /**
  53481. * 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.
  53482. */
  53483. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53484. /**
  53485. * Dispose and release the lens flare with its associated resources.
  53486. */
  53487. dispose(): void;
  53488. }
  53489. }
  53490. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53491. import { Nullable } from "babylonjs/types";
  53492. import { Scene } from "babylonjs/scene";
  53493. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53494. import { AbstractScene } from "babylonjs/abstractScene";
  53495. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53496. module "babylonjs/abstractScene" {
  53497. interface AbstractScene {
  53498. /**
  53499. * The list of lens flare system added to the scene
  53500. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53501. */
  53502. lensFlareSystems: Array<LensFlareSystem>;
  53503. /**
  53504. * Removes the given lens flare system from this scene.
  53505. * @param toRemove The lens flare system to remove
  53506. * @returns The index of the removed lens flare system
  53507. */
  53508. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53509. /**
  53510. * Adds the given lens flare system to this scene
  53511. * @param newLensFlareSystem The lens flare system to add
  53512. */
  53513. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53514. /**
  53515. * Gets a lens flare system using its name
  53516. * @param name defines the name to look for
  53517. * @returns the lens flare system or null if not found
  53518. */
  53519. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53520. /**
  53521. * Gets a lens flare system using its id
  53522. * @param id defines the id to look for
  53523. * @returns the lens flare system or null if not found
  53524. */
  53525. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53526. }
  53527. }
  53528. /**
  53529. * Defines the lens flare scene component responsible to manage any lens flares
  53530. * in a given scene.
  53531. */
  53532. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53533. /**
  53534. * The component name helpfull to identify the component in the list of scene components.
  53535. */
  53536. readonly name: string;
  53537. /**
  53538. * The scene the component belongs to.
  53539. */
  53540. scene: Scene;
  53541. /**
  53542. * Creates a new instance of the component for the given scene
  53543. * @param scene Defines the scene to register the component in
  53544. */
  53545. constructor(scene: Scene);
  53546. /**
  53547. * Registers the component in a given scene
  53548. */
  53549. register(): void;
  53550. /**
  53551. * Rebuilds the elements related to this component in case of
  53552. * context lost for instance.
  53553. */
  53554. rebuild(): void;
  53555. /**
  53556. * Adds all the elements from the container to the scene
  53557. * @param container the container holding the elements
  53558. */
  53559. addFromContainer(container: AbstractScene): void;
  53560. /**
  53561. * Removes all the elements in the container from the scene
  53562. * @param container contains the elements to remove
  53563. * @param dispose if the removed element should be disposed (default: false)
  53564. */
  53565. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53566. /**
  53567. * Serializes the component data to the specified json object
  53568. * @param serializationObject The object to serialize to
  53569. */
  53570. serialize(serializationObject: any): void;
  53571. /**
  53572. * Disposes the component and the associated ressources.
  53573. */
  53574. dispose(): void;
  53575. private _draw;
  53576. }
  53577. }
  53578. declare module "babylonjs/LensFlares/index" {
  53579. export * from "babylonjs/LensFlares/lensFlare";
  53580. export * from "babylonjs/LensFlares/lensFlareSystem";
  53581. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53582. }
  53583. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53584. import { Scene } from "babylonjs/scene";
  53585. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53586. import { AbstractScene } from "babylonjs/abstractScene";
  53587. /**
  53588. * Defines the shadow generator component responsible to manage any shadow generators
  53589. * in a given scene.
  53590. */
  53591. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53592. /**
  53593. * The component name helpfull to identify the component in the list of scene components.
  53594. */
  53595. readonly name: string;
  53596. /**
  53597. * The scene the component belongs to.
  53598. */
  53599. scene: Scene;
  53600. /**
  53601. * Creates a new instance of the component for the given scene
  53602. * @param scene Defines the scene to register the component in
  53603. */
  53604. constructor(scene: Scene);
  53605. /**
  53606. * Registers the component in a given scene
  53607. */
  53608. register(): void;
  53609. /**
  53610. * Rebuilds the elements related to this component in case of
  53611. * context lost for instance.
  53612. */
  53613. rebuild(): void;
  53614. /**
  53615. * Serializes the component data to the specified json object
  53616. * @param serializationObject The object to serialize to
  53617. */
  53618. serialize(serializationObject: any): void;
  53619. /**
  53620. * Adds all the elements from the container to the scene
  53621. * @param container the container holding the elements
  53622. */
  53623. addFromContainer(container: AbstractScene): void;
  53624. /**
  53625. * Removes all the elements in the container from the scene
  53626. * @param container contains the elements to remove
  53627. * @param dispose if the removed element should be disposed (default: false)
  53628. */
  53629. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53630. /**
  53631. * Rebuilds the elements related to this component in case of
  53632. * context lost for instance.
  53633. */
  53634. dispose(): void;
  53635. private _gatherRenderTargets;
  53636. }
  53637. }
  53638. declare module "babylonjs/Lights/Shadows/index" {
  53639. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53640. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53641. }
  53642. declare module "babylonjs/Lights/pointLight" {
  53643. import { Scene } from "babylonjs/scene";
  53644. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53646. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53647. import { Effect } from "babylonjs/Materials/effect";
  53648. /**
  53649. * A point light is a light defined by an unique point in world space.
  53650. * The light is emitted in every direction from this point.
  53651. * A good example of a point light is a standard light bulb.
  53652. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53653. */
  53654. export class PointLight extends ShadowLight {
  53655. private _shadowAngle;
  53656. /**
  53657. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53658. * This specifies what angle the shadow will use to be created.
  53659. *
  53660. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53661. */
  53662. /**
  53663. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53664. * This specifies what angle the shadow will use to be created.
  53665. *
  53666. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53667. */
  53668. shadowAngle: number;
  53669. /**
  53670. * Gets the direction if it has been set.
  53671. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53672. */
  53673. /**
  53674. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53675. */
  53676. direction: Vector3;
  53677. /**
  53678. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53679. * A PointLight emits the light in every direction.
  53680. * It can cast shadows.
  53681. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53682. * ```javascript
  53683. * var pointLight = new PointLight("pl", camera.position, scene);
  53684. * ```
  53685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53686. * @param name The light friendly name
  53687. * @param position The position of the point light in the scene
  53688. * @param scene The scene the lights belongs to
  53689. */
  53690. constructor(name: string, position: Vector3, scene: Scene);
  53691. /**
  53692. * Returns the string "PointLight"
  53693. * @returns the class name
  53694. */
  53695. getClassName(): string;
  53696. /**
  53697. * Returns the integer 0.
  53698. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53699. */
  53700. getTypeID(): number;
  53701. /**
  53702. * Specifies wether or not the shadowmap should be a cube texture.
  53703. * @returns true if the shadowmap needs to be a cube texture.
  53704. */
  53705. needCube(): boolean;
  53706. /**
  53707. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53708. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53709. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53710. */
  53711. getShadowDirection(faceIndex?: number): Vector3;
  53712. /**
  53713. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53714. * - fov = PI / 2
  53715. * - aspect ratio : 1.0
  53716. * - z-near and far equal to the active camera minZ and maxZ.
  53717. * Returns the PointLight.
  53718. */
  53719. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53720. protected _buildUniformLayout(): void;
  53721. /**
  53722. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53723. * @param effect The effect to update
  53724. * @param lightIndex The index of the light in the effect to update
  53725. * @returns The point light
  53726. */
  53727. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53728. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53729. /**
  53730. * Prepares the list of defines specific to the light type.
  53731. * @param defines the list of defines
  53732. * @param lightIndex defines the index of the light for the effect
  53733. */
  53734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53735. }
  53736. }
  53737. declare module "babylonjs/Lights/index" {
  53738. export * from "babylonjs/Lights/light";
  53739. export * from "babylonjs/Lights/shadowLight";
  53740. export * from "babylonjs/Lights/Shadows/index";
  53741. export * from "babylonjs/Lights/directionalLight";
  53742. export * from "babylonjs/Lights/hemisphericLight";
  53743. export * from "babylonjs/Lights/pointLight";
  53744. export * from "babylonjs/Lights/spotLight";
  53745. }
  53746. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53747. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53748. /**
  53749. * Header information of HDR texture files.
  53750. */
  53751. export interface HDRInfo {
  53752. /**
  53753. * The height of the texture in pixels.
  53754. */
  53755. height: number;
  53756. /**
  53757. * The width of the texture in pixels.
  53758. */
  53759. width: number;
  53760. /**
  53761. * The index of the beginning of the data in the binary file.
  53762. */
  53763. dataPosition: number;
  53764. }
  53765. /**
  53766. * This groups tools to convert HDR texture to native colors array.
  53767. */
  53768. export class HDRTools {
  53769. private static Ldexp;
  53770. private static Rgbe2float;
  53771. private static readStringLine;
  53772. /**
  53773. * Reads header information from an RGBE texture stored in a native array.
  53774. * More information on this format are available here:
  53775. * https://en.wikipedia.org/wiki/RGBE_image_format
  53776. *
  53777. * @param uint8array The binary file stored in native array.
  53778. * @return The header information.
  53779. */
  53780. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53781. /**
  53782. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53783. * This RGBE texture needs to store the information as a panorama.
  53784. *
  53785. * More information on this format are available here:
  53786. * https://en.wikipedia.org/wiki/RGBE_image_format
  53787. *
  53788. * @param buffer The binary file stored in an array buffer.
  53789. * @param size The expected size of the extracted cubemap.
  53790. * @return The Cube Map information.
  53791. */
  53792. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53793. /**
  53794. * Returns the pixels data extracted from an RGBE texture.
  53795. * This pixels will be stored left to right up to down in the R G B order in one array.
  53796. *
  53797. * More information on this format are available here:
  53798. * https://en.wikipedia.org/wiki/RGBE_image_format
  53799. *
  53800. * @param uint8array The binary file stored in an array buffer.
  53801. * @param hdrInfo The header information of the file.
  53802. * @return The pixels data in RGB right to left up to down order.
  53803. */
  53804. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53805. private static RGBE_ReadPixels_RLE;
  53806. }
  53807. }
  53808. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53809. import { Nullable } from "babylonjs/types";
  53810. import { Scene } from "babylonjs/scene";
  53811. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53813. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53814. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53815. /**
  53816. * This represents a texture coming from an HDR input.
  53817. *
  53818. * The only supported format is currently panorama picture stored in RGBE format.
  53819. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53820. */
  53821. export class HDRCubeTexture extends BaseTexture {
  53822. private static _facesMapping;
  53823. private _generateHarmonics;
  53824. private _noMipmap;
  53825. private _textureMatrix;
  53826. private _size;
  53827. private _onLoad;
  53828. private _onError;
  53829. /**
  53830. * The texture URL.
  53831. */
  53832. url: string;
  53833. /**
  53834. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53835. */
  53836. coordinatesMode: number;
  53837. protected _isBlocking: boolean;
  53838. /**
  53839. * Sets wether or not the texture is blocking during loading.
  53840. */
  53841. /**
  53842. * Gets wether or not the texture is blocking during loading.
  53843. */
  53844. isBlocking: boolean;
  53845. protected _rotationY: number;
  53846. /**
  53847. * Sets texture matrix rotation angle around Y axis in radians.
  53848. */
  53849. /**
  53850. * Gets texture matrix rotation angle around Y axis radians.
  53851. */
  53852. rotationY: number;
  53853. /**
  53854. * Gets or sets the center of the bounding box associated with the cube texture
  53855. * It must define where the camera used to render the texture was set
  53856. */
  53857. boundingBoxPosition: Vector3;
  53858. private _boundingBoxSize;
  53859. /**
  53860. * Gets or sets the size of the bounding box associated with the cube texture
  53861. * When defined, the cubemap will switch to local mode
  53862. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53863. * @example https://www.babylonjs-playground.com/#RNASML
  53864. */
  53865. boundingBoxSize: Vector3;
  53866. /**
  53867. * Instantiates an HDRTexture from the following parameters.
  53868. *
  53869. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53870. * @param scene The scene the texture will be used in
  53871. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53872. * @param noMipmap Forces to not generate the mipmap if true
  53873. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53874. * @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)
  53875. * @param reserved Reserved flag for internal use.
  53876. */
  53877. 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>);
  53878. /**
  53879. * Get the current class name of the texture useful for serialization or dynamic coding.
  53880. * @returns "HDRCubeTexture"
  53881. */
  53882. getClassName(): string;
  53883. /**
  53884. * Occurs when the file is raw .hdr file.
  53885. */
  53886. private loadTexture;
  53887. clone(): HDRCubeTexture;
  53888. delayLoad(): void;
  53889. /**
  53890. * Get the texture reflection matrix used to rotate/transform the reflection.
  53891. * @returns the reflection matrix
  53892. */
  53893. getReflectionTextureMatrix(): Matrix;
  53894. /**
  53895. * Set the texture reflection matrix used to rotate/transform the reflection.
  53896. * @param value Define the reflection matrix to set
  53897. */
  53898. setReflectionTextureMatrix(value: Matrix): void;
  53899. /**
  53900. * Parses a JSON representation of an HDR Texture in order to create the texture
  53901. * @param parsedTexture Define the JSON representation
  53902. * @param scene Define the scene the texture should be created in
  53903. * @param rootUrl Define the root url in case we need to load relative dependencies
  53904. * @returns the newly created texture after parsing
  53905. */
  53906. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53907. serialize(): any;
  53908. }
  53909. }
  53910. declare module "babylonjs/Physics/physicsEngine" {
  53911. import { Nullable } from "babylonjs/types";
  53912. import { Vector3 } from "babylonjs/Maths/math.vector";
  53913. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53914. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53915. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53916. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53917. /**
  53918. * Class used to control physics engine
  53919. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53920. */
  53921. export class PhysicsEngine implements IPhysicsEngine {
  53922. private _physicsPlugin;
  53923. /**
  53924. * Global value used to control the smallest number supported by the simulation
  53925. */
  53926. static Epsilon: number;
  53927. private _impostors;
  53928. private _joints;
  53929. /**
  53930. * Gets the gravity vector used by the simulation
  53931. */
  53932. gravity: Vector3;
  53933. /**
  53934. * Factory used to create the default physics plugin.
  53935. * @returns The default physics plugin
  53936. */
  53937. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53938. /**
  53939. * Creates a new Physics Engine
  53940. * @param gravity defines the gravity vector used by the simulation
  53941. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53942. */
  53943. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53944. /**
  53945. * Sets the gravity vector used by the simulation
  53946. * @param gravity defines the gravity vector to use
  53947. */
  53948. setGravity(gravity: Vector3): void;
  53949. /**
  53950. * Set the time step of the physics engine.
  53951. * Default is 1/60.
  53952. * To slow it down, enter 1/600 for example.
  53953. * To speed it up, 1/30
  53954. * @param newTimeStep defines the new timestep to apply to this world.
  53955. */
  53956. setTimeStep(newTimeStep?: number): void;
  53957. /**
  53958. * Get the time step of the physics engine.
  53959. * @returns the current time step
  53960. */
  53961. getTimeStep(): number;
  53962. /**
  53963. * Release all resources
  53964. */
  53965. dispose(): void;
  53966. /**
  53967. * Gets the name of the current physics plugin
  53968. * @returns the name of the plugin
  53969. */
  53970. getPhysicsPluginName(): string;
  53971. /**
  53972. * Adding a new impostor for the impostor tracking.
  53973. * This will be done by the impostor itself.
  53974. * @param impostor the impostor to add
  53975. */
  53976. addImpostor(impostor: PhysicsImpostor): void;
  53977. /**
  53978. * Remove an impostor from the engine.
  53979. * This impostor and its mesh will not longer be updated by the physics engine.
  53980. * @param impostor the impostor to remove
  53981. */
  53982. removeImpostor(impostor: PhysicsImpostor): void;
  53983. /**
  53984. * Add a joint to the physics engine
  53985. * @param mainImpostor defines the main impostor to which the joint is added.
  53986. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53987. * @param joint defines the joint that will connect both impostors.
  53988. */
  53989. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53990. /**
  53991. * Removes a joint from the simulation
  53992. * @param mainImpostor defines the impostor used with the joint
  53993. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53994. * @param joint defines the joint to remove
  53995. */
  53996. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53997. /**
  53998. * Called by the scene. No need to call it.
  53999. * @param delta defines the timespam between frames
  54000. */
  54001. _step(delta: number): void;
  54002. /**
  54003. * Gets the current plugin used to run the simulation
  54004. * @returns current plugin
  54005. */
  54006. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54007. /**
  54008. * Gets the list of physic impostors
  54009. * @returns an array of PhysicsImpostor
  54010. */
  54011. getImpostors(): Array<PhysicsImpostor>;
  54012. /**
  54013. * Gets the impostor for a physics enabled object
  54014. * @param object defines the object impersonated by the impostor
  54015. * @returns the PhysicsImpostor or null if not found
  54016. */
  54017. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54018. /**
  54019. * Gets the impostor for a physics body object
  54020. * @param body defines physics body used by the impostor
  54021. * @returns the PhysicsImpostor or null if not found
  54022. */
  54023. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54024. /**
  54025. * Does a raycast in the physics world
  54026. * @param from when should the ray start?
  54027. * @param to when should the ray end?
  54028. * @returns PhysicsRaycastResult
  54029. */
  54030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54031. }
  54032. }
  54033. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54034. import { Nullable } from "babylonjs/types";
  54035. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54037. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54038. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54039. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54040. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54041. /** @hidden */
  54042. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54043. private _useDeltaForWorldStep;
  54044. world: any;
  54045. name: string;
  54046. private _physicsMaterials;
  54047. private _fixedTimeStep;
  54048. private _cannonRaycastResult;
  54049. private _raycastResult;
  54050. private _physicsBodysToRemoveAfterStep;
  54051. BJSCANNON: any;
  54052. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54053. setGravity(gravity: Vector3): void;
  54054. setTimeStep(timeStep: number): void;
  54055. getTimeStep(): number;
  54056. executeStep(delta: number): void;
  54057. private _removeMarkedPhysicsBodiesFromWorld;
  54058. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54059. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54060. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54061. private _processChildMeshes;
  54062. removePhysicsBody(impostor: PhysicsImpostor): void;
  54063. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54064. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54065. private _addMaterial;
  54066. private _checkWithEpsilon;
  54067. private _createShape;
  54068. private _createHeightmap;
  54069. private _minus90X;
  54070. private _plus90X;
  54071. private _tmpPosition;
  54072. private _tmpDeltaPosition;
  54073. private _tmpUnityRotation;
  54074. private _updatePhysicsBodyTransformation;
  54075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54077. isSupported(): boolean;
  54078. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54079. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54080. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54081. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54082. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54083. getBodyMass(impostor: PhysicsImpostor): number;
  54084. getBodyFriction(impostor: PhysicsImpostor): number;
  54085. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54086. getBodyRestitution(impostor: PhysicsImpostor): number;
  54087. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54088. sleepBody(impostor: PhysicsImpostor): void;
  54089. wakeUpBody(impostor: PhysicsImpostor): void;
  54090. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54091. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54092. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54093. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54094. getRadius(impostor: PhysicsImpostor): number;
  54095. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54096. dispose(): void;
  54097. private _extendNamespace;
  54098. /**
  54099. * Does a raycast in the physics world
  54100. * @param from when should the ray start?
  54101. * @param to when should the ray end?
  54102. * @returns PhysicsRaycastResult
  54103. */
  54104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54105. }
  54106. }
  54107. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54108. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54109. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54110. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54112. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54113. import { Nullable } from "babylonjs/types";
  54114. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54115. /** @hidden */
  54116. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54117. world: any;
  54118. name: string;
  54119. BJSOIMO: any;
  54120. private _raycastResult;
  54121. constructor(iterations?: number, oimoInjection?: any);
  54122. setGravity(gravity: Vector3): void;
  54123. setTimeStep(timeStep: number): void;
  54124. getTimeStep(): number;
  54125. private _tmpImpostorsArray;
  54126. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54127. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54128. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54129. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54130. private _tmpPositionVector;
  54131. removePhysicsBody(impostor: PhysicsImpostor): void;
  54132. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54133. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54134. isSupported(): boolean;
  54135. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54136. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54137. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54138. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54139. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54140. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54141. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54142. getBodyMass(impostor: PhysicsImpostor): number;
  54143. getBodyFriction(impostor: PhysicsImpostor): number;
  54144. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54145. getBodyRestitution(impostor: PhysicsImpostor): number;
  54146. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54147. sleepBody(impostor: PhysicsImpostor): void;
  54148. wakeUpBody(impostor: PhysicsImpostor): void;
  54149. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54150. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54151. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54152. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54153. getRadius(impostor: PhysicsImpostor): number;
  54154. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54155. dispose(): void;
  54156. /**
  54157. * Does a raycast in the physics world
  54158. * @param from when should the ray start?
  54159. * @param to when should the ray end?
  54160. * @returns PhysicsRaycastResult
  54161. */
  54162. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54163. }
  54164. }
  54165. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54166. import { Nullable } from "babylonjs/types";
  54167. import { Scene } from "babylonjs/scene";
  54168. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54169. import { Color4 } from "babylonjs/Maths/math.color";
  54170. import { Mesh } from "babylonjs/Meshes/mesh";
  54171. /**
  54172. * Class containing static functions to help procedurally build meshes
  54173. */
  54174. export class RibbonBuilder {
  54175. /**
  54176. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54177. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54178. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54179. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54180. * * 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
  54181. * * 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
  54182. * * 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
  54183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54186. * * 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
  54187. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54188. * * 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
  54189. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54191. * @param name defines the name of the mesh
  54192. * @param options defines the options used to create the mesh
  54193. * @param scene defines the hosting scene
  54194. * @returns the ribbon mesh
  54195. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54197. */
  54198. static CreateRibbon(name: string, options: {
  54199. pathArray: Vector3[][];
  54200. closeArray?: boolean;
  54201. closePath?: boolean;
  54202. offset?: number;
  54203. updatable?: boolean;
  54204. sideOrientation?: number;
  54205. frontUVs?: Vector4;
  54206. backUVs?: Vector4;
  54207. instance?: Mesh;
  54208. invertUV?: boolean;
  54209. uvs?: Vector2[];
  54210. colors?: Color4[];
  54211. }, scene?: Nullable<Scene>): Mesh;
  54212. }
  54213. }
  54214. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54215. import { Nullable } from "babylonjs/types";
  54216. import { Scene } from "babylonjs/scene";
  54217. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54218. import { Mesh } from "babylonjs/Meshes/mesh";
  54219. /**
  54220. * Class containing static functions to help procedurally build meshes
  54221. */
  54222. export class ShapeBuilder {
  54223. /**
  54224. * 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.
  54225. * * 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.
  54226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54227. * * 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.
  54228. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54229. * * 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
  54230. * * 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
  54231. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54236. * @param name defines the name of the mesh
  54237. * @param options defines the options used to create the mesh
  54238. * @param scene defines the hosting scene
  54239. * @returns the extruded shape mesh
  54240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54242. */
  54243. static ExtrudeShape(name: string, options: {
  54244. shape: Vector3[];
  54245. path: Vector3[];
  54246. scale?: number;
  54247. rotation?: number;
  54248. cap?: number;
  54249. updatable?: boolean;
  54250. sideOrientation?: number;
  54251. frontUVs?: Vector4;
  54252. backUVs?: Vector4;
  54253. instance?: Mesh;
  54254. invertUV?: boolean;
  54255. }, scene?: Nullable<Scene>): Mesh;
  54256. /**
  54257. * Creates an custom extruded shape mesh.
  54258. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54259. * * 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.
  54260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54261. * * 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
  54262. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54263. * * 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
  54264. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54265. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54266. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54267. * * 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
  54268. * * 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
  54269. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54274. * @param name defines the name of the mesh
  54275. * @param options defines the options used to create the mesh
  54276. * @param scene defines the hosting scene
  54277. * @returns the custom extruded shape mesh
  54278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54281. */
  54282. static ExtrudeShapeCustom(name: string, options: {
  54283. shape: Vector3[];
  54284. path: Vector3[];
  54285. scaleFunction?: any;
  54286. rotationFunction?: any;
  54287. ribbonCloseArray?: boolean;
  54288. ribbonClosePath?: boolean;
  54289. cap?: number;
  54290. updatable?: boolean;
  54291. sideOrientation?: number;
  54292. frontUVs?: Vector4;
  54293. backUVs?: Vector4;
  54294. instance?: Mesh;
  54295. invertUV?: boolean;
  54296. }, scene?: Nullable<Scene>): Mesh;
  54297. private static _ExtrudeShapeGeneric;
  54298. }
  54299. }
  54300. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54301. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54302. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54303. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54304. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54305. import { Nullable } from "babylonjs/types";
  54306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54307. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54308. /**
  54309. * AmmoJS Physics plugin
  54310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54311. * @see https://github.com/kripken/ammo.js/
  54312. */
  54313. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54314. private _useDeltaForWorldStep;
  54315. /**
  54316. * Reference to the Ammo library
  54317. */
  54318. bjsAMMO: any;
  54319. /**
  54320. * Created ammoJS world which physics bodies are added to
  54321. */
  54322. world: any;
  54323. /**
  54324. * Name of the plugin
  54325. */
  54326. name: string;
  54327. private _timeStep;
  54328. private _fixedTimeStep;
  54329. private _maxSteps;
  54330. private _tmpQuaternion;
  54331. private _tmpAmmoTransform;
  54332. private _tmpAmmoQuaternion;
  54333. private _tmpAmmoConcreteContactResultCallback;
  54334. private _collisionConfiguration;
  54335. private _dispatcher;
  54336. private _overlappingPairCache;
  54337. private _solver;
  54338. private _softBodySolver;
  54339. private _tmpAmmoVectorA;
  54340. private _tmpAmmoVectorB;
  54341. private _tmpAmmoVectorC;
  54342. private _tmpAmmoVectorD;
  54343. private _tmpContactCallbackResult;
  54344. private _tmpAmmoVectorRCA;
  54345. private _tmpAmmoVectorRCB;
  54346. private _raycastResult;
  54347. private static readonly DISABLE_COLLISION_FLAG;
  54348. private static readonly KINEMATIC_FLAG;
  54349. private static readonly DISABLE_DEACTIVATION_FLAG;
  54350. /**
  54351. * Initializes the ammoJS plugin
  54352. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54353. * @param ammoInjection can be used to inject your own ammo reference
  54354. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54355. */
  54356. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54357. /**
  54358. * Sets the gravity of the physics world (m/(s^2))
  54359. * @param gravity Gravity to set
  54360. */
  54361. setGravity(gravity: Vector3): void;
  54362. /**
  54363. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54364. * @param timeStep timestep to use in seconds
  54365. */
  54366. setTimeStep(timeStep: number): void;
  54367. /**
  54368. * 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)
  54369. * @param fixedTimeStep fixedTimeStep to use in seconds
  54370. */
  54371. setFixedTimeStep(fixedTimeStep: number): void;
  54372. /**
  54373. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54374. * @param maxSteps the maximum number of steps by the physics engine per frame
  54375. */
  54376. setMaxSteps(maxSteps: number): void;
  54377. /**
  54378. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54379. * @returns the current timestep in seconds
  54380. */
  54381. getTimeStep(): number;
  54382. private _isImpostorInContact;
  54383. private _isImpostorPairInContact;
  54384. private _stepSimulation;
  54385. /**
  54386. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54387. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54388. * After the step the babylon meshes are set to the position of the physics imposters
  54389. * @param delta amount of time to step forward
  54390. * @param impostors array of imposters to update before/after the step
  54391. */
  54392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54393. /**
  54394. * Update babylon mesh to match physics world object
  54395. * @param impostor imposter to match
  54396. */
  54397. private _afterSoftStep;
  54398. /**
  54399. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54400. * @param impostor imposter to match
  54401. */
  54402. private _ropeStep;
  54403. /**
  54404. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54405. * @param impostor imposter to match
  54406. */
  54407. private _softbodyOrClothStep;
  54408. private _tmpVector;
  54409. private _tmpMatrix;
  54410. /**
  54411. * Applies an impulse on the imposter
  54412. * @param impostor imposter to apply impulse to
  54413. * @param force amount of force to be applied to the imposter
  54414. * @param contactPoint the location to apply the impulse on the imposter
  54415. */
  54416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54417. /**
  54418. * Applies a force on the imposter
  54419. * @param impostor imposter to apply force
  54420. * @param force amount of force to be applied to the imposter
  54421. * @param contactPoint the location to apply the force on the imposter
  54422. */
  54423. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54424. /**
  54425. * Creates a physics body using the plugin
  54426. * @param impostor the imposter to create the physics body on
  54427. */
  54428. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54429. /**
  54430. * Removes the physics body from the imposter and disposes of the body's memory
  54431. * @param impostor imposter to remove the physics body from
  54432. */
  54433. removePhysicsBody(impostor: PhysicsImpostor): void;
  54434. /**
  54435. * Generates a joint
  54436. * @param impostorJoint the imposter joint to create the joint with
  54437. */
  54438. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54439. /**
  54440. * Removes a joint
  54441. * @param impostorJoint the imposter joint to remove the joint from
  54442. */
  54443. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54444. private _addMeshVerts;
  54445. /**
  54446. * Initialise the soft body vertices to match its object's (mesh) vertices
  54447. * Softbody vertices (nodes) are in world space and to match this
  54448. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54449. * @param impostor to create the softbody for
  54450. */
  54451. private _softVertexData;
  54452. /**
  54453. * Create an impostor's soft body
  54454. * @param impostor to create the softbody for
  54455. */
  54456. private _createSoftbody;
  54457. /**
  54458. * Create cloth for an impostor
  54459. * @param impostor to create the softbody for
  54460. */
  54461. private _createCloth;
  54462. /**
  54463. * Create rope for an impostor
  54464. * @param impostor to create the softbody for
  54465. */
  54466. private _createRope;
  54467. private _addHullVerts;
  54468. private _createShape;
  54469. /**
  54470. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54471. * @param impostor imposter containing the physics body and babylon object
  54472. */
  54473. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54474. /**
  54475. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54476. * @param impostor imposter containing the physics body and babylon object
  54477. * @param newPosition new position
  54478. * @param newRotation new rotation
  54479. */
  54480. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54481. /**
  54482. * If this plugin is supported
  54483. * @returns true if its supported
  54484. */
  54485. isSupported(): boolean;
  54486. /**
  54487. * Sets the linear velocity of the physics body
  54488. * @param impostor imposter to set the velocity on
  54489. * @param velocity velocity to set
  54490. */
  54491. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54492. /**
  54493. * Sets the angular velocity of the physics body
  54494. * @param impostor imposter to set the velocity on
  54495. * @param velocity velocity to set
  54496. */
  54497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54498. /**
  54499. * gets the linear velocity
  54500. * @param impostor imposter to get linear velocity from
  54501. * @returns linear velocity
  54502. */
  54503. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54504. /**
  54505. * gets the angular velocity
  54506. * @param impostor imposter to get angular velocity from
  54507. * @returns angular velocity
  54508. */
  54509. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54510. /**
  54511. * Sets the mass of physics body
  54512. * @param impostor imposter to set the mass on
  54513. * @param mass mass to set
  54514. */
  54515. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54516. /**
  54517. * Gets the mass of the physics body
  54518. * @param impostor imposter to get the mass from
  54519. * @returns mass
  54520. */
  54521. getBodyMass(impostor: PhysicsImpostor): number;
  54522. /**
  54523. * Gets friction of the impostor
  54524. * @param impostor impostor to get friction from
  54525. * @returns friction value
  54526. */
  54527. getBodyFriction(impostor: PhysicsImpostor): number;
  54528. /**
  54529. * Sets friction of the impostor
  54530. * @param impostor impostor to set friction on
  54531. * @param friction friction value
  54532. */
  54533. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54534. /**
  54535. * Gets restitution of the impostor
  54536. * @param impostor impostor to get restitution from
  54537. * @returns restitution value
  54538. */
  54539. getBodyRestitution(impostor: PhysicsImpostor): number;
  54540. /**
  54541. * Sets resitution of the impostor
  54542. * @param impostor impostor to set resitution on
  54543. * @param restitution resitution value
  54544. */
  54545. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54546. /**
  54547. * Gets pressure inside the impostor
  54548. * @param impostor impostor to get pressure from
  54549. * @returns pressure value
  54550. */
  54551. getBodyPressure(impostor: PhysicsImpostor): number;
  54552. /**
  54553. * Sets pressure inside a soft body impostor
  54554. * Cloth and rope must remain 0 pressure
  54555. * @param impostor impostor to set pressure on
  54556. * @param pressure pressure value
  54557. */
  54558. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54559. /**
  54560. * Gets stiffness of the impostor
  54561. * @param impostor impostor to get stiffness from
  54562. * @returns pressure value
  54563. */
  54564. getBodyStiffness(impostor: PhysicsImpostor): number;
  54565. /**
  54566. * Sets stiffness of the impostor
  54567. * @param impostor impostor to set stiffness on
  54568. * @param stiffness stiffness value from 0 to 1
  54569. */
  54570. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54571. /**
  54572. * Gets velocityIterations of the impostor
  54573. * @param impostor impostor to get velocity iterations from
  54574. * @returns velocityIterations value
  54575. */
  54576. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54577. /**
  54578. * Sets velocityIterations of the impostor
  54579. * @param impostor impostor to set velocity iterations on
  54580. * @param velocityIterations velocityIterations value
  54581. */
  54582. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54583. /**
  54584. * Gets positionIterations of the impostor
  54585. * @param impostor impostor to get position iterations from
  54586. * @returns positionIterations value
  54587. */
  54588. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54589. /**
  54590. * Sets positionIterations of the impostor
  54591. * @param impostor impostor to set position on
  54592. * @param positionIterations positionIterations value
  54593. */
  54594. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54595. /**
  54596. * Append an anchor to a cloth object
  54597. * @param impostor is the cloth impostor to add anchor to
  54598. * @param otherImpostor is the rigid impostor to anchor to
  54599. * @param width ratio across width from 0 to 1
  54600. * @param height ratio up height from 0 to 1
  54601. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54602. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54603. */
  54604. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54605. /**
  54606. * Append an hook to a rope object
  54607. * @param impostor is the rope impostor to add hook to
  54608. * @param otherImpostor is the rigid impostor to hook to
  54609. * @param length ratio along the rope from 0 to 1
  54610. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54611. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54612. */
  54613. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54614. /**
  54615. * Sleeps the physics body and stops it from being active
  54616. * @param impostor impostor to sleep
  54617. */
  54618. sleepBody(impostor: PhysicsImpostor): void;
  54619. /**
  54620. * Activates the physics body
  54621. * @param impostor impostor to activate
  54622. */
  54623. wakeUpBody(impostor: PhysicsImpostor): void;
  54624. /**
  54625. * Updates the distance parameters of the joint
  54626. * @param joint joint to update
  54627. * @param maxDistance maximum distance of the joint
  54628. * @param minDistance minimum distance of the joint
  54629. */
  54630. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54631. /**
  54632. * Sets a motor on the joint
  54633. * @param joint joint to set motor on
  54634. * @param speed speed of the motor
  54635. * @param maxForce maximum force of the motor
  54636. * @param motorIndex index of the motor
  54637. */
  54638. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54639. /**
  54640. * Sets the motors limit
  54641. * @param joint joint to set limit on
  54642. * @param upperLimit upper limit
  54643. * @param lowerLimit lower limit
  54644. */
  54645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54646. /**
  54647. * Syncs the position and rotation of a mesh with the impostor
  54648. * @param mesh mesh to sync
  54649. * @param impostor impostor to update the mesh with
  54650. */
  54651. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54652. /**
  54653. * Gets the radius of the impostor
  54654. * @param impostor impostor to get radius from
  54655. * @returns the radius
  54656. */
  54657. getRadius(impostor: PhysicsImpostor): number;
  54658. /**
  54659. * Gets the box size of the impostor
  54660. * @param impostor impostor to get box size from
  54661. * @param result the resulting box size
  54662. */
  54663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54664. /**
  54665. * Disposes of the impostor
  54666. */
  54667. dispose(): void;
  54668. /**
  54669. * Does a raycast in the physics world
  54670. * @param from when should the ray start?
  54671. * @param to when should the ray end?
  54672. * @returns PhysicsRaycastResult
  54673. */
  54674. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54675. }
  54676. }
  54677. declare module "babylonjs/Probes/reflectionProbe" {
  54678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54679. import { Vector3 } from "babylonjs/Maths/math.vector";
  54680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54681. import { Nullable } from "babylonjs/types";
  54682. import { Scene } from "babylonjs/scene";
  54683. module "babylonjs/abstractScene" {
  54684. interface AbstractScene {
  54685. /**
  54686. * The list of reflection probes added to the scene
  54687. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54688. */
  54689. reflectionProbes: Array<ReflectionProbe>;
  54690. /**
  54691. * Removes the given reflection probe from this scene.
  54692. * @param toRemove The reflection probe to remove
  54693. * @returns The index of the removed reflection probe
  54694. */
  54695. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54696. /**
  54697. * Adds the given reflection probe to this scene.
  54698. * @param newReflectionProbe The reflection probe to add
  54699. */
  54700. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54701. }
  54702. }
  54703. /**
  54704. * Class used to generate realtime reflection / refraction cube textures
  54705. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54706. */
  54707. export class ReflectionProbe {
  54708. /** defines the name of the probe */
  54709. name: string;
  54710. private _scene;
  54711. private _renderTargetTexture;
  54712. private _projectionMatrix;
  54713. private _viewMatrix;
  54714. private _target;
  54715. private _add;
  54716. private _attachedMesh;
  54717. private _invertYAxis;
  54718. /** Gets or sets probe position (center of the cube map) */
  54719. position: Vector3;
  54720. /**
  54721. * Creates a new reflection probe
  54722. * @param name defines the name of the probe
  54723. * @param size defines the texture resolution (for each face)
  54724. * @param scene defines the hosting scene
  54725. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54726. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54727. */
  54728. constructor(
  54729. /** defines the name of the probe */
  54730. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54731. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54732. samples: number;
  54733. /** Gets or sets the refresh rate to use (on every frame by default) */
  54734. refreshRate: number;
  54735. /**
  54736. * Gets the hosting scene
  54737. * @returns a Scene
  54738. */
  54739. getScene(): Scene;
  54740. /** Gets the internal CubeTexture used to render to */
  54741. readonly cubeTexture: RenderTargetTexture;
  54742. /** Gets the list of meshes to render */
  54743. readonly renderList: Nullable<AbstractMesh[]>;
  54744. /**
  54745. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54746. * @param mesh defines the mesh to attach to
  54747. */
  54748. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54749. /**
  54750. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54751. * @param renderingGroupId The rendering group id corresponding to its index
  54752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54753. */
  54754. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54755. /**
  54756. * Clean all associated resources
  54757. */
  54758. dispose(): void;
  54759. /**
  54760. * Converts the reflection probe information to a readable string for debug purpose.
  54761. * @param fullDetails Supports for multiple levels of logging within scene loading
  54762. * @returns the human readable reflection probe info
  54763. */
  54764. toString(fullDetails?: boolean): string;
  54765. /**
  54766. * Get the class name of the relfection probe.
  54767. * @returns "ReflectionProbe"
  54768. */
  54769. getClassName(): string;
  54770. /**
  54771. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54772. * @returns The JSON representation of the texture
  54773. */
  54774. serialize(): any;
  54775. /**
  54776. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54777. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54778. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54779. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54780. * @returns The parsed reflection probe if successful
  54781. */
  54782. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54783. }
  54784. }
  54785. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54786. /** @hidden */
  54787. export var _BabylonLoaderRegistered: boolean;
  54788. /**
  54789. * Helps setting up some configuration for the babylon file loader.
  54790. */
  54791. export class BabylonFileLoaderConfiguration {
  54792. /**
  54793. * The loader does not allow injecting custom physix engine into the plugins.
  54794. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54795. * So you could set this variable to your engine import to make it work.
  54796. */
  54797. static LoaderInjectedPhysicsEngine: any;
  54798. }
  54799. }
  54800. declare module "babylonjs/Loading/Plugins/index" {
  54801. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54802. }
  54803. declare module "babylonjs/Loading/index" {
  54804. export * from "babylonjs/Loading/loadingScreen";
  54805. export * from "babylonjs/Loading/Plugins/index";
  54806. export * from "babylonjs/Loading/sceneLoader";
  54807. export * from "babylonjs/Loading/sceneLoaderFlags";
  54808. }
  54809. declare module "babylonjs/Materials/Background/index" {
  54810. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54811. }
  54812. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54813. import { Scene } from "babylonjs/scene";
  54814. import { Color3 } from "babylonjs/Maths/math.color";
  54815. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54817. /**
  54818. * The Physically based simple base material of BJS.
  54819. *
  54820. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54821. * It is used as the base class for both the specGloss and metalRough conventions.
  54822. */
  54823. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54824. /**
  54825. * Number of Simultaneous lights allowed on the material.
  54826. */
  54827. maxSimultaneousLights: number;
  54828. /**
  54829. * If sets to true, disables all the lights affecting the material.
  54830. */
  54831. disableLighting: boolean;
  54832. /**
  54833. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54834. */
  54835. environmentTexture: BaseTexture;
  54836. /**
  54837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54838. */
  54839. invertNormalMapX: boolean;
  54840. /**
  54841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54842. */
  54843. invertNormalMapY: boolean;
  54844. /**
  54845. * Normal map used in the model.
  54846. */
  54847. normalTexture: BaseTexture;
  54848. /**
  54849. * Emissivie color used to self-illuminate the model.
  54850. */
  54851. emissiveColor: Color3;
  54852. /**
  54853. * Emissivie texture used to self-illuminate the model.
  54854. */
  54855. emissiveTexture: BaseTexture;
  54856. /**
  54857. * Occlusion Channel Strenght.
  54858. */
  54859. occlusionStrength: number;
  54860. /**
  54861. * Occlusion Texture of the material (adding extra occlusion effects).
  54862. */
  54863. occlusionTexture: BaseTexture;
  54864. /**
  54865. * Defines the alpha limits in alpha test mode.
  54866. */
  54867. alphaCutOff: number;
  54868. /**
  54869. * Gets the current double sided mode.
  54870. */
  54871. /**
  54872. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54873. */
  54874. doubleSided: boolean;
  54875. /**
  54876. * Stores the pre-calculated light information of a mesh in a texture.
  54877. */
  54878. lightmapTexture: BaseTexture;
  54879. /**
  54880. * If true, the light map contains occlusion information instead of lighting info.
  54881. */
  54882. useLightmapAsShadowmap: boolean;
  54883. /**
  54884. * Instantiates a new PBRMaterial instance.
  54885. *
  54886. * @param name The material name
  54887. * @param scene The scene the material will be use in.
  54888. */
  54889. constructor(name: string, scene: Scene);
  54890. getClassName(): string;
  54891. }
  54892. }
  54893. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54894. import { Scene } from "babylonjs/scene";
  54895. import { Color3 } from "babylonjs/Maths/math.color";
  54896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54897. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54898. /**
  54899. * The PBR material of BJS following the metal roughness convention.
  54900. *
  54901. * This fits to the PBR convention in the GLTF definition:
  54902. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54903. */
  54904. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54905. /**
  54906. * The base color has two different interpretations depending on the value of metalness.
  54907. * When the material is a metal, the base color is the specific measured reflectance value
  54908. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54909. * of the material.
  54910. */
  54911. baseColor: Color3;
  54912. /**
  54913. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54914. * well as opacity information in the alpha channel.
  54915. */
  54916. baseTexture: BaseTexture;
  54917. /**
  54918. * Specifies the metallic scalar value of the material.
  54919. * Can also be used to scale the metalness values of the metallic texture.
  54920. */
  54921. metallic: number;
  54922. /**
  54923. * Specifies the roughness scalar value of the material.
  54924. * Can also be used to scale the roughness values of the metallic texture.
  54925. */
  54926. roughness: number;
  54927. /**
  54928. * Texture containing both the metallic value in the B channel and the
  54929. * roughness value in the G channel to keep better precision.
  54930. */
  54931. metallicRoughnessTexture: BaseTexture;
  54932. /**
  54933. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54934. *
  54935. * @param name The material name
  54936. * @param scene The scene the material will be use in.
  54937. */
  54938. constructor(name: string, scene: Scene);
  54939. /**
  54940. * Return the currrent class name of the material.
  54941. */
  54942. getClassName(): string;
  54943. /**
  54944. * Makes a duplicate of the current material.
  54945. * @param name - name to use for the new material.
  54946. */
  54947. clone(name: string): PBRMetallicRoughnessMaterial;
  54948. /**
  54949. * Serialize the material to a parsable JSON object.
  54950. */
  54951. serialize(): any;
  54952. /**
  54953. * Parses a JSON object correponding to the serialize function.
  54954. */
  54955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54956. }
  54957. }
  54958. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54959. import { Scene } from "babylonjs/scene";
  54960. import { Color3 } from "babylonjs/Maths/math.color";
  54961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54962. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54963. /**
  54964. * The PBR material of BJS following the specular glossiness convention.
  54965. *
  54966. * This fits to the PBR convention in the GLTF definition:
  54967. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54968. */
  54969. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54970. /**
  54971. * Specifies the diffuse color of the material.
  54972. */
  54973. diffuseColor: Color3;
  54974. /**
  54975. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54976. * channel.
  54977. */
  54978. diffuseTexture: BaseTexture;
  54979. /**
  54980. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54981. */
  54982. specularColor: Color3;
  54983. /**
  54984. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54985. */
  54986. glossiness: number;
  54987. /**
  54988. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54989. */
  54990. specularGlossinessTexture: BaseTexture;
  54991. /**
  54992. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54993. *
  54994. * @param name The material name
  54995. * @param scene The scene the material will be use in.
  54996. */
  54997. constructor(name: string, scene: Scene);
  54998. /**
  54999. * Return the currrent class name of the material.
  55000. */
  55001. getClassName(): string;
  55002. /**
  55003. * Makes a duplicate of the current material.
  55004. * @param name - name to use for the new material.
  55005. */
  55006. clone(name: string): PBRSpecularGlossinessMaterial;
  55007. /**
  55008. * Serialize the material to a parsable JSON object.
  55009. */
  55010. serialize(): any;
  55011. /**
  55012. * Parses a JSON object correponding to the serialize function.
  55013. */
  55014. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55015. }
  55016. }
  55017. declare module "babylonjs/Materials/PBR/index" {
  55018. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55019. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55020. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55021. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55022. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55023. }
  55024. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55025. import { Nullable } from "babylonjs/types";
  55026. import { Scene } from "babylonjs/scene";
  55027. import { Matrix } from "babylonjs/Maths/math.vector";
  55028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55029. /**
  55030. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55031. * It can help converting any input color in a desired output one. This can then be used to create effects
  55032. * from sepia, black and white to sixties or futuristic rendering...
  55033. *
  55034. * The only supported format is currently 3dl.
  55035. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55036. */
  55037. export class ColorGradingTexture extends BaseTexture {
  55038. /**
  55039. * The current texture matrix. (will always be identity in color grading texture)
  55040. */
  55041. private _textureMatrix;
  55042. /**
  55043. * The texture URL.
  55044. */
  55045. url: string;
  55046. /**
  55047. * Empty line regex stored for GC.
  55048. */
  55049. private static _noneEmptyLineRegex;
  55050. private _engine;
  55051. /**
  55052. * Instantiates a ColorGradingTexture from the following parameters.
  55053. *
  55054. * @param url The location of the color gradind data (currently only supporting 3dl)
  55055. * @param scene The scene the texture will be used in
  55056. */
  55057. constructor(url: string, scene: Scene);
  55058. /**
  55059. * Returns the texture matrix used in most of the material.
  55060. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55061. */
  55062. getTextureMatrix(): Matrix;
  55063. /**
  55064. * Occurs when the file being loaded is a .3dl LUT file.
  55065. */
  55066. private load3dlTexture;
  55067. /**
  55068. * Starts the loading process of the texture.
  55069. */
  55070. private loadTexture;
  55071. /**
  55072. * Clones the color gradind texture.
  55073. */
  55074. clone(): ColorGradingTexture;
  55075. /**
  55076. * Called during delayed load for textures.
  55077. */
  55078. delayLoad(): void;
  55079. /**
  55080. * Parses a color grading texture serialized by Babylon.
  55081. * @param parsedTexture The texture information being parsedTexture
  55082. * @param scene The scene to load the texture in
  55083. * @param rootUrl The root url of the data assets to load
  55084. * @return A color gradind texture
  55085. */
  55086. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55087. /**
  55088. * Serializes the LUT texture to json format.
  55089. */
  55090. serialize(): any;
  55091. }
  55092. }
  55093. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55095. import { Scene } from "babylonjs/scene";
  55096. import { Nullable } from "babylonjs/types";
  55097. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55098. /**
  55099. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55100. */
  55101. export class EquiRectangularCubeTexture extends BaseTexture {
  55102. /** The six faces of the cube. */
  55103. private static _FacesMapping;
  55104. private _noMipmap;
  55105. private _onLoad;
  55106. private _onError;
  55107. /** The size of the cubemap. */
  55108. private _size;
  55109. /** The buffer of the image. */
  55110. private _buffer;
  55111. /** The width of the input image. */
  55112. private _width;
  55113. /** The height of the input image. */
  55114. private _height;
  55115. /** The URL to the image. */
  55116. url: string;
  55117. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55118. coordinatesMode: number;
  55119. /**
  55120. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55121. * @param url The location of the image
  55122. * @param scene The scene the texture will be used in
  55123. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55124. * @param noMipmap Forces to not generate the mipmap if true
  55125. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55126. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55127. * @param onLoad — defines a callback called when texture is loaded
  55128. * @param onError — defines a callback called if there is an error
  55129. */
  55130. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55131. /**
  55132. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55133. */
  55134. private loadImage;
  55135. /**
  55136. * Convert the image buffer into a cubemap and create a CubeTexture.
  55137. */
  55138. private loadTexture;
  55139. /**
  55140. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55141. * @param buffer The ArrayBuffer that should be converted.
  55142. * @returns The buffer as Float32Array.
  55143. */
  55144. private getFloat32ArrayFromArrayBuffer;
  55145. /**
  55146. * Get the current class name of the texture useful for serialization or dynamic coding.
  55147. * @returns "EquiRectangularCubeTexture"
  55148. */
  55149. getClassName(): string;
  55150. /**
  55151. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55152. * @returns A clone of the current EquiRectangularCubeTexture.
  55153. */
  55154. clone(): EquiRectangularCubeTexture;
  55155. }
  55156. }
  55157. declare module "babylonjs/Misc/tga" {
  55158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55159. /**
  55160. * Based on jsTGALoader - Javascript loader for TGA file
  55161. * By Vincent Thibault
  55162. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55163. */
  55164. export class TGATools {
  55165. private static _TYPE_INDEXED;
  55166. private static _TYPE_RGB;
  55167. private static _TYPE_GREY;
  55168. private static _TYPE_RLE_INDEXED;
  55169. private static _TYPE_RLE_RGB;
  55170. private static _TYPE_RLE_GREY;
  55171. private static _ORIGIN_MASK;
  55172. private static _ORIGIN_SHIFT;
  55173. private static _ORIGIN_BL;
  55174. private static _ORIGIN_BR;
  55175. private static _ORIGIN_UL;
  55176. private static _ORIGIN_UR;
  55177. /**
  55178. * Gets the header of a TGA file
  55179. * @param data defines the TGA data
  55180. * @returns the header
  55181. */
  55182. static GetTGAHeader(data: Uint8Array): any;
  55183. /**
  55184. * Uploads TGA content to a Babylon Texture
  55185. * @hidden
  55186. */
  55187. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55188. /** @hidden */
  55189. 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;
  55190. /** @hidden */
  55191. 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;
  55192. /** @hidden */
  55193. 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;
  55194. /** @hidden */
  55195. 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;
  55196. /** @hidden */
  55197. 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;
  55198. /** @hidden */
  55199. 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;
  55200. }
  55201. }
  55202. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55203. import { Nullable } from "babylonjs/types";
  55204. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55205. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55206. /**
  55207. * Implementation of the TGA Texture Loader.
  55208. * @hidden
  55209. */
  55210. export class _TGATextureLoader implements IInternalTextureLoader {
  55211. /**
  55212. * Defines wether the loader supports cascade loading the different faces.
  55213. */
  55214. readonly supportCascades: boolean;
  55215. /**
  55216. * This returns if the loader support the current file information.
  55217. * @param extension defines the file extension of the file being loaded
  55218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55219. * @param fallback defines the fallback internal texture if any
  55220. * @param isBase64 defines whether the texture is encoded as a base64
  55221. * @param isBuffer defines whether the texture data are stored as a buffer
  55222. * @returns true if the loader can load the specified file
  55223. */
  55224. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55225. /**
  55226. * Transform the url before loading if required.
  55227. * @param rootUrl the url of the texture
  55228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55229. * @returns the transformed texture
  55230. */
  55231. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55232. /**
  55233. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55234. * @param rootUrl the url of the texture
  55235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55236. * @returns the fallback texture
  55237. */
  55238. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55239. /**
  55240. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55241. * @param data contains the texture data
  55242. * @param texture defines the BabylonJS internal texture
  55243. * @param createPolynomials will be true if polynomials have been requested
  55244. * @param onLoad defines the callback to trigger once the texture is ready
  55245. * @param onError defines the callback to trigger in case of error
  55246. */
  55247. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55248. /**
  55249. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55250. * @param data contains the texture data
  55251. * @param texture defines the BabylonJS internal texture
  55252. * @param callback defines the method to call once ready to upload
  55253. */
  55254. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55255. }
  55256. }
  55257. declare module "babylonjs/Misc/basis" {
  55258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55259. /**
  55260. * Info about the .basis files
  55261. */
  55262. class BasisFileInfo {
  55263. /**
  55264. * If the file has alpha
  55265. */
  55266. hasAlpha: boolean;
  55267. /**
  55268. * Info about each image of the basis file
  55269. */
  55270. images: Array<{
  55271. levels: Array<{
  55272. width: number;
  55273. height: number;
  55274. transcodedPixels: ArrayBufferView;
  55275. }>;
  55276. }>;
  55277. }
  55278. /**
  55279. * Result of transcoding a basis file
  55280. */
  55281. class TranscodeResult {
  55282. /**
  55283. * Info about the .basis file
  55284. */
  55285. fileInfo: BasisFileInfo;
  55286. /**
  55287. * Format to use when loading the file
  55288. */
  55289. format: number;
  55290. }
  55291. /**
  55292. * Configuration options for the Basis transcoder
  55293. */
  55294. export class BasisTranscodeConfiguration {
  55295. /**
  55296. * Supported compression formats used to determine the supported output format of the transcoder
  55297. */
  55298. supportedCompressionFormats?: {
  55299. /**
  55300. * etc1 compression format
  55301. */
  55302. etc1?: boolean;
  55303. /**
  55304. * s3tc compression format
  55305. */
  55306. s3tc?: boolean;
  55307. /**
  55308. * pvrtc compression format
  55309. */
  55310. pvrtc?: boolean;
  55311. /**
  55312. * etc2 compression format
  55313. */
  55314. etc2?: boolean;
  55315. };
  55316. /**
  55317. * If mipmap levels should be loaded for transcoded images (Default: true)
  55318. */
  55319. loadMipmapLevels?: boolean;
  55320. /**
  55321. * Index of a single image to load (Default: all images)
  55322. */
  55323. loadSingleImage?: number;
  55324. }
  55325. /**
  55326. * Used to load .Basis files
  55327. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55328. */
  55329. export class BasisTools {
  55330. private static _IgnoreSupportedFormats;
  55331. /**
  55332. * URL to use when loading the basis transcoder
  55333. */
  55334. static JSModuleURL: string;
  55335. /**
  55336. * URL to use when loading the wasm module for the transcoder
  55337. */
  55338. static WasmModuleURL: string;
  55339. /**
  55340. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55341. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55342. * @returns internal format corresponding to the Basis format
  55343. */
  55344. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55345. private static _WorkerPromise;
  55346. private static _Worker;
  55347. private static _actionId;
  55348. private static _CreateWorkerAsync;
  55349. /**
  55350. * Transcodes a loaded image file to compressed pixel data
  55351. * @param imageData image data to transcode
  55352. * @param config configuration options for the transcoding
  55353. * @returns a promise resulting in the transcoded image
  55354. */
  55355. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55356. /**
  55357. * Loads a texture from the transcode result
  55358. * @param texture texture load to
  55359. * @param transcodeResult the result of transcoding the basis file to load from
  55360. */
  55361. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55362. }
  55363. }
  55364. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55365. import { Nullable } from "babylonjs/types";
  55366. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55367. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55368. /**
  55369. * Loader for .basis file format
  55370. */
  55371. export class _BasisTextureLoader implements IInternalTextureLoader {
  55372. /**
  55373. * Defines whether the loader supports cascade loading the different faces.
  55374. */
  55375. readonly supportCascades: boolean;
  55376. /**
  55377. * This returns if the loader support the current file information.
  55378. * @param extension defines the file extension of the file being loaded
  55379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55380. * @param fallback defines the fallback internal texture if any
  55381. * @param isBase64 defines whether the texture is encoded as a base64
  55382. * @param isBuffer defines whether the texture data are stored as a buffer
  55383. * @returns true if the loader can load the specified file
  55384. */
  55385. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55386. /**
  55387. * Transform the url before loading if required.
  55388. * @param rootUrl the url of the texture
  55389. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55390. * @returns the transformed texture
  55391. */
  55392. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55393. /**
  55394. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55395. * @param rootUrl the url of the texture
  55396. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55397. * @returns the fallback texture
  55398. */
  55399. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55400. /**
  55401. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55402. * @param data contains the texture data
  55403. * @param texture defines the BabylonJS internal texture
  55404. * @param createPolynomials will be true if polynomials have been requested
  55405. * @param onLoad defines the callback to trigger once the texture is ready
  55406. * @param onError defines the callback to trigger in case of error
  55407. */
  55408. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55409. /**
  55410. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55411. * @param data contains the texture data
  55412. * @param texture defines the BabylonJS internal texture
  55413. * @param callback defines the method to call once ready to upload
  55414. */
  55415. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55416. }
  55417. }
  55418. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55419. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55420. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55421. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55422. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55423. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55424. }
  55425. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55426. import { Scene } from "babylonjs/scene";
  55427. import { Texture } from "babylonjs/Materials/Textures/texture";
  55428. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55429. /**
  55430. * 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.
  55431. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55432. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55433. */
  55434. export class CustomProceduralTexture extends ProceduralTexture {
  55435. private _animate;
  55436. private _time;
  55437. private _config;
  55438. private _texturePath;
  55439. /**
  55440. * Instantiates a new Custom Procedural Texture.
  55441. * 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.
  55442. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55443. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55444. * @param name Define the name of the texture
  55445. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55446. * @param size Define the size of the texture to create
  55447. * @param scene Define the scene the texture belongs to
  55448. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55449. * @param generateMipMaps Define if the texture should creates mip maps or not
  55450. */
  55451. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55452. private _loadJson;
  55453. /**
  55454. * Is the texture ready to be used ? (rendered at least once)
  55455. * @returns true if ready, otherwise, false.
  55456. */
  55457. isReady(): boolean;
  55458. /**
  55459. * Render the texture to its associated render target.
  55460. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55461. */
  55462. render(useCameraPostProcess?: boolean): void;
  55463. /**
  55464. * Update the list of dependant textures samplers in the shader.
  55465. */
  55466. updateTextures(): void;
  55467. /**
  55468. * Update the uniform values of the procedural texture in the shader.
  55469. */
  55470. updateShaderUniforms(): void;
  55471. /**
  55472. * Define if the texture animates or not.
  55473. */
  55474. animate: boolean;
  55475. }
  55476. }
  55477. declare module "babylonjs/Shaders/noise.fragment" {
  55478. /** @hidden */
  55479. export var noisePixelShader: {
  55480. name: string;
  55481. shader: string;
  55482. };
  55483. }
  55484. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55485. import { Nullable } from "babylonjs/types";
  55486. import { Scene } from "babylonjs/scene";
  55487. import { Texture } from "babylonjs/Materials/Textures/texture";
  55488. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55489. import "babylonjs/Shaders/noise.fragment";
  55490. /**
  55491. * Class used to generate noise procedural textures
  55492. */
  55493. export class NoiseProceduralTexture extends ProceduralTexture {
  55494. private _time;
  55495. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55496. brightness: number;
  55497. /** Defines the number of octaves to process */
  55498. octaves: number;
  55499. /** Defines the level of persistence (0.8 by default) */
  55500. persistence: number;
  55501. /** Gets or sets animation speed factor (default is 1) */
  55502. animationSpeedFactor: number;
  55503. /**
  55504. * Creates a new NoiseProceduralTexture
  55505. * @param name defines the name fo the texture
  55506. * @param size defines the size of the texture (default is 256)
  55507. * @param scene defines the hosting scene
  55508. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55509. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55510. */
  55511. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55512. private _updateShaderUniforms;
  55513. protected _getDefines(): string;
  55514. /** Generate the current state of the procedural texture */
  55515. render(useCameraPostProcess?: boolean): void;
  55516. /**
  55517. * Serializes this noise procedural texture
  55518. * @returns a serialized noise procedural texture object
  55519. */
  55520. serialize(): any;
  55521. /**
  55522. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55523. * @param parsedTexture defines parsed texture data
  55524. * @param scene defines the current scene
  55525. * @param rootUrl defines the root URL containing noise procedural texture information
  55526. * @returns a parsed NoiseProceduralTexture
  55527. */
  55528. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55529. }
  55530. }
  55531. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55532. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55533. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55534. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55535. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55536. }
  55537. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55538. import { Nullable } from "babylonjs/types";
  55539. import { Scene } from "babylonjs/scene";
  55540. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55541. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55542. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55543. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55544. /**
  55545. * Raw cube texture where the raw buffers are passed in
  55546. */
  55547. export class RawCubeTexture extends CubeTexture {
  55548. /**
  55549. * Creates a cube texture where the raw buffers are passed in.
  55550. * @param scene defines the scene the texture is attached to
  55551. * @param data defines the array of data to use to create each face
  55552. * @param size defines the size of the textures
  55553. * @param format defines the format of the data
  55554. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55555. * @param generateMipMaps defines if the engine should generate the mip levels
  55556. * @param invertY defines if data must be stored with Y axis inverted
  55557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55558. * @param compression defines the compression used (null by default)
  55559. */
  55560. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55561. /**
  55562. * Updates the raw cube texture.
  55563. * @param data defines the data to store
  55564. * @param format defines the data format
  55565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55566. * @param invertY defines if data must be stored with Y axis inverted
  55567. * @param compression defines the compression used (null by default)
  55568. * @param level defines which level of the texture to update
  55569. */
  55570. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55571. /**
  55572. * Updates a raw cube texture with RGBD encoded data.
  55573. * @param data defines the array of data [mipmap][face] to use to create each face
  55574. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55577. * @returns a promsie that resolves when the operation is complete
  55578. */
  55579. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55580. /**
  55581. * Clones the raw cube texture.
  55582. * @return a new cube texture
  55583. */
  55584. clone(): CubeTexture;
  55585. /** @hidden */
  55586. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55587. }
  55588. }
  55589. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55590. import { Scene } from "babylonjs/scene";
  55591. import { Texture } from "babylonjs/Materials/Textures/texture";
  55592. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55593. /**
  55594. * Class used to store 3D textures containing user data
  55595. */
  55596. export class RawTexture3D extends Texture {
  55597. /** Gets or sets the texture format to use */
  55598. format: number;
  55599. private _engine;
  55600. /**
  55601. * Create a new RawTexture3D
  55602. * @param data defines the data of the texture
  55603. * @param width defines the width of the texture
  55604. * @param height defines the height of the texture
  55605. * @param depth defines the depth of the texture
  55606. * @param format defines the texture format to use
  55607. * @param scene defines the hosting scene
  55608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55609. * @param invertY defines if texture must be stored with Y axis inverted
  55610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55612. */
  55613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55614. /** Gets or sets the texture format to use */
  55615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55616. /**
  55617. * Update the texture with new data
  55618. * @param data defines the data to store in the texture
  55619. */
  55620. update(data: ArrayBufferView): void;
  55621. }
  55622. }
  55623. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55624. import { Scene } from "babylonjs/scene";
  55625. import { Texture } from "babylonjs/Materials/Textures/texture";
  55626. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55627. /**
  55628. * Class used to store 2D array textures containing user data
  55629. */
  55630. export class RawTexture2DArray extends Texture {
  55631. /** Gets or sets the texture format to use */
  55632. format: number;
  55633. private _engine;
  55634. /**
  55635. * Create a new RawTexture2DArray
  55636. * @param data defines the data of the texture
  55637. * @param width defines the width of the texture
  55638. * @param height defines the height of the texture
  55639. * @param depth defines the number of layers of the texture
  55640. * @param format defines the texture format to use
  55641. * @param scene defines the hosting scene
  55642. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55643. * @param invertY defines if texture must be stored with Y axis inverted
  55644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55645. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55646. */
  55647. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55648. /** Gets or sets the texture format to use */
  55649. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55650. /**
  55651. * Update the texture with new data
  55652. * @param data defines the data to store in the texture
  55653. */
  55654. update(data: ArrayBufferView): void;
  55655. }
  55656. }
  55657. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55658. import { Scene } from "babylonjs/scene";
  55659. import { Plane } from "babylonjs/Maths/math.plane";
  55660. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55661. /**
  55662. * Creates a refraction texture used by refraction channel of the standard material.
  55663. * It is like a mirror but to see through a material.
  55664. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55665. */
  55666. export class RefractionTexture extends RenderTargetTexture {
  55667. /**
  55668. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55669. * 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.
  55670. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55671. */
  55672. refractionPlane: Plane;
  55673. /**
  55674. * Define how deep under the surface we should see.
  55675. */
  55676. depth: number;
  55677. /**
  55678. * Creates a refraction texture used by refraction channel of the standard material.
  55679. * It is like a mirror but to see through a material.
  55680. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55681. * @param name Define the texture name
  55682. * @param size Define the size of the underlying texture
  55683. * @param scene Define the scene the refraction belongs to
  55684. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55685. */
  55686. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55687. /**
  55688. * Clone the refraction texture.
  55689. * @returns the cloned texture
  55690. */
  55691. clone(): RefractionTexture;
  55692. /**
  55693. * Serialize the texture to a JSON representation you could use in Parse later on
  55694. * @returns the serialized JSON representation
  55695. */
  55696. serialize(): any;
  55697. }
  55698. }
  55699. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55700. import { Nullable } from "babylonjs/types";
  55701. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55702. import { Matrix } from "babylonjs/Maths/math.vector";
  55703. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55704. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55705. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55706. import { Scene } from "babylonjs/scene";
  55707. /**
  55708. * Defines the options related to the creation of an HtmlElementTexture
  55709. */
  55710. export interface IHtmlElementTextureOptions {
  55711. /**
  55712. * Defines wether mip maps should be created or not.
  55713. */
  55714. generateMipMaps?: boolean;
  55715. /**
  55716. * Defines the sampling mode of the texture.
  55717. */
  55718. samplingMode?: number;
  55719. /**
  55720. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55721. */
  55722. engine: Nullable<ThinEngine>;
  55723. /**
  55724. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55725. */
  55726. scene: Nullable<Scene>;
  55727. }
  55728. /**
  55729. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55730. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55731. * is automatically managed.
  55732. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55733. * in your application.
  55734. *
  55735. * As the update is not automatic, you need to call them manually.
  55736. */
  55737. export class HtmlElementTexture extends BaseTexture {
  55738. /**
  55739. * The texture URL.
  55740. */
  55741. element: HTMLVideoElement | HTMLCanvasElement;
  55742. private static readonly DefaultOptions;
  55743. private _textureMatrix;
  55744. private _engine;
  55745. private _isVideo;
  55746. private _generateMipMaps;
  55747. private _samplingMode;
  55748. /**
  55749. * Instantiates a HtmlElementTexture from the following parameters.
  55750. *
  55751. * @param name Defines the name of the texture
  55752. * @param element Defines the video or canvas the texture is filled with
  55753. * @param options Defines the other none mandatory texture creation options
  55754. */
  55755. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55756. private _createInternalTexture;
  55757. /**
  55758. * Returns the texture matrix used in most of the material.
  55759. */
  55760. getTextureMatrix(): Matrix;
  55761. /**
  55762. * Updates the content of the texture.
  55763. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55764. */
  55765. update(invertY?: Nullable<boolean>): void;
  55766. }
  55767. }
  55768. declare module "babylonjs/Materials/Textures/index" {
  55769. export * from "babylonjs/Materials/Textures/baseTexture";
  55770. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55771. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55772. export * from "babylonjs/Materials/Textures/cubeTexture";
  55773. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55774. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55775. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55776. export * from "babylonjs/Materials/Textures/internalTexture";
  55777. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55778. export * from "babylonjs/Materials/Textures/Loaders/index";
  55779. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55780. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55781. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55782. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55783. export * from "babylonjs/Materials/Textures/rawTexture";
  55784. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55785. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55786. export * from "babylonjs/Materials/Textures/refractionTexture";
  55787. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55788. export * from "babylonjs/Materials/Textures/texture";
  55789. export * from "babylonjs/Materials/Textures/videoTexture";
  55790. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55791. }
  55792. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55793. /**
  55794. * Enum used to define the target of a block
  55795. */
  55796. export enum NodeMaterialBlockTargets {
  55797. /** Vertex shader */
  55798. Vertex = 1,
  55799. /** Fragment shader */
  55800. Fragment = 2,
  55801. /** Neutral */
  55802. Neutral = 4,
  55803. /** Vertex and Fragment */
  55804. VertexAndFragment = 3
  55805. }
  55806. }
  55807. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55808. /**
  55809. * Defines the kind of connection point for node based material
  55810. */
  55811. export enum NodeMaterialBlockConnectionPointTypes {
  55812. /** Float */
  55813. Float = 1,
  55814. /** Int */
  55815. Int = 2,
  55816. /** Vector2 */
  55817. Vector2 = 4,
  55818. /** Vector3 */
  55819. Vector3 = 8,
  55820. /** Vector4 */
  55821. Vector4 = 16,
  55822. /** Color3 */
  55823. Color3 = 32,
  55824. /** Color4 */
  55825. Color4 = 64,
  55826. /** Matrix */
  55827. Matrix = 128,
  55828. /** Detect type based on connection */
  55829. AutoDetect = 1024,
  55830. /** Output type that will be defined by input type */
  55831. BasedOnInput = 2048
  55832. }
  55833. }
  55834. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55835. /**
  55836. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55837. */
  55838. export enum NodeMaterialBlockConnectionPointMode {
  55839. /** Value is an uniform */
  55840. Uniform = 0,
  55841. /** Value is a mesh attribute */
  55842. Attribute = 1,
  55843. /** Value is a varying between vertex and fragment shaders */
  55844. Varying = 2,
  55845. /** Mode is undefined */
  55846. Undefined = 3
  55847. }
  55848. }
  55849. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55850. /**
  55851. * Enum used to define system values e.g. values automatically provided by the system
  55852. */
  55853. export enum NodeMaterialSystemValues {
  55854. /** World */
  55855. World = 1,
  55856. /** View */
  55857. View = 2,
  55858. /** Projection */
  55859. Projection = 3,
  55860. /** ViewProjection */
  55861. ViewProjection = 4,
  55862. /** WorldView */
  55863. WorldView = 5,
  55864. /** WorldViewProjection */
  55865. WorldViewProjection = 6,
  55866. /** CameraPosition */
  55867. CameraPosition = 7,
  55868. /** Fog Color */
  55869. FogColor = 8,
  55870. /** Delta time */
  55871. DeltaTime = 9
  55872. }
  55873. }
  55874. declare module "babylonjs/Materials/Node/Enums/index" {
  55875. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55876. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55877. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55878. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55879. }
  55880. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55882. /**
  55883. * Root class for all node material optimizers
  55884. */
  55885. export class NodeMaterialOptimizer {
  55886. /**
  55887. * Function used to optimize a NodeMaterial graph
  55888. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55889. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55890. */
  55891. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55892. }
  55893. }
  55894. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55898. import { Scene } from "babylonjs/scene";
  55899. /**
  55900. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55901. */
  55902. export class TransformBlock extends NodeMaterialBlock {
  55903. /**
  55904. * Defines the value to use to complement W value to transform it to a Vector4
  55905. */
  55906. complementW: number;
  55907. /**
  55908. * Defines the value to use to complement z value to transform it to a Vector4
  55909. */
  55910. complementZ: number;
  55911. /**
  55912. * Creates a new TransformBlock
  55913. * @param name defines the block name
  55914. */
  55915. constructor(name: string);
  55916. /**
  55917. * Gets the current class name
  55918. * @returns the class name
  55919. */
  55920. getClassName(): string;
  55921. /**
  55922. * Gets the vector input
  55923. */
  55924. readonly vector: NodeMaterialConnectionPoint;
  55925. /**
  55926. * Gets the output component
  55927. */
  55928. readonly output: NodeMaterialConnectionPoint;
  55929. /**
  55930. * Gets the matrix transform input
  55931. */
  55932. readonly transform: NodeMaterialConnectionPoint;
  55933. protected _buildBlock(state: NodeMaterialBuildState): this;
  55934. serialize(): any;
  55935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55936. protected _dumpPropertiesCode(): string;
  55937. }
  55938. }
  55939. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55943. /**
  55944. * Block used to output the vertex position
  55945. */
  55946. export class VertexOutputBlock extends NodeMaterialBlock {
  55947. /**
  55948. * Creates a new VertexOutputBlock
  55949. * @param name defines the block name
  55950. */
  55951. constructor(name: string);
  55952. /**
  55953. * Gets the current class name
  55954. * @returns the class name
  55955. */
  55956. getClassName(): string;
  55957. /**
  55958. * Gets the vector input component
  55959. */
  55960. readonly vector: NodeMaterialConnectionPoint;
  55961. protected _buildBlock(state: NodeMaterialBuildState): this;
  55962. }
  55963. }
  55964. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55968. /**
  55969. * Block used to output the final color
  55970. */
  55971. export class FragmentOutputBlock extends NodeMaterialBlock {
  55972. /**
  55973. * Create a new FragmentOutputBlock
  55974. * @param name defines the block name
  55975. */
  55976. constructor(name: string);
  55977. /**
  55978. * Gets the current class name
  55979. * @returns the class name
  55980. */
  55981. getClassName(): string;
  55982. /**
  55983. * Gets the rgba input component
  55984. */
  55985. readonly rgba: NodeMaterialConnectionPoint;
  55986. /**
  55987. * Gets the rgb input component
  55988. */
  55989. readonly rgb: NodeMaterialConnectionPoint;
  55990. /**
  55991. * Gets the a input component
  55992. */
  55993. readonly a: NodeMaterialConnectionPoint;
  55994. protected _buildBlock(state: NodeMaterialBuildState): this;
  55995. }
  55996. }
  55997. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56004. import { Effect } from "babylonjs/Materials/effect";
  56005. import { Mesh } from "babylonjs/Meshes/mesh";
  56006. import { Nullable } from "babylonjs/types";
  56007. import { Scene } from "babylonjs/scene";
  56008. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56009. /**
  56010. * Block used to read a reflection texture from a sampler
  56011. */
  56012. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56013. private _define3DName;
  56014. private _defineCubicName;
  56015. private _defineExplicitName;
  56016. private _defineProjectionName;
  56017. private _defineLocalCubicName;
  56018. private _defineSphericalName;
  56019. private _definePlanarName;
  56020. private _defineEquirectangularName;
  56021. private _defineMirroredEquirectangularFixedName;
  56022. private _defineEquirectangularFixedName;
  56023. private _defineSkyboxName;
  56024. private _cubeSamplerName;
  56025. private _2DSamplerName;
  56026. private _positionUVWName;
  56027. private _directionWName;
  56028. private _reflectionCoordsName;
  56029. private _reflection2DCoordsName;
  56030. private _reflectionColorName;
  56031. private _reflectionMatrixName;
  56032. /**
  56033. * Gets or sets the texture associated with the node
  56034. */
  56035. texture: Nullable<BaseTexture>;
  56036. /**
  56037. * Create a new TextureBlock
  56038. * @param name defines the block name
  56039. */
  56040. constructor(name: string);
  56041. /**
  56042. * Gets the current class name
  56043. * @returns the class name
  56044. */
  56045. getClassName(): string;
  56046. /**
  56047. * Gets the world position input component
  56048. */
  56049. readonly position: NodeMaterialConnectionPoint;
  56050. /**
  56051. * Gets the world position input component
  56052. */
  56053. readonly worldPosition: NodeMaterialConnectionPoint;
  56054. /**
  56055. * Gets the world normal input component
  56056. */
  56057. readonly worldNormal: NodeMaterialConnectionPoint;
  56058. /**
  56059. * Gets the world input component
  56060. */
  56061. readonly world: NodeMaterialConnectionPoint;
  56062. /**
  56063. * Gets the camera (or eye) position component
  56064. */
  56065. readonly cameraPosition: NodeMaterialConnectionPoint;
  56066. /**
  56067. * Gets the view input component
  56068. */
  56069. readonly view: NodeMaterialConnectionPoint;
  56070. /**
  56071. * Gets the rgb output component
  56072. */
  56073. readonly rgb: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Gets the r output component
  56076. */
  56077. readonly r: NodeMaterialConnectionPoint;
  56078. /**
  56079. * Gets the g output component
  56080. */
  56081. readonly g: NodeMaterialConnectionPoint;
  56082. /**
  56083. * Gets the b output component
  56084. */
  56085. readonly b: NodeMaterialConnectionPoint;
  56086. autoConfigure(material: NodeMaterial): void;
  56087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56088. isReady(): boolean;
  56089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56090. private _injectVertexCode;
  56091. private _writeOutput;
  56092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56093. protected _dumpPropertiesCode(): string;
  56094. serialize(): any;
  56095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56096. }
  56097. }
  56098. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56101. import { Scene } from "babylonjs/scene";
  56102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56103. import { Matrix } from "babylonjs/Maths/math.vector";
  56104. import { Mesh } from "babylonjs/Meshes/mesh";
  56105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56106. import { Observable } from "babylonjs/Misc/observable";
  56107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56109. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56110. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56111. import { Nullable } from "babylonjs/types";
  56112. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56113. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56114. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56115. /**
  56116. * Interface used to configure the node material editor
  56117. */
  56118. export interface INodeMaterialEditorOptions {
  56119. /** Define the URl to load node editor script */
  56120. editorURL?: string;
  56121. }
  56122. /** @hidden */
  56123. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56124. /** BONES */
  56125. NUM_BONE_INFLUENCERS: number;
  56126. BonesPerMesh: number;
  56127. BONETEXTURE: boolean;
  56128. /** MORPH TARGETS */
  56129. MORPHTARGETS: boolean;
  56130. MORPHTARGETS_NORMAL: boolean;
  56131. MORPHTARGETS_TANGENT: boolean;
  56132. MORPHTARGETS_UV: boolean;
  56133. NUM_MORPH_INFLUENCERS: number;
  56134. /** IMAGE PROCESSING */
  56135. IMAGEPROCESSING: boolean;
  56136. VIGNETTE: boolean;
  56137. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56138. VIGNETTEBLENDMODEOPAQUE: boolean;
  56139. TONEMAPPING: boolean;
  56140. TONEMAPPING_ACES: boolean;
  56141. CONTRAST: boolean;
  56142. EXPOSURE: boolean;
  56143. COLORCURVES: boolean;
  56144. COLORGRADING: boolean;
  56145. COLORGRADING3D: boolean;
  56146. SAMPLER3DGREENDEPTH: boolean;
  56147. SAMPLER3DBGRMAP: boolean;
  56148. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56149. /** MISC. */
  56150. BUMPDIRECTUV: number;
  56151. constructor();
  56152. setValue(name: string, value: boolean): void;
  56153. }
  56154. /**
  56155. * Class used to configure NodeMaterial
  56156. */
  56157. export interface INodeMaterialOptions {
  56158. /**
  56159. * Defines if blocks should emit comments
  56160. */
  56161. emitComments: boolean;
  56162. }
  56163. /**
  56164. * Class used to create a node based material built by assembling shader blocks
  56165. */
  56166. export class NodeMaterial extends PushMaterial {
  56167. private static _BuildIdGenerator;
  56168. private _options;
  56169. private _vertexCompilationState;
  56170. private _fragmentCompilationState;
  56171. private _sharedData;
  56172. private _buildId;
  56173. private _buildWasSuccessful;
  56174. private _cachedWorldViewMatrix;
  56175. private _cachedWorldViewProjectionMatrix;
  56176. private _optimizers;
  56177. private _animationFrame;
  56178. /** Define the URl to load node editor script */
  56179. static EditorURL: string;
  56180. private BJSNODEMATERIALEDITOR;
  56181. /** Get the inspector from bundle or global */
  56182. private _getGlobalNodeMaterialEditor;
  56183. /**
  56184. * 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)
  56185. */
  56186. ignoreAlpha: boolean;
  56187. /**
  56188. * Defines the maximum number of lights that can be used in the material
  56189. */
  56190. maxSimultaneousLights: number;
  56191. /**
  56192. * Observable raised when the material is built
  56193. */
  56194. onBuildObservable: Observable<NodeMaterial>;
  56195. /**
  56196. * Gets or sets the root nodes of the material vertex shader
  56197. */
  56198. _vertexOutputNodes: NodeMaterialBlock[];
  56199. /**
  56200. * Gets or sets the root nodes of the material fragment (pixel) shader
  56201. */
  56202. _fragmentOutputNodes: NodeMaterialBlock[];
  56203. /** Gets or sets options to control the node material overall behavior */
  56204. options: INodeMaterialOptions;
  56205. /**
  56206. * Default configuration related to image processing available in the standard Material.
  56207. */
  56208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56209. /**
  56210. * Gets the image processing configuration used either in this material.
  56211. */
  56212. /**
  56213. * Sets the Default image processing configuration used either in the this material.
  56214. *
  56215. * If sets to null, the scene one is in use.
  56216. */
  56217. imageProcessingConfiguration: ImageProcessingConfiguration;
  56218. /**
  56219. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56220. */
  56221. attachedBlocks: NodeMaterialBlock[];
  56222. /**
  56223. * Create a new node based material
  56224. * @param name defines the material name
  56225. * @param scene defines the hosting scene
  56226. * @param options defines creation option
  56227. */
  56228. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56229. /**
  56230. * Gets the current class name of the material e.g. "NodeMaterial"
  56231. * @returns the class name
  56232. */
  56233. getClassName(): string;
  56234. /**
  56235. * Keep track of the image processing observer to allow dispose and replace.
  56236. */
  56237. private _imageProcessingObserver;
  56238. /**
  56239. * Attaches a new image processing configuration to the Standard Material.
  56240. * @param configuration
  56241. */
  56242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56243. /**
  56244. * Get a block by its name
  56245. * @param name defines the name of the block to retrieve
  56246. * @returns the required block or null if not found
  56247. */
  56248. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56249. /**
  56250. * Get a block by its name
  56251. * @param predicate defines the predicate used to find the good candidate
  56252. * @returns the required block or null if not found
  56253. */
  56254. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56255. /**
  56256. * Get an input block by its name
  56257. * @param predicate defines the predicate used to find the good candidate
  56258. * @returns the required input block or null if not found
  56259. */
  56260. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56261. /**
  56262. * Gets the list of input blocks attached to this material
  56263. * @returns an array of InputBlocks
  56264. */
  56265. getInputBlocks(): InputBlock[];
  56266. /**
  56267. * Adds a new optimizer to the list of optimizers
  56268. * @param optimizer defines the optimizers to add
  56269. * @returns the current material
  56270. */
  56271. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56272. /**
  56273. * Remove an optimizer from the list of optimizers
  56274. * @param optimizer defines the optimizers to remove
  56275. * @returns the current material
  56276. */
  56277. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56278. /**
  56279. * Add a new block to the list of output nodes
  56280. * @param node defines the node to add
  56281. * @returns the current material
  56282. */
  56283. addOutputNode(node: NodeMaterialBlock): this;
  56284. /**
  56285. * Remove a block from the list of root nodes
  56286. * @param node defines the node to remove
  56287. * @returns the current material
  56288. */
  56289. removeOutputNode(node: NodeMaterialBlock): this;
  56290. private _addVertexOutputNode;
  56291. private _removeVertexOutputNode;
  56292. private _addFragmentOutputNode;
  56293. private _removeFragmentOutputNode;
  56294. /**
  56295. * Specifies if the material will require alpha blending
  56296. * @returns a boolean specifying if alpha blending is needed
  56297. */
  56298. needAlphaBlending(): boolean;
  56299. /**
  56300. * Specifies if this material should be rendered in alpha test mode
  56301. * @returns a boolean specifying if an alpha test is needed.
  56302. */
  56303. needAlphaTesting(): boolean;
  56304. private _initializeBlock;
  56305. private _resetDualBlocks;
  56306. /**
  56307. * Build the material and generates the inner effect
  56308. * @param verbose defines if the build should log activity
  56309. */
  56310. build(verbose?: boolean): void;
  56311. /**
  56312. * Runs an otpimization phase to try to improve the shader code
  56313. */
  56314. optimize(): void;
  56315. private _prepareDefinesForAttributes;
  56316. /**
  56317. * Get if the submesh is ready to be used and all its information available.
  56318. * Child classes can use it to update shaders
  56319. * @param mesh defines the mesh to check
  56320. * @param subMesh defines which submesh to check
  56321. * @param useInstances specifies that instances should be used
  56322. * @returns a boolean indicating that the submesh is ready or not
  56323. */
  56324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56325. /**
  56326. * Get a string representing the shaders built by the current node graph
  56327. */
  56328. readonly compiledShaders: string;
  56329. /**
  56330. * Binds the world matrix to the material
  56331. * @param world defines the world transformation matrix
  56332. */
  56333. bindOnlyWorldMatrix(world: Matrix): void;
  56334. /**
  56335. * Binds the submesh to this material by preparing the effect and shader to draw
  56336. * @param world defines the world transformation matrix
  56337. * @param mesh defines the mesh containing the submesh
  56338. * @param subMesh defines the submesh to bind the material to
  56339. */
  56340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56341. /**
  56342. * Gets the active textures from the material
  56343. * @returns an array of textures
  56344. */
  56345. getActiveTextures(): BaseTexture[];
  56346. /**
  56347. * Gets the list of texture blocks
  56348. * @returns an array of texture blocks
  56349. */
  56350. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56351. /**
  56352. * Specifies if the material uses a texture
  56353. * @param texture defines the texture to check against the material
  56354. * @returns a boolean specifying if the material uses the texture
  56355. */
  56356. hasTexture(texture: BaseTexture): boolean;
  56357. /**
  56358. * Disposes the material
  56359. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56360. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56361. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56362. */
  56363. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56364. /** Creates the node editor window. */
  56365. private _createNodeEditor;
  56366. /**
  56367. * Launch the node material editor
  56368. * @param config Define the configuration of the editor
  56369. * @return a promise fulfilled when the node editor is visible
  56370. */
  56371. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56372. /**
  56373. * Clear the current material
  56374. */
  56375. clear(): void;
  56376. /**
  56377. * Clear the current material and set it to a default state
  56378. */
  56379. setToDefault(): void;
  56380. /**
  56381. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56382. * @param url defines the url to load from
  56383. * @returns a promise that will fullfil when the material is fully loaded
  56384. */
  56385. loadAsync(url: string): Promise<void>;
  56386. private _gatherBlocks;
  56387. /**
  56388. * Generate a string containing the code declaration required to create an equivalent of this material
  56389. * @returns a string
  56390. */
  56391. generateCode(): string;
  56392. /**
  56393. * Serializes this material in a JSON representation
  56394. * @returns the serialized material object
  56395. */
  56396. serialize(): any;
  56397. private _restoreConnections;
  56398. /**
  56399. * Clear the current graph and load a new one from a serialization object
  56400. * @param source defines the JSON representation of the material
  56401. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56402. */
  56403. loadFromSerialization(source: any, rootUrl?: string): void;
  56404. /**
  56405. * Creates a node material from parsed material data
  56406. * @param source defines the JSON representation of the material
  56407. * @param scene defines the hosting scene
  56408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56409. * @returns a new node material
  56410. */
  56411. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56412. /**
  56413. * Creates a new node material set to default basic configuration
  56414. * @param name defines the name of the material
  56415. * @param scene defines the hosting scene
  56416. * @returns a new NodeMaterial
  56417. */
  56418. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56419. }
  56420. }
  56421. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56424. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56427. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56428. import { Effect } from "babylonjs/Materials/effect";
  56429. import { Mesh } from "babylonjs/Meshes/mesh";
  56430. import { Nullable } from "babylonjs/types";
  56431. import { Texture } from "babylonjs/Materials/Textures/texture";
  56432. import { Scene } from "babylonjs/scene";
  56433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56434. /**
  56435. * Block used to read a texture from a sampler
  56436. */
  56437. export class TextureBlock extends NodeMaterialBlock {
  56438. private _defineName;
  56439. private _linearDefineName;
  56440. private _samplerName;
  56441. private _transformedUVName;
  56442. private _textureTransformName;
  56443. private _textureInfoName;
  56444. private _mainUVName;
  56445. private _mainUVDefineName;
  56446. /**
  56447. * Gets or sets the texture associated with the node
  56448. */
  56449. texture: Nullable<Texture>;
  56450. /**
  56451. * Create a new TextureBlock
  56452. * @param name defines the block name
  56453. */
  56454. constructor(name: string);
  56455. /**
  56456. * Gets the current class name
  56457. * @returns the class name
  56458. */
  56459. getClassName(): string;
  56460. /**
  56461. * Gets the uv input component
  56462. */
  56463. readonly uv: NodeMaterialConnectionPoint;
  56464. /**
  56465. * Gets the rgba output component
  56466. */
  56467. readonly rgba: NodeMaterialConnectionPoint;
  56468. /**
  56469. * Gets the rgb output component
  56470. */
  56471. readonly rgb: NodeMaterialConnectionPoint;
  56472. /**
  56473. * Gets the r output component
  56474. */
  56475. readonly r: NodeMaterialConnectionPoint;
  56476. /**
  56477. * Gets the g output component
  56478. */
  56479. readonly g: NodeMaterialConnectionPoint;
  56480. /**
  56481. * Gets the b output component
  56482. */
  56483. readonly b: NodeMaterialConnectionPoint;
  56484. /**
  56485. * Gets the a output component
  56486. */
  56487. readonly a: NodeMaterialConnectionPoint;
  56488. readonly target: NodeMaterialBlockTargets;
  56489. autoConfigure(material: NodeMaterial): void;
  56490. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56492. isReady(): boolean;
  56493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56494. private readonly _isMixed;
  56495. private _injectVertexCode;
  56496. private _writeOutput;
  56497. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56498. protected _dumpPropertiesCode(): string;
  56499. serialize(): any;
  56500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56501. }
  56502. }
  56503. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56506. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56507. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56508. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56509. import { Scene } from "babylonjs/scene";
  56510. /**
  56511. * Class used to store shared data between 2 NodeMaterialBuildState
  56512. */
  56513. export class NodeMaterialBuildStateSharedData {
  56514. /**
  56515. * Gets the list of emitted varyings
  56516. */
  56517. temps: string[];
  56518. /**
  56519. * Gets the list of emitted varyings
  56520. */
  56521. varyings: string[];
  56522. /**
  56523. * Gets the varying declaration string
  56524. */
  56525. varyingDeclaration: string;
  56526. /**
  56527. * Input blocks
  56528. */
  56529. inputBlocks: InputBlock[];
  56530. /**
  56531. * Input blocks
  56532. */
  56533. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56534. /**
  56535. * Bindable blocks (Blocks that need to set data to the effect)
  56536. */
  56537. bindableBlocks: NodeMaterialBlock[];
  56538. /**
  56539. * List of blocks that can provide a compilation fallback
  56540. */
  56541. blocksWithFallbacks: NodeMaterialBlock[];
  56542. /**
  56543. * List of blocks that can provide a define update
  56544. */
  56545. blocksWithDefines: NodeMaterialBlock[];
  56546. /**
  56547. * List of blocks that can provide a repeatable content
  56548. */
  56549. repeatableContentBlocks: NodeMaterialBlock[];
  56550. /**
  56551. * List of blocks that can provide a dynamic list of uniforms
  56552. */
  56553. dynamicUniformBlocks: NodeMaterialBlock[];
  56554. /**
  56555. * List of blocks that can block the isReady function for the material
  56556. */
  56557. blockingBlocks: NodeMaterialBlock[];
  56558. /**
  56559. * Gets the list of animated inputs
  56560. */
  56561. animatedInputs: InputBlock[];
  56562. /**
  56563. * Build Id used to avoid multiple recompilations
  56564. */
  56565. buildId: number;
  56566. /** List of emitted variables */
  56567. variableNames: {
  56568. [key: string]: number;
  56569. };
  56570. /** List of emitted defines */
  56571. defineNames: {
  56572. [key: string]: number;
  56573. };
  56574. /** Should emit comments? */
  56575. emitComments: boolean;
  56576. /** Emit build activity */
  56577. verbose: boolean;
  56578. /** Gets or sets the hosting scene */
  56579. scene: Scene;
  56580. /**
  56581. * Gets the compilation hints emitted at compilation time
  56582. */
  56583. hints: {
  56584. needWorldViewMatrix: boolean;
  56585. needWorldViewProjectionMatrix: boolean;
  56586. needAlphaBlending: boolean;
  56587. needAlphaTesting: boolean;
  56588. };
  56589. /**
  56590. * List of compilation checks
  56591. */
  56592. checks: {
  56593. emitVertex: boolean;
  56594. emitFragment: boolean;
  56595. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56596. };
  56597. /** Creates a new shared data */
  56598. constructor();
  56599. /**
  56600. * Emits console errors and exceptions if there is a failing check
  56601. */
  56602. emitErrors(): void;
  56603. }
  56604. }
  56605. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56606. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56607. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56608. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56609. /**
  56610. * Class used to store node based material build state
  56611. */
  56612. export class NodeMaterialBuildState {
  56613. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56614. supportUniformBuffers: boolean;
  56615. /**
  56616. * Gets the list of emitted attributes
  56617. */
  56618. attributes: string[];
  56619. /**
  56620. * Gets the list of emitted uniforms
  56621. */
  56622. uniforms: string[];
  56623. /**
  56624. * Gets the list of emitted constants
  56625. */
  56626. constants: string[];
  56627. /**
  56628. * Gets the list of emitted samplers
  56629. */
  56630. samplers: string[];
  56631. /**
  56632. * Gets the list of emitted functions
  56633. */
  56634. functions: {
  56635. [key: string]: string;
  56636. };
  56637. /**
  56638. * Gets the list of emitted extensions
  56639. */
  56640. extensions: {
  56641. [key: string]: string;
  56642. };
  56643. /**
  56644. * Gets the target of the compilation state
  56645. */
  56646. target: NodeMaterialBlockTargets;
  56647. /**
  56648. * Gets the list of emitted counters
  56649. */
  56650. counters: {
  56651. [key: string]: number;
  56652. };
  56653. /**
  56654. * Shared data between multiple NodeMaterialBuildState instances
  56655. */
  56656. sharedData: NodeMaterialBuildStateSharedData;
  56657. /** @hidden */
  56658. _vertexState: NodeMaterialBuildState;
  56659. /** @hidden */
  56660. _attributeDeclaration: string;
  56661. /** @hidden */
  56662. _uniformDeclaration: string;
  56663. /** @hidden */
  56664. _constantDeclaration: string;
  56665. /** @hidden */
  56666. _samplerDeclaration: string;
  56667. /** @hidden */
  56668. _varyingTransfer: string;
  56669. private _repeatableContentAnchorIndex;
  56670. /** @hidden */
  56671. _builtCompilationString: string;
  56672. /**
  56673. * Gets the emitted compilation strings
  56674. */
  56675. compilationString: string;
  56676. /**
  56677. * Finalize the compilation strings
  56678. * @param state defines the current compilation state
  56679. */
  56680. finalize(state: NodeMaterialBuildState): void;
  56681. /** @hidden */
  56682. readonly _repeatableContentAnchor: string;
  56683. /** @hidden */
  56684. _getFreeVariableName(prefix: string): string;
  56685. /** @hidden */
  56686. _getFreeDefineName(prefix: string): string;
  56687. /** @hidden */
  56688. _excludeVariableName(name: string): void;
  56689. /** @hidden */
  56690. _emit2DSampler(name: string): void;
  56691. /** @hidden */
  56692. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56693. /** @hidden */
  56694. _emitExtension(name: string, extension: string): void;
  56695. /** @hidden */
  56696. _emitFunction(name: string, code: string, comments: string): void;
  56697. /** @hidden */
  56698. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56699. replaceStrings?: {
  56700. search: RegExp;
  56701. replace: string;
  56702. }[];
  56703. repeatKey?: string;
  56704. }): string;
  56705. /** @hidden */
  56706. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56707. repeatKey?: string;
  56708. removeAttributes?: boolean;
  56709. removeUniforms?: boolean;
  56710. removeVaryings?: boolean;
  56711. removeIfDef?: boolean;
  56712. replaceStrings?: {
  56713. search: RegExp;
  56714. replace: string;
  56715. }[];
  56716. }, storeKey?: string): void;
  56717. /** @hidden */
  56718. _registerTempVariable(name: string): boolean;
  56719. /** @hidden */
  56720. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56721. /** @hidden */
  56722. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56723. /** @hidden */
  56724. _emitFloat(value: number): string;
  56725. }
  56726. }
  56727. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56728. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56730. import { Nullable } from "babylonjs/types";
  56731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56732. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56733. import { Effect } from "babylonjs/Materials/effect";
  56734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56735. import { Mesh } from "babylonjs/Meshes/mesh";
  56736. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56737. import { Scene } from "babylonjs/scene";
  56738. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56739. /**
  56740. * Defines a block that can be used inside a node based material
  56741. */
  56742. export class NodeMaterialBlock {
  56743. private _buildId;
  56744. private _buildTarget;
  56745. private _target;
  56746. private _isFinalMerger;
  56747. private _isInput;
  56748. protected _isUnique: boolean;
  56749. /** @hidden */
  56750. _codeVariableName: string;
  56751. /** @hidden */
  56752. _inputs: NodeMaterialConnectionPoint[];
  56753. /** @hidden */
  56754. _outputs: NodeMaterialConnectionPoint[];
  56755. /** @hidden */
  56756. _preparationId: number;
  56757. /**
  56758. * Gets or sets the name of the block
  56759. */
  56760. name: string;
  56761. /**
  56762. * Gets or sets the unique id of the node
  56763. */
  56764. uniqueId: number;
  56765. /**
  56766. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56767. */
  56768. readonly isUnique: boolean;
  56769. /**
  56770. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56771. */
  56772. readonly isFinalMerger: boolean;
  56773. /**
  56774. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56775. */
  56776. readonly isInput: boolean;
  56777. /**
  56778. * Gets or sets the build Id
  56779. */
  56780. buildId: number;
  56781. /**
  56782. * Gets or sets the target of the block
  56783. */
  56784. target: NodeMaterialBlockTargets;
  56785. /**
  56786. * Gets the list of input points
  56787. */
  56788. readonly inputs: NodeMaterialConnectionPoint[];
  56789. /** Gets the list of output points */
  56790. readonly outputs: NodeMaterialConnectionPoint[];
  56791. /**
  56792. * Find an input by its name
  56793. * @param name defines the name of the input to look for
  56794. * @returns the input or null if not found
  56795. */
  56796. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56797. /**
  56798. * Find an output by its name
  56799. * @param name defines the name of the outputto look for
  56800. * @returns the output or null if not found
  56801. */
  56802. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56803. /**
  56804. * Creates a new NodeMaterialBlock
  56805. * @param name defines the block name
  56806. * @param target defines the target of that block (Vertex by default)
  56807. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56808. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56809. */
  56810. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56811. /**
  56812. * Initialize the block and prepare the context for build
  56813. * @param state defines the state that will be used for the build
  56814. */
  56815. initialize(state: NodeMaterialBuildState): void;
  56816. /**
  56817. * Bind data to effect. Will only be called for blocks with isBindable === true
  56818. * @param effect defines the effect to bind data to
  56819. * @param nodeMaterial defines the hosting NodeMaterial
  56820. * @param mesh defines the mesh that will be rendered
  56821. */
  56822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56823. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56824. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56825. protected _writeFloat(value: number): string;
  56826. /**
  56827. * Gets the current class name e.g. "NodeMaterialBlock"
  56828. * @returns the class name
  56829. */
  56830. getClassName(): string;
  56831. /**
  56832. * Register a new input. Must be called inside a block constructor
  56833. * @param name defines the connection point name
  56834. * @param type defines the connection point type
  56835. * @param isOptional defines a boolean indicating that this input can be omitted
  56836. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56837. * @returns the current block
  56838. */
  56839. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56840. /**
  56841. * Register a new output. Must be called inside a block constructor
  56842. * @param name defines the connection point name
  56843. * @param type defines the connection point type
  56844. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56845. * @returns the current block
  56846. */
  56847. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56848. /**
  56849. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56850. * @param forOutput defines an optional connection point to check compatibility with
  56851. * @returns the first available input or null
  56852. */
  56853. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56854. /**
  56855. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56856. * @param forBlock defines an optional block to check compatibility with
  56857. * @returns the first available input or null
  56858. */
  56859. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56860. /**
  56861. * Gets the sibling of the given output
  56862. * @param current defines the current output
  56863. * @returns the next output in the list or null
  56864. */
  56865. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56866. /**
  56867. * Connect current block with another block
  56868. * @param other defines the block to connect with
  56869. * @param options define the various options to help pick the right connections
  56870. * @returns the current block
  56871. */
  56872. connectTo(other: NodeMaterialBlock, options?: {
  56873. input?: string;
  56874. output?: string;
  56875. outputSwizzle?: string;
  56876. }): this | undefined;
  56877. protected _buildBlock(state: NodeMaterialBuildState): void;
  56878. /**
  56879. * Add uniforms, samplers and uniform buffers at compilation time
  56880. * @param state defines the state to update
  56881. * @param nodeMaterial defines the node material requesting the update
  56882. * @param defines defines the material defines to update
  56883. * @param uniformBuffers defines the list of uniform buffer names
  56884. */
  56885. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56886. /**
  56887. * Add potential fallbacks if shader compilation fails
  56888. * @param mesh defines the mesh to be rendered
  56889. * @param fallbacks defines the current prioritized list of fallbacks
  56890. */
  56891. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56892. /**
  56893. * Initialize defines for shader compilation
  56894. * @param mesh defines the mesh to be rendered
  56895. * @param nodeMaterial defines the node material requesting the update
  56896. * @param defines defines the material defines to update
  56897. * @param useInstances specifies that instances should be used
  56898. */
  56899. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56900. /**
  56901. * Update defines for shader compilation
  56902. * @param mesh defines the mesh to be rendered
  56903. * @param nodeMaterial defines the node material requesting the update
  56904. * @param defines defines the material defines to update
  56905. * @param useInstances specifies that instances should be used
  56906. */
  56907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56908. /**
  56909. * Lets the block try to connect some inputs automatically
  56910. * @param material defines the hosting NodeMaterial
  56911. */
  56912. autoConfigure(material: NodeMaterial): void;
  56913. /**
  56914. * Function called when a block is declared as repeatable content generator
  56915. * @param vertexShaderState defines the current compilation state for the vertex shader
  56916. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56917. * @param mesh defines the mesh to be rendered
  56918. * @param defines defines the material defines to update
  56919. */
  56920. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56921. /**
  56922. * Checks if the block is ready
  56923. * @param mesh defines the mesh to be rendered
  56924. * @param nodeMaterial defines the node material requesting the update
  56925. * @param defines defines the material defines to update
  56926. * @param useInstances specifies that instances should be used
  56927. * @returns true if the block is ready
  56928. */
  56929. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56930. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56931. private _processBuild;
  56932. /**
  56933. * Compile the current node and generate the shader code
  56934. * @param state defines the current compilation state (uniforms, samplers, current string)
  56935. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56936. * @returns true if already built
  56937. */
  56938. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56939. protected _inputRename(name: string): string;
  56940. protected _outputRename(name: string): string;
  56941. protected _dumpPropertiesCode(): string;
  56942. /** @hidden */
  56943. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56944. /** @hidden */
  56945. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56946. /**
  56947. * Clone the current block to a new identical block
  56948. * @param scene defines the hosting scene
  56949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56950. * @returns a copy of the current block
  56951. */
  56952. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56953. /**
  56954. * Serializes this block in a JSON representation
  56955. * @returns the serialized block object
  56956. */
  56957. serialize(): any;
  56958. /** @hidden */
  56959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56960. /**
  56961. * Release resources
  56962. */
  56963. dispose(): void;
  56964. }
  56965. }
  56966. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56967. /**
  56968. * Enum defining the type of animations supported by InputBlock
  56969. */
  56970. export enum AnimatedInputBlockTypes {
  56971. /** No animation */
  56972. None = 0,
  56973. /** Time based animation. Will only work for floats */
  56974. Time = 1
  56975. }
  56976. }
  56977. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56979. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56980. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56981. import { Nullable } from "babylonjs/types";
  56982. import { Effect } from "babylonjs/Materials/effect";
  56983. import { Matrix } from "babylonjs/Maths/math.vector";
  56984. import { Scene } from "babylonjs/scene";
  56985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56988. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56989. /**
  56990. * Block used to expose an input value
  56991. */
  56992. export class InputBlock extends NodeMaterialBlock {
  56993. private _mode;
  56994. private _associatedVariableName;
  56995. private _storedValue;
  56996. private _valueCallback;
  56997. private _type;
  56998. private _animationType;
  56999. /** Gets or set a value used to limit the range of float values */
  57000. min: number;
  57001. /** Gets or set a value used to limit the range of float values */
  57002. max: number;
  57003. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57004. matrixMode: number;
  57005. /** @hidden */
  57006. _systemValue: Nullable<NodeMaterialSystemValues>;
  57007. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57008. visibleInInspector: boolean;
  57009. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57010. isConstant: boolean;
  57011. /**
  57012. * Gets or sets the connection point type (default is float)
  57013. */
  57014. readonly type: NodeMaterialBlockConnectionPointTypes;
  57015. /**
  57016. * Creates a new InputBlock
  57017. * @param name defines the block name
  57018. * @param target defines the target of that block (Vertex by default)
  57019. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57020. */
  57021. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57022. /**
  57023. * Gets the output component
  57024. */
  57025. readonly output: NodeMaterialConnectionPoint;
  57026. /**
  57027. * Set the source of this connection point to a vertex attribute
  57028. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57029. * @returns the current connection point
  57030. */
  57031. setAsAttribute(attributeName?: string): InputBlock;
  57032. /**
  57033. * Set the source of this connection point to a system value
  57034. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57035. * @returns the current connection point
  57036. */
  57037. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57038. /**
  57039. * Gets or sets the value of that point.
  57040. * Please note that this value will be ignored if valueCallback is defined
  57041. */
  57042. value: any;
  57043. /**
  57044. * Gets or sets a callback used to get the value of that point.
  57045. * Please note that setting this value will force the connection point to ignore the value property
  57046. */
  57047. valueCallback: () => any;
  57048. /**
  57049. * Gets or sets the associated variable name in the shader
  57050. */
  57051. associatedVariableName: string;
  57052. /** Gets or sets the type of animation applied to the input */
  57053. animationType: AnimatedInputBlockTypes;
  57054. /**
  57055. * Gets a boolean indicating that this connection point not defined yet
  57056. */
  57057. readonly isUndefined: boolean;
  57058. /**
  57059. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57060. * In this case the connection point name must be the name of the uniform to use.
  57061. * Can only be set on inputs
  57062. */
  57063. isUniform: boolean;
  57064. /**
  57065. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57066. * In this case the connection point name must be the name of the attribute to use
  57067. * Can only be set on inputs
  57068. */
  57069. isAttribute: boolean;
  57070. /**
  57071. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57072. * Can only be set on exit points
  57073. */
  57074. isVarying: boolean;
  57075. /**
  57076. * Gets a boolean indicating that the current connection point is a system value
  57077. */
  57078. readonly isSystemValue: boolean;
  57079. /**
  57080. * Gets or sets the current well known value or null if not defined as a system value
  57081. */
  57082. systemValue: Nullable<NodeMaterialSystemValues>;
  57083. /**
  57084. * Gets the current class name
  57085. * @returns the class name
  57086. */
  57087. getClassName(): string;
  57088. /**
  57089. * Animate the input if animationType !== None
  57090. * @param scene defines the rendering scene
  57091. */
  57092. animate(scene: Scene): void;
  57093. private _emitDefine;
  57094. initialize(state: NodeMaterialBuildState): void;
  57095. /**
  57096. * Set the input block to its default value (based on its type)
  57097. */
  57098. setDefaultValue(): void;
  57099. private _emitConstant;
  57100. private _emit;
  57101. /** @hidden */
  57102. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57103. /** @hidden */
  57104. _transmit(effect: Effect, scene: Scene): void;
  57105. protected _buildBlock(state: NodeMaterialBuildState): void;
  57106. protected _dumpPropertiesCode(): string;
  57107. serialize(): any;
  57108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57109. }
  57110. }
  57111. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57112. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57113. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57114. import { Nullable } from "babylonjs/types";
  57115. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57116. import { Observable } from "babylonjs/Misc/observable";
  57117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57118. /**
  57119. * Enum used to define the compatibility state between two connection points
  57120. */
  57121. export enum NodeMaterialConnectionPointCompatibilityStates {
  57122. /** Points are compatibles */
  57123. Compatible = 0,
  57124. /** Points are incompatible because of their types */
  57125. TypeIncompatible = 1,
  57126. /** Points are incompatible because of their targets (vertex vs fragment) */
  57127. TargetIncompatible = 2
  57128. }
  57129. /**
  57130. * Defines a connection point for a block
  57131. */
  57132. export class NodeMaterialConnectionPoint {
  57133. /** @hidden */
  57134. _ownerBlock: NodeMaterialBlock;
  57135. /** @hidden */
  57136. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57137. private _endpoints;
  57138. private _associatedVariableName;
  57139. /** @hidden */
  57140. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57141. /** @hidden */
  57142. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57143. private _type;
  57144. /** @hidden */
  57145. _enforceAssociatedVariableName: boolean;
  57146. /**
  57147. * Gets or sets the additional types supported by this connection point
  57148. */
  57149. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57150. /**
  57151. * Gets or sets the additional types excluded by this connection point
  57152. */
  57153. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57154. /**
  57155. * Observable triggered when this point is connected
  57156. */
  57157. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57158. /**
  57159. * Gets or sets the associated variable name in the shader
  57160. */
  57161. associatedVariableName: string;
  57162. /**
  57163. * Gets or sets the connection point type (default is float)
  57164. */
  57165. type: NodeMaterialBlockConnectionPointTypes;
  57166. /**
  57167. * Gets or sets the connection point name
  57168. */
  57169. name: string;
  57170. /**
  57171. * Gets or sets a boolean indicating that this connection point can be omitted
  57172. */
  57173. isOptional: boolean;
  57174. /**
  57175. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57176. */
  57177. define: string;
  57178. /** @hidden */
  57179. _prioritizeVertex: boolean;
  57180. private _target;
  57181. /** Gets or sets the target of that connection point */
  57182. target: NodeMaterialBlockTargets;
  57183. /**
  57184. * Gets a boolean indicating that the current point is connected
  57185. */
  57186. readonly isConnected: boolean;
  57187. /**
  57188. * Gets a boolean indicating that the current point is connected to an input block
  57189. */
  57190. readonly isConnectedToInputBlock: boolean;
  57191. /**
  57192. * Gets a the connected input block (if any)
  57193. */
  57194. readonly connectInputBlock: Nullable<InputBlock>;
  57195. /** Get the other side of the connection (if any) */
  57196. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57197. /** Get the block that owns this connection point */
  57198. readonly ownerBlock: NodeMaterialBlock;
  57199. /** Get the block connected on the other side of this connection (if any) */
  57200. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57201. /** Get the block connected on the endpoints of this connection (if any) */
  57202. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57203. /** Gets the list of connected endpoints */
  57204. readonly endpoints: NodeMaterialConnectionPoint[];
  57205. /** Gets a boolean indicating if that output point is connected to at least one input */
  57206. readonly hasEndpoints: boolean;
  57207. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57208. readonly isConnectedInVertexShader: boolean;
  57209. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57210. readonly isConnectedInFragmentShader: boolean;
  57211. /**
  57212. * Creates a new connection point
  57213. * @param name defines the connection point name
  57214. * @param ownerBlock defines the block hosting this connection point
  57215. */
  57216. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57217. /**
  57218. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57219. * @returns the class name
  57220. */
  57221. getClassName(): string;
  57222. /**
  57223. * Gets a boolean indicating if the current point can be connected to another point
  57224. * @param connectionPoint defines the other connection point
  57225. * @returns a boolean
  57226. */
  57227. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57228. /**
  57229. * Gets a number indicating if the current point can be connected to another point
  57230. * @param connectionPoint defines the other connection point
  57231. * @returns a number defining the compatibility state
  57232. */
  57233. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57234. /**
  57235. * Connect this point to another connection point
  57236. * @param connectionPoint defines the other connection point
  57237. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57238. * @returns the current connection point
  57239. */
  57240. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57241. /**
  57242. * Disconnect this point from one of his endpoint
  57243. * @param endpoint defines the other connection point
  57244. * @returns the current connection point
  57245. */
  57246. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57247. /**
  57248. * Serializes this point in a JSON representation
  57249. * @returns the serialized point object
  57250. */
  57251. serialize(): any;
  57252. /**
  57253. * Release resources
  57254. */
  57255. dispose(): void;
  57256. }
  57257. }
  57258. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57262. import { Mesh } from "babylonjs/Meshes/mesh";
  57263. import { Effect } from "babylonjs/Materials/effect";
  57264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57265. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57266. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57268. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57269. /**
  57270. * Block used to add support for vertex skinning (bones)
  57271. */
  57272. export class BonesBlock extends NodeMaterialBlock {
  57273. /**
  57274. * Creates a new BonesBlock
  57275. * @param name defines the block name
  57276. */
  57277. constructor(name: string);
  57278. /**
  57279. * Initialize the block and prepare the context for build
  57280. * @param state defines the state that will be used for the build
  57281. */
  57282. initialize(state: NodeMaterialBuildState): void;
  57283. /**
  57284. * Gets the current class name
  57285. * @returns the class name
  57286. */
  57287. getClassName(): string;
  57288. /**
  57289. * Gets the matrix indices input component
  57290. */
  57291. readonly matricesIndices: NodeMaterialConnectionPoint;
  57292. /**
  57293. * Gets the matrix weights input component
  57294. */
  57295. readonly matricesWeights: NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the extra matrix indices input component
  57298. */
  57299. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the extra matrix weights input component
  57302. */
  57303. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the world input component
  57306. */
  57307. readonly world: NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the output component
  57310. */
  57311. readonly output: NodeMaterialConnectionPoint;
  57312. autoConfigure(material: NodeMaterial): void;
  57313. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57316. protected _buildBlock(state: NodeMaterialBuildState): this;
  57317. }
  57318. }
  57319. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57324. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57325. /**
  57326. * Block used to add support for instances
  57327. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57328. */
  57329. export class InstancesBlock extends NodeMaterialBlock {
  57330. /**
  57331. * Creates a new InstancesBlock
  57332. * @param name defines the block name
  57333. */
  57334. constructor(name: string);
  57335. /**
  57336. * Gets the current class name
  57337. * @returns the class name
  57338. */
  57339. getClassName(): string;
  57340. /**
  57341. * Gets the first world row input component
  57342. */
  57343. readonly world0: NodeMaterialConnectionPoint;
  57344. /**
  57345. * Gets the second world row input component
  57346. */
  57347. readonly world1: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the third world row input component
  57350. */
  57351. readonly world2: NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the forth world row input component
  57354. */
  57355. readonly world3: NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the world input component
  57358. */
  57359. readonly world: NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the output component
  57362. */
  57363. readonly output: NodeMaterialConnectionPoint;
  57364. autoConfigure(material: NodeMaterial): void;
  57365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57366. protected _buildBlock(state: NodeMaterialBuildState): this;
  57367. }
  57368. }
  57369. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57374. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57375. import { Effect } from "babylonjs/Materials/effect";
  57376. import { Mesh } from "babylonjs/Meshes/mesh";
  57377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57378. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57379. /**
  57380. * Block used to add morph targets support to vertex shader
  57381. */
  57382. export class MorphTargetsBlock extends NodeMaterialBlock {
  57383. private _repeatableContentAnchor;
  57384. private _repeatebleContentGenerated;
  57385. /**
  57386. * Create a new MorphTargetsBlock
  57387. * @param name defines the block name
  57388. */
  57389. constructor(name: string);
  57390. /**
  57391. * Gets the current class name
  57392. * @returns the class name
  57393. */
  57394. getClassName(): string;
  57395. /**
  57396. * Gets the position input component
  57397. */
  57398. readonly position: NodeMaterialConnectionPoint;
  57399. /**
  57400. * Gets the normal input component
  57401. */
  57402. readonly normal: NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the tangent input component
  57405. */
  57406. readonly tangent: NodeMaterialConnectionPoint;
  57407. /**
  57408. * Gets the tangent input component
  57409. */
  57410. readonly uv: NodeMaterialConnectionPoint;
  57411. /**
  57412. * Gets the position output component
  57413. */
  57414. readonly positionOutput: NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the normal output component
  57417. */
  57418. readonly normalOutput: NodeMaterialConnectionPoint;
  57419. /**
  57420. * Gets the tangent output component
  57421. */
  57422. readonly tangentOutput: NodeMaterialConnectionPoint;
  57423. /**
  57424. * Gets the tangent output component
  57425. */
  57426. readonly uvOutput: NodeMaterialConnectionPoint;
  57427. initialize(state: NodeMaterialBuildState): void;
  57428. autoConfigure(material: NodeMaterial): void;
  57429. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57431. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57432. protected _buildBlock(state: NodeMaterialBuildState): this;
  57433. }
  57434. }
  57435. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57439. import { Nullable } from "babylonjs/types";
  57440. import { Scene } from "babylonjs/scene";
  57441. import { Effect } from "babylonjs/Materials/effect";
  57442. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57443. import { Mesh } from "babylonjs/Meshes/mesh";
  57444. import { Light } from "babylonjs/Lights/light";
  57445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57446. /**
  57447. * Block used to get data information from a light
  57448. */
  57449. export class LightInformationBlock extends NodeMaterialBlock {
  57450. private _lightDataUniformName;
  57451. private _lightColorUniformName;
  57452. private _lightTypeDefineName;
  57453. /**
  57454. * Gets or sets the light associated with this block
  57455. */
  57456. light: Nullable<Light>;
  57457. /**
  57458. * Creates a new LightInformationBlock
  57459. * @param name defines the block name
  57460. */
  57461. constructor(name: string);
  57462. /**
  57463. * Gets the current class name
  57464. * @returns the class name
  57465. */
  57466. getClassName(): string;
  57467. /**
  57468. * Gets the world position input component
  57469. */
  57470. readonly worldPosition: NodeMaterialConnectionPoint;
  57471. /**
  57472. * Gets the direction output component
  57473. */
  57474. readonly direction: NodeMaterialConnectionPoint;
  57475. /**
  57476. * Gets the direction output component
  57477. */
  57478. readonly color: NodeMaterialConnectionPoint;
  57479. /**
  57480. * Gets the direction output component
  57481. */
  57482. readonly intensity: NodeMaterialConnectionPoint;
  57483. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57485. protected _buildBlock(state: NodeMaterialBuildState): this;
  57486. serialize(): any;
  57487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57488. }
  57489. }
  57490. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57491. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57492. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57493. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57494. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57495. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57496. }
  57497. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57502. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57503. import { Effect } from "babylonjs/Materials/effect";
  57504. import { Mesh } from "babylonjs/Meshes/mesh";
  57505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57506. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57507. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57508. /**
  57509. * Block used to add image processing support to fragment shader
  57510. */
  57511. export class ImageProcessingBlock extends NodeMaterialBlock {
  57512. /**
  57513. * Create a new ImageProcessingBlock
  57514. * @param name defines the block name
  57515. */
  57516. constructor(name: string);
  57517. /**
  57518. * Gets the current class name
  57519. * @returns the class name
  57520. */
  57521. getClassName(): string;
  57522. /**
  57523. * Gets the color input component
  57524. */
  57525. readonly color: NodeMaterialConnectionPoint;
  57526. /**
  57527. * Gets the output component
  57528. */
  57529. readonly output: NodeMaterialConnectionPoint;
  57530. /**
  57531. * Initialize the block and prepare the context for build
  57532. * @param state defines the state that will be used for the build
  57533. */
  57534. initialize(state: NodeMaterialBuildState): void;
  57535. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57537. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57538. protected _buildBlock(state: NodeMaterialBuildState): this;
  57539. }
  57540. }
  57541. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57545. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57547. import { Effect } from "babylonjs/Materials/effect";
  57548. import { Mesh } from "babylonjs/Meshes/mesh";
  57549. import { Scene } from "babylonjs/scene";
  57550. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57551. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57552. /**
  57553. * Block used to pertub normals based on a normal map
  57554. */
  57555. export class PerturbNormalBlock extends NodeMaterialBlock {
  57556. private _tangentSpaceParameterName;
  57557. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57558. invertX: boolean;
  57559. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57560. invertY: boolean;
  57561. /**
  57562. * Create a new PerturbNormalBlock
  57563. * @param name defines the block name
  57564. */
  57565. constructor(name: string);
  57566. /**
  57567. * Gets the current class name
  57568. * @returns the class name
  57569. */
  57570. getClassName(): string;
  57571. /**
  57572. * Gets the world position input component
  57573. */
  57574. readonly worldPosition: NodeMaterialConnectionPoint;
  57575. /**
  57576. * Gets the world normal input component
  57577. */
  57578. readonly worldNormal: NodeMaterialConnectionPoint;
  57579. /**
  57580. * Gets the uv input component
  57581. */
  57582. readonly uv: NodeMaterialConnectionPoint;
  57583. /**
  57584. * Gets the normal map color input component
  57585. */
  57586. readonly normalMapColor: NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the strength input component
  57589. */
  57590. readonly strength: NodeMaterialConnectionPoint;
  57591. /**
  57592. * Gets the output component
  57593. */
  57594. readonly output: NodeMaterialConnectionPoint;
  57595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57597. autoConfigure(material: NodeMaterial): void;
  57598. protected _buildBlock(state: NodeMaterialBuildState): this;
  57599. protected _dumpPropertiesCode(): string;
  57600. serialize(): any;
  57601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57602. }
  57603. }
  57604. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57608. /**
  57609. * Block used to discard a pixel if a value is smaller than a cutoff
  57610. */
  57611. export class DiscardBlock extends NodeMaterialBlock {
  57612. /**
  57613. * Create a new DiscardBlock
  57614. * @param name defines the block name
  57615. */
  57616. constructor(name: string);
  57617. /**
  57618. * Gets the current class name
  57619. * @returns the class name
  57620. */
  57621. getClassName(): string;
  57622. /**
  57623. * Gets the color input component
  57624. */
  57625. readonly value: NodeMaterialConnectionPoint;
  57626. /**
  57627. * Gets the cutoff input component
  57628. */
  57629. readonly cutoff: NodeMaterialConnectionPoint;
  57630. protected _buildBlock(state: NodeMaterialBuildState): this;
  57631. }
  57632. }
  57633. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57637. /**
  57638. * Block used to test if the fragment shader is front facing
  57639. */
  57640. export class FrontFacingBlock extends NodeMaterialBlock {
  57641. /**
  57642. * Creates a new FrontFacingBlock
  57643. * @param name defines the block name
  57644. */
  57645. constructor(name: string);
  57646. /**
  57647. * Gets the current class name
  57648. * @returns the class name
  57649. */
  57650. getClassName(): string;
  57651. /**
  57652. * Gets the output component
  57653. */
  57654. readonly output: NodeMaterialConnectionPoint;
  57655. protected _buildBlock(state: NodeMaterialBuildState): this;
  57656. }
  57657. }
  57658. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57659. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57660. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57661. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57662. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57663. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57664. }
  57665. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57666. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57668. import { Mesh } from "babylonjs/Meshes/mesh";
  57669. import { Effect } from "babylonjs/Materials/effect";
  57670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57672. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57673. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57674. /**
  57675. * Block used to add support for scene fog
  57676. */
  57677. export class FogBlock extends NodeMaterialBlock {
  57678. private _fogDistanceName;
  57679. private _fogParameters;
  57680. /**
  57681. * Create a new FogBlock
  57682. * @param name defines the block name
  57683. */
  57684. constructor(name: string);
  57685. /**
  57686. * Gets the current class name
  57687. * @returns the class name
  57688. */
  57689. getClassName(): string;
  57690. /**
  57691. * Gets the world position input component
  57692. */
  57693. readonly worldPosition: NodeMaterialConnectionPoint;
  57694. /**
  57695. * Gets the view input component
  57696. */
  57697. readonly view: NodeMaterialConnectionPoint;
  57698. /**
  57699. * Gets the color input component
  57700. */
  57701. readonly input: NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the fog color input component
  57704. */
  57705. readonly fogColor: NodeMaterialConnectionPoint;
  57706. /**
  57707. * Gets the output component
  57708. */
  57709. readonly output: NodeMaterialConnectionPoint;
  57710. autoConfigure(material: NodeMaterial): void;
  57711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57713. protected _buildBlock(state: NodeMaterialBuildState): this;
  57714. }
  57715. }
  57716. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57721. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57722. import { Effect } from "babylonjs/Materials/effect";
  57723. import { Mesh } from "babylonjs/Meshes/mesh";
  57724. import { Light } from "babylonjs/Lights/light";
  57725. import { Nullable } from "babylonjs/types";
  57726. import { Scene } from "babylonjs/scene";
  57727. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57728. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57729. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57730. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57731. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57732. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57733. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57734. /**
  57735. * Block used to add light in the fragment shader
  57736. */
  57737. export class LightBlock extends NodeMaterialBlock {
  57738. private _lightId;
  57739. /**
  57740. * Gets or sets the light associated with this block
  57741. */
  57742. light: Nullable<Light>;
  57743. /**
  57744. * Create a new LightBlock
  57745. * @param name defines the block name
  57746. */
  57747. constructor(name: string);
  57748. /**
  57749. * Gets the current class name
  57750. * @returns the class name
  57751. */
  57752. getClassName(): string;
  57753. /**
  57754. * Gets the world position input component
  57755. */
  57756. readonly worldPosition: NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the world normal input component
  57759. */
  57760. readonly worldNormal: NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the camera (or eye) position component
  57763. */
  57764. readonly cameraPosition: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the glossiness component
  57767. */
  57768. readonly glossiness: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the glossinness power component
  57771. */
  57772. readonly glossPower: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the diffuse color component
  57775. */
  57776. readonly diffuseColor: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the specular color component
  57779. */
  57780. readonly specularColor: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the diffuse output component
  57783. */
  57784. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57785. /**
  57786. * Gets the specular output component
  57787. */
  57788. readonly specularOutput: NodeMaterialConnectionPoint;
  57789. autoConfigure(material: NodeMaterial): void;
  57790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57791. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57793. private _injectVertexCode;
  57794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57795. serialize(): any;
  57796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57797. }
  57798. }
  57799. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57800. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57801. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57802. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57803. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57804. }
  57805. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57806. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57807. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57808. }
  57809. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57813. /**
  57814. * Block used to multiply 2 values
  57815. */
  57816. export class MultiplyBlock extends NodeMaterialBlock {
  57817. /**
  57818. * Creates a new MultiplyBlock
  57819. * @param name defines the block name
  57820. */
  57821. constructor(name: string);
  57822. /**
  57823. * Gets the current class name
  57824. * @returns the class name
  57825. */
  57826. getClassName(): string;
  57827. /**
  57828. * Gets the left operand input component
  57829. */
  57830. readonly left: NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the right operand input component
  57833. */
  57834. readonly right: NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the output component
  57837. */
  57838. readonly output: NodeMaterialConnectionPoint;
  57839. protected _buildBlock(state: NodeMaterialBuildState): this;
  57840. }
  57841. }
  57842. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57846. /**
  57847. * Block used to add 2 vectors
  57848. */
  57849. export class AddBlock extends NodeMaterialBlock {
  57850. /**
  57851. * Creates a new AddBlock
  57852. * @param name defines the block name
  57853. */
  57854. constructor(name: string);
  57855. /**
  57856. * Gets the current class name
  57857. * @returns the class name
  57858. */
  57859. getClassName(): string;
  57860. /**
  57861. * Gets the left operand input component
  57862. */
  57863. readonly left: NodeMaterialConnectionPoint;
  57864. /**
  57865. * Gets the right operand input component
  57866. */
  57867. readonly right: NodeMaterialConnectionPoint;
  57868. /**
  57869. * Gets the output component
  57870. */
  57871. readonly output: NodeMaterialConnectionPoint;
  57872. protected _buildBlock(state: NodeMaterialBuildState): this;
  57873. }
  57874. }
  57875. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57879. /**
  57880. * Block used to scale a vector by a float
  57881. */
  57882. export class ScaleBlock extends NodeMaterialBlock {
  57883. /**
  57884. * Creates a new ScaleBlock
  57885. * @param name defines the block name
  57886. */
  57887. constructor(name: string);
  57888. /**
  57889. * Gets the current class name
  57890. * @returns the class name
  57891. */
  57892. getClassName(): string;
  57893. /**
  57894. * Gets the input component
  57895. */
  57896. readonly input: NodeMaterialConnectionPoint;
  57897. /**
  57898. * Gets the factor input component
  57899. */
  57900. readonly factor: NodeMaterialConnectionPoint;
  57901. /**
  57902. * Gets the output component
  57903. */
  57904. readonly output: NodeMaterialConnectionPoint;
  57905. protected _buildBlock(state: NodeMaterialBuildState): this;
  57906. }
  57907. }
  57908. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57912. import { Scene } from "babylonjs/scene";
  57913. /**
  57914. * Block used to clamp a float
  57915. */
  57916. export class ClampBlock extends NodeMaterialBlock {
  57917. /** Gets or sets the minimum range */
  57918. minimum: number;
  57919. /** Gets or sets the maximum range */
  57920. maximum: number;
  57921. /**
  57922. * Creates a new ClampBlock
  57923. * @param name defines the block name
  57924. */
  57925. constructor(name: string);
  57926. /**
  57927. * Gets the current class name
  57928. * @returns the class name
  57929. */
  57930. getClassName(): string;
  57931. /**
  57932. * Gets the value input component
  57933. */
  57934. readonly value: NodeMaterialConnectionPoint;
  57935. /**
  57936. * Gets the output component
  57937. */
  57938. readonly output: NodeMaterialConnectionPoint;
  57939. protected _buildBlock(state: NodeMaterialBuildState): this;
  57940. protected _dumpPropertiesCode(): string;
  57941. serialize(): any;
  57942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57943. }
  57944. }
  57945. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57949. /**
  57950. * Block used to apply a cross product between 2 vectors
  57951. */
  57952. export class CrossBlock extends NodeMaterialBlock {
  57953. /**
  57954. * Creates a new CrossBlock
  57955. * @param name defines the block name
  57956. */
  57957. constructor(name: string);
  57958. /**
  57959. * Gets the current class name
  57960. * @returns the class name
  57961. */
  57962. getClassName(): string;
  57963. /**
  57964. * Gets the left operand input component
  57965. */
  57966. readonly left: NodeMaterialConnectionPoint;
  57967. /**
  57968. * Gets the right operand input component
  57969. */
  57970. readonly right: NodeMaterialConnectionPoint;
  57971. /**
  57972. * Gets the output component
  57973. */
  57974. readonly output: NodeMaterialConnectionPoint;
  57975. protected _buildBlock(state: NodeMaterialBuildState): this;
  57976. }
  57977. }
  57978. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57982. /**
  57983. * Block used to apply a dot product between 2 vectors
  57984. */
  57985. export class DotBlock extends NodeMaterialBlock {
  57986. /**
  57987. * Creates a new DotBlock
  57988. * @param name defines the block name
  57989. */
  57990. constructor(name: string);
  57991. /**
  57992. * Gets the current class name
  57993. * @returns the class name
  57994. */
  57995. getClassName(): string;
  57996. /**
  57997. * Gets the left operand input component
  57998. */
  57999. readonly left: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the right operand input component
  58002. */
  58003. readonly right: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the output component
  58006. */
  58007. readonly output: NodeMaterialConnectionPoint;
  58008. protected _buildBlock(state: NodeMaterialBuildState): this;
  58009. }
  58010. }
  58011. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58015. import { Vector2 } from "babylonjs/Maths/math.vector";
  58016. import { Scene } from "babylonjs/scene";
  58017. /**
  58018. * Block used to remap a float from a range to a new one
  58019. */
  58020. export class RemapBlock extends NodeMaterialBlock {
  58021. /**
  58022. * Gets or sets the source range
  58023. */
  58024. sourceRange: Vector2;
  58025. /**
  58026. * Gets or sets the target range
  58027. */
  58028. targetRange: Vector2;
  58029. /**
  58030. * Creates a new RemapBlock
  58031. * @param name defines the block name
  58032. */
  58033. constructor(name: string);
  58034. /**
  58035. * Gets the current class name
  58036. * @returns the class name
  58037. */
  58038. getClassName(): string;
  58039. /**
  58040. * Gets the input component
  58041. */
  58042. readonly input: NodeMaterialConnectionPoint;
  58043. /**
  58044. * Gets the source min input component
  58045. */
  58046. readonly sourceMin: NodeMaterialConnectionPoint;
  58047. /**
  58048. * Gets the source max input component
  58049. */
  58050. readonly sourceMax: NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the target min input component
  58053. */
  58054. readonly targetMin: NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the target max input component
  58057. */
  58058. readonly targetMax: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the output component
  58061. */
  58062. readonly output: NodeMaterialConnectionPoint;
  58063. protected _buildBlock(state: NodeMaterialBuildState): this;
  58064. protected _dumpPropertiesCode(): string;
  58065. serialize(): any;
  58066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58067. }
  58068. }
  58069. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58073. /**
  58074. * Block used to normalize a vector
  58075. */
  58076. export class NormalizeBlock extends NodeMaterialBlock {
  58077. /**
  58078. * Creates a new NormalizeBlock
  58079. * @param name defines the block name
  58080. */
  58081. constructor(name: string);
  58082. /**
  58083. * Gets the current class name
  58084. * @returns the class name
  58085. */
  58086. getClassName(): string;
  58087. /**
  58088. * Gets the input component
  58089. */
  58090. readonly input: NodeMaterialConnectionPoint;
  58091. /**
  58092. * Gets the output component
  58093. */
  58094. readonly output: NodeMaterialConnectionPoint;
  58095. protected _buildBlock(state: NodeMaterialBuildState): this;
  58096. }
  58097. }
  58098. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58102. import { Scene } from "babylonjs/scene";
  58103. /**
  58104. * Operations supported by the Trigonometry block
  58105. */
  58106. export enum TrigonometryBlockOperations {
  58107. /** Cos */
  58108. Cos = 0,
  58109. /** Sin */
  58110. Sin = 1,
  58111. /** Abs */
  58112. Abs = 2,
  58113. /** Exp */
  58114. Exp = 3,
  58115. /** Exp2 */
  58116. Exp2 = 4,
  58117. /** Round */
  58118. Round = 5,
  58119. /** Floor */
  58120. Floor = 6,
  58121. /** Ceiling */
  58122. Ceiling = 7,
  58123. /** Square root */
  58124. Sqrt = 8,
  58125. /** Log */
  58126. Log = 9,
  58127. /** Tangent */
  58128. Tan = 10,
  58129. /** Arc tangent */
  58130. ArcTan = 11,
  58131. /** Arc cosinus */
  58132. ArcCos = 12,
  58133. /** Arc sinus */
  58134. ArcSin = 13,
  58135. /** Fraction */
  58136. Fract = 14,
  58137. /** Sign */
  58138. Sign = 15,
  58139. /** To radians (from degrees) */
  58140. Radians = 16,
  58141. /** To degrees (from radians) */
  58142. Degrees = 17
  58143. }
  58144. /**
  58145. * Block used to apply trigonometry operation to floats
  58146. */
  58147. export class TrigonometryBlock extends NodeMaterialBlock {
  58148. /**
  58149. * Gets or sets the operation applied by the block
  58150. */
  58151. operation: TrigonometryBlockOperations;
  58152. /**
  58153. * Creates a new TrigonometryBlock
  58154. * @param name defines the block name
  58155. */
  58156. constructor(name: string);
  58157. /**
  58158. * Gets the current class name
  58159. * @returns the class name
  58160. */
  58161. getClassName(): string;
  58162. /**
  58163. * Gets the input component
  58164. */
  58165. readonly input: NodeMaterialConnectionPoint;
  58166. /**
  58167. * Gets the output component
  58168. */
  58169. readonly output: NodeMaterialConnectionPoint;
  58170. protected _buildBlock(state: NodeMaterialBuildState): this;
  58171. serialize(): any;
  58172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58173. }
  58174. }
  58175. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58179. /**
  58180. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58181. */
  58182. export class ColorMergerBlock extends NodeMaterialBlock {
  58183. /**
  58184. * Create a new ColorMergerBlock
  58185. * @param name defines the block name
  58186. */
  58187. constructor(name: string);
  58188. /**
  58189. * Gets the current class name
  58190. * @returns the class name
  58191. */
  58192. getClassName(): string;
  58193. /**
  58194. * Gets the r component (input)
  58195. */
  58196. readonly r: NodeMaterialConnectionPoint;
  58197. /**
  58198. * Gets the g component (input)
  58199. */
  58200. readonly g: NodeMaterialConnectionPoint;
  58201. /**
  58202. * Gets the b component (input)
  58203. */
  58204. readonly b: NodeMaterialConnectionPoint;
  58205. /**
  58206. * Gets the a component (input)
  58207. */
  58208. readonly a: NodeMaterialConnectionPoint;
  58209. /**
  58210. * Gets the rgba component (output)
  58211. */
  58212. readonly rgba: NodeMaterialConnectionPoint;
  58213. /**
  58214. * Gets the rgb component (output)
  58215. */
  58216. readonly rgb: NodeMaterialConnectionPoint;
  58217. protected _buildBlock(state: NodeMaterialBuildState): this;
  58218. }
  58219. }
  58220. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58224. /**
  58225. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58226. */
  58227. export class VectorMergerBlock extends NodeMaterialBlock {
  58228. /**
  58229. * Create a new VectorMergerBlock
  58230. * @param name defines the block name
  58231. */
  58232. constructor(name: string);
  58233. /**
  58234. * Gets the current class name
  58235. * @returns the class name
  58236. */
  58237. getClassName(): string;
  58238. /**
  58239. * Gets the x component (input)
  58240. */
  58241. readonly x: NodeMaterialConnectionPoint;
  58242. /**
  58243. * Gets the y component (input)
  58244. */
  58245. readonly y: NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the z component (input)
  58248. */
  58249. readonly z: NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the w component (input)
  58252. */
  58253. readonly w: NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the xyzw component (output)
  58256. */
  58257. readonly xyzw: NodeMaterialConnectionPoint;
  58258. /**
  58259. * Gets the xyz component (output)
  58260. */
  58261. readonly xyz: NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the xy component (output)
  58264. */
  58265. readonly xy: NodeMaterialConnectionPoint;
  58266. protected _buildBlock(state: NodeMaterialBuildState): this;
  58267. }
  58268. }
  58269. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58273. /**
  58274. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58275. */
  58276. export class ColorSplitterBlock extends NodeMaterialBlock {
  58277. /**
  58278. * Create a new ColorSplitterBlock
  58279. * @param name defines the block name
  58280. */
  58281. constructor(name: string);
  58282. /**
  58283. * Gets the current class name
  58284. * @returns the class name
  58285. */
  58286. getClassName(): string;
  58287. /**
  58288. * Gets the rgba component (input)
  58289. */
  58290. readonly rgba: NodeMaterialConnectionPoint;
  58291. /**
  58292. * Gets the rgb component (input)
  58293. */
  58294. readonly rgbIn: NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the rgb component (output)
  58297. */
  58298. readonly rgbOut: NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the r component (output)
  58301. */
  58302. readonly r: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the g component (output)
  58305. */
  58306. readonly g: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the b component (output)
  58309. */
  58310. readonly b: NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the a component (output)
  58313. */
  58314. readonly a: NodeMaterialConnectionPoint;
  58315. protected _inputRename(name: string): string;
  58316. protected _outputRename(name: string): string;
  58317. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58318. }
  58319. }
  58320. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58324. /**
  58325. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58326. */
  58327. export class VectorSplitterBlock extends NodeMaterialBlock {
  58328. /**
  58329. * Create a new VectorSplitterBlock
  58330. * @param name defines the block name
  58331. */
  58332. constructor(name: string);
  58333. /**
  58334. * Gets the current class name
  58335. * @returns the class name
  58336. */
  58337. getClassName(): string;
  58338. /**
  58339. * Gets the xyzw component (input)
  58340. */
  58341. readonly xyzw: NodeMaterialConnectionPoint;
  58342. /**
  58343. * Gets the xyz component (input)
  58344. */
  58345. readonly xyzIn: NodeMaterialConnectionPoint;
  58346. /**
  58347. * Gets the xy component (input)
  58348. */
  58349. readonly xyIn: NodeMaterialConnectionPoint;
  58350. /**
  58351. * Gets the xyz component (output)
  58352. */
  58353. readonly xyzOut: NodeMaterialConnectionPoint;
  58354. /**
  58355. * Gets the xy component (output)
  58356. */
  58357. readonly xyOut: NodeMaterialConnectionPoint;
  58358. /**
  58359. * Gets the x component (output)
  58360. */
  58361. readonly x: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the y component (output)
  58364. */
  58365. readonly y: NodeMaterialConnectionPoint;
  58366. /**
  58367. * Gets the z component (output)
  58368. */
  58369. readonly z: NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the w component (output)
  58372. */
  58373. readonly w: NodeMaterialConnectionPoint;
  58374. protected _inputRename(name: string): string;
  58375. protected _outputRename(name: string): string;
  58376. protected _buildBlock(state: NodeMaterialBuildState): this;
  58377. }
  58378. }
  58379. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58383. /**
  58384. * Block used to lerp between 2 values
  58385. */
  58386. export class LerpBlock extends NodeMaterialBlock {
  58387. /**
  58388. * Creates a new LerpBlock
  58389. * @param name defines the block name
  58390. */
  58391. constructor(name: string);
  58392. /**
  58393. * Gets the current class name
  58394. * @returns the class name
  58395. */
  58396. getClassName(): string;
  58397. /**
  58398. * Gets the left operand input component
  58399. */
  58400. readonly left: NodeMaterialConnectionPoint;
  58401. /**
  58402. * Gets the right operand input component
  58403. */
  58404. readonly right: NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the gradient operand input component
  58407. */
  58408. readonly gradient: NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the output component
  58411. */
  58412. readonly output: NodeMaterialConnectionPoint;
  58413. protected _buildBlock(state: NodeMaterialBuildState): this;
  58414. }
  58415. }
  58416. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58420. /**
  58421. * Block used to divide 2 vectors
  58422. */
  58423. export class DivideBlock extends NodeMaterialBlock {
  58424. /**
  58425. * Creates a new DivideBlock
  58426. * @param name defines the block name
  58427. */
  58428. constructor(name: string);
  58429. /**
  58430. * Gets the current class name
  58431. * @returns the class name
  58432. */
  58433. getClassName(): string;
  58434. /**
  58435. * Gets the left operand input component
  58436. */
  58437. readonly left: NodeMaterialConnectionPoint;
  58438. /**
  58439. * Gets the right operand input component
  58440. */
  58441. readonly right: NodeMaterialConnectionPoint;
  58442. /**
  58443. * Gets the output component
  58444. */
  58445. readonly output: NodeMaterialConnectionPoint;
  58446. protected _buildBlock(state: NodeMaterialBuildState): this;
  58447. }
  58448. }
  58449. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58453. /**
  58454. * Block used to subtract 2 vectors
  58455. */
  58456. export class SubtractBlock extends NodeMaterialBlock {
  58457. /**
  58458. * Creates a new SubtractBlock
  58459. * @param name defines the block name
  58460. */
  58461. constructor(name: string);
  58462. /**
  58463. * Gets the current class name
  58464. * @returns the class name
  58465. */
  58466. getClassName(): string;
  58467. /**
  58468. * Gets the left operand input component
  58469. */
  58470. readonly left: NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the right operand input component
  58473. */
  58474. readonly right: NodeMaterialConnectionPoint;
  58475. /**
  58476. * Gets the output component
  58477. */
  58478. readonly output: NodeMaterialConnectionPoint;
  58479. protected _buildBlock(state: NodeMaterialBuildState): this;
  58480. }
  58481. }
  58482. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58486. /**
  58487. * Block used to step a value
  58488. */
  58489. export class StepBlock extends NodeMaterialBlock {
  58490. /**
  58491. * Creates a new StepBlock
  58492. * @param name defines the block name
  58493. */
  58494. constructor(name: string);
  58495. /**
  58496. * Gets the current class name
  58497. * @returns the class name
  58498. */
  58499. getClassName(): string;
  58500. /**
  58501. * Gets the value operand input component
  58502. */
  58503. readonly value: NodeMaterialConnectionPoint;
  58504. /**
  58505. * Gets the edge operand input component
  58506. */
  58507. readonly edge: NodeMaterialConnectionPoint;
  58508. /**
  58509. * Gets the output component
  58510. */
  58511. readonly output: NodeMaterialConnectionPoint;
  58512. protected _buildBlock(state: NodeMaterialBuildState): this;
  58513. }
  58514. }
  58515. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58519. /**
  58520. * Block used to get the opposite (1 - x) of a value
  58521. */
  58522. export class OneMinusBlock extends NodeMaterialBlock {
  58523. /**
  58524. * Creates a new OneMinusBlock
  58525. * @param name defines the block name
  58526. */
  58527. constructor(name: string);
  58528. /**
  58529. * Gets the current class name
  58530. * @returns the class name
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Gets the input component
  58535. */
  58536. readonly input: NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the output component
  58539. */
  58540. readonly output: NodeMaterialConnectionPoint;
  58541. protected _buildBlock(state: NodeMaterialBuildState): this;
  58542. }
  58543. }
  58544. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58548. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58549. /**
  58550. * Block used to get the view direction
  58551. */
  58552. export class ViewDirectionBlock extends NodeMaterialBlock {
  58553. /**
  58554. * Creates a new ViewDirectionBlock
  58555. * @param name defines the block name
  58556. */
  58557. constructor(name: string);
  58558. /**
  58559. * Gets the current class name
  58560. * @returns the class name
  58561. */
  58562. getClassName(): string;
  58563. /**
  58564. * Gets the world position component
  58565. */
  58566. readonly worldPosition: NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the camera position component
  58569. */
  58570. readonly cameraPosition: NodeMaterialConnectionPoint;
  58571. /**
  58572. * Gets the output component
  58573. */
  58574. readonly output: NodeMaterialConnectionPoint;
  58575. autoConfigure(material: NodeMaterial): void;
  58576. protected _buildBlock(state: NodeMaterialBuildState): this;
  58577. }
  58578. }
  58579. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58583. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58584. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58585. /**
  58586. * Block used to compute fresnel value
  58587. */
  58588. export class FresnelBlock extends NodeMaterialBlock {
  58589. /**
  58590. * Create a new FresnelBlock
  58591. * @param name defines the block name
  58592. */
  58593. constructor(name: string);
  58594. /**
  58595. * Gets the current class name
  58596. * @returns the class name
  58597. */
  58598. getClassName(): string;
  58599. /**
  58600. * Gets the world normal input component
  58601. */
  58602. readonly worldNormal: NodeMaterialConnectionPoint;
  58603. /**
  58604. * Gets the view direction input component
  58605. */
  58606. readonly viewDirection: NodeMaterialConnectionPoint;
  58607. /**
  58608. * Gets the bias input component
  58609. */
  58610. readonly bias: NodeMaterialConnectionPoint;
  58611. /**
  58612. * Gets the camera (or eye) position component
  58613. */
  58614. readonly power: NodeMaterialConnectionPoint;
  58615. /**
  58616. * Gets the fresnel output component
  58617. */
  58618. readonly fresnel: NodeMaterialConnectionPoint;
  58619. autoConfigure(material: NodeMaterial): void;
  58620. protected _buildBlock(state: NodeMaterialBuildState): this;
  58621. }
  58622. }
  58623. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58627. /**
  58628. * Block used to get the max of 2 values
  58629. */
  58630. export class MaxBlock extends NodeMaterialBlock {
  58631. /**
  58632. * Creates a new MaxBlock
  58633. * @param name defines the block name
  58634. */
  58635. constructor(name: string);
  58636. /**
  58637. * Gets the current class name
  58638. * @returns the class name
  58639. */
  58640. getClassName(): string;
  58641. /**
  58642. * Gets the left operand input component
  58643. */
  58644. readonly left: NodeMaterialConnectionPoint;
  58645. /**
  58646. * Gets the right operand input component
  58647. */
  58648. readonly right: NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the output component
  58651. */
  58652. readonly output: NodeMaterialConnectionPoint;
  58653. protected _buildBlock(state: NodeMaterialBuildState): this;
  58654. }
  58655. }
  58656. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58660. /**
  58661. * Block used to get the min of 2 values
  58662. */
  58663. export class MinBlock extends NodeMaterialBlock {
  58664. /**
  58665. * Creates a new MinBlock
  58666. * @param name defines the block name
  58667. */
  58668. constructor(name: string);
  58669. /**
  58670. * Gets the current class name
  58671. * @returns the class name
  58672. */
  58673. getClassName(): string;
  58674. /**
  58675. * Gets the left operand input component
  58676. */
  58677. readonly left: NodeMaterialConnectionPoint;
  58678. /**
  58679. * Gets the right operand input component
  58680. */
  58681. readonly right: NodeMaterialConnectionPoint;
  58682. /**
  58683. * Gets the output component
  58684. */
  58685. readonly output: NodeMaterialConnectionPoint;
  58686. protected _buildBlock(state: NodeMaterialBuildState): this;
  58687. }
  58688. }
  58689. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58693. /**
  58694. * Block used to get the distance between 2 values
  58695. */
  58696. export class DistanceBlock extends NodeMaterialBlock {
  58697. /**
  58698. * Creates a new DistanceBlock
  58699. * @param name defines the block name
  58700. */
  58701. constructor(name: string);
  58702. /**
  58703. * Gets the current class name
  58704. * @returns the class name
  58705. */
  58706. getClassName(): string;
  58707. /**
  58708. * Gets the left operand input component
  58709. */
  58710. readonly left: NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the right operand input component
  58713. */
  58714. readonly right: NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the output component
  58717. */
  58718. readonly output: NodeMaterialConnectionPoint;
  58719. protected _buildBlock(state: NodeMaterialBuildState): this;
  58720. }
  58721. }
  58722. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58726. /**
  58727. * Block used to get the length of a vector
  58728. */
  58729. export class LengthBlock extends NodeMaterialBlock {
  58730. /**
  58731. * Creates a new LengthBlock
  58732. * @param name defines the block name
  58733. */
  58734. constructor(name: string);
  58735. /**
  58736. * Gets the current class name
  58737. * @returns the class name
  58738. */
  58739. getClassName(): string;
  58740. /**
  58741. * Gets the value input component
  58742. */
  58743. readonly value: NodeMaterialConnectionPoint;
  58744. /**
  58745. * Gets the output component
  58746. */
  58747. readonly output: NodeMaterialConnectionPoint;
  58748. protected _buildBlock(state: NodeMaterialBuildState): this;
  58749. }
  58750. }
  58751. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58755. /**
  58756. * Block used to get negative version of a value (i.e. x * -1)
  58757. */
  58758. export class NegateBlock extends NodeMaterialBlock {
  58759. /**
  58760. * Creates a new NegateBlock
  58761. * @param name defines the block name
  58762. */
  58763. constructor(name: string);
  58764. /**
  58765. * Gets the current class name
  58766. * @returns the class name
  58767. */
  58768. getClassName(): string;
  58769. /**
  58770. * Gets the value input component
  58771. */
  58772. readonly value: NodeMaterialConnectionPoint;
  58773. /**
  58774. * Gets the output component
  58775. */
  58776. readonly output: NodeMaterialConnectionPoint;
  58777. protected _buildBlock(state: NodeMaterialBuildState): this;
  58778. }
  58779. }
  58780. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58784. /**
  58785. * Block used to get the value of the first parameter raised to the power of the second
  58786. */
  58787. export class PowBlock extends NodeMaterialBlock {
  58788. /**
  58789. * Creates a new PowBlock
  58790. * @param name defines the block name
  58791. */
  58792. constructor(name: string);
  58793. /**
  58794. * Gets the current class name
  58795. * @returns the class name
  58796. */
  58797. getClassName(): string;
  58798. /**
  58799. * Gets the value operand input component
  58800. */
  58801. readonly value: NodeMaterialConnectionPoint;
  58802. /**
  58803. * Gets the power operand input component
  58804. */
  58805. readonly power: NodeMaterialConnectionPoint;
  58806. /**
  58807. * Gets the output component
  58808. */
  58809. readonly output: NodeMaterialConnectionPoint;
  58810. protected _buildBlock(state: NodeMaterialBuildState): this;
  58811. }
  58812. }
  58813. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58818. /**
  58819. * Block used to get a random number
  58820. */
  58821. export class RandomNumberBlock extends NodeMaterialBlock {
  58822. /**
  58823. * Creates a new RandomNumberBlock
  58824. * @param name defines the block name
  58825. */
  58826. constructor(name: string);
  58827. /**
  58828. * Gets the current class name
  58829. * @returns the class name
  58830. */
  58831. getClassName(): string;
  58832. /**
  58833. * Gets the seed input component
  58834. */
  58835. readonly seed: NodeMaterialConnectionPoint;
  58836. /**
  58837. * Gets the output component
  58838. */
  58839. readonly output: NodeMaterialConnectionPoint;
  58840. protected _buildBlock(state: NodeMaterialBuildState): this;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58847. /**
  58848. * Block used to compute arc tangent of 2 values
  58849. */
  58850. export class ArcTan2Block extends NodeMaterialBlock {
  58851. /**
  58852. * Creates a new ArcTan2Block
  58853. * @param name defines the block name
  58854. */
  58855. constructor(name: string);
  58856. /**
  58857. * Gets the current class name
  58858. * @returns the class name
  58859. */
  58860. getClassName(): string;
  58861. /**
  58862. * Gets the x operand input component
  58863. */
  58864. readonly x: NodeMaterialConnectionPoint;
  58865. /**
  58866. * Gets the y operand input component
  58867. */
  58868. readonly y: NodeMaterialConnectionPoint;
  58869. /**
  58870. * Gets the output component
  58871. */
  58872. readonly output: NodeMaterialConnectionPoint;
  58873. protected _buildBlock(state: NodeMaterialBuildState): this;
  58874. }
  58875. }
  58876. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58880. /**
  58881. * Block used to smooth step a value
  58882. */
  58883. export class SmoothStepBlock extends NodeMaterialBlock {
  58884. /**
  58885. * Creates a new SmoothStepBlock
  58886. * @param name defines the block name
  58887. */
  58888. constructor(name: string);
  58889. /**
  58890. * Gets the current class name
  58891. * @returns the class name
  58892. */
  58893. getClassName(): string;
  58894. /**
  58895. * Gets the value operand input component
  58896. */
  58897. readonly value: NodeMaterialConnectionPoint;
  58898. /**
  58899. * Gets the first edge operand input component
  58900. */
  58901. readonly edge0: NodeMaterialConnectionPoint;
  58902. /**
  58903. * Gets the second edge operand input component
  58904. */
  58905. readonly edge1: NodeMaterialConnectionPoint;
  58906. /**
  58907. * Gets the output component
  58908. */
  58909. readonly output: NodeMaterialConnectionPoint;
  58910. protected _buildBlock(state: NodeMaterialBuildState): this;
  58911. }
  58912. }
  58913. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58917. /**
  58918. * Block used to get the reciprocal (1 / x) of a value
  58919. */
  58920. export class ReciprocalBlock extends NodeMaterialBlock {
  58921. /**
  58922. * Creates a new ReciprocalBlock
  58923. * @param name defines the block name
  58924. */
  58925. constructor(name: string);
  58926. /**
  58927. * Gets the current class name
  58928. * @returns the class name
  58929. */
  58930. getClassName(): string;
  58931. /**
  58932. * Gets the input component
  58933. */
  58934. readonly input: NodeMaterialConnectionPoint;
  58935. /**
  58936. * Gets the output component
  58937. */
  58938. readonly output: NodeMaterialConnectionPoint;
  58939. protected _buildBlock(state: NodeMaterialBuildState): this;
  58940. }
  58941. }
  58942. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58946. /**
  58947. * Block used to replace a color by another one
  58948. */
  58949. export class ReplaceColorBlock extends NodeMaterialBlock {
  58950. /**
  58951. * Creates a new ReplaceColorBlock
  58952. * @param name defines the block name
  58953. */
  58954. constructor(name: string);
  58955. /**
  58956. * Gets the current class name
  58957. * @returns the class name
  58958. */
  58959. getClassName(): string;
  58960. /**
  58961. * Gets the value input component
  58962. */
  58963. readonly value: NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the reference input component
  58966. */
  58967. readonly reference: NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the distance input component
  58970. */
  58971. readonly distance: NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the replacement input component
  58974. */
  58975. readonly replacement: NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the output component
  58978. */
  58979. readonly output: NodeMaterialConnectionPoint;
  58980. protected _buildBlock(state: NodeMaterialBuildState): this;
  58981. }
  58982. }
  58983. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58987. /**
  58988. * Block used to posterize a value
  58989. * @see https://en.wikipedia.org/wiki/Posterization
  58990. */
  58991. export class PosterizeBlock extends NodeMaterialBlock {
  58992. /**
  58993. * Creates a new PosterizeBlock
  58994. * @param name defines the block name
  58995. */
  58996. constructor(name: string);
  58997. /**
  58998. * Gets the current class name
  58999. * @returns the class name
  59000. */
  59001. getClassName(): string;
  59002. /**
  59003. * Gets the value input component
  59004. */
  59005. readonly value: NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the steps input component
  59008. */
  59009. readonly steps: NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the output component
  59012. */
  59013. readonly output: NodeMaterialConnectionPoint;
  59014. protected _buildBlock(state: NodeMaterialBuildState): this;
  59015. }
  59016. }
  59017. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59021. import { Scene } from "babylonjs/scene";
  59022. /**
  59023. * Operations supported by the Wave block
  59024. */
  59025. export enum WaveBlockKind {
  59026. /** SawTooth */
  59027. SawTooth = 0,
  59028. /** Square */
  59029. Square = 1,
  59030. /** Triangle */
  59031. Triangle = 2
  59032. }
  59033. /**
  59034. * Block used to apply wave operation to floats
  59035. */
  59036. export class WaveBlock extends NodeMaterialBlock {
  59037. /**
  59038. * Gets or sets the kibnd of wave to be applied by the block
  59039. */
  59040. kind: WaveBlockKind;
  59041. /**
  59042. * Creates a new WaveBlock
  59043. * @param name defines the block name
  59044. */
  59045. constructor(name: string);
  59046. /**
  59047. * Gets the current class name
  59048. * @returns the class name
  59049. */
  59050. getClassName(): string;
  59051. /**
  59052. * Gets the input component
  59053. */
  59054. readonly input: NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the output component
  59057. */
  59058. readonly output: NodeMaterialConnectionPoint;
  59059. protected _buildBlock(state: NodeMaterialBuildState): this;
  59060. serialize(): any;
  59061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59062. }
  59063. }
  59064. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59068. import { Color3 } from "babylonjs/Maths/math.color";
  59069. import { Scene } from "babylonjs/scene";
  59070. /**
  59071. * Class used to store a color step for the GradientBlock
  59072. */
  59073. export class GradientBlockColorStep {
  59074. /**
  59075. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59076. */
  59077. step: number;
  59078. /**
  59079. * Gets or sets the color associated with this step
  59080. */
  59081. color: Color3;
  59082. /**
  59083. * Creates a new GradientBlockColorStep
  59084. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59085. * @param color defines the color associated with this step
  59086. */
  59087. constructor(
  59088. /**
  59089. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59090. */
  59091. step: number,
  59092. /**
  59093. * Gets or sets the color associated with this step
  59094. */
  59095. color: Color3);
  59096. }
  59097. /**
  59098. * Block used to return a color from a gradient based on an input value between 0 and 1
  59099. */
  59100. export class GradientBlock extends NodeMaterialBlock {
  59101. /**
  59102. * Gets or sets the list of color steps
  59103. */
  59104. colorSteps: GradientBlockColorStep[];
  59105. /**
  59106. * Creates a new GradientBlock
  59107. * @param name defines the block name
  59108. */
  59109. constructor(name: string);
  59110. /**
  59111. * Gets the current class name
  59112. * @returns the class name
  59113. */
  59114. getClassName(): string;
  59115. /**
  59116. * Gets the gradient input component
  59117. */
  59118. readonly gradient: NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the output component
  59121. */
  59122. readonly output: NodeMaterialConnectionPoint;
  59123. private _writeColorConstant;
  59124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59125. serialize(): any;
  59126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59127. protected _dumpPropertiesCode(): string;
  59128. }
  59129. }
  59130. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59134. /**
  59135. * Block used to normalize lerp between 2 values
  59136. */
  59137. export class NLerpBlock extends NodeMaterialBlock {
  59138. /**
  59139. * Creates a new NLerpBlock
  59140. * @param name defines the block name
  59141. */
  59142. constructor(name: string);
  59143. /**
  59144. * Gets the current class name
  59145. * @returns the class name
  59146. */
  59147. getClassName(): string;
  59148. /**
  59149. * Gets the left operand input component
  59150. */
  59151. readonly left: NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the right operand input component
  59154. */
  59155. readonly right: NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the gradient operand input component
  59158. */
  59159. readonly gradient: NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the output component
  59162. */
  59163. readonly output: NodeMaterialConnectionPoint;
  59164. protected _buildBlock(state: NodeMaterialBuildState): this;
  59165. }
  59166. }
  59167. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59171. import { Scene } from "babylonjs/scene";
  59172. /**
  59173. * block used to Generate a Worley Noise 3D Noise Pattern
  59174. */
  59175. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59176. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59177. manhattanDistance: boolean;
  59178. /**
  59179. * Creates a new WorleyNoise3DBlock
  59180. * @param name defines the block name
  59181. */
  59182. constructor(name: string);
  59183. /**
  59184. * Gets the current class name
  59185. * @returns the class name
  59186. */
  59187. getClassName(): string;
  59188. /**
  59189. * Gets the position input component
  59190. */
  59191. readonly position: NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the jitter input component
  59194. */
  59195. readonly jitter: NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the output component
  59198. */
  59199. readonly output: NodeMaterialConnectionPoint;
  59200. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59201. /**
  59202. * Exposes the properties to the UI?
  59203. */
  59204. protected _dumpPropertiesCode(): string;
  59205. /**
  59206. * Exposes the properties to the Seralize?
  59207. */
  59208. serialize(): any;
  59209. /**
  59210. * Exposes the properties to the deseralize?
  59211. */
  59212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59213. }
  59214. }
  59215. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59219. /**
  59220. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59221. */
  59222. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59223. /**
  59224. * Creates a new SimplexPerlin3DBlock
  59225. * @param name defines the block name
  59226. */
  59227. constructor(name: string);
  59228. /**
  59229. * Gets the current class name
  59230. * @returns the class name
  59231. */
  59232. getClassName(): string;
  59233. /**
  59234. * Gets the position operand input component
  59235. */
  59236. readonly position: NodeMaterialConnectionPoint;
  59237. /**
  59238. * Gets the output component
  59239. */
  59240. readonly output: NodeMaterialConnectionPoint;
  59241. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59242. }
  59243. }
  59244. declare module "babylonjs/Materials/Node/Blocks/index" {
  59245. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59246. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59247. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59248. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59249. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59250. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59251. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59252. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59253. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59254. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59255. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59256. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59257. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59258. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59259. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59260. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59261. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59262. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59263. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59264. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59265. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59266. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59267. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59268. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59269. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59270. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59271. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59272. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59273. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59274. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59275. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59276. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59277. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59278. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59279. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59280. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59281. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59282. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59283. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59284. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59285. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59286. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59287. }
  59288. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59289. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59290. }
  59291. declare module "babylonjs/Materials/Node/index" {
  59292. export * from "babylonjs/Materials/Node/Enums/index";
  59293. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59294. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59295. export * from "babylonjs/Materials/Node/nodeMaterial";
  59296. export * from "babylonjs/Materials/Node/Blocks/index";
  59297. export * from "babylonjs/Materials/Node/Optimizers/index";
  59298. }
  59299. declare module "babylonjs/Materials/effectRenderer" {
  59300. import { Nullable } from "babylonjs/types";
  59301. import { Texture } from "babylonjs/Materials/Textures/texture";
  59302. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59303. import { Viewport } from "babylonjs/Maths/math.viewport";
  59304. import { Observable } from "babylonjs/Misc/observable";
  59305. import { Effect } from "babylonjs/Materials/effect";
  59306. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59307. import "babylonjs/Shaders/postprocess.vertex";
  59308. /**
  59309. * Effect Render Options
  59310. */
  59311. export interface IEffectRendererOptions {
  59312. /**
  59313. * Defines the vertices positions.
  59314. */
  59315. positions?: number[];
  59316. /**
  59317. * Defines the indices.
  59318. */
  59319. indices?: number[];
  59320. }
  59321. /**
  59322. * Helper class to render one or more effects
  59323. */
  59324. export class EffectRenderer {
  59325. private engine;
  59326. private static _DefaultOptions;
  59327. private _vertexBuffers;
  59328. private _indexBuffer;
  59329. private _ringBufferIndex;
  59330. private _ringScreenBuffer;
  59331. private _fullscreenViewport;
  59332. private _getNextFrameBuffer;
  59333. /**
  59334. * Creates an effect renderer
  59335. * @param engine the engine to use for rendering
  59336. * @param options defines the options of the effect renderer
  59337. */
  59338. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59339. /**
  59340. * Sets the current viewport in normalized coordinates 0-1
  59341. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59342. */
  59343. setViewport(viewport?: Viewport): void;
  59344. /**
  59345. * Binds the embedded attributes buffer to the effect.
  59346. * @param effect Defines the effect to bind the attributes for
  59347. */
  59348. bindBuffers(effect: Effect): void;
  59349. /**
  59350. * Sets the current effect wrapper to use during draw.
  59351. * The effect needs to be ready before calling this api.
  59352. * This also sets the default full screen position attribute.
  59353. * @param effectWrapper Defines the effect to draw with
  59354. */
  59355. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59356. /**
  59357. * Draws a full screen quad.
  59358. */
  59359. draw(): void;
  59360. /**
  59361. * renders one or more effects to a specified texture
  59362. * @param effectWrappers list of effects to renderer
  59363. * @param outputTexture texture to draw to, if null it will render to the screen
  59364. */
  59365. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59366. /**
  59367. * Disposes of the effect renderer
  59368. */
  59369. dispose(): void;
  59370. }
  59371. /**
  59372. * Options to create an EffectWrapper
  59373. */
  59374. interface EffectWrapperCreationOptions {
  59375. /**
  59376. * Engine to use to create the effect
  59377. */
  59378. engine: ThinEngine;
  59379. /**
  59380. * Fragment shader for the effect
  59381. */
  59382. fragmentShader: string;
  59383. /**
  59384. * Vertex shader for the effect
  59385. */
  59386. vertexShader?: string;
  59387. /**
  59388. * Attributes to use in the shader
  59389. */
  59390. attributeNames?: Array<string>;
  59391. /**
  59392. * Uniforms to use in the shader
  59393. */
  59394. uniformNames?: Array<string>;
  59395. /**
  59396. * Texture sampler names to use in the shader
  59397. */
  59398. samplerNames?: Array<string>;
  59399. /**
  59400. * The friendly name of the effect displayed in Spector.
  59401. */
  59402. name?: string;
  59403. }
  59404. /**
  59405. * Wraps an effect to be used for rendering
  59406. */
  59407. export class EffectWrapper {
  59408. /**
  59409. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59410. */
  59411. onApplyObservable: Observable<{}>;
  59412. /**
  59413. * The underlying effect
  59414. */
  59415. effect: Effect;
  59416. /**
  59417. * Creates an effect to be renderer
  59418. * @param creationOptions options to create the effect
  59419. */
  59420. constructor(creationOptions: EffectWrapperCreationOptions);
  59421. /**
  59422. * Disposes of the effect wrapper
  59423. */
  59424. dispose(): void;
  59425. }
  59426. }
  59427. declare module "babylonjs/Materials/index" {
  59428. export * from "babylonjs/Materials/Background/index";
  59429. export * from "babylonjs/Materials/colorCurves";
  59430. export * from "babylonjs/Materials/iEffectFallbacks";
  59431. export * from "babylonjs/Materials/effectFallbacks";
  59432. export * from "babylonjs/Materials/effect";
  59433. export * from "babylonjs/Materials/fresnelParameters";
  59434. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59435. export * from "babylonjs/Materials/material";
  59436. export * from "babylonjs/Materials/materialDefines";
  59437. export * from "babylonjs/Materials/materialHelper";
  59438. export * from "babylonjs/Materials/multiMaterial";
  59439. export * from "babylonjs/Materials/PBR/index";
  59440. export * from "babylonjs/Materials/pushMaterial";
  59441. export * from "babylonjs/Materials/shaderMaterial";
  59442. export * from "babylonjs/Materials/standardMaterial";
  59443. export * from "babylonjs/Materials/Textures/index";
  59444. export * from "babylonjs/Materials/uniformBuffer";
  59445. export * from "babylonjs/Materials/materialFlags";
  59446. export * from "babylonjs/Materials/Node/index";
  59447. export * from "babylonjs/Materials/effectRenderer";
  59448. }
  59449. declare module "babylonjs/Maths/index" {
  59450. export * from "babylonjs/Maths/math.scalar";
  59451. export * from "babylonjs/Maths/math";
  59452. export * from "babylonjs/Maths/sphericalPolynomial";
  59453. }
  59454. declare module "babylonjs/Misc/workerPool" {
  59455. import { IDisposable } from "babylonjs/scene";
  59456. /**
  59457. * Helper class to push actions to a pool of workers.
  59458. */
  59459. export class WorkerPool implements IDisposable {
  59460. private _workerInfos;
  59461. private _pendingActions;
  59462. /**
  59463. * Constructor
  59464. * @param workers Array of workers to use for actions
  59465. */
  59466. constructor(workers: Array<Worker>);
  59467. /**
  59468. * Terminates all workers and clears any pending actions.
  59469. */
  59470. dispose(): void;
  59471. /**
  59472. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59473. * pended until a worker has completed its action.
  59474. * @param action The action to perform. Call onComplete when the action is complete.
  59475. */
  59476. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59477. private _execute;
  59478. }
  59479. }
  59480. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59481. import { IDisposable } from "babylonjs/scene";
  59482. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59483. /**
  59484. * Configuration for Draco compression
  59485. */
  59486. export interface IDracoCompressionConfiguration {
  59487. /**
  59488. * Configuration for the decoder.
  59489. */
  59490. decoder: {
  59491. /**
  59492. * The url to the WebAssembly module.
  59493. */
  59494. wasmUrl?: string;
  59495. /**
  59496. * The url to the WebAssembly binary.
  59497. */
  59498. wasmBinaryUrl?: string;
  59499. /**
  59500. * The url to the fallback JavaScript module.
  59501. */
  59502. fallbackUrl?: string;
  59503. };
  59504. }
  59505. /**
  59506. * Draco compression (https://google.github.io/draco/)
  59507. *
  59508. * This class wraps the Draco module.
  59509. *
  59510. * **Encoder**
  59511. *
  59512. * The encoder is not currently implemented.
  59513. *
  59514. * **Decoder**
  59515. *
  59516. * 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.
  59517. *
  59518. * To update the configuration, use the following code:
  59519. * ```javascript
  59520. * DracoCompression.Configuration = {
  59521. * decoder: {
  59522. * wasmUrl: "<url to the WebAssembly library>",
  59523. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59524. * fallbackUrl: "<url to the fallback JavaScript library>",
  59525. * }
  59526. * };
  59527. * ```
  59528. *
  59529. * 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.
  59530. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59531. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59532. *
  59533. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59534. * ```javascript
  59535. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59536. * ```
  59537. *
  59538. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59539. */
  59540. export class DracoCompression implements IDisposable {
  59541. private _workerPoolPromise?;
  59542. private _decoderModulePromise?;
  59543. /**
  59544. * The configuration. Defaults to the following urls:
  59545. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59546. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59547. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59548. */
  59549. static Configuration: IDracoCompressionConfiguration;
  59550. /**
  59551. * Returns true if the decoder configuration is available.
  59552. */
  59553. static readonly DecoderAvailable: boolean;
  59554. /**
  59555. * Default number of workers to create when creating the draco compression object.
  59556. */
  59557. static DefaultNumWorkers: number;
  59558. private static GetDefaultNumWorkers;
  59559. private static _Default;
  59560. /**
  59561. * Default instance for the draco compression object.
  59562. */
  59563. static readonly Default: DracoCompression;
  59564. /**
  59565. * Constructor
  59566. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59567. */
  59568. constructor(numWorkers?: number);
  59569. /**
  59570. * Stop all async operations and release resources.
  59571. */
  59572. dispose(): void;
  59573. /**
  59574. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59575. * @returns a promise that resolves when ready
  59576. */
  59577. whenReadyAsync(): Promise<void>;
  59578. /**
  59579. * Decode Draco compressed mesh data to vertex data.
  59580. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59581. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59582. * @returns A promise that resolves with the decoded vertex data
  59583. */
  59584. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59585. [kind: string]: number;
  59586. }): Promise<VertexData>;
  59587. }
  59588. }
  59589. declare module "babylonjs/Meshes/Compression/index" {
  59590. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59591. }
  59592. declare module "babylonjs/Meshes/csg" {
  59593. import { Nullable } from "babylonjs/types";
  59594. import { Scene } from "babylonjs/scene";
  59595. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59596. import { Mesh } from "babylonjs/Meshes/mesh";
  59597. import { Material } from "babylonjs/Materials/material";
  59598. /**
  59599. * Class for building Constructive Solid Geometry
  59600. */
  59601. export class CSG {
  59602. private polygons;
  59603. /**
  59604. * The world matrix
  59605. */
  59606. matrix: Matrix;
  59607. /**
  59608. * Stores the position
  59609. */
  59610. position: Vector3;
  59611. /**
  59612. * Stores the rotation
  59613. */
  59614. rotation: Vector3;
  59615. /**
  59616. * Stores the rotation quaternion
  59617. */
  59618. rotationQuaternion: Nullable<Quaternion>;
  59619. /**
  59620. * Stores the scaling vector
  59621. */
  59622. scaling: Vector3;
  59623. /**
  59624. * Convert the Mesh to CSG
  59625. * @param mesh The Mesh to convert to CSG
  59626. * @returns A new CSG from the Mesh
  59627. */
  59628. static FromMesh(mesh: Mesh): CSG;
  59629. /**
  59630. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59631. * @param polygons Polygons used to construct a CSG solid
  59632. */
  59633. private static FromPolygons;
  59634. /**
  59635. * Clones, or makes a deep copy, of the CSG
  59636. * @returns A new CSG
  59637. */
  59638. clone(): CSG;
  59639. /**
  59640. * Unions this CSG with another CSG
  59641. * @param csg The CSG to union against this CSG
  59642. * @returns The unioned CSG
  59643. */
  59644. union(csg: CSG): CSG;
  59645. /**
  59646. * Unions this CSG with another CSG in place
  59647. * @param csg The CSG to union against this CSG
  59648. */
  59649. unionInPlace(csg: CSG): void;
  59650. /**
  59651. * Subtracts this CSG with another CSG
  59652. * @param csg The CSG to subtract against this CSG
  59653. * @returns A new CSG
  59654. */
  59655. subtract(csg: CSG): CSG;
  59656. /**
  59657. * Subtracts this CSG with another CSG in place
  59658. * @param csg The CSG to subtact against this CSG
  59659. */
  59660. subtractInPlace(csg: CSG): void;
  59661. /**
  59662. * Intersect this CSG with another CSG
  59663. * @param csg The CSG to intersect against this CSG
  59664. * @returns A new CSG
  59665. */
  59666. intersect(csg: CSG): CSG;
  59667. /**
  59668. * Intersects this CSG with another CSG in place
  59669. * @param csg The CSG to intersect against this CSG
  59670. */
  59671. intersectInPlace(csg: CSG): void;
  59672. /**
  59673. * Return a new CSG solid with solid and empty space switched. This solid is
  59674. * not modified.
  59675. * @returns A new CSG solid with solid and empty space switched
  59676. */
  59677. inverse(): CSG;
  59678. /**
  59679. * Inverses the CSG in place
  59680. */
  59681. inverseInPlace(): void;
  59682. /**
  59683. * This is used to keep meshes transformations so they can be restored
  59684. * when we build back a Babylon Mesh
  59685. * NB : All CSG operations are performed in world coordinates
  59686. * @param csg The CSG to copy the transform attributes from
  59687. * @returns This CSG
  59688. */
  59689. copyTransformAttributes(csg: CSG): CSG;
  59690. /**
  59691. * Build Raw mesh from CSG
  59692. * Coordinates here are in world space
  59693. * @param name The name of the mesh geometry
  59694. * @param scene The Scene
  59695. * @param keepSubMeshes Specifies if the submeshes should be kept
  59696. * @returns A new Mesh
  59697. */
  59698. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59699. /**
  59700. * Build Mesh from CSG taking material and transforms into account
  59701. * @param name The name of the Mesh
  59702. * @param material The material of the Mesh
  59703. * @param scene The Scene
  59704. * @param keepSubMeshes Specifies if submeshes should be kept
  59705. * @returns The new Mesh
  59706. */
  59707. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59708. }
  59709. }
  59710. declare module "babylonjs/Meshes/trailMesh" {
  59711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59712. import { Mesh } from "babylonjs/Meshes/mesh";
  59713. import { Scene } from "babylonjs/scene";
  59714. /**
  59715. * Class used to create a trail following a mesh
  59716. */
  59717. export class TrailMesh extends Mesh {
  59718. private _generator;
  59719. private _autoStart;
  59720. private _running;
  59721. private _diameter;
  59722. private _length;
  59723. private _sectionPolygonPointsCount;
  59724. private _sectionVectors;
  59725. private _sectionNormalVectors;
  59726. private _beforeRenderObserver;
  59727. /**
  59728. * @constructor
  59729. * @param name The value used by scene.getMeshByName() to do a lookup.
  59730. * @param generator The mesh to generate a trail.
  59731. * @param scene The scene to add this mesh to.
  59732. * @param diameter Diameter of trailing mesh. Default is 1.
  59733. * @param length Length of trailing mesh. Default is 60.
  59734. * @param autoStart Automatically start trailing mesh. Default true.
  59735. */
  59736. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59737. /**
  59738. * "TrailMesh"
  59739. * @returns "TrailMesh"
  59740. */
  59741. getClassName(): string;
  59742. private _createMesh;
  59743. /**
  59744. * Start trailing mesh.
  59745. */
  59746. start(): void;
  59747. /**
  59748. * Stop trailing mesh.
  59749. */
  59750. stop(): void;
  59751. /**
  59752. * Update trailing mesh geometry.
  59753. */
  59754. update(): void;
  59755. /**
  59756. * Returns a new TrailMesh object.
  59757. * @param name is a string, the name given to the new mesh
  59758. * @param newGenerator use new generator object for cloned trail mesh
  59759. * @returns a new mesh
  59760. */
  59761. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59762. /**
  59763. * Serializes this trail mesh
  59764. * @param serializationObject object to write serialization to
  59765. */
  59766. serialize(serializationObject: any): void;
  59767. /**
  59768. * Parses a serialized trail mesh
  59769. * @param parsedMesh the serialized mesh
  59770. * @param scene the scene to create the trail mesh in
  59771. * @returns the created trail mesh
  59772. */
  59773. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59774. }
  59775. }
  59776. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59777. import { Nullable } from "babylonjs/types";
  59778. import { Scene } from "babylonjs/scene";
  59779. import { Vector4 } from "babylonjs/Maths/math.vector";
  59780. import { Color4 } from "babylonjs/Maths/math.color";
  59781. import { Mesh } from "babylonjs/Meshes/mesh";
  59782. /**
  59783. * Class containing static functions to help procedurally build meshes
  59784. */
  59785. export class TiledBoxBuilder {
  59786. /**
  59787. * Creates a box mesh
  59788. * 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)
  59789. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59793. * @param name defines the name of the mesh
  59794. * @param options defines the options used to create the mesh
  59795. * @param scene defines the hosting scene
  59796. * @returns the box mesh
  59797. */
  59798. static CreateTiledBox(name: string, options: {
  59799. pattern?: number;
  59800. width?: number;
  59801. height?: number;
  59802. depth?: number;
  59803. tileSize?: number;
  59804. tileWidth?: number;
  59805. tileHeight?: number;
  59806. alignHorizontal?: number;
  59807. alignVertical?: number;
  59808. faceUV?: Vector4[];
  59809. faceColors?: Color4[];
  59810. sideOrientation?: number;
  59811. updatable?: boolean;
  59812. }, scene?: Nullable<Scene>): Mesh;
  59813. }
  59814. }
  59815. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59816. import { Vector4 } from "babylonjs/Maths/math.vector";
  59817. import { Mesh } from "babylonjs/Meshes/mesh";
  59818. /**
  59819. * Class containing static functions to help procedurally build meshes
  59820. */
  59821. export class TorusKnotBuilder {
  59822. /**
  59823. * Creates a torus knot mesh
  59824. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59825. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59826. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59827. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59831. * @param name defines the name of the mesh
  59832. * @param options defines the options used to create the mesh
  59833. * @param scene defines the hosting scene
  59834. * @returns the torus knot mesh
  59835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59836. */
  59837. static CreateTorusKnot(name: string, options: {
  59838. radius?: number;
  59839. tube?: number;
  59840. radialSegments?: number;
  59841. tubularSegments?: number;
  59842. p?: number;
  59843. q?: number;
  59844. updatable?: boolean;
  59845. sideOrientation?: number;
  59846. frontUVs?: Vector4;
  59847. backUVs?: Vector4;
  59848. }, scene: any): Mesh;
  59849. }
  59850. }
  59851. declare module "babylonjs/Meshes/polygonMesh" {
  59852. import { Scene } from "babylonjs/scene";
  59853. import { Vector2 } from "babylonjs/Maths/math.vector";
  59854. import { Mesh } from "babylonjs/Meshes/mesh";
  59855. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59856. import { Path2 } from "babylonjs/Maths/math.path";
  59857. /**
  59858. * Polygon
  59859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59860. */
  59861. export class Polygon {
  59862. /**
  59863. * Creates a rectangle
  59864. * @param xmin bottom X coord
  59865. * @param ymin bottom Y coord
  59866. * @param xmax top X coord
  59867. * @param ymax top Y coord
  59868. * @returns points that make the resulting rectation
  59869. */
  59870. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59871. /**
  59872. * Creates a circle
  59873. * @param radius radius of circle
  59874. * @param cx scale in x
  59875. * @param cy scale in y
  59876. * @param numberOfSides number of sides that make up the circle
  59877. * @returns points that make the resulting circle
  59878. */
  59879. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59880. /**
  59881. * Creates a polygon from input string
  59882. * @param input Input polygon data
  59883. * @returns the parsed points
  59884. */
  59885. static Parse(input: string): Vector2[];
  59886. /**
  59887. * Starts building a polygon from x and y coordinates
  59888. * @param x x coordinate
  59889. * @param y y coordinate
  59890. * @returns the started path2
  59891. */
  59892. static StartingAt(x: number, y: number): Path2;
  59893. }
  59894. /**
  59895. * Builds a polygon
  59896. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59897. */
  59898. export class PolygonMeshBuilder {
  59899. private _points;
  59900. private _outlinepoints;
  59901. private _holes;
  59902. private _name;
  59903. private _scene;
  59904. private _epoints;
  59905. private _eholes;
  59906. private _addToepoint;
  59907. /**
  59908. * Babylon reference to the earcut plugin.
  59909. */
  59910. bjsEarcut: any;
  59911. /**
  59912. * Creates a PolygonMeshBuilder
  59913. * @param name name of the builder
  59914. * @param contours Path of the polygon
  59915. * @param scene scene to add to when creating the mesh
  59916. * @param earcutInjection can be used to inject your own earcut reference
  59917. */
  59918. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59919. /**
  59920. * Adds a whole within the polygon
  59921. * @param hole Array of points defining the hole
  59922. * @returns this
  59923. */
  59924. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59925. /**
  59926. * Creates the polygon
  59927. * @param updatable If the mesh should be updatable
  59928. * @param depth The depth of the mesh created
  59929. * @returns the created mesh
  59930. */
  59931. build(updatable?: boolean, depth?: number): Mesh;
  59932. /**
  59933. * Creates the polygon
  59934. * @param depth The depth of the mesh created
  59935. * @returns the created VertexData
  59936. */
  59937. buildVertexData(depth?: number): VertexData;
  59938. /**
  59939. * Adds a side to the polygon
  59940. * @param positions points that make the polygon
  59941. * @param normals normals of the polygon
  59942. * @param uvs uvs of the polygon
  59943. * @param indices indices of the polygon
  59944. * @param bounds bounds of the polygon
  59945. * @param points points of the polygon
  59946. * @param depth depth of the polygon
  59947. * @param flip flip of the polygon
  59948. */
  59949. private addSide;
  59950. }
  59951. }
  59952. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59953. import { Scene } from "babylonjs/scene";
  59954. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59955. import { Color4 } from "babylonjs/Maths/math.color";
  59956. import { Mesh } from "babylonjs/Meshes/mesh";
  59957. import { Nullable } from "babylonjs/types";
  59958. /**
  59959. * Class containing static functions to help procedurally build meshes
  59960. */
  59961. export class PolygonBuilder {
  59962. /**
  59963. * Creates a polygon mesh
  59964. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59965. * * 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
  59966. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59969. * * Remember you can only change the shape positions, not their number when updating a polygon
  59970. * @param name defines the name of the mesh
  59971. * @param options defines the options used to create the mesh
  59972. * @param scene defines the hosting scene
  59973. * @param earcutInjection can be used to inject your own earcut reference
  59974. * @returns the polygon mesh
  59975. */
  59976. static CreatePolygon(name: string, options: {
  59977. shape: Vector3[];
  59978. holes?: Vector3[][];
  59979. depth?: number;
  59980. faceUV?: Vector4[];
  59981. faceColors?: Color4[];
  59982. updatable?: boolean;
  59983. sideOrientation?: number;
  59984. frontUVs?: Vector4;
  59985. backUVs?: Vector4;
  59986. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59987. /**
  59988. * Creates an extruded polygon mesh, with depth in the Y direction.
  59989. * * 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)
  59990. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59991. * @param name defines the name of the mesh
  59992. * @param options defines the options used to create the mesh
  59993. * @param scene defines the hosting scene
  59994. * @param earcutInjection can be used to inject your own earcut reference
  59995. * @returns the polygon mesh
  59996. */
  59997. static ExtrudePolygon(name: string, options: {
  59998. shape: Vector3[];
  59999. holes?: Vector3[][];
  60000. depth?: number;
  60001. faceUV?: Vector4[];
  60002. faceColors?: Color4[];
  60003. updatable?: boolean;
  60004. sideOrientation?: number;
  60005. frontUVs?: Vector4;
  60006. backUVs?: Vector4;
  60007. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60008. }
  60009. }
  60010. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60011. import { Scene } from "babylonjs/scene";
  60012. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60013. import { Mesh } from "babylonjs/Meshes/mesh";
  60014. import { Nullable } from "babylonjs/types";
  60015. /**
  60016. * Class containing static functions to help procedurally build meshes
  60017. */
  60018. export class LatheBuilder {
  60019. /**
  60020. * Creates lathe mesh.
  60021. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60022. * * 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
  60023. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60024. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60025. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60026. * * 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
  60027. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60028. * * 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
  60029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60033. * @param name defines the name of the mesh
  60034. * @param options defines the options used to create the mesh
  60035. * @param scene defines the hosting scene
  60036. * @returns the lathe mesh
  60037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60038. */
  60039. static CreateLathe(name: string, options: {
  60040. shape: Vector3[];
  60041. radius?: number;
  60042. tessellation?: number;
  60043. clip?: number;
  60044. arc?: number;
  60045. closed?: boolean;
  60046. updatable?: boolean;
  60047. sideOrientation?: number;
  60048. frontUVs?: Vector4;
  60049. backUVs?: Vector4;
  60050. cap?: number;
  60051. invertUV?: boolean;
  60052. }, scene?: Nullable<Scene>): Mesh;
  60053. }
  60054. }
  60055. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60056. import { Nullable } from "babylonjs/types";
  60057. import { Scene } from "babylonjs/scene";
  60058. import { Vector4 } from "babylonjs/Maths/math.vector";
  60059. import { Mesh } from "babylonjs/Meshes/mesh";
  60060. /**
  60061. * Class containing static functions to help procedurally build meshes
  60062. */
  60063. export class TiledPlaneBuilder {
  60064. /**
  60065. * Creates a tiled plane mesh
  60066. * * The parameter `pattern` will, depending on value, do nothing or
  60067. * * * flip (reflect about central vertical) alternate tiles across and up
  60068. * * * flip every tile on alternate rows
  60069. * * * rotate (180 degs) alternate tiles across and up
  60070. * * * rotate every tile on alternate rows
  60071. * * * flip and rotate alternate tiles across and up
  60072. * * * flip and rotate every tile on alternate rows
  60073. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60074. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60077. * * 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)
  60078. * * 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)
  60079. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60080. * @param name defines the name of the mesh
  60081. * @param options defines the options used to create the mesh
  60082. * @param scene defines the hosting scene
  60083. * @returns the box mesh
  60084. */
  60085. static CreateTiledPlane(name: string, options: {
  60086. pattern?: number;
  60087. tileSize?: number;
  60088. tileWidth?: number;
  60089. tileHeight?: number;
  60090. size?: number;
  60091. width?: number;
  60092. height?: number;
  60093. alignHorizontal?: number;
  60094. alignVertical?: number;
  60095. sideOrientation?: number;
  60096. frontUVs?: Vector4;
  60097. backUVs?: Vector4;
  60098. updatable?: boolean;
  60099. }, scene?: Nullable<Scene>): Mesh;
  60100. }
  60101. }
  60102. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60103. import { Nullable } from "babylonjs/types";
  60104. import { Scene } from "babylonjs/scene";
  60105. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60106. import { Mesh } from "babylonjs/Meshes/mesh";
  60107. /**
  60108. * Class containing static functions to help procedurally build meshes
  60109. */
  60110. export class TubeBuilder {
  60111. /**
  60112. * Creates a tube mesh.
  60113. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60114. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60115. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60116. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60117. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60118. * * 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)
  60119. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60120. * * 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
  60121. * * 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
  60122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60126. * @param name defines the name of the mesh
  60127. * @param options defines the options used to create the mesh
  60128. * @param scene defines the hosting scene
  60129. * @returns the tube mesh
  60130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60131. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60132. */
  60133. static CreateTube(name: string, options: {
  60134. path: Vector3[];
  60135. radius?: number;
  60136. tessellation?: number;
  60137. radiusFunction?: {
  60138. (i: number, distance: number): number;
  60139. };
  60140. cap?: number;
  60141. arc?: number;
  60142. updatable?: boolean;
  60143. sideOrientation?: number;
  60144. frontUVs?: Vector4;
  60145. backUVs?: Vector4;
  60146. instance?: Mesh;
  60147. invertUV?: boolean;
  60148. }, scene?: Nullable<Scene>): Mesh;
  60149. }
  60150. }
  60151. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60152. import { Scene } from "babylonjs/scene";
  60153. import { Vector4 } from "babylonjs/Maths/math.vector";
  60154. import { Mesh } from "babylonjs/Meshes/mesh";
  60155. import { Nullable } from "babylonjs/types";
  60156. /**
  60157. * Class containing static functions to help procedurally build meshes
  60158. */
  60159. export class IcoSphereBuilder {
  60160. /**
  60161. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60162. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60163. * * 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`)
  60164. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60165. * * 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
  60166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60169. * @param name defines the name of the mesh
  60170. * @param options defines the options used to create the mesh
  60171. * @param scene defines the hosting scene
  60172. * @returns the icosahedron mesh
  60173. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60174. */
  60175. static CreateIcoSphere(name: string, options: {
  60176. radius?: number;
  60177. radiusX?: number;
  60178. radiusY?: number;
  60179. radiusZ?: number;
  60180. flat?: boolean;
  60181. subdivisions?: number;
  60182. sideOrientation?: number;
  60183. frontUVs?: Vector4;
  60184. backUVs?: Vector4;
  60185. updatable?: boolean;
  60186. }, scene?: Nullable<Scene>): Mesh;
  60187. }
  60188. }
  60189. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60190. import { Vector3 } from "babylonjs/Maths/math.vector";
  60191. import { Mesh } from "babylonjs/Meshes/mesh";
  60192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60193. /**
  60194. * Class containing static functions to help procedurally build meshes
  60195. */
  60196. export class DecalBuilder {
  60197. /**
  60198. * Creates a decal mesh.
  60199. * 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
  60200. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60201. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60202. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60203. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60204. * @param name defines the name of the mesh
  60205. * @param sourceMesh defines the mesh where the decal must be applied
  60206. * @param options defines the options used to create the mesh
  60207. * @param scene defines the hosting scene
  60208. * @returns the decal mesh
  60209. * @see https://doc.babylonjs.com/how_to/decals
  60210. */
  60211. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60212. position?: Vector3;
  60213. normal?: Vector3;
  60214. size?: Vector3;
  60215. angle?: number;
  60216. }): Mesh;
  60217. }
  60218. }
  60219. declare module "babylonjs/Meshes/meshBuilder" {
  60220. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60221. import { Nullable } from "babylonjs/types";
  60222. import { Scene } from "babylonjs/scene";
  60223. import { Mesh } from "babylonjs/Meshes/mesh";
  60224. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60225. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60227. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60228. import { Plane } from "babylonjs/Maths/math.plane";
  60229. /**
  60230. * Class containing static functions to help procedurally build meshes
  60231. */
  60232. export class MeshBuilder {
  60233. /**
  60234. * Creates a box mesh
  60235. * * The parameter `size` sets the size (float) of each box side (default 1)
  60236. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60237. * * 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)
  60238. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60242. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60243. * @param name defines the name of the mesh
  60244. * @param options defines the options used to create the mesh
  60245. * @param scene defines the hosting scene
  60246. * @returns the box mesh
  60247. */
  60248. static CreateBox(name: string, options: {
  60249. size?: number;
  60250. width?: number;
  60251. height?: number;
  60252. depth?: number;
  60253. faceUV?: Vector4[];
  60254. faceColors?: Color4[];
  60255. sideOrientation?: number;
  60256. frontUVs?: Vector4;
  60257. backUVs?: Vector4;
  60258. updatable?: boolean;
  60259. }, scene?: Nullable<Scene>): Mesh;
  60260. /**
  60261. * Creates a tiled box mesh
  60262. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60264. * @param name defines the name of the mesh
  60265. * @param options defines the options used to create the mesh
  60266. * @param scene defines the hosting scene
  60267. * @returns the tiled box mesh
  60268. */
  60269. static CreateTiledBox(name: string, options: {
  60270. pattern?: number;
  60271. size?: number;
  60272. width?: number;
  60273. height?: number;
  60274. depth: number;
  60275. tileSize?: number;
  60276. tileWidth?: number;
  60277. tileHeight?: number;
  60278. faceUV?: Vector4[];
  60279. faceColors?: Color4[];
  60280. alignHorizontal?: number;
  60281. alignVertical?: number;
  60282. sideOrientation?: number;
  60283. updatable?: boolean;
  60284. }, scene?: Nullable<Scene>): Mesh;
  60285. /**
  60286. * Creates a sphere mesh
  60287. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60288. * * 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`)
  60289. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60290. * * 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
  60291. * * 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)
  60292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60295. * @param name defines the name of the mesh
  60296. * @param options defines the options used to create the mesh
  60297. * @param scene defines the hosting scene
  60298. * @returns the sphere mesh
  60299. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60300. */
  60301. static CreateSphere(name: string, options: {
  60302. segments?: number;
  60303. diameter?: number;
  60304. diameterX?: number;
  60305. diameterY?: number;
  60306. diameterZ?: number;
  60307. arc?: number;
  60308. slice?: number;
  60309. sideOrientation?: number;
  60310. frontUVs?: Vector4;
  60311. backUVs?: Vector4;
  60312. updatable?: boolean;
  60313. }, scene?: Nullable<Scene>): Mesh;
  60314. /**
  60315. * Creates a plane polygonal mesh. By default, this is a disc
  60316. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60317. * * 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
  60318. * * 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
  60319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60322. * @param name defines the name of the mesh
  60323. * @param options defines the options used to create the mesh
  60324. * @param scene defines the hosting scene
  60325. * @returns the plane polygonal mesh
  60326. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60327. */
  60328. static CreateDisc(name: string, options: {
  60329. radius?: number;
  60330. tessellation?: number;
  60331. arc?: number;
  60332. updatable?: boolean;
  60333. sideOrientation?: number;
  60334. frontUVs?: Vector4;
  60335. backUVs?: Vector4;
  60336. }, scene?: Nullable<Scene>): Mesh;
  60337. /**
  60338. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60339. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60340. * * 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`)
  60341. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60342. * * 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
  60343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60346. * @param name defines the name of the mesh
  60347. * @param options defines the options used to create the mesh
  60348. * @param scene defines the hosting scene
  60349. * @returns the icosahedron mesh
  60350. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60351. */
  60352. static CreateIcoSphere(name: string, options: {
  60353. radius?: number;
  60354. radiusX?: number;
  60355. radiusY?: number;
  60356. radiusZ?: number;
  60357. flat?: boolean;
  60358. subdivisions?: number;
  60359. sideOrientation?: number;
  60360. frontUVs?: Vector4;
  60361. backUVs?: Vector4;
  60362. updatable?: boolean;
  60363. }, scene?: Nullable<Scene>): Mesh;
  60364. /**
  60365. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60366. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60367. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60368. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60369. * * 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
  60370. * * 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
  60371. * * 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
  60372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60375. * * 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
  60376. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60377. * * 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
  60378. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60380. * @param name defines the name of the mesh
  60381. * @param options defines the options used to create the mesh
  60382. * @param scene defines the hosting scene
  60383. * @returns the ribbon mesh
  60384. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60385. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60386. */
  60387. static CreateRibbon(name: string, options: {
  60388. pathArray: Vector3[][];
  60389. closeArray?: boolean;
  60390. closePath?: boolean;
  60391. offset?: number;
  60392. updatable?: boolean;
  60393. sideOrientation?: number;
  60394. frontUVs?: Vector4;
  60395. backUVs?: Vector4;
  60396. instance?: Mesh;
  60397. invertUV?: boolean;
  60398. uvs?: Vector2[];
  60399. colors?: Color4[];
  60400. }, scene?: Nullable<Scene>): Mesh;
  60401. /**
  60402. * Creates a cylinder or a cone mesh
  60403. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60404. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60405. * * 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.
  60406. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60407. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60408. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60409. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60410. * * 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).
  60411. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60412. * * 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).
  60413. * * 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
  60414. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60415. * * 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
  60416. * * 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.
  60417. * * If `enclose` is false, a ring surface is one element.
  60418. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60419. * * 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
  60420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60423. * @param name defines the name of the mesh
  60424. * @param options defines the options used to create the mesh
  60425. * @param scene defines the hosting scene
  60426. * @returns the cylinder mesh
  60427. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60428. */
  60429. static CreateCylinder(name: string, options: {
  60430. height?: number;
  60431. diameterTop?: number;
  60432. diameterBottom?: number;
  60433. diameter?: number;
  60434. tessellation?: number;
  60435. subdivisions?: number;
  60436. arc?: number;
  60437. faceColors?: Color4[];
  60438. faceUV?: Vector4[];
  60439. updatable?: boolean;
  60440. hasRings?: boolean;
  60441. enclose?: boolean;
  60442. cap?: number;
  60443. sideOrientation?: number;
  60444. frontUVs?: Vector4;
  60445. backUVs?: Vector4;
  60446. }, scene?: Nullable<Scene>): Mesh;
  60447. /**
  60448. * Creates a torus mesh
  60449. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60450. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60451. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60455. * @param name defines the name of the mesh
  60456. * @param options defines the options used to create the mesh
  60457. * @param scene defines the hosting scene
  60458. * @returns the torus mesh
  60459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60460. */
  60461. static CreateTorus(name: string, options: {
  60462. diameter?: number;
  60463. thickness?: number;
  60464. tessellation?: number;
  60465. updatable?: boolean;
  60466. sideOrientation?: number;
  60467. frontUVs?: Vector4;
  60468. backUVs?: Vector4;
  60469. }, scene?: Nullable<Scene>): Mesh;
  60470. /**
  60471. * Creates a torus knot mesh
  60472. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60473. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60474. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60475. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60479. * @param name defines the name of the mesh
  60480. * @param options defines the options used to create the mesh
  60481. * @param scene defines the hosting scene
  60482. * @returns the torus knot mesh
  60483. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60484. */
  60485. static CreateTorusKnot(name: string, options: {
  60486. radius?: number;
  60487. tube?: number;
  60488. radialSegments?: number;
  60489. tubularSegments?: number;
  60490. p?: number;
  60491. q?: number;
  60492. updatable?: boolean;
  60493. sideOrientation?: number;
  60494. frontUVs?: Vector4;
  60495. backUVs?: Vector4;
  60496. }, scene?: Nullable<Scene>): Mesh;
  60497. /**
  60498. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60499. * * 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
  60500. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60501. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60502. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60503. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60504. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60505. * * 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
  60506. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60509. * @param name defines the name of the new line system
  60510. * @param options defines the options used to create the line system
  60511. * @param scene defines the hosting scene
  60512. * @returns a new line system mesh
  60513. */
  60514. static CreateLineSystem(name: string, options: {
  60515. lines: Vector3[][];
  60516. updatable?: boolean;
  60517. instance?: Nullable<LinesMesh>;
  60518. colors?: Nullable<Color4[][]>;
  60519. useVertexAlpha?: boolean;
  60520. }, scene: Nullable<Scene>): LinesMesh;
  60521. /**
  60522. * Creates a line mesh
  60523. * 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
  60524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60525. * * The parameter `points` is an array successive Vector3
  60526. * * 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
  60527. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60528. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60529. * * When updating an instance, remember that only point positions can change, not the number of points
  60530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60532. * @param name defines the name of the new line system
  60533. * @param options defines the options used to create the line system
  60534. * @param scene defines the hosting scene
  60535. * @returns a new line mesh
  60536. */
  60537. static CreateLines(name: string, options: {
  60538. points: Vector3[];
  60539. updatable?: boolean;
  60540. instance?: Nullable<LinesMesh>;
  60541. colors?: Color4[];
  60542. useVertexAlpha?: boolean;
  60543. }, scene?: Nullable<Scene>): LinesMesh;
  60544. /**
  60545. * Creates a dashed line mesh
  60546. * * 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
  60547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60548. * * The parameter `points` is an array successive Vector3
  60549. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60550. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60551. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60552. * * 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
  60553. * * When updating an instance, remember that only point positions can change, not the number of points
  60554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60555. * @param name defines the name of the mesh
  60556. * @param options defines the options used to create the mesh
  60557. * @param scene defines the hosting scene
  60558. * @returns the dashed line mesh
  60559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60560. */
  60561. static CreateDashedLines(name: string, options: {
  60562. points: Vector3[];
  60563. dashSize?: number;
  60564. gapSize?: number;
  60565. dashNb?: number;
  60566. updatable?: boolean;
  60567. instance?: LinesMesh;
  60568. }, scene?: Nullable<Scene>): LinesMesh;
  60569. /**
  60570. * 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.
  60571. * * 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.
  60572. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60573. * * 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.
  60574. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60575. * * 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
  60576. * * 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
  60577. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60582. * @param name defines the name of the mesh
  60583. * @param options defines the options used to create the mesh
  60584. * @param scene defines the hosting scene
  60585. * @returns the extruded shape mesh
  60586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60588. */
  60589. static ExtrudeShape(name: string, options: {
  60590. shape: Vector3[];
  60591. path: Vector3[];
  60592. scale?: number;
  60593. rotation?: number;
  60594. cap?: number;
  60595. updatable?: boolean;
  60596. sideOrientation?: number;
  60597. frontUVs?: Vector4;
  60598. backUVs?: Vector4;
  60599. instance?: Mesh;
  60600. invertUV?: boolean;
  60601. }, scene?: Nullable<Scene>): Mesh;
  60602. /**
  60603. * Creates an custom extruded shape mesh.
  60604. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60605. * * 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.
  60606. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60607. * * 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
  60608. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60609. * * 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
  60610. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60611. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60612. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60613. * * 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
  60614. * * 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
  60615. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60620. * @param name defines the name of the mesh
  60621. * @param options defines the options used to create the mesh
  60622. * @param scene defines the hosting scene
  60623. * @returns the custom extruded shape mesh
  60624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60627. */
  60628. static ExtrudeShapeCustom(name: string, options: {
  60629. shape: Vector3[];
  60630. path: Vector3[];
  60631. scaleFunction?: any;
  60632. rotationFunction?: any;
  60633. ribbonCloseArray?: boolean;
  60634. ribbonClosePath?: boolean;
  60635. cap?: number;
  60636. updatable?: boolean;
  60637. sideOrientation?: number;
  60638. frontUVs?: Vector4;
  60639. backUVs?: Vector4;
  60640. instance?: Mesh;
  60641. invertUV?: boolean;
  60642. }, scene?: Nullable<Scene>): Mesh;
  60643. /**
  60644. * Creates lathe mesh.
  60645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60646. * * 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
  60647. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60648. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60649. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60650. * * 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
  60651. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60652. * * 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
  60653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60657. * @param name defines the name of the mesh
  60658. * @param options defines the options used to create the mesh
  60659. * @param scene defines the hosting scene
  60660. * @returns the lathe mesh
  60661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60662. */
  60663. static CreateLathe(name: string, options: {
  60664. shape: Vector3[];
  60665. radius?: number;
  60666. tessellation?: number;
  60667. clip?: number;
  60668. arc?: number;
  60669. closed?: boolean;
  60670. updatable?: boolean;
  60671. sideOrientation?: number;
  60672. frontUVs?: Vector4;
  60673. backUVs?: Vector4;
  60674. cap?: number;
  60675. invertUV?: boolean;
  60676. }, scene?: Nullable<Scene>): Mesh;
  60677. /**
  60678. * Creates a tiled plane mesh
  60679. * * You can set a limited pattern arrangement with the tiles
  60680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60683. * @param name defines the name of the mesh
  60684. * @param options defines the options used to create the mesh
  60685. * @param scene defines the hosting scene
  60686. * @returns the plane mesh
  60687. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60688. */
  60689. static CreateTiledPlane(name: string, options: {
  60690. pattern?: number;
  60691. tileSize?: number;
  60692. tileWidth?: number;
  60693. tileHeight?: number;
  60694. size?: number;
  60695. width?: number;
  60696. height?: number;
  60697. alignHorizontal?: number;
  60698. alignVertical?: number;
  60699. sideOrientation?: number;
  60700. frontUVs?: Vector4;
  60701. backUVs?: Vector4;
  60702. updatable?: boolean;
  60703. }, scene?: Nullable<Scene>): Mesh;
  60704. /**
  60705. * Creates a plane mesh
  60706. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60707. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60708. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60712. * @param name defines the name of the mesh
  60713. * @param options defines the options used to create the mesh
  60714. * @param scene defines the hosting scene
  60715. * @returns the plane mesh
  60716. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60717. */
  60718. static CreatePlane(name: string, options: {
  60719. size?: number;
  60720. width?: number;
  60721. height?: number;
  60722. sideOrientation?: number;
  60723. frontUVs?: Vector4;
  60724. backUVs?: Vector4;
  60725. updatable?: boolean;
  60726. sourcePlane?: Plane;
  60727. }, scene?: Nullable<Scene>): Mesh;
  60728. /**
  60729. * Creates a ground mesh
  60730. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60731. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60733. * @param name defines the name of the mesh
  60734. * @param options defines the options used to create the mesh
  60735. * @param scene defines the hosting scene
  60736. * @returns the ground mesh
  60737. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60738. */
  60739. static CreateGround(name: string, options: {
  60740. width?: number;
  60741. height?: number;
  60742. subdivisions?: number;
  60743. subdivisionsX?: number;
  60744. subdivisionsY?: number;
  60745. updatable?: boolean;
  60746. }, scene?: Nullable<Scene>): Mesh;
  60747. /**
  60748. * Creates a tiled ground mesh
  60749. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60750. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60751. * * 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
  60752. * * 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
  60753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60754. * @param name defines the name of the mesh
  60755. * @param options defines the options used to create the mesh
  60756. * @param scene defines the hosting scene
  60757. * @returns the tiled ground mesh
  60758. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60759. */
  60760. static CreateTiledGround(name: string, options: {
  60761. xmin: number;
  60762. zmin: number;
  60763. xmax: number;
  60764. zmax: number;
  60765. subdivisions?: {
  60766. w: number;
  60767. h: number;
  60768. };
  60769. precision?: {
  60770. w: number;
  60771. h: number;
  60772. };
  60773. updatable?: boolean;
  60774. }, scene?: Nullable<Scene>): Mesh;
  60775. /**
  60776. * Creates a ground mesh from a height map
  60777. * * The parameter `url` sets the URL of the height map image resource.
  60778. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60779. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60780. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60781. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60782. * * 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.
  60783. * * 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).
  60784. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60786. * @param name defines the name of the mesh
  60787. * @param url defines the url to the height map
  60788. * @param options defines the options used to create the mesh
  60789. * @param scene defines the hosting scene
  60790. * @returns the ground mesh
  60791. * @see https://doc.babylonjs.com/babylon101/height_map
  60792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60793. */
  60794. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60795. width?: number;
  60796. height?: number;
  60797. subdivisions?: number;
  60798. minHeight?: number;
  60799. maxHeight?: number;
  60800. colorFilter?: Color3;
  60801. alphaFilter?: number;
  60802. updatable?: boolean;
  60803. onReady?: (mesh: GroundMesh) => void;
  60804. }, scene?: Nullable<Scene>): GroundMesh;
  60805. /**
  60806. * Creates a polygon mesh
  60807. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60808. * * 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
  60809. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60812. * * Remember you can only change the shape positions, not their number when updating a polygon
  60813. * @param name defines the name of the mesh
  60814. * @param options defines the options used to create the mesh
  60815. * @param scene defines the hosting scene
  60816. * @param earcutInjection can be used to inject your own earcut reference
  60817. * @returns the polygon mesh
  60818. */
  60819. static CreatePolygon(name: string, options: {
  60820. shape: Vector3[];
  60821. holes?: Vector3[][];
  60822. depth?: number;
  60823. faceUV?: Vector4[];
  60824. faceColors?: Color4[];
  60825. updatable?: boolean;
  60826. sideOrientation?: number;
  60827. frontUVs?: Vector4;
  60828. backUVs?: Vector4;
  60829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60830. /**
  60831. * Creates an extruded polygon mesh, with depth in the Y direction.
  60832. * * 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)
  60833. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60834. * @param name defines the name of the mesh
  60835. * @param options defines the options used to create the mesh
  60836. * @param scene defines the hosting scene
  60837. * @param earcutInjection can be used to inject your own earcut reference
  60838. * @returns the polygon mesh
  60839. */
  60840. static ExtrudePolygon(name: string, options: {
  60841. shape: Vector3[];
  60842. holes?: Vector3[][];
  60843. depth?: number;
  60844. faceUV?: Vector4[];
  60845. faceColors?: Color4[];
  60846. updatable?: boolean;
  60847. sideOrientation?: number;
  60848. frontUVs?: Vector4;
  60849. backUVs?: Vector4;
  60850. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60851. /**
  60852. * Creates a tube mesh.
  60853. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60854. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60855. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60856. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60857. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60858. * * 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)
  60859. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60860. * * 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
  60861. * * 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
  60862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60866. * @param name defines the name of the mesh
  60867. * @param options defines the options used to create the mesh
  60868. * @param scene defines the hosting scene
  60869. * @returns the tube mesh
  60870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60871. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60872. */
  60873. static CreateTube(name: string, options: {
  60874. path: Vector3[];
  60875. radius?: number;
  60876. tessellation?: number;
  60877. radiusFunction?: {
  60878. (i: number, distance: number): number;
  60879. };
  60880. cap?: number;
  60881. arc?: number;
  60882. updatable?: boolean;
  60883. sideOrientation?: number;
  60884. frontUVs?: Vector4;
  60885. backUVs?: Vector4;
  60886. instance?: Mesh;
  60887. invertUV?: boolean;
  60888. }, scene?: Nullable<Scene>): Mesh;
  60889. /**
  60890. * Creates a polyhedron mesh
  60891. * * 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
  60892. * * The parameter `size` (positive float, default 1) sets the polygon size
  60893. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60894. * * 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`
  60895. * * 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
  60896. * * 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)`)
  60897. * * 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
  60898. * * 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
  60899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60902. * @param name defines the name of the mesh
  60903. * @param options defines the options used to create the mesh
  60904. * @param scene defines the hosting scene
  60905. * @returns the polyhedron mesh
  60906. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60907. */
  60908. static CreatePolyhedron(name: string, options: {
  60909. type?: number;
  60910. size?: number;
  60911. sizeX?: number;
  60912. sizeY?: number;
  60913. sizeZ?: number;
  60914. custom?: any;
  60915. faceUV?: Vector4[];
  60916. faceColors?: Color4[];
  60917. flat?: boolean;
  60918. updatable?: boolean;
  60919. sideOrientation?: number;
  60920. frontUVs?: Vector4;
  60921. backUVs?: Vector4;
  60922. }, scene?: Nullable<Scene>): Mesh;
  60923. /**
  60924. * Creates a decal mesh.
  60925. * 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
  60926. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60927. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60928. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60929. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60930. * @param name defines the name of the mesh
  60931. * @param sourceMesh defines the mesh where the decal must be applied
  60932. * @param options defines the options used to create the mesh
  60933. * @param scene defines the hosting scene
  60934. * @returns the decal mesh
  60935. * @see https://doc.babylonjs.com/how_to/decals
  60936. */
  60937. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60938. position?: Vector3;
  60939. normal?: Vector3;
  60940. size?: Vector3;
  60941. angle?: number;
  60942. }): Mesh;
  60943. }
  60944. }
  60945. declare module "babylonjs/Meshes/meshSimplification" {
  60946. import { Mesh } from "babylonjs/Meshes/mesh";
  60947. /**
  60948. * A simplifier interface for future simplification implementations
  60949. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60950. */
  60951. export interface ISimplifier {
  60952. /**
  60953. * Simplification of a given mesh according to the given settings.
  60954. * Since this requires computation, it is assumed that the function runs async.
  60955. * @param settings The settings of the simplification, including quality and distance
  60956. * @param successCallback A callback that will be called after the mesh was simplified.
  60957. * @param errorCallback in case of an error, this callback will be called. optional.
  60958. */
  60959. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60960. }
  60961. /**
  60962. * Expected simplification settings.
  60963. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60964. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60965. */
  60966. export interface ISimplificationSettings {
  60967. /**
  60968. * Gets or sets the expected quality
  60969. */
  60970. quality: number;
  60971. /**
  60972. * Gets or sets the distance when this optimized version should be used
  60973. */
  60974. distance: number;
  60975. /**
  60976. * Gets an already optimized mesh
  60977. */
  60978. optimizeMesh?: boolean;
  60979. }
  60980. /**
  60981. * Class used to specify simplification options
  60982. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60983. */
  60984. export class SimplificationSettings implements ISimplificationSettings {
  60985. /** expected quality */
  60986. quality: number;
  60987. /** distance when this optimized version should be used */
  60988. distance: number;
  60989. /** already optimized mesh */
  60990. optimizeMesh?: boolean | undefined;
  60991. /**
  60992. * Creates a SimplificationSettings
  60993. * @param quality expected quality
  60994. * @param distance distance when this optimized version should be used
  60995. * @param optimizeMesh already optimized mesh
  60996. */
  60997. constructor(
  60998. /** expected quality */
  60999. quality: number,
  61000. /** distance when this optimized version should be used */
  61001. distance: number,
  61002. /** already optimized mesh */
  61003. optimizeMesh?: boolean | undefined);
  61004. }
  61005. /**
  61006. * Interface used to define a simplification task
  61007. */
  61008. export interface ISimplificationTask {
  61009. /**
  61010. * Array of settings
  61011. */
  61012. settings: Array<ISimplificationSettings>;
  61013. /**
  61014. * Simplification type
  61015. */
  61016. simplificationType: SimplificationType;
  61017. /**
  61018. * Mesh to simplify
  61019. */
  61020. mesh: Mesh;
  61021. /**
  61022. * Callback called on success
  61023. */
  61024. successCallback?: () => void;
  61025. /**
  61026. * Defines if parallel processing can be used
  61027. */
  61028. parallelProcessing: boolean;
  61029. }
  61030. /**
  61031. * Queue used to order the simplification tasks
  61032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61033. */
  61034. export class SimplificationQueue {
  61035. private _simplificationArray;
  61036. /**
  61037. * Gets a boolean indicating that the process is still running
  61038. */
  61039. running: boolean;
  61040. /**
  61041. * Creates a new queue
  61042. */
  61043. constructor();
  61044. /**
  61045. * Adds a new simplification task
  61046. * @param task defines a task to add
  61047. */
  61048. addTask(task: ISimplificationTask): void;
  61049. /**
  61050. * Execute next task
  61051. */
  61052. executeNext(): void;
  61053. /**
  61054. * Execute a simplification task
  61055. * @param task defines the task to run
  61056. */
  61057. runSimplification(task: ISimplificationTask): void;
  61058. private getSimplifier;
  61059. }
  61060. /**
  61061. * The implemented types of simplification
  61062. * At the moment only Quadratic Error Decimation is implemented
  61063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61064. */
  61065. export enum SimplificationType {
  61066. /** Quadratic error decimation */
  61067. QUADRATIC = 0
  61068. }
  61069. }
  61070. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61071. import { Scene } from "babylonjs/scene";
  61072. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61073. import { ISceneComponent } from "babylonjs/sceneComponent";
  61074. module "babylonjs/scene" {
  61075. interface Scene {
  61076. /** @hidden (Backing field) */
  61077. _simplificationQueue: SimplificationQueue;
  61078. /**
  61079. * Gets or sets the simplification queue attached to the scene
  61080. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61081. */
  61082. simplificationQueue: SimplificationQueue;
  61083. }
  61084. }
  61085. module "babylonjs/Meshes/mesh" {
  61086. interface Mesh {
  61087. /**
  61088. * Simplify the mesh according to the given array of settings.
  61089. * Function will return immediately and will simplify async
  61090. * @param settings a collection of simplification settings
  61091. * @param parallelProcessing should all levels calculate parallel or one after the other
  61092. * @param simplificationType the type of simplification to run
  61093. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61094. * @returns the current mesh
  61095. */
  61096. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61097. }
  61098. }
  61099. /**
  61100. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61101. * created in a scene
  61102. */
  61103. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61104. /**
  61105. * The component name helpfull to identify the component in the list of scene components.
  61106. */
  61107. readonly name: string;
  61108. /**
  61109. * The scene the component belongs to.
  61110. */
  61111. scene: Scene;
  61112. /**
  61113. * Creates a new instance of the component for the given scene
  61114. * @param scene Defines the scene to register the component in
  61115. */
  61116. constructor(scene: Scene);
  61117. /**
  61118. * Registers the component in a given scene
  61119. */
  61120. register(): void;
  61121. /**
  61122. * Rebuilds the elements related to this component in case of
  61123. * context lost for instance.
  61124. */
  61125. rebuild(): void;
  61126. /**
  61127. * Disposes the component and the associated ressources
  61128. */
  61129. dispose(): void;
  61130. private _beforeCameraUpdate;
  61131. }
  61132. }
  61133. declare module "babylonjs/Meshes/Builders/index" {
  61134. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61135. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61136. export * from "babylonjs/Meshes/Builders/discBuilder";
  61137. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61138. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61139. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61140. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61141. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61142. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61143. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61144. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61145. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61146. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61147. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61148. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61149. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61150. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61151. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61152. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61153. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61154. }
  61155. declare module "babylonjs/Meshes/index" {
  61156. export * from "babylonjs/Meshes/abstractMesh";
  61157. export * from "babylonjs/Meshes/buffer";
  61158. export * from "babylonjs/Meshes/Compression/index";
  61159. export * from "babylonjs/Meshes/csg";
  61160. export * from "babylonjs/Meshes/geometry";
  61161. export * from "babylonjs/Meshes/groundMesh";
  61162. export * from "babylonjs/Meshes/trailMesh";
  61163. export * from "babylonjs/Meshes/instancedMesh";
  61164. export * from "babylonjs/Meshes/linesMesh";
  61165. export * from "babylonjs/Meshes/mesh";
  61166. export * from "babylonjs/Meshes/mesh.vertexData";
  61167. export * from "babylonjs/Meshes/meshBuilder";
  61168. export * from "babylonjs/Meshes/meshSimplification";
  61169. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61170. export * from "babylonjs/Meshes/polygonMesh";
  61171. export * from "babylonjs/Meshes/subMesh";
  61172. export * from "babylonjs/Meshes/meshLODLevel";
  61173. export * from "babylonjs/Meshes/transformNode";
  61174. export * from "babylonjs/Meshes/Builders/index";
  61175. export * from "babylonjs/Meshes/dataBuffer";
  61176. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61177. }
  61178. declare module "babylonjs/Morph/index" {
  61179. export * from "babylonjs/Morph/morphTarget";
  61180. export * from "babylonjs/Morph/morphTargetManager";
  61181. }
  61182. declare module "babylonjs/Navigation/INavigationEngine" {
  61183. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61184. import { Vector3 } from "babylonjs/Maths/math";
  61185. import { Mesh } from "babylonjs/Meshes/mesh";
  61186. import { Scene } from "babylonjs/scene";
  61187. /**
  61188. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61189. */
  61190. export interface INavigationEnginePlugin {
  61191. /**
  61192. * plugin name
  61193. */
  61194. name: string;
  61195. /**
  61196. * Creates a navigation mesh
  61197. * @param meshes array of all the geometry used to compute the navigatio mesh
  61198. * @param parameters bunch of parameters used to filter geometry
  61199. */
  61200. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61201. /**
  61202. * Create a navigation mesh debug mesh
  61203. * @param scene is where the mesh will be added
  61204. * @returns debug display mesh
  61205. */
  61206. createDebugNavMesh(scene: Scene): Mesh;
  61207. /**
  61208. * Get a navigation mesh constrained position, closest to the parameter position
  61209. * @param position world position
  61210. * @returns the closest point to position constrained by the navigation mesh
  61211. */
  61212. getClosestPoint(position: Vector3): Vector3;
  61213. /**
  61214. * Get a navigation mesh constrained position, within a particular radius
  61215. * @param position world position
  61216. * @param maxRadius the maximum distance to the constrained world position
  61217. * @returns the closest point to position constrained by the navigation mesh
  61218. */
  61219. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61220. /**
  61221. * Compute the final position from a segment made of destination-position
  61222. * @param position world position
  61223. * @param destination world position
  61224. * @returns the resulting point along the navmesh
  61225. */
  61226. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61227. /**
  61228. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61229. * @param start world position
  61230. * @param end world position
  61231. * @returns array containing world position composing the path
  61232. */
  61233. computePath(start: Vector3, end: Vector3): Vector3[];
  61234. /**
  61235. * If this plugin is supported
  61236. * @returns true if plugin is supported
  61237. */
  61238. isSupported(): boolean;
  61239. /**
  61240. * Create a new Crowd so you can add agents
  61241. * @param maxAgents the maximum agent count in the crowd
  61242. * @param maxAgentRadius the maximum radius an agent can have
  61243. * @param scene to attach the crowd to
  61244. * @returns the crowd you can add agents to
  61245. */
  61246. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61247. /**
  61248. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61249. * The queries will try to find a solution within those bounds
  61250. * default is (1,1,1)
  61251. * @param extent x,y,z value that define the extent around the queries point of reference
  61252. */
  61253. setDefaultQueryExtent(extent: Vector3): void;
  61254. /**
  61255. * Get the Bounding box extent specified by setDefaultQueryExtent
  61256. * @returns the box extent values
  61257. */
  61258. getDefaultQueryExtent(): Vector3;
  61259. /**
  61260. * Release all resources
  61261. */
  61262. dispose(): void;
  61263. }
  61264. /**
  61265. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61266. */
  61267. export interface ICrowd {
  61268. /**
  61269. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61270. * You can attach anything to that node. The node position is updated in the scene update tick.
  61271. * @param pos world position that will be constrained by the navigation mesh
  61272. * @param parameters agent parameters
  61273. * @param transform hooked to the agent that will be update by the scene
  61274. * @returns agent index
  61275. */
  61276. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61277. /**
  61278. * Returns the agent position in world space
  61279. * @param index agent index returned by addAgent
  61280. * @returns world space position
  61281. */
  61282. getAgentPosition(index: number): Vector3;
  61283. /**
  61284. * Gets the agent velocity in world space
  61285. * @param index agent index returned by addAgent
  61286. * @returns world space velocity
  61287. */
  61288. getAgentVelocity(index: number): Vector3;
  61289. /**
  61290. * remove a particular agent previously created
  61291. * @param index agent index returned by addAgent
  61292. */
  61293. removeAgent(index: number): void;
  61294. /**
  61295. * get the list of all agents attached to this crowd
  61296. * @returns list of agent indices
  61297. */
  61298. getAgents(): number[];
  61299. /**
  61300. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61301. * @param deltaTime in seconds
  61302. */
  61303. update(deltaTime: number): void;
  61304. /**
  61305. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61306. * @param index agent index returned by addAgent
  61307. * @param destination targeted world position
  61308. */
  61309. agentGoto(index: number, destination: Vector3): void;
  61310. /**
  61311. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61312. * The queries will try to find a solution within those bounds
  61313. * default is (1,1,1)
  61314. * @param extent x,y,z value that define the extent around the queries point of reference
  61315. */
  61316. setDefaultQueryExtent(extent: Vector3): void;
  61317. /**
  61318. * Get the Bounding box extent specified by setDefaultQueryExtent
  61319. * @returns the box extent values
  61320. */
  61321. getDefaultQueryExtent(): Vector3;
  61322. /**
  61323. * Release all resources
  61324. */
  61325. dispose(): void;
  61326. }
  61327. /**
  61328. * Configures an agent
  61329. */
  61330. export interface IAgentParameters {
  61331. /**
  61332. * Agent radius. [Limit: >= 0]
  61333. */
  61334. radius: number;
  61335. /**
  61336. * Agent height. [Limit: > 0]
  61337. */
  61338. height: number;
  61339. /**
  61340. * Maximum allowed acceleration. [Limit: >= 0]
  61341. */
  61342. maxAcceleration: number;
  61343. /**
  61344. * Maximum allowed speed. [Limit: >= 0]
  61345. */
  61346. maxSpeed: number;
  61347. /**
  61348. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61349. */
  61350. collisionQueryRange: number;
  61351. /**
  61352. * The path visibility optimization range. [Limit: > 0]
  61353. */
  61354. pathOptimizationRange: number;
  61355. /**
  61356. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61357. */
  61358. separationWeight: number;
  61359. }
  61360. /**
  61361. * Configures the navigation mesh creation
  61362. */
  61363. export interface INavMeshParameters {
  61364. /**
  61365. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61366. */
  61367. cs: number;
  61368. /**
  61369. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61370. */
  61371. ch: number;
  61372. /**
  61373. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61374. */
  61375. walkableSlopeAngle: number;
  61376. /**
  61377. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61378. * be considered walkable. [Limit: >= 3] [Units: vx]
  61379. */
  61380. walkableHeight: number;
  61381. /**
  61382. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61383. */
  61384. walkableClimb: number;
  61385. /**
  61386. * The distance to erode/shrink the walkable area of the heightfield away from
  61387. * obstructions. [Limit: >=0] [Units: vx]
  61388. */
  61389. walkableRadius: number;
  61390. /**
  61391. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61392. */
  61393. maxEdgeLen: number;
  61394. /**
  61395. * The maximum distance a simplfied contour's border edges should deviate
  61396. * the original raw contour. [Limit: >=0] [Units: vx]
  61397. */
  61398. maxSimplificationError: number;
  61399. /**
  61400. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61401. */
  61402. minRegionArea: number;
  61403. /**
  61404. * Any regions with a span count smaller than this value will, if possible,
  61405. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61406. */
  61407. mergeRegionArea: number;
  61408. /**
  61409. * The maximum number of vertices allowed for polygons generated during the
  61410. * contour to polygon conversion process. [Limit: >= 3]
  61411. */
  61412. maxVertsPerPoly: number;
  61413. /**
  61414. * Sets the sampling distance to use when generating the detail mesh.
  61415. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61416. */
  61417. detailSampleDist: number;
  61418. /**
  61419. * The maximum distance the detail mesh surface should deviate from heightfield
  61420. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61421. */
  61422. detailSampleMaxError: number;
  61423. }
  61424. }
  61425. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61426. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61427. import { Mesh } from "babylonjs/Meshes/mesh";
  61428. import { Scene } from "babylonjs/scene";
  61429. import { Vector3 } from "babylonjs/Maths/math";
  61430. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61431. /**
  61432. * RecastJS navigation plugin
  61433. */
  61434. export class RecastJSPlugin implements INavigationEnginePlugin {
  61435. /**
  61436. * Reference to the Recast library
  61437. */
  61438. bjsRECAST: any;
  61439. /**
  61440. * plugin name
  61441. */
  61442. name: string;
  61443. /**
  61444. * the first navmesh created. We might extend this to support multiple navmeshes
  61445. */
  61446. navMesh: any;
  61447. /**
  61448. * Initializes the recastJS plugin
  61449. * @param recastInjection can be used to inject your own recast reference
  61450. */
  61451. constructor(recastInjection?: any);
  61452. /**
  61453. * Creates a navigation mesh
  61454. * @param meshes array of all the geometry used to compute the navigatio mesh
  61455. * @param parameters bunch of parameters used to filter geometry
  61456. */
  61457. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61458. /**
  61459. * Create a navigation mesh debug mesh
  61460. * @param scene is where the mesh will be added
  61461. * @returns debug display mesh
  61462. */
  61463. createDebugNavMesh(scene: Scene): Mesh;
  61464. /**
  61465. * Get a navigation mesh constrained position, closest to the parameter position
  61466. * @param position world position
  61467. * @returns the closest point to position constrained by the navigation mesh
  61468. */
  61469. getClosestPoint(position: Vector3): Vector3;
  61470. /**
  61471. * Get a navigation mesh constrained position, within a particular radius
  61472. * @param position world position
  61473. * @param maxRadius the maximum distance to the constrained world position
  61474. * @returns the closest point to position constrained by the navigation mesh
  61475. */
  61476. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61477. /**
  61478. * Compute the final position from a segment made of destination-position
  61479. * @param position world position
  61480. * @param destination world position
  61481. * @returns the resulting point along the navmesh
  61482. */
  61483. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61484. /**
  61485. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61486. * @param start world position
  61487. * @param end world position
  61488. * @returns array containing world position composing the path
  61489. */
  61490. computePath(start: Vector3, end: Vector3): Vector3[];
  61491. /**
  61492. * Create a new Crowd so you can add agents
  61493. * @param maxAgents the maximum agent count in the crowd
  61494. * @param maxAgentRadius the maximum radius an agent can have
  61495. * @param scene to attach the crowd to
  61496. * @returns the crowd you can add agents to
  61497. */
  61498. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61499. /**
  61500. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61501. * The queries will try to find a solution within those bounds
  61502. * default is (1,1,1)
  61503. * @param extent x,y,z value that define the extent around the queries point of reference
  61504. */
  61505. setDefaultQueryExtent(extent: Vector3): void;
  61506. /**
  61507. * Get the Bounding box extent specified by setDefaultQueryExtent
  61508. * @returns the box extent values
  61509. */
  61510. getDefaultQueryExtent(): Vector3;
  61511. /**
  61512. * Disposes
  61513. */
  61514. dispose(): void;
  61515. /**
  61516. * If this plugin is supported
  61517. * @returns true if plugin is supported
  61518. */
  61519. isSupported(): boolean;
  61520. }
  61521. /**
  61522. * Recast detour crowd implementation
  61523. */
  61524. export class RecastJSCrowd implements ICrowd {
  61525. /**
  61526. * Recast/detour plugin
  61527. */
  61528. bjsRECASTPlugin: RecastJSPlugin;
  61529. /**
  61530. * Link to the detour crowd
  61531. */
  61532. recastCrowd: any;
  61533. /**
  61534. * One transform per agent
  61535. */
  61536. transforms: TransformNode[];
  61537. /**
  61538. * All agents created
  61539. */
  61540. agents: number[];
  61541. /**
  61542. * Link to the scene is kept to unregister the crowd from the scene
  61543. */
  61544. private _scene;
  61545. /**
  61546. * Observer for crowd updates
  61547. */
  61548. private _onBeforeAnimationsObserver;
  61549. /**
  61550. * Constructor
  61551. * @param plugin recastJS plugin
  61552. * @param maxAgents the maximum agent count in the crowd
  61553. * @param maxAgentRadius the maximum radius an agent can have
  61554. * @param scene to attach the crowd to
  61555. * @returns the crowd you can add agents to
  61556. */
  61557. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61558. /**
  61559. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61560. * You can attach anything to that node. The node position is updated in the scene update tick.
  61561. * @param pos world position that will be constrained by the navigation mesh
  61562. * @param parameters agent parameters
  61563. * @param transform hooked to the agent that will be update by the scene
  61564. * @returns agent index
  61565. */
  61566. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61567. /**
  61568. * Returns the agent position in world space
  61569. * @param index agent index returned by addAgent
  61570. * @returns world space position
  61571. */
  61572. getAgentPosition(index: number): Vector3;
  61573. /**
  61574. * Returns the agent velocity in world space
  61575. * @param index agent index returned by addAgent
  61576. * @returns world space velocity
  61577. */
  61578. getAgentVelocity(index: number): Vector3;
  61579. /**
  61580. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61581. * @param index agent index returned by addAgent
  61582. * @param destination targeted world position
  61583. */
  61584. agentGoto(index: number, destination: Vector3): void;
  61585. /**
  61586. * remove a particular agent previously created
  61587. * @param index agent index returned by addAgent
  61588. */
  61589. removeAgent(index: number): void;
  61590. /**
  61591. * get the list of all agents attached to this crowd
  61592. * @returns list of agent indices
  61593. */
  61594. getAgents(): number[];
  61595. /**
  61596. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61597. * @param deltaTime in seconds
  61598. */
  61599. update(deltaTime: number): void;
  61600. /**
  61601. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61602. * The queries will try to find a solution within those bounds
  61603. * default is (1,1,1)
  61604. * @param extent x,y,z value that define the extent around the queries point of reference
  61605. */
  61606. setDefaultQueryExtent(extent: Vector3): void;
  61607. /**
  61608. * Get the Bounding box extent specified by setDefaultQueryExtent
  61609. * @returns the box extent values
  61610. */
  61611. getDefaultQueryExtent(): Vector3;
  61612. /**
  61613. * Release all resources
  61614. */
  61615. dispose(): void;
  61616. }
  61617. }
  61618. declare module "babylonjs/Navigation/Plugins/index" {
  61619. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61620. }
  61621. declare module "babylonjs/Navigation/index" {
  61622. export * from "babylonjs/Navigation/INavigationEngine";
  61623. export * from "babylonjs/Navigation/Plugins/index";
  61624. }
  61625. declare module "babylonjs/Offline/database" {
  61626. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61627. /**
  61628. * Class used to enable access to IndexedDB
  61629. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61630. */
  61631. export class Database implements IOfflineProvider {
  61632. private _callbackManifestChecked;
  61633. private _currentSceneUrl;
  61634. private _db;
  61635. private _enableSceneOffline;
  61636. private _enableTexturesOffline;
  61637. private _manifestVersionFound;
  61638. private _mustUpdateRessources;
  61639. private _hasReachedQuota;
  61640. private _isSupported;
  61641. private _idbFactory;
  61642. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61643. private static IsUASupportingBlobStorage;
  61644. /**
  61645. * Gets a boolean indicating if Database storate is enabled (off by default)
  61646. */
  61647. static IDBStorageEnabled: boolean;
  61648. /**
  61649. * Gets a boolean indicating if scene must be saved in the database
  61650. */
  61651. readonly enableSceneOffline: boolean;
  61652. /**
  61653. * Gets a boolean indicating if textures must be saved in the database
  61654. */
  61655. readonly enableTexturesOffline: boolean;
  61656. /**
  61657. * Creates a new Database
  61658. * @param urlToScene defines the url to load the scene
  61659. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61660. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61661. */
  61662. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61663. private static _ParseURL;
  61664. private static _ReturnFullUrlLocation;
  61665. private _checkManifestFile;
  61666. /**
  61667. * Open the database and make it available
  61668. * @param successCallback defines the callback to call on success
  61669. * @param errorCallback defines the callback to call on error
  61670. */
  61671. open(successCallback: () => void, errorCallback: () => void): void;
  61672. /**
  61673. * Loads an image from the database
  61674. * @param url defines the url to load from
  61675. * @param image defines the target DOM image
  61676. */
  61677. loadImage(url: string, image: HTMLImageElement): void;
  61678. private _loadImageFromDBAsync;
  61679. private _saveImageIntoDBAsync;
  61680. private _checkVersionFromDB;
  61681. private _loadVersionFromDBAsync;
  61682. private _saveVersionIntoDBAsync;
  61683. /**
  61684. * Loads a file from database
  61685. * @param url defines the URL to load from
  61686. * @param sceneLoaded defines a callback to call on success
  61687. * @param progressCallBack defines a callback to call when progress changed
  61688. * @param errorCallback defines a callback to call on error
  61689. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61690. */
  61691. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61692. private _loadFileAsync;
  61693. private _saveFileAsync;
  61694. /**
  61695. * Validates if xhr data is correct
  61696. * @param xhr defines the request to validate
  61697. * @param dataType defines the expected data type
  61698. * @returns true if data is correct
  61699. */
  61700. private static _ValidateXHRData;
  61701. }
  61702. }
  61703. declare module "babylonjs/Offline/index" {
  61704. export * from "babylonjs/Offline/database";
  61705. export * from "babylonjs/Offline/IOfflineProvider";
  61706. }
  61707. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61708. /** @hidden */
  61709. export var gpuUpdateParticlesPixelShader: {
  61710. name: string;
  61711. shader: string;
  61712. };
  61713. }
  61714. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61715. /** @hidden */
  61716. export var gpuUpdateParticlesVertexShader: {
  61717. name: string;
  61718. shader: string;
  61719. };
  61720. }
  61721. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61722. /** @hidden */
  61723. export var clipPlaneFragmentDeclaration2: {
  61724. name: string;
  61725. shader: string;
  61726. };
  61727. }
  61728. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61729. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61730. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61732. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61733. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61734. /** @hidden */
  61735. export var gpuRenderParticlesPixelShader: {
  61736. name: string;
  61737. shader: string;
  61738. };
  61739. }
  61740. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61741. /** @hidden */
  61742. export var clipPlaneVertexDeclaration2: {
  61743. name: string;
  61744. shader: string;
  61745. };
  61746. }
  61747. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61748. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61749. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61750. /** @hidden */
  61751. export var gpuRenderParticlesVertexShader: {
  61752. name: string;
  61753. shader: string;
  61754. };
  61755. }
  61756. declare module "babylonjs/Particles/gpuParticleSystem" {
  61757. import { Nullable } from "babylonjs/types";
  61758. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61759. import { Observable } from "babylonjs/Misc/observable";
  61760. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61761. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61762. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61763. import { Scene, IDisposable } from "babylonjs/scene";
  61764. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61765. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61766. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61767. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61768. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61769. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61770. /**
  61771. * This represents a GPU particle system in Babylon
  61772. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61773. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61774. */
  61775. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61776. /**
  61777. * The layer mask we are rendering the particles through.
  61778. */
  61779. layerMask: number;
  61780. private _capacity;
  61781. private _activeCount;
  61782. private _currentActiveCount;
  61783. private _accumulatedCount;
  61784. private _renderEffect;
  61785. private _updateEffect;
  61786. private _buffer0;
  61787. private _buffer1;
  61788. private _spriteBuffer;
  61789. private _updateVAO;
  61790. private _renderVAO;
  61791. private _targetIndex;
  61792. private _sourceBuffer;
  61793. private _targetBuffer;
  61794. private _engine;
  61795. private _currentRenderId;
  61796. private _started;
  61797. private _stopped;
  61798. private _timeDelta;
  61799. private _randomTexture;
  61800. private _randomTexture2;
  61801. private _attributesStrideSize;
  61802. private _updateEffectOptions;
  61803. private _randomTextureSize;
  61804. private _actualFrame;
  61805. private readonly _rawTextureWidth;
  61806. /**
  61807. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61808. */
  61809. static readonly IsSupported: boolean;
  61810. /**
  61811. * An event triggered when the system is disposed.
  61812. */
  61813. onDisposeObservable: Observable<GPUParticleSystem>;
  61814. /**
  61815. * Gets the maximum number of particles active at the same time.
  61816. * @returns The max number of active particles.
  61817. */
  61818. getCapacity(): number;
  61819. /**
  61820. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61821. * to override the particles.
  61822. */
  61823. forceDepthWrite: boolean;
  61824. /**
  61825. * Gets or set the number of active particles
  61826. */
  61827. activeParticleCount: number;
  61828. private _preWarmDone;
  61829. /**
  61830. * Is this system ready to be used/rendered
  61831. * @return true if the system is ready
  61832. */
  61833. isReady(): boolean;
  61834. /**
  61835. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61836. * @returns True if it has been started, otherwise false.
  61837. */
  61838. isStarted(): boolean;
  61839. /**
  61840. * Starts the particle system and begins to emit
  61841. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61842. */
  61843. start(delay?: number): void;
  61844. /**
  61845. * Stops the particle system.
  61846. */
  61847. stop(): void;
  61848. /**
  61849. * Remove all active particles
  61850. */
  61851. reset(): void;
  61852. /**
  61853. * Returns the string "GPUParticleSystem"
  61854. * @returns a string containing the class name
  61855. */
  61856. getClassName(): string;
  61857. private _colorGradientsTexture;
  61858. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61859. /**
  61860. * Adds a new color gradient
  61861. * @param gradient defines the gradient to use (between 0 and 1)
  61862. * @param color1 defines the color to affect to the specified gradient
  61863. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61864. * @returns the current particle system
  61865. */
  61866. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61867. /**
  61868. * Remove a specific color gradient
  61869. * @param gradient defines the gradient to remove
  61870. * @returns the current particle system
  61871. */
  61872. removeColorGradient(gradient: number): GPUParticleSystem;
  61873. private _angularSpeedGradientsTexture;
  61874. private _sizeGradientsTexture;
  61875. private _velocityGradientsTexture;
  61876. private _limitVelocityGradientsTexture;
  61877. private _dragGradientsTexture;
  61878. private _addFactorGradient;
  61879. /**
  61880. * Adds a new size gradient
  61881. * @param gradient defines the gradient to use (between 0 and 1)
  61882. * @param factor defines the size factor to affect to the specified gradient
  61883. * @returns the current particle system
  61884. */
  61885. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61886. /**
  61887. * Remove a specific size gradient
  61888. * @param gradient defines the gradient to remove
  61889. * @returns the current particle system
  61890. */
  61891. removeSizeGradient(gradient: number): GPUParticleSystem;
  61892. /**
  61893. * Adds a new angular speed gradient
  61894. * @param gradient defines the gradient to use (between 0 and 1)
  61895. * @param factor defines the angular speed to affect to the specified gradient
  61896. * @returns the current particle system
  61897. */
  61898. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61899. /**
  61900. * Remove a specific angular speed gradient
  61901. * @param gradient defines the gradient to remove
  61902. * @returns the current particle system
  61903. */
  61904. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61905. /**
  61906. * Adds a new velocity gradient
  61907. * @param gradient defines the gradient to use (between 0 and 1)
  61908. * @param factor defines the velocity to affect to the specified gradient
  61909. * @returns the current particle system
  61910. */
  61911. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61912. /**
  61913. * Remove a specific velocity gradient
  61914. * @param gradient defines the gradient to remove
  61915. * @returns the current particle system
  61916. */
  61917. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61918. /**
  61919. * Adds a new limit velocity gradient
  61920. * @param gradient defines the gradient to use (between 0 and 1)
  61921. * @param factor defines the limit velocity value to affect to the specified gradient
  61922. * @returns the current particle system
  61923. */
  61924. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61925. /**
  61926. * Remove a specific limit velocity gradient
  61927. * @param gradient defines the gradient to remove
  61928. * @returns the current particle system
  61929. */
  61930. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61931. /**
  61932. * Adds a new drag gradient
  61933. * @param gradient defines the gradient to use (between 0 and 1)
  61934. * @param factor defines the drag value to affect to the specified gradient
  61935. * @returns the current particle system
  61936. */
  61937. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61938. /**
  61939. * Remove a specific drag gradient
  61940. * @param gradient defines the gradient to remove
  61941. * @returns the current particle system
  61942. */
  61943. removeDragGradient(gradient: number): GPUParticleSystem;
  61944. /**
  61945. * Not supported by GPUParticleSystem
  61946. * @param gradient defines the gradient to use (between 0 and 1)
  61947. * @param factor defines the emit rate value to affect to the specified gradient
  61948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61949. * @returns the current particle system
  61950. */
  61951. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61952. /**
  61953. * Not supported by GPUParticleSystem
  61954. * @param gradient defines the gradient to remove
  61955. * @returns the current particle system
  61956. */
  61957. removeEmitRateGradient(gradient: number): IParticleSystem;
  61958. /**
  61959. * Not supported by GPUParticleSystem
  61960. * @param gradient defines the gradient to use (between 0 and 1)
  61961. * @param factor defines the start size value to affect to the specified gradient
  61962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61963. * @returns the current particle system
  61964. */
  61965. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61966. /**
  61967. * Not supported by GPUParticleSystem
  61968. * @param gradient defines the gradient to remove
  61969. * @returns the current particle system
  61970. */
  61971. removeStartSizeGradient(gradient: number): IParticleSystem;
  61972. /**
  61973. * Not supported by GPUParticleSystem
  61974. * @param gradient defines the gradient to use (between 0 and 1)
  61975. * @param min defines the color remap minimal range
  61976. * @param max defines the color remap maximal range
  61977. * @returns the current particle system
  61978. */
  61979. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61980. /**
  61981. * Not supported by GPUParticleSystem
  61982. * @param gradient defines the gradient to remove
  61983. * @returns the current particle system
  61984. */
  61985. removeColorRemapGradient(): IParticleSystem;
  61986. /**
  61987. * Not supported by GPUParticleSystem
  61988. * @param gradient defines the gradient to use (between 0 and 1)
  61989. * @param min defines the alpha remap minimal range
  61990. * @param max defines the alpha remap maximal range
  61991. * @returns the current particle system
  61992. */
  61993. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61994. /**
  61995. * Not supported by GPUParticleSystem
  61996. * @param gradient defines the gradient to remove
  61997. * @returns the current particle system
  61998. */
  61999. removeAlphaRemapGradient(): IParticleSystem;
  62000. /**
  62001. * Not supported by GPUParticleSystem
  62002. * @param gradient defines the gradient to use (between 0 and 1)
  62003. * @param color defines the color to affect to the specified gradient
  62004. * @returns the current particle system
  62005. */
  62006. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62007. /**
  62008. * Not supported by GPUParticleSystem
  62009. * @param gradient defines the gradient to remove
  62010. * @returns the current particle system
  62011. */
  62012. removeRampGradient(): IParticleSystem;
  62013. /**
  62014. * Not supported by GPUParticleSystem
  62015. * @returns the list of ramp gradients
  62016. */
  62017. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62018. /**
  62019. * Not supported by GPUParticleSystem
  62020. * Gets or sets a boolean indicating that ramp gradients must be used
  62021. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62022. */
  62023. useRampGradients: boolean;
  62024. /**
  62025. * Not supported by GPUParticleSystem
  62026. * @param gradient defines the gradient to use (between 0 and 1)
  62027. * @param factor defines the life time factor to affect to the specified gradient
  62028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62029. * @returns the current particle system
  62030. */
  62031. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62032. /**
  62033. * Not supported by GPUParticleSystem
  62034. * @param gradient defines the gradient to remove
  62035. * @returns the current particle system
  62036. */
  62037. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62038. /**
  62039. * Instantiates a GPU particle system.
  62040. * 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.
  62041. * @param name The name of the particle system
  62042. * @param options The options used to create the system
  62043. * @param scene The scene the particle system belongs to
  62044. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62045. */
  62046. constructor(name: string, options: Partial<{
  62047. capacity: number;
  62048. randomTextureSize: number;
  62049. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62050. protected _reset(): void;
  62051. private _createUpdateVAO;
  62052. private _createRenderVAO;
  62053. private _initialize;
  62054. /** @hidden */
  62055. _recreateUpdateEffect(): void;
  62056. /** @hidden */
  62057. _recreateRenderEffect(): void;
  62058. /**
  62059. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62060. * @param preWarm defines if we are in the pre-warmimg phase
  62061. */
  62062. animate(preWarm?: boolean): void;
  62063. private _createFactorGradientTexture;
  62064. private _createSizeGradientTexture;
  62065. private _createAngularSpeedGradientTexture;
  62066. private _createVelocityGradientTexture;
  62067. private _createLimitVelocityGradientTexture;
  62068. private _createDragGradientTexture;
  62069. private _createColorGradientTexture;
  62070. /**
  62071. * Renders the particle system in its current state
  62072. * @param preWarm defines if the system should only update the particles but not render them
  62073. * @returns the current number of particles
  62074. */
  62075. render(preWarm?: boolean): number;
  62076. /**
  62077. * Rebuilds the particle system
  62078. */
  62079. rebuild(): void;
  62080. private _releaseBuffers;
  62081. private _releaseVAOs;
  62082. /**
  62083. * Disposes the particle system and free the associated resources
  62084. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62085. */
  62086. dispose(disposeTexture?: boolean): void;
  62087. /**
  62088. * Clones the particle system.
  62089. * @param name The name of the cloned object
  62090. * @param newEmitter The new emitter to use
  62091. * @returns the cloned particle system
  62092. */
  62093. clone(name: string, newEmitter: any): GPUParticleSystem;
  62094. /**
  62095. * Serializes the particle system to a JSON object.
  62096. * @returns the JSON object
  62097. */
  62098. serialize(): any;
  62099. /**
  62100. * Parses a JSON object to create a GPU particle system.
  62101. * @param parsedParticleSystem The JSON object to parse
  62102. * @param scene The scene to create the particle system in
  62103. * @param rootUrl The root url to use to load external dependencies like texture
  62104. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62105. * @returns the parsed GPU particle system
  62106. */
  62107. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62108. }
  62109. }
  62110. declare module "babylonjs/Particles/particleSystemSet" {
  62111. import { Nullable } from "babylonjs/types";
  62112. import { Color3 } from "babylonjs/Maths/math.color";
  62113. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62116. import { Scene, IDisposable } from "babylonjs/scene";
  62117. /**
  62118. * Represents a set of particle systems working together to create a specific effect
  62119. */
  62120. export class ParticleSystemSet implements IDisposable {
  62121. /**
  62122. * Gets or sets base Assets URL
  62123. */
  62124. static BaseAssetsUrl: string;
  62125. private _emitterCreationOptions;
  62126. private _emitterNode;
  62127. /**
  62128. * Gets the particle system list
  62129. */
  62130. systems: IParticleSystem[];
  62131. /**
  62132. * Gets the emitter node used with this set
  62133. */
  62134. readonly emitterNode: Nullable<TransformNode>;
  62135. /**
  62136. * Creates a new emitter mesh as a sphere
  62137. * @param options defines the options used to create the sphere
  62138. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62139. * @param scene defines the hosting scene
  62140. */
  62141. setEmitterAsSphere(options: {
  62142. diameter: number;
  62143. segments: number;
  62144. color: Color3;
  62145. }, renderingGroupId: number, scene: Scene): void;
  62146. /**
  62147. * Starts all particle systems of the set
  62148. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62149. */
  62150. start(emitter?: AbstractMesh): void;
  62151. /**
  62152. * Release all associated resources
  62153. */
  62154. dispose(): void;
  62155. /**
  62156. * Serialize the set into a JSON compatible object
  62157. * @returns a JSON compatible representation of the set
  62158. */
  62159. serialize(): any;
  62160. /**
  62161. * Parse a new ParticleSystemSet from a serialized source
  62162. * @param data defines a JSON compatible representation of the set
  62163. * @param scene defines the hosting scene
  62164. * @param gpu defines if we want GPU particles or CPU particles
  62165. * @returns a new ParticleSystemSet
  62166. */
  62167. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62168. }
  62169. }
  62170. declare module "babylonjs/Particles/particleHelper" {
  62171. import { Nullable } from "babylonjs/types";
  62172. import { Scene } from "babylonjs/scene";
  62173. import { Vector3 } from "babylonjs/Maths/math.vector";
  62174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62175. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62176. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62177. /**
  62178. * This class is made for on one-liner static method to help creating particle system set.
  62179. */
  62180. export class ParticleHelper {
  62181. /**
  62182. * Gets or sets base Assets URL
  62183. */
  62184. static BaseAssetsUrl: string;
  62185. /**
  62186. * Create a default particle system that you can tweak
  62187. * @param emitter defines the emitter to use
  62188. * @param capacity defines the system capacity (default is 500 particles)
  62189. * @param scene defines the hosting scene
  62190. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62191. * @returns the new Particle system
  62192. */
  62193. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62194. /**
  62195. * This is the main static method (one-liner) of this helper to create different particle systems
  62196. * @param type This string represents the type to the particle system to create
  62197. * @param scene The scene where the particle system should live
  62198. * @param gpu If the system will use gpu
  62199. * @returns the ParticleSystemSet created
  62200. */
  62201. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62202. /**
  62203. * Static function used to export a particle system to a ParticleSystemSet variable.
  62204. * Please note that the emitter shape is not exported
  62205. * @param systems defines the particle systems to export
  62206. * @returns the created particle system set
  62207. */
  62208. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62209. }
  62210. }
  62211. declare module "babylonjs/Particles/particleSystemComponent" {
  62212. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62213. import { Effect } from "babylonjs/Materials/effect";
  62214. import "babylonjs/Shaders/particles.vertex";
  62215. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62216. module "babylonjs/Engines/engine" {
  62217. interface Engine {
  62218. /**
  62219. * Create an effect to use with particle systems.
  62220. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62221. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62222. * @param uniformsNames defines a list of attribute names
  62223. * @param samplers defines an array of string used to represent textures
  62224. * @param defines defines the string containing the defines to use to compile the shaders
  62225. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62226. * @param onCompiled defines a function to call when the effect creation is successful
  62227. * @param onError defines a function to call when the effect creation has failed
  62228. * @returns the new Effect
  62229. */
  62230. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62231. }
  62232. }
  62233. module "babylonjs/Meshes/mesh" {
  62234. interface Mesh {
  62235. /**
  62236. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62237. * @returns an array of IParticleSystem
  62238. */
  62239. getEmittedParticleSystems(): IParticleSystem[];
  62240. /**
  62241. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62242. * @returns an array of IParticleSystem
  62243. */
  62244. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62245. }
  62246. }
  62247. /**
  62248. * @hidden
  62249. */
  62250. export var _IDoNeedToBeInTheBuild: number;
  62251. }
  62252. declare module "babylonjs/Particles/pointsCloudSystem" {
  62253. import { Color4 } from "babylonjs/Maths/math";
  62254. import { Mesh } from "babylonjs/Meshes/mesh";
  62255. import { Scene, IDisposable } from "babylonjs/scene";
  62256. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62257. /** Defines the 4 color options */
  62258. export enum PointColor {
  62259. /** color value */
  62260. Color = 2,
  62261. /** uv value */
  62262. UV = 1,
  62263. /** random value */
  62264. Random = 0,
  62265. /** stated value */
  62266. Stated = 3
  62267. }
  62268. /**
  62269. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62270. * 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.
  62271. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62272. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62273. *
  62274. * Full documentation here : TO BE ENTERED
  62275. */
  62276. export class PointsCloudSystem implements IDisposable {
  62277. /**
  62278. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62279. * Example : var p = SPS.particles[i];
  62280. */
  62281. particles: CloudPoint[];
  62282. /**
  62283. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62284. */
  62285. nbParticles: number;
  62286. /**
  62287. * This a counter for your own usage. It's not set by any SPS functions.
  62288. */
  62289. counter: number;
  62290. /**
  62291. * The PCS name. This name is also given to the underlying mesh.
  62292. */
  62293. name: string;
  62294. /**
  62295. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62296. */
  62297. mesh: Mesh;
  62298. /**
  62299. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62300. * Please read :
  62301. */
  62302. vars: any;
  62303. /**
  62304. * @hidden
  62305. */
  62306. _size: number;
  62307. private _scene;
  62308. private _promises;
  62309. private _positions;
  62310. private _indices;
  62311. private _normals;
  62312. private _colors;
  62313. private _uvs;
  62314. private _indices32;
  62315. private _positions32;
  62316. private _colors32;
  62317. private _uvs32;
  62318. private _updatable;
  62319. private _isVisibilityBoxLocked;
  62320. private _alwaysVisible;
  62321. private _groups;
  62322. private _groupCounter;
  62323. private _computeParticleColor;
  62324. private _computeParticleTexture;
  62325. private _computeParticleRotation;
  62326. private _computeBoundingBox;
  62327. private _isReady;
  62328. /**
  62329. * Creates a PCS (Points Cloud System) object
  62330. * @param name (String) is the PCS name, this will be the underlying mesh name
  62331. * @param pointSize (number) is the size for each point
  62332. * @param scene (Scene) is the scene in which the PCS is added
  62333. * @param options defines the options of the PCS e.g.
  62334. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62335. */
  62336. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62337. updatable?: boolean;
  62338. });
  62339. /**
  62340. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62341. * If no points were added to the PCS, the returned mesh is just a single point.
  62342. * @returns a promise for the created mesh
  62343. */
  62344. buildMeshAsync(): Promise<Mesh>;
  62345. /**
  62346. * @hidden
  62347. */
  62348. private _buildMesh;
  62349. private _addParticle;
  62350. private _randomUnitVector;
  62351. private _getColorIndicesForCoord;
  62352. private _setPointsColorOrUV;
  62353. private _colorFromTexture;
  62354. private _calculateDensity;
  62355. /**
  62356. * Adds points to the PCS in random positions within a unit sphere
  62357. * @param nb (positive integer) the number of particles to be created from this model
  62358. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62359. * @returns the number of groups in the system
  62360. */
  62361. addPoints(nb: number, pointFunction?: any): number;
  62362. /**
  62363. * Adds points to the PCS from the surface of the model shape
  62364. * @param mesh is any Mesh object that will be used as a surface model for the points
  62365. * @param nb (positive integer) the number of particles to be created from this model
  62366. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62367. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62368. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62369. * @returns the number of groups in the system
  62370. */
  62371. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62372. /**
  62373. * Adds points to the PCS inside the model shape
  62374. * @param mesh is any Mesh object that will be used as a surface model for the points
  62375. * @param nb (positive integer) the number of particles to be created from this model
  62376. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62377. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62378. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62379. * @returns the number of groups in the system
  62380. */
  62381. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62382. /**
  62383. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62384. * This method calls `updateParticle()` for each particle of the SPS.
  62385. * For an animated SPS, it is usually called within the render loop.
  62386. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62387. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62388. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62389. * @returns the PCS.
  62390. */
  62391. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62392. /**
  62393. * Disposes the PCS.
  62394. */
  62395. dispose(): void;
  62396. /**
  62397. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62398. * doc :
  62399. * @returns the PCS.
  62400. */
  62401. refreshVisibleSize(): PointsCloudSystem;
  62402. /**
  62403. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62404. * @param size the size (float) of the visibility box
  62405. * note : this doesn't lock the PCS mesh bounding box.
  62406. * doc :
  62407. */
  62408. setVisibilityBox(size: number): void;
  62409. /**
  62410. * Gets whether the PCS is always visible or not
  62411. * doc :
  62412. */
  62413. /**
  62414. * Sets the PCS as always visible or not
  62415. * doc :
  62416. */
  62417. isAlwaysVisible: boolean;
  62418. /**
  62419. * Tells to `setParticles()` to compute the particle rotations or not
  62420. * Default value : false. The PCS is faster when it's set to false
  62421. * Note : particle rotations are only applied to parent particles
  62422. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62423. */
  62424. computeParticleRotation: boolean;
  62425. /**
  62426. * Tells to `setParticles()` to compute the particle colors or not.
  62427. * Default value : true. The PCS is faster when it's set to false.
  62428. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62429. */
  62430. /**
  62431. * Gets if `setParticles()` computes the particle colors or not.
  62432. * Default value : false. The PCS is faster when it's set to false.
  62433. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62434. */
  62435. computeParticleColor: boolean;
  62436. /**
  62437. * Gets if `setParticles()` computes the particle textures or not.
  62438. * Default value : false. The PCS is faster when it's set to false.
  62439. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62440. */
  62441. computeParticleTexture: boolean;
  62442. /**
  62443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62444. */
  62445. /**
  62446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62447. */
  62448. computeBoundingBox: boolean;
  62449. /**
  62450. * This function does nothing. It may be overwritten to set all the particle first values.
  62451. * The PCS doesn't call this function, you may have to call it by your own.
  62452. * doc :
  62453. */
  62454. initParticles(): void;
  62455. /**
  62456. * This function does nothing. It may be overwritten to recycle a particle
  62457. * The PCS doesn't call this function, you can to call it
  62458. * doc :
  62459. * @param particle The particle to recycle
  62460. * @returns the recycled particle
  62461. */
  62462. recycleParticle(particle: CloudPoint): CloudPoint;
  62463. /**
  62464. * Updates a particle : this function should be overwritten by the user.
  62465. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62466. * doc :
  62467. * @example : just set a particle position or velocity and recycle conditions
  62468. * @param particle The particle to update
  62469. * @returns the updated particle
  62470. */
  62471. updateParticle(particle: CloudPoint): CloudPoint;
  62472. /**
  62473. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62474. * This does nothing and may be overwritten by the user.
  62475. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62476. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62477. * @param update the boolean update value actually passed to setParticles()
  62478. */
  62479. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62480. /**
  62481. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62482. * This will be passed three parameters.
  62483. * This does nothing and may be overwritten by the user.
  62484. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62485. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62486. * @param update the boolean update value actually passed to setParticles()
  62487. */
  62488. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62489. }
  62490. }
  62491. declare module "babylonjs/Particles/cloudPoint" {
  62492. import { Nullable } from "babylonjs/types";
  62493. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62494. import { Mesh } from "babylonjs/Meshes/mesh";
  62495. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62496. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62497. /**
  62498. * Represents one particle of a points cloud system.
  62499. */
  62500. export class CloudPoint {
  62501. /**
  62502. * particle global index
  62503. */
  62504. idx: number;
  62505. /**
  62506. * The color of the particle
  62507. */
  62508. color: Nullable<Color4>;
  62509. /**
  62510. * The world space position of the particle.
  62511. */
  62512. position: Vector3;
  62513. /**
  62514. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62515. */
  62516. rotation: Vector3;
  62517. /**
  62518. * The world space rotation quaternion of the particle.
  62519. */
  62520. rotationQuaternion: Nullable<Quaternion>;
  62521. /**
  62522. * The uv of the particle.
  62523. */
  62524. uv: Nullable<Vector2>;
  62525. /**
  62526. * The current speed of the particle.
  62527. */
  62528. velocity: Vector3;
  62529. /**
  62530. * The pivot point in the particle local space.
  62531. */
  62532. pivot: Vector3;
  62533. /**
  62534. * Must the particle be translated from its pivot point in its local space ?
  62535. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62536. * Default : false
  62537. */
  62538. translateFromPivot: boolean;
  62539. /**
  62540. * Index of this particle in the global "positions" array (Internal use)
  62541. * @hidden
  62542. */
  62543. _pos: number;
  62544. /**
  62545. * @hidden Index of this particle in the global "indices" array (Internal use)
  62546. */
  62547. _ind: number;
  62548. /**
  62549. * Group this particle belongs to
  62550. */
  62551. _group: PointsGroup;
  62552. /**
  62553. * Group id of this particle
  62554. */
  62555. groupId: number;
  62556. /**
  62557. * Index of the particle in its group id (Internal use)
  62558. */
  62559. idxInGroup: number;
  62560. /**
  62561. * @hidden Particle BoundingInfo object (Internal use)
  62562. */
  62563. _boundingInfo: BoundingInfo;
  62564. /**
  62565. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62566. */
  62567. _pcs: PointsCloudSystem;
  62568. /**
  62569. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62570. */
  62571. _stillInvisible: boolean;
  62572. /**
  62573. * @hidden Last computed particle rotation matrix
  62574. */
  62575. _rotationMatrix: number[];
  62576. /**
  62577. * Parent particle Id, if any.
  62578. * Default null.
  62579. */
  62580. parentId: Nullable<number>;
  62581. /**
  62582. * @hidden Internal global position in the PCS.
  62583. */
  62584. _globalPosition: Vector3;
  62585. /**
  62586. * Creates a Point Cloud object.
  62587. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62588. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62589. * @param group (PointsGroup) is the group the particle belongs to
  62590. * @param groupId (integer) is the group identifier in the PCS.
  62591. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62592. * @param pcs defines the PCS it is associated to
  62593. */
  62594. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62595. /**
  62596. * get point size
  62597. */
  62598. /**
  62599. * Set point size
  62600. */
  62601. size: Vector3;
  62602. /**
  62603. * Legacy support, changed quaternion to rotationQuaternion
  62604. */
  62605. /**
  62606. * Legacy support, changed quaternion to rotationQuaternion
  62607. */
  62608. quaternion: Nullable<Quaternion>;
  62609. /**
  62610. * Returns a boolean. True if the particle intersects a mesh, else false
  62611. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62612. * @param target is the object (point or mesh) what the intersection is computed against
  62613. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62614. * @returns true if it intersects
  62615. */
  62616. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62617. /**
  62618. * get the rotation matrix of the particle
  62619. * @hidden
  62620. */
  62621. getRotationMatrix(m: Matrix): void;
  62622. }
  62623. /**
  62624. * Represents a group of points in a points cloud system
  62625. * * PCS internal tool, don't use it manually.
  62626. */
  62627. export class PointsGroup {
  62628. /**
  62629. * The group id
  62630. * @hidden
  62631. */
  62632. groupID: number;
  62633. /**
  62634. * image data for group (internal use)
  62635. * @hidden
  62636. */
  62637. _groupImageData: Nullable<ArrayBufferView>;
  62638. /**
  62639. * Image Width (internal use)
  62640. * @hidden
  62641. */
  62642. _groupImgWidth: number;
  62643. /**
  62644. * Image Height (internal use)
  62645. * @hidden
  62646. */
  62647. _groupImgHeight: number;
  62648. /**
  62649. * Custom position function (internal use)
  62650. * @hidden
  62651. */
  62652. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62653. /**
  62654. * density per facet for surface points
  62655. * @hidden
  62656. */
  62657. _groupDensity: number[];
  62658. /**
  62659. * Only when points are colored by texture carries pointer to texture list array
  62660. * @hidden
  62661. */
  62662. _textureNb: number;
  62663. /**
  62664. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62665. * PCS internal tool, don't use it manually.
  62666. * @hidden
  62667. */
  62668. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62669. }
  62670. }
  62671. declare module "babylonjs/Particles/index" {
  62672. export * from "babylonjs/Particles/baseParticleSystem";
  62673. export * from "babylonjs/Particles/EmitterTypes/index";
  62674. export * from "babylonjs/Particles/gpuParticleSystem";
  62675. export * from "babylonjs/Particles/IParticleSystem";
  62676. export * from "babylonjs/Particles/particle";
  62677. export * from "babylonjs/Particles/particleHelper";
  62678. export * from "babylonjs/Particles/particleSystem";
  62679. export * from "babylonjs/Particles/particleSystemComponent";
  62680. export * from "babylonjs/Particles/particleSystemSet";
  62681. export * from "babylonjs/Particles/solidParticle";
  62682. export * from "babylonjs/Particles/solidParticleSystem";
  62683. export * from "babylonjs/Particles/cloudPoint";
  62684. export * from "babylonjs/Particles/pointsCloudSystem";
  62685. export * from "babylonjs/Particles/subEmitter";
  62686. }
  62687. declare module "babylonjs/Physics/physicsEngineComponent" {
  62688. import { Nullable } from "babylonjs/types";
  62689. import { Observable, Observer } from "babylonjs/Misc/observable";
  62690. import { Vector3 } from "babylonjs/Maths/math.vector";
  62691. import { Mesh } from "babylonjs/Meshes/mesh";
  62692. import { ISceneComponent } from "babylonjs/sceneComponent";
  62693. import { Scene } from "babylonjs/scene";
  62694. import { Node } from "babylonjs/node";
  62695. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62696. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62697. module "babylonjs/scene" {
  62698. interface Scene {
  62699. /** @hidden (Backing field) */
  62700. _physicsEngine: Nullable<IPhysicsEngine>;
  62701. /**
  62702. * Gets the current physics engine
  62703. * @returns a IPhysicsEngine or null if none attached
  62704. */
  62705. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62706. /**
  62707. * Enables physics to the current scene
  62708. * @param gravity defines the scene's gravity for the physics engine
  62709. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62710. * @return a boolean indicating if the physics engine was initialized
  62711. */
  62712. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62713. /**
  62714. * Disables and disposes the physics engine associated with the scene
  62715. */
  62716. disablePhysicsEngine(): void;
  62717. /**
  62718. * Gets a boolean indicating if there is an active physics engine
  62719. * @returns a boolean indicating if there is an active physics engine
  62720. */
  62721. isPhysicsEnabled(): boolean;
  62722. /**
  62723. * Deletes a physics compound impostor
  62724. * @param compound defines the compound to delete
  62725. */
  62726. deleteCompoundImpostor(compound: any): void;
  62727. /**
  62728. * An event triggered when physic simulation is about to be run
  62729. */
  62730. onBeforePhysicsObservable: Observable<Scene>;
  62731. /**
  62732. * An event triggered when physic simulation has been done
  62733. */
  62734. onAfterPhysicsObservable: Observable<Scene>;
  62735. }
  62736. }
  62737. module "babylonjs/Meshes/abstractMesh" {
  62738. interface AbstractMesh {
  62739. /** @hidden */
  62740. _physicsImpostor: Nullable<PhysicsImpostor>;
  62741. /**
  62742. * Gets or sets impostor used for physic simulation
  62743. * @see http://doc.babylonjs.com/features/physics_engine
  62744. */
  62745. physicsImpostor: Nullable<PhysicsImpostor>;
  62746. /**
  62747. * Gets the current physics impostor
  62748. * @see http://doc.babylonjs.com/features/physics_engine
  62749. * @returns a physics impostor or null
  62750. */
  62751. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62752. /** Apply a physic impulse to the mesh
  62753. * @param force defines the force to apply
  62754. * @param contactPoint defines where to apply the force
  62755. * @returns the current mesh
  62756. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62757. */
  62758. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62759. /**
  62760. * Creates a physic joint between two meshes
  62761. * @param otherMesh defines the other mesh to use
  62762. * @param pivot1 defines the pivot to use on this mesh
  62763. * @param pivot2 defines the pivot to use on the other mesh
  62764. * @param options defines additional options (can be plugin dependent)
  62765. * @returns the current mesh
  62766. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62767. */
  62768. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62769. /** @hidden */
  62770. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62771. }
  62772. }
  62773. /**
  62774. * Defines the physics engine scene component responsible to manage a physics engine
  62775. */
  62776. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62777. /**
  62778. * The component name helpful to identify the component in the list of scene components.
  62779. */
  62780. readonly name: string;
  62781. /**
  62782. * The scene the component belongs to.
  62783. */
  62784. scene: Scene;
  62785. /**
  62786. * Creates a new instance of the component for the given scene
  62787. * @param scene Defines the scene to register the component in
  62788. */
  62789. constructor(scene: Scene);
  62790. /**
  62791. * Registers the component in a given scene
  62792. */
  62793. register(): void;
  62794. /**
  62795. * Rebuilds the elements related to this component in case of
  62796. * context lost for instance.
  62797. */
  62798. rebuild(): void;
  62799. /**
  62800. * Disposes the component and the associated ressources
  62801. */
  62802. dispose(): void;
  62803. }
  62804. }
  62805. declare module "babylonjs/Physics/physicsHelper" {
  62806. import { Nullable } from "babylonjs/types";
  62807. import { Vector3 } from "babylonjs/Maths/math.vector";
  62808. import { Mesh } from "babylonjs/Meshes/mesh";
  62809. import { Scene } from "babylonjs/scene";
  62810. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62811. /**
  62812. * A helper for physics simulations
  62813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62814. */
  62815. export class PhysicsHelper {
  62816. private _scene;
  62817. private _physicsEngine;
  62818. /**
  62819. * Initializes the Physics helper
  62820. * @param scene Babylon.js scene
  62821. */
  62822. constructor(scene: Scene);
  62823. /**
  62824. * Applies a radial explosion impulse
  62825. * @param origin the origin of the explosion
  62826. * @param radiusOrEventOptions the radius or the options of radial explosion
  62827. * @param strength the explosion strength
  62828. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62829. * @returns A physics radial explosion event, or null
  62830. */
  62831. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62832. /**
  62833. * Applies a radial explosion force
  62834. * @param origin the origin of the explosion
  62835. * @param radiusOrEventOptions the radius or the options of radial explosion
  62836. * @param strength the explosion strength
  62837. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62838. * @returns A physics radial explosion event, or null
  62839. */
  62840. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62841. /**
  62842. * Creates a gravitational field
  62843. * @param origin the origin of the explosion
  62844. * @param radiusOrEventOptions the radius or the options of radial explosion
  62845. * @param strength the explosion strength
  62846. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62847. * @returns A physics gravitational field event, or null
  62848. */
  62849. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62850. /**
  62851. * Creates a physics updraft event
  62852. * @param origin the origin of the updraft
  62853. * @param radiusOrEventOptions the radius or the options of the updraft
  62854. * @param strength the strength of the updraft
  62855. * @param height the height of the updraft
  62856. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62857. * @returns A physics updraft event, or null
  62858. */
  62859. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62860. /**
  62861. * Creates a physics vortex event
  62862. * @param origin the of the vortex
  62863. * @param radiusOrEventOptions the radius or the options of the vortex
  62864. * @param strength the strength of the vortex
  62865. * @param height the height of the vortex
  62866. * @returns a Physics vortex event, or null
  62867. * A physics vortex event or null
  62868. */
  62869. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62870. }
  62871. /**
  62872. * Represents a physics radial explosion event
  62873. */
  62874. class PhysicsRadialExplosionEvent {
  62875. private _scene;
  62876. private _options;
  62877. private _sphere;
  62878. private _dataFetched;
  62879. /**
  62880. * Initializes a radial explosioin event
  62881. * @param _scene BabylonJS scene
  62882. * @param _options The options for the vortex event
  62883. */
  62884. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62885. /**
  62886. * Returns the data related to the radial explosion event (sphere).
  62887. * @returns The radial explosion event data
  62888. */
  62889. getData(): PhysicsRadialExplosionEventData;
  62890. /**
  62891. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62892. * @param impostor A physics imposter
  62893. * @param origin the origin of the explosion
  62894. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62895. */
  62896. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62897. /**
  62898. * Triggers affecterd impostors callbacks
  62899. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62900. */
  62901. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62902. /**
  62903. * Disposes the sphere.
  62904. * @param force Specifies if the sphere should be disposed by force
  62905. */
  62906. dispose(force?: boolean): void;
  62907. /*** Helpers ***/
  62908. private _prepareSphere;
  62909. private _intersectsWithSphere;
  62910. }
  62911. /**
  62912. * Represents a gravitational field event
  62913. */
  62914. class PhysicsGravitationalFieldEvent {
  62915. private _physicsHelper;
  62916. private _scene;
  62917. private _origin;
  62918. private _options;
  62919. private _tickCallback;
  62920. private _sphere;
  62921. private _dataFetched;
  62922. /**
  62923. * Initializes the physics gravitational field event
  62924. * @param _physicsHelper A physics helper
  62925. * @param _scene BabylonJS scene
  62926. * @param _origin The origin position of the gravitational field event
  62927. * @param _options The options for the vortex event
  62928. */
  62929. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62930. /**
  62931. * Returns the data related to the gravitational field event (sphere).
  62932. * @returns A gravitational field event
  62933. */
  62934. getData(): PhysicsGravitationalFieldEventData;
  62935. /**
  62936. * Enables the gravitational field.
  62937. */
  62938. enable(): void;
  62939. /**
  62940. * Disables the gravitational field.
  62941. */
  62942. disable(): void;
  62943. /**
  62944. * Disposes the sphere.
  62945. * @param force The force to dispose from the gravitational field event
  62946. */
  62947. dispose(force?: boolean): void;
  62948. private _tick;
  62949. }
  62950. /**
  62951. * Represents a physics updraft event
  62952. */
  62953. class PhysicsUpdraftEvent {
  62954. private _scene;
  62955. private _origin;
  62956. private _options;
  62957. private _physicsEngine;
  62958. private _originTop;
  62959. private _originDirection;
  62960. private _tickCallback;
  62961. private _cylinder;
  62962. private _cylinderPosition;
  62963. private _dataFetched;
  62964. /**
  62965. * Initializes the physics updraft event
  62966. * @param _scene BabylonJS scene
  62967. * @param _origin The origin position of the updraft
  62968. * @param _options The options for the updraft event
  62969. */
  62970. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62971. /**
  62972. * Returns the data related to the updraft event (cylinder).
  62973. * @returns A physics updraft event
  62974. */
  62975. getData(): PhysicsUpdraftEventData;
  62976. /**
  62977. * Enables the updraft.
  62978. */
  62979. enable(): void;
  62980. /**
  62981. * Disables the updraft.
  62982. */
  62983. disable(): void;
  62984. /**
  62985. * Disposes the cylinder.
  62986. * @param force Specifies if the updraft should be disposed by force
  62987. */
  62988. dispose(force?: boolean): void;
  62989. private getImpostorHitData;
  62990. private _tick;
  62991. /*** Helpers ***/
  62992. private _prepareCylinder;
  62993. private _intersectsWithCylinder;
  62994. }
  62995. /**
  62996. * Represents a physics vortex event
  62997. */
  62998. class PhysicsVortexEvent {
  62999. private _scene;
  63000. private _origin;
  63001. private _options;
  63002. private _physicsEngine;
  63003. private _originTop;
  63004. private _tickCallback;
  63005. private _cylinder;
  63006. private _cylinderPosition;
  63007. private _dataFetched;
  63008. /**
  63009. * Initializes the physics vortex event
  63010. * @param _scene The BabylonJS scene
  63011. * @param _origin The origin position of the vortex
  63012. * @param _options The options for the vortex event
  63013. */
  63014. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63015. /**
  63016. * Returns the data related to the vortex event (cylinder).
  63017. * @returns The physics vortex event data
  63018. */
  63019. getData(): PhysicsVortexEventData;
  63020. /**
  63021. * Enables the vortex.
  63022. */
  63023. enable(): void;
  63024. /**
  63025. * Disables the cortex.
  63026. */
  63027. disable(): void;
  63028. /**
  63029. * Disposes the sphere.
  63030. * @param force
  63031. */
  63032. dispose(force?: boolean): void;
  63033. private getImpostorHitData;
  63034. private _tick;
  63035. /*** Helpers ***/
  63036. private _prepareCylinder;
  63037. private _intersectsWithCylinder;
  63038. }
  63039. /**
  63040. * Options fot the radial explosion event
  63041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63042. */
  63043. export class PhysicsRadialExplosionEventOptions {
  63044. /**
  63045. * The radius of the sphere for the radial explosion.
  63046. */
  63047. radius: number;
  63048. /**
  63049. * The strenth of the explosion.
  63050. */
  63051. strength: number;
  63052. /**
  63053. * The strenght of the force in correspondence to the distance of the affected object
  63054. */
  63055. falloff: PhysicsRadialImpulseFalloff;
  63056. /**
  63057. * Sphere options for the radial explosion.
  63058. */
  63059. sphere: {
  63060. segments: number;
  63061. diameter: number;
  63062. };
  63063. /**
  63064. * Sphere options for the radial explosion.
  63065. */
  63066. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63067. }
  63068. /**
  63069. * Options fot the updraft event
  63070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63071. */
  63072. export class PhysicsUpdraftEventOptions {
  63073. /**
  63074. * The radius of the cylinder for the vortex
  63075. */
  63076. radius: number;
  63077. /**
  63078. * The strenth of the updraft.
  63079. */
  63080. strength: number;
  63081. /**
  63082. * The height of the cylinder for the updraft.
  63083. */
  63084. height: number;
  63085. /**
  63086. * The mode for the the updraft.
  63087. */
  63088. updraftMode: PhysicsUpdraftMode;
  63089. }
  63090. /**
  63091. * Options fot the vortex event
  63092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63093. */
  63094. export class PhysicsVortexEventOptions {
  63095. /**
  63096. * The radius of the cylinder for the vortex
  63097. */
  63098. radius: number;
  63099. /**
  63100. * The strenth of the vortex.
  63101. */
  63102. strength: number;
  63103. /**
  63104. * The height of the cylinder for the vortex.
  63105. */
  63106. height: number;
  63107. /**
  63108. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63109. */
  63110. centripetalForceThreshold: number;
  63111. /**
  63112. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63113. */
  63114. centripetalForceMultiplier: number;
  63115. /**
  63116. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63117. */
  63118. centrifugalForceMultiplier: number;
  63119. /**
  63120. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63121. */
  63122. updraftForceMultiplier: number;
  63123. }
  63124. /**
  63125. * The strenght of the force in correspondence to the distance of the affected object
  63126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63127. */
  63128. export enum PhysicsRadialImpulseFalloff {
  63129. /** Defines that impulse is constant in strength across it's whole radius */
  63130. Constant = 0,
  63131. /** Defines that impulse gets weaker if it's further from the origin */
  63132. Linear = 1
  63133. }
  63134. /**
  63135. * The strength of the force in correspondence to the distance of the affected object
  63136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63137. */
  63138. export enum PhysicsUpdraftMode {
  63139. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63140. Center = 0,
  63141. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63142. Perpendicular = 1
  63143. }
  63144. /**
  63145. * Interface for a physics hit data
  63146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63147. */
  63148. export interface PhysicsHitData {
  63149. /**
  63150. * The force applied at the contact point
  63151. */
  63152. force: Vector3;
  63153. /**
  63154. * The contact point
  63155. */
  63156. contactPoint: Vector3;
  63157. /**
  63158. * The distance from the origin to the contact point
  63159. */
  63160. distanceFromOrigin: number;
  63161. }
  63162. /**
  63163. * Interface for radial explosion event data
  63164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63165. */
  63166. export interface PhysicsRadialExplosionEventData {
  63167. /**
  63168. * A sphere used for the radial explosion event
  63169. */
  63170. sphere: Mesh;
  63171. }
  63172. /**
  63173. * Interface for gravitational field event data
  63174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63175. */
  63176. export interface PhysicsGravitationalFieldEventData {
  63177. /**
  63178. * A sphere mesh used for the gravitational field event
  63179. */
  63180. sphere: Mesh;
  63181. }
  63182. /**
  63183. * Interface for updraft event data
  63184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63185. */
  63186. export interface PhysicsUpdraftEventData {
  63187. /**
  63188. * A cylinder used for the updraft event
  63189. */
  63190. cylinder: Mesh;
  63191. }
  63192. /**
  63193. * Interface for vortex event data
  63194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63195. */
  63196. export interface PhysicsVortexEventData {
  63197. /**
  63198. * A cylinder used for the vortex event
  63199. */
  63200. cylinder: Mesh;
  63201. }
  63202. /**
  63203. * Interface for an affected physics impostor
  63204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63205. */
  63206. export interface PhysicsAffectedImpostorWithData {
  63207. /**
  63208. * The impostor affected by the effect
  63209. */
  63210. impostor: PhysicsImpostor;
  63211. /**
  63212. * The data about the hit/horce from the explosion
  63213. */
  63214. hitData: PhysicsHitData;
  63215. }
  63216. }
  63217. declare module "babylonjs/Physics/Plugins/index" {
  63218. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63219. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63220. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63221. }
  63222. declare module "babylonjs/Physics/index" {
  63223. export * from "babylonjs/Physics/IPhysicsEngine";
  63224. export * from "babylonjs/Physics/physicsEngine";
  63225. export * from "babylonjs/Physics/physicsEngineComponent";
  63226. export * from "babylonjs/Physics/physicsHelper";
  63227. export * from "babylonjs/Physics/physicsImpostor";
  63228. export * from "babylonjs/Physics/physicsJoint";
  63229. export * from "babylonjs/Physics/Plugins/index";
  63230. }
  63231. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63232. /** @hidden */
  63233. export var blackAndWhitePixelShader: {
  63234. name: string;
  63235. shader: string;
  63236. };
  63237. }
  63238. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63240. import { Camera } from "babylonjs/Cameras/camera";
  63241. import { Engine } from "babylonjs/Engines/engine";
  63242. import "babylonjs/Shaders/blackAndWhite.fragment";
  63243. /**
  63244. * Post process used to render in black and white
  63245. */
  63246. export class BlackAndWhitePostProcess extends PostProcess {
  63247. /**
  63248. * Linear about to convert he result to black and white (default: 1)
  63249. */
  63250. degree: number;
  63251. /**
  63252. * Creates a black and white post process
  63253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63254. * @param name The name of the effect.
  63255. * @param options The required width/height ratio to downsize to before computing the render pass.
  63256. * @param camera The camera to apply the render pass to.
  63257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63258. * @param engine The engine which the post process will be applied. (default: current engine)
  63259. * @param reusable If the post process can be reused on the same frame. (default: false)
  63260. */
  63261. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63262. }
  63263. }
  63264. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63265. import { Nullable } from "babylonjs/types";
  63266. import { Camera } from "babylonjs/Cameras/camera";
  63267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63268. import { Engine } from "babylonjs/Engines/engine";
  63269. /**
  63270. * This represents a set of one or more post processes in Babylon.
  63271. * A post process can be used to apply a shader to a texture after it is rendered.
  63272. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63273. */
  63274. export class PostProcessRenderEffect {
  63275. private _postProcesses;
  63276. private _getPostProcesses;
  63277. private _singleInstance;
  63278. private _cameras;
  63279. private _indicesForCamera;
  63280. /**
  63281. * Name of the effect
  63282. * @hidden
  63283. */
  63284. _name: string;
  63285. /**
  63286. * Instantiates a post process render effect.
  63287. * A post process can be used to apply a shader to a texture after it is rendered.
  63288. * @param engine The engine the effect is tied to
  63289. * @param name The name of the effect
  63290. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63291. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63292. */
  63293. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63294. /**
  63295. * Checks if all the post processes in the effect are supported.
  63296. */
  63297. readonly isSupported: boolean;
  63298. /**
  63299. * Updates the current state of the effect
  63300. * @hidden
  63301. */
  63302. _update(): void;
  63303. /**
  63304. * Attaches the effect on cameras
  63305. * @param cameras The camera to attach to.
  63306. * @hidden
  63307. */
  63308. _attachCameras(cameras: Camera): void;
  63309. /**
  63310. * Attaches the effect on cameras
  63311. * @param cameras The camera to attach to.
  63312. * @hidden
  63313. */
  63314. _attachCameras(cameras: Camera[]): void;
  63315. /**
  63316. * Detaches the effect on cameras
  63317. * @param cameras The camera to detatch from.
  63318. * @hidden
  63319. */
  63320. _detachCameras(cameras: Camera): void;
  63321. /**
  63322. * Detatches the effect on cameras
  63323. * @param cameras The camera to detatch from.
  63324. * @hidden
  63325. */
  63326. _detachCameras(cameras: Camera[]): void;
  63327. /**
  63328. * Enables the effect on given cameras
  63329. * @param cameras The camera to enable.
  63330. * @hidden
  63331. */
  63332. _enable(cameras: Camera): void;
  63333. /**
  63334. * Enables the effect on given cameras
  63335. * @param cameras The camera to enable.
  63336. * @hidden
  63337. */
  63338. _enable(cameras: Nullable<Camera[]>): void;
  63339. /**
  63340. * Disables the effect on the given cameras
  63341. * @param cameras The camera to disable.
  63342. * @hidden
  63343. */
  63344. _disable(cameras: Camera): void;
  63345. /**
  63346. * Disables the effect on the given cameras
  63347. * @param cameras The camera to disable.
  63348. * @hidden
  63349. */
  63350. _disable(cameras: Nullable<Camera[]>): void;
  63351. /**
  63352. * Gets a list of the post processes contained in the effect.
  63353. * @param camera The camera to get the post processes on.
  63354. * @returns The list of the post processes in the effect.
  63355. */
  63356. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63357. }
  63358. }
  63359. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63360. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63361. /** @hidden */
  63362. export var extractHighlightsPixelShader: {
  63363. name: string;
  63364. shader: string;
  63365. };
  63366. }
  63367. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63368. import { Nullable } from "babylonjs/types";
  63369. import { Camera } from "babylonjs/Cameras/camera";
  63370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63371. import { Engine } from "babylonjs/Engines/engine";
  63372. import "babylonjs/Shaders/extractHighlights.fragment";
  63373. /**
  63374. * 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.
  63375. */
  63376. export class ExtractHighlightsPostProcess extends PostProcess {
  63377. /**
  63378. * The luminance threshold, pixels below this value will be set to black.
  63379. */
  63380. threshold: number;
  63381. /** @hidden */
  63382. _exposure: number;
  63383. /**
  63384. * Post process which has the input texture to be used when performing highlight extraction
  63385. * @hidden
  63386. */
  63387. _inputPostProcess: Nullable<PostProcess>;
  63388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63389. }
  63390. }
  63391. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63392. /** @hidden */
  63393. export var bloomMergePixelShader: {
  63394. name: string;
  63395. shader: string;
  63396. };
  63397. }
  63398. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63400. import { Nullable } from "babylonjs/types";
  63401. import { Engine } from "babylonjs/Engines/engine";
  63402. import { Camera } from "babylonjs/Cameras/camera";
  63403. import "babylonjs/Shaders/bloomMerge.fragment";
  63404. /**
  63405. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63406. */
  63407. export class BloomMergePostProcess extends PostProcess {
  63408. /** Weight of the bloom to be added to the original input. */
  63409. weight: number;
  63410. /**
  63411. * Creates a new instance of @see BloomMergePostProcess
  63412. * @param name The name of the effect.
  63413. * @param originalFromInput Post process which's input will be used for the merge.
  63414. * @param blurred Blurred highlights post process which's output will be used.
  63415. * @param weight Weight of the bloom to be added to the original input.
  63416. * @param options The required width/height ratio to downsize to before computing the render pass.
  63417. * @param camera The camera to apply the render pass to.
  63418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63419. * @param engine The engine which the post process will be applied. (default: current engine)
  63420. * @param reusable If the post process can be reused on the same frame. (default: false)
  63421. * @param textureType Type of textures used when performing the post process. (default: 0)
  63422. * @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)
  63423. */
  63424. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63425. /** Weight of the bloom to be added to the original input. */
  63426. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63427. }
  63428. }
  63429. declare module "babylonjs/PostProcesses/bloomEffect" {
  63430. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63431. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63432. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63433. import { Camera } from "babylonjs/Cameras/camera";
  63434. import { Scene } from "babylonjs/scene";
  63435. /**
  63436. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63437. */
  63438. export class BloomEffect extends PostProcessRenderEffect {
  63439. private bloomScale;
  63440. /**
  63441. * @hidden Internal
  63442. */
  63443. _effects: Array<PostProcess>;
  63444. /**
  63445. * @hidden Internal
  63446. */
  63447. _downscale: ExtractHighlightsPostProcess;
  63448. private _blurX;
  63449. private _blurY;
  63450. private _merge;
  63451. /**
  63452. * The luminance threshold to find bright areas of the image to bloom.
  63453. */
  63454. threshold: number;
  63455. /**
  63456. * The strength of the bloom.
  63457. */
  63458. weight: number;
  63459. /**
  63460. * Specifies the size of the bloom blur kernel, relative to the final output size
  63461. */
  63462. kernel: number;
  63463. /**
  63464. * Creates a new instance of @see BloomEffect
  63465. * @param scene The scene the effect belongs to.
  63466. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63467. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63468. * @param bloomWeight The the strength of bloom.
  63469. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63470. * @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)
  63471. */
  63472. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63473. /**
  63474. * Disposes each of the internal effects for a given camera.
  63475. * @param camera The camera to dispose the effect on.
  63476. */
  63477. disposeEffects(camera: Camera): void;
  63478. /**
  63479. * @hidden Internal
  63480. */
  63481. _updateEffects(): void;
  63482. /**
  63483. * Internal
  63484. * @returns if all the contained post processes are ready.
  63485. * @hidden
  63486. */
  63487. _isReady(): boolean;
  63488. }
  63489. }
  63490. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63491. /** @hidden */
  63492. export var chromaticAberrationPixelShader: {
  63493. name: string;
  63494. shader: string;
  63495. };
  63496. }
  63497. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63498. import { Vector2 } from "babylonjs/Maths/math.vector";
  63499. import { Nullable } from "babylonjs/types";
  63500. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63501. import { Camera } from "babylonjs/Cameras/camera";
  63502. import { Engine } from "babylonjs/Engines/engine";
  63503. import "babylonjs/Shaders/chromaticAberration.fragment";
  63504. /**
  63505. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63506. */
  63507. export class ChromaticAberrationPostProcess extends PostProcess {
  63508. /**
  63509. * The amount of seperation of rgb channels (default: 30)
  63510. */
  63511. aberrationAmount: number;
  63512. /**
  63513. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63514. */
  63515. radialIntensity: number;
  63516. /**
  63517. * 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))
  63518. */
  63519. direction: Vector2;
  63520. /**
  63521. * 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))
  63522. */
  63523. centerPosition: Vector2;
  63524. /**
  63525. * Creates a new instance ChromaticAberrationPostProcess
  63526. * @param name The name of the effect.
  63527. * @param screenWidth The width of the screen to apply the effect on.
  63528. * @param screenHeight The height of the screen to apply the effect on.
  63529. * @param options The required width/height ratio to downsize to before computing the render pass.
  63530. * @param camera The camera to apply the render pass to.
  63531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63532. * @param engine The engine which the post process will be applied. (default: current engine)
  63533. * @param reusable If the post process can be reused on the same frame. (default: false)
  63534. * @param textureType Type of textures used when performing the post process. (default: 0)
  63535. * @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)
  63536. */
  63537. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63538. }
  63539. }
  63540. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63541. /** @hidden */
  63542. export var circleOfConfusionPixelShader: {
  63543. name: string;
  63544. shader: string;
  63545. };
  63546. }
  63547. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63548. import { Nullable } from "babylonjs/types";
  63549. import { Engine } from "babylonjs/Engines/engine";
  63550. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63552. import { Camera } from "babylonjs/Cameras/camera";
  63553. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63554. /**
  63555. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63556. */
  63557. export class CircleOfConfusionPostProcess extends PostProcess {
  63558. /**
  63559. * 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.
  63560. */
  63561. lensSize: number;
  63562. /**
  63563. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63564. */
  63565. fStop: number;
  63566. /**
  63567. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63568. */
  63569. focusDistance: number;
  63570. /**
  63571. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63572. */
  63573. focalLength: number;
  63574. private _depthTexture;
  63575. /**
  63576. * Creates a new instance CircleOfConfusionPostProcess
  63577. * @param name The name of the effect.
  63578. * @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.
  63579. * @param options The required width/height ratio to downsize to before computing the render pass.
  63580. * @param camera The camera to apply the render pass to.
  63581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63582. * @param engine The engine which the post process will be applied. (default: current engine)
  63583. * @param reusable If the post process can be reused on the same frame. (default: false)
  63584. * @param textureType Type of textures used when performing the post process. (default: 0)
  63585. * @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)
  63586. */
  63587. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63588. /**
  63589. * 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.
  63590. */
  63591. depthTexture: RenderTargetTexture;
  63592. }
  63593. }
  63594. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63595. /** @hidden */
  63596. export var colorCorrectionPixelShader: {
  63597. name: string;
  63598. shader: string;
  63599. };
  63600. }
  63601. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63602. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63603. import { Engine } from "babylonjs/Engines/engine";
  63604. import { Camera } from "babylonjs/Cameras/camera";
  63605. import "babylonjs/Shaders/colorCorrection.fragment";
  63606. /**
  63607. *
  63608. * This post-process allows the modification of rendered colors by using
  63609. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63610. *
  63611. * The object needs to be provided an url to a texture containing the color
  63612. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63613. * Use an image editing software to tweak the LUT to match your needs.
  63614. *
  63615. * For an example of a color LUT, see here:
  63616. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63617. * For explanations on color grading, see here:
  63618. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63619. *
  63620. */
  63621. export class ColorCorrectionPostProcess extends PostProcess {
  63622. private _colorTableTexture;
  63623. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63624. }
  63625. }
  63626. declare module "babylonjs/Shaders/convolution.fragment" {
  63627. /** @hidden */
  63628. export var convolutionPixelShader: {
  63629. name: string;
  63630. shader: string;
  63631. };
  63632. }
  63633. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63635. import { Nullable } from "babylonjs/types";
  63636. import { Camera } from "babylonjs/Cameras/camera";
  63637. import { Engine } from "babylonjs/Engines/engine";
  63638. import "babylonjs/Shaders/convolution.fragment";
  63639. /**
  63640. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63641. * input texture to perform effects such as edge detection or sharpening
  63642. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63643. */
  63644. export class ConvolutionPostProcess extends PostProcess {
  63645. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63646. kernel: number[];
  63647. /**
  63648. * Creates a new instance ConvolutionPostProcess
  63649. * @param name The name of the effect.
  63650. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63651. * @param options The required width/height ratio to downsize to before computing the render pass.
  63652. * @param camera The camera to apply the render pass to.
  63653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63654. * @param engine The engine which the post process will be applied. (default: current engine)
  63655. * @param reusable If the post process can be reused on the same frame. (default: false)
  63656. * @param textureType Type of textures used when performing the post process. (default: 0)
  63657. */
  63658. constructor(name: string,
  63659. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63660. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63661. /**
  63662. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63663. */
  63664. static EdgeDetect0Kernel: number[];
  63665. /**
  63666. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63667. */
  63668. static EdgeDetect1Kernel: number[];
  63669. /**
  63670. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63671. */
  63672. static EdgeDetect2Kernel: number[];
  63673. /**
  63674. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63675. */
  63676. static SharpenKernel: number[];
  63677. /**
  63678. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63679. */
  63680. static EmbossKernel: number[];
  63681. /**
  63682. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63683. */
  63684. static GaussianKernel: number[];
  63685. }
  63686. }
  63687. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63688. import { Nullable } from "babylonjs/types";
  63689. import { Vector2 } from "babylonjs/Maths/math.vector";
  63690. import { Camera } from "babylonjs/Cameras/camera";
  63691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63692. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63693. import { Engine } from "babylonjs/Engines/engine";
  63694. import { Scene } from "babylonjs/scene";
  63695. /**
  63696. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63697. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63698. * based on samples that have a large difference in distance than the center pixel.
  63699. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63700. */
  63701. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63702. direction: Vector2;
  63703. /**
  63704. * Creates a new instance CircleOfConfusionPostProcess
  63705. * @param name The name of the effect.
  63706. * @param scene The scene the effect belongs to.
  63707. * @param direction The direction the blur should be applied.
  63708. * @param kernel The size of the kernel used to blur.
  63709. * @param options The required width/height ratio to downsize to before computing the render pass.
  63710. * @param camera The camera to apply the render pass to.
  63711. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63712. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63714. * @param engine The engine which the post process will be applied. (default: current engine)
  63715. * @param reusable If the post process can be reused on the same frame. (default: false)
  63716. * @param textureType Type of textures used when performing the post process. (default: 0)
  63717. * @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)
  63718. */
  63719. 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);
  63720. }
  63721. }
  63722. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63723. /** @hidden */
  63724. export var depthOfFieldMergePixelShader: {
  63725. name: string;
  63726. shader: string;
  63727. };
  63728. }
  63729. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63730. import { Nullable } from "babylonjs/types";
  63731. import { Camera } from "babylonjs/Cameras/camera";
  63732. import { Effect } from "babylonjs/Materials/effect";
  63733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63734. import { Engine } from "babylonjs/Engines/engine";
  63735. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63736. /**
  63737. * Options to be set when merging outputs from the default pipeline.
  63738. */
  63739. export class DepthOfFieldMergePostProcessOptions {
  63740. /**
  63741. * The original image to merge on top of
  63742. */
  63743. originalFromInput: PostProcess;
  63744. /**
  63745. * Parameters to perform the merge of the depth of field effect
  63746. */
  63747. depthOfField?: {
  63748. circleOfConfusion: PostProcess;
  63749. blurSteps: Array<PostProcess>;
  63750. };
  63751. /**
  63752. * Parameters to perform the merge of bloom effect
  63753. */
  63754. bloom?: {
  63755. blurred: PostProcess;
  63756. weight: number;
  63757. };
  63758. }
  63759. /**
  63760. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63761. */
  63762. export class DepthOfFieldMergePostProcess extends PostProcess {
  63763. private blurSteps;
  63764. /**
  63765. * Creates a new instance of DepthOfFieldMergePostProcess
  63766. * @param name The name of the effect.
  63767. * @param originalFromInput Post process which's input will be used for the merge.
  63768. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63769. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63770. * @param options The required width/height ratio to downsize to before computing the render pass.
  63771. * @param camera The camera to apply the render pass to.
  63772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63773. * @param engine The engine which the post process will be applied. (default: current engine)
  63774. * @param reusable If the post process can be reused on the same frame. (default: false)
  63775. * @param textureType Type of textures used when performing the post process. (default: 0)
  63776. * @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)
  63777. */
  63778. 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);
  63779. /**
  63780. * Updates the effect with the current post process compile time values and recompiles the shader.
  63781. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63782. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63783. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63784. * @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
  63785. * @param onCompiled Called when the shader has been compiled.
  63786. * @param onError Called if there is an error when compiling a shader.
  63787. */
  63788. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63789. }
  63790. }
  63791. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63792. import { Nullable } from "babylonjs/types";
  63793. import { Camera } from "babylonjs/Cameras/camera";
  63794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63796. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63797. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63798. import { Scene } from "babylonjs/scene";
  63799. /**
  63800. * Specifies the level of max blur that should be applied when using the depth of field effect
  63801. */
  63802. export enum DepthOfFieldEffectBlurLevel {
  63803. /**
  63804. * Subtle blur
  63805. */
  63806. Low = 0,
  63807. /**
  63808. * Medium blur
  63809. */
  63810. Medium = 1,
  63811. /**
  63812. * Large blur
  63813. */
  63814. High = 2
  63815. }
  63816. /**
  63817. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63818. */
  63819. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63820. private _circleOfConfusion;
  63821. /**
  63822. * @hidden Internal, blurs from high to low
  63823. */
  63824. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63825. private _depthOfFieldBlurY;
  63826. private _dofMerge;
  63827. /**
  63828. * @hidden Internal post processes in depth of field effect
  63829. */
  63830. _effects: Array<PostProcess>;
  63831. /**
  63832. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63833. */
  63834. focalLength: number;
  63835. /**
  63836. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63837. */
  63838. fStop: number;
  63839. /**
  63840. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63841. */
  63842. focusDistance: number;
  63843. /**
  63844. * 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.
  63845. */
  63846. lensSize: number;
  63847. /**
  63848. * Creates a new instance DepthOfFieldEffect
  63849. * @param scene The scene the effect belongs to.
  63850. * @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.
  63851. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63852. * @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)
  63853. */
  63854. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63855. /**
  63856. * Get the current class name of the current effet
  63857. * @returns "DepthOfFieldEffect"
  63858. */
  63859. getClassName(): string;
  63860. /**
  63861. * 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.
  63862. */
  63863. depthTexture: RenderTargetTexture;
  63864. /**
  63865. * Disposes each of the internal effects for a given camera.
  63866. * @param camera The camera to dispose the effect on.
  63867. */
  63868. disposeEffects(camera: Camera): void;
  63869. /**
  63870. * @hidden Internal
  63871. */
  63872. _updateEffects(): void;
  63873. /**
  63874. * Internal
  63875. * @returns if all the contained post processes are ready.
  63876. * @hidden
  63877. */
  63878. _isReady(): boolean;
  63879. }
  63880. }
  63881. declare module "babylonjs/Shaders/displayPass.fragment" {
  63882. /** @hidden */
  63883. export var displayPassPixelShader: {
  63884. name: string;
  63885. shader: string;
  63886. };
  63887. }
  63888. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63889. import { Nullable } from "babylonjs/types";
  63890. import { Camera } from "babylonjs/Cameras/camera";
  63891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63892. import { Engine } from "babylonjs/Engines/engine";
  63893. import "babylonjs/Shaders/displayPass.fragment";
  63894. /**
  63895. * DisplayPassPostProcess which produces an output the same as it's input
  63896. */
  63897. export class DisplayPassPostProcess extends PostProcess {
  63898. /**
  63899. * Creates the DisplayPassPostProcess
  63900. * @param name The name of the effect.
  63901. * @param options The required width/height ratio to downsize to before computing the render pass.
  63902. * @param camera The camera to apply the render pass to.
  63903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63904. * @param engine The engine which the post process will be applied. (default: current engine)
  63905. * @param reusable If the post process can be reused on the same frame. (default: false)
  63906. */
  63907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63908. }
  63909. }
  63910. declare module "babylonjs/Shaders/filter.fragment" {
  63911. /** @hidden */
  63912. export var filterPixelShader: {
  63913. name: string;
  63914. shader: string;
  63915. };
  63916. }
  63917. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63918. import { Nullable } from "babylonjs/types";
  63919. import { Matrix } from "babylonjs/Maths/math.vector";
  63920. import { Camera } from "babylonjs/Cameras/camera";
  63921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63922. import { Engine } from "babylonjs/Engines/engine";
  63923. import "babylonjs/Shaders/filter.fragment";
  63924. /**
  63925. * Applies a kernel filter to the image
  63926. */
  63927. export class FilterPostProcess extends PostProcess {
  63928. /** The matrix to be applied to the image */
  63929. kernelMatrix: Matrix;
  63930. /**
  63931. *
  63932. * @param name The name of the effect.
  63933. * @param kernelMatrix The matrix to be applied to the image
  63934. * @param options The required width/height ratio to downsize to before computing the render pass.
  63935. * @param camera The camera to apply the render pass to.
  63936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63937. * @param engine The engine which the post process will be applied. (default: current engine)
  63938. * @param reusable If the post process can be reused on the same frame. (default: false)
  63939. */
  63940. constructor(name: string,
  63941. /** The matrix to be applied to the image */
  63942. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63943. }
  63944. }
  63945. declare module "babylonjs/Shaders/fxaa.fragment" {
  63946. /** @hidden */
  63947. export var fxaaPixelShader: {
  63948. name: string;
  63949. shader: string;
  63950. };
  63951. }
  63952. declare module "babylonjs/Shaders/fxaa.vertex" {
  63953. /** @hidden */
  63954. export var fxaaVertexShader: {
  63955. name: string;
  63956. shader: string;
  63957. };
  63958. }
  63959. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63960. import { Nullable } from "babylonjs/types";
  63961. import { Camera } from "babylonjs/Cameras/camera";
  63962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63963. import { Engine } from "babylonjs/Engines/engine";
  63964. import "babylonjs/Shaders/fxaa.fragment";
  63965. import "babylonjs/Shaders/fxaa.vertex";
  63966. /**
  63967. * Fxaa post process
  63968. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63969. */
  63970. export class FxaaPostProcess extends PostProcess {
  63971. /** @hidden */
  63972. texelWidth: number;
  63973. /** @hidden */
  63974. texelHeight: number;
  63975. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63976. private _getDefines;
  63977. }
  63978. }
  63979. declare module "babylonjs/Shaders/grain.fragment" {
  63980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63981. /** @hidden */
  63982. export var grainPixelShader: {
  63983. name: string;
  63984. shader: string;
  63985. };
  63986. }
  63987. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63988. import { Nullable } from "babylonjs/types";
  63989. import { Camera } from "babylonjs/Cameras/camera";
  63990. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63991. import { Engine } from "babylonjs/Engines/engine";
  63992. import "babylonjs/Shaders/grain.fragment";
  63993. /**
  63994. * The GrainPostProcess adds noise to the image at mid luminance levels
  63995. */
  63996. export class GrainPostProcess extends PostProcess {
  63997. /**
  63998. * The intensity of the grain added (default: 30)
  63999. */
  64000. intensity: number;
  64001. /**
  64002. * If the grain should be randomized on every frame
  64003. */
  64004. animated: boolean;
  64005. /**
  64006. * Creates a new instance of @see GrainPostProcess
  64007. * @param name The name of the effect.
  64008. * @param options The required width/height ratio to downsize to before computing the render pass.
  64009. * @param camera The camera to apply the render pass to.
  64010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64011. * @param engine The engine which the post process will be applied. (default: current engine)
  64012. * @param reusable If the post process can be reused on the same frame. (default: false)
  64013. * @param textureType Type of textures used when performing the post process. (default: 0)
  64014. * @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)
  64015. */
  64016. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64017. }
  64018. }
  64019. declare module "babylonjs/Shaders/highlights.fragment" {
  64020. /** @hidden */
  64021. export var highlightsPixelShader: {
  64022. name: string;
  64023. shader: string;
  64024. };
  64025. }
  64026. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64027. import { Nullable } from "babylonjs/types";
  64028. import { Camera } from "babylonjs/Cameras/camera";
  64029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64030. import { Engine } from "babylonjs/Engines/engine";
  64031. import "babylonjs/Shaders/highlights.fragment";
  64032. /**
  64033. * Extracts highlights from the image
  64034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64035. */
  64036. export class HighlightsPostProcess extends PostProcess {
  64037. /**
  64038. * Extracts highlights from the image
  64039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64040. * @param name The name of the effect.
  64041. * @param options The required width/height ratio to downsize to before computing the render pass.
  64042. * @param camera The camera to apply the render pass to.
  64043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64044. * @param engine The engine which the post process will be applied. (default: current engine)
  64045. * @param reusable If the post process can be reused on the same frame. (default: false)
  64046. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64047. */
  64048. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64049. }
  64050. }
  64051. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64052. /** @hidden */
  64053. export var mrtFragmentDeclaration: {
  64054. name: string;
  64055. shader: string;
  64056. };
  64057. }
  64058. declare module "babylonjs/Shaders/geometry.fragment" {
  64059. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64060. /** @hidden */
  64061. export var geometryPixelShader: {
  64062. name: string;
  64063. shader: string;
  64064. };
  64065. }
  64066. declare module "babylonjs/Shaders/geometry.vertex" {
  64067. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64068. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64070. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64072. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64073. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64074. /** @hidden */
  64075. export var geometryVertexShader: {
  64076. name: string;
  64077. shader: string;
  64078. };
  64079. }
  64080. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64081. import { Matrix } from "babylonjs/Maths/math.vector";
  64082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64083. import { Mesh } from "babylonjs/Meshes/mesh";
  64084. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64085. import { Effect } from "babylonjs/Materials/effect";
  64086. import { Scene } from "babylonjs/scene";
  64087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64088. import "babylonjs/Shaders/geometry.fragment";
  64089. import "babylonjs/Shaders/geometry.vertex";
  64090. /** @hidden */
  64091. interface ISavedTransformationMatrix {
  64092. world: Matrix;
  64093. viewProjection: Matrix;
  64094. }
  64095. /**
  64096. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64097. */
  64098. export class GeometryBufferRenderer {
  64099. /**
  64100. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64101. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64102. */
  64103. static readonly POSITION_TEXTURE_TYPE: number;
  64104. /**
  64105. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64106. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64107. */
  64108. static readonly VELOCITY_TEXTURE_TYPE: number;
  64109. /**
  64110. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64111. * in order to compute objects velocities when enableVelocity is set to "true"
  64112. * @hidden
  64113. */
  64114. _previousTransformationMatrices: {
  64115. [index: number]: ISavedTransformationMatrix;
  64116. };
  64117. /**
  64118. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64119. * in order to compute objects velocities when enableVelocity is set to "true"
  64120. * @hidden
  64121. */
  64122. _previousBonesTransformationMatrices: {
  64123. [index: number]: Float32Array;
  64124. };
  64125. /**
  64126. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64127. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64128. */
  64129. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64130. private _scene;
  64131. private _multiRenderTarget;
  64132. private _ratio;
  64133. private _enablePosition;
  64134. private _enableVelocity;
  64135. private _positionIndex;
  64136. private _velocityIndex;
  64137. protected _effect: Effect;
  64138. protected _cachedDefines: string;
  64139. /**
  64140. * Set the render list (meshes to be rendered) used in the G buffer.
  64141. */
  64142. renderList: Mesh[];
  64143. /**
  64144. * Gets wether or not G buffer are supported by the running hardware.
  64145. * This requires draw buffer supports
  64146. */
  64147. readonly isSupported: boolean;
  64148. /**
  64149. * Returns the index of the given texture type in the G-Buffer textures array
  64150. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64151. * @returns the index of the given texture type in the G-Buffer textures array
  64152. */
  64153. getTextureIndex(textureType: number): number;
  64154. /**
  64155. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64156. */
  64157. /**
  64158. * Sets whether or not objects positions are enabled for the G buffer.
  64159. */
  64160. enablePosition: boolean;
  64161. /**
  64162. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64163. */
  64164. /**
  64165. * Sets wether or not objects velocities are enabled for the G buffer.
  64166. */
  64167. enableVelocity: boolean;
  64168. /**
  64169. * Gets the scene associated with the buffer.
  64170. */
  64171. readonly scene: Scene;
  64172. /**
  64173. * Gets the ratio used by the buffer during its creation.
  64174. * How big is the buffer related to the main canvas.
  64175. */
  64176. readonly ratio: number;
  64177. /** @hidden */
  64178. static _SceneComponentInitialization: (scene: Scene) => void;
  64179. /**
  64180. * Creates a new G Buffer for the scene
  64181. * @param scene The scene the buffer belongs to
  64182. * @param ratio How big is the buffer related to the main canvas.
  64183. */
  64184. constructor(scene: Scene, ratio?: number);
  64185. /**
  64186. * Checks wether everything is ready to render a submesh to the G buffer.
  64187. * @param subMesh the submesh to check readiness for
  64188. * @param useInstances is the mesh drawn using instance or not
  64189. * @returns true if ready otherwise false
  64190. */
  64191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64192. /**
  64193. * Gets the current underlying G Buffer.
  64194. * @returns the buffer
  64195. */
  64196. getGBuffer(): MultiRenderTarget;
  64197. /**
  64198. * Gets the number of samples used to render the buffer (anti aliasing).
  64199. */
  64200. /**
  64201. * Sets the number of samples used to render the buffer (anti aliasing).
  64202. */
  64203. samples: number;
  64204. /**
  64205. * Disposes the renderer and frees up associated resources.
  64206. */
  64207. dispose(): void;
  64208. protected _createRenderTargets(): void;
  64209. private _copyBonesTransformationMatrices;
  64210. }
  64211. }
  64212. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64213. import { Nullable } from "babylonjs/types";
  64214. import { Scene } from "babylonjs/scene";
  64215. import { ISceneComponent } from "babylonjs/sceneComponent";
  64216. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64217. module "babylonjs/scene" {
  64218. interface Scene {
  64219. /** @hidden (Backing field) */
  64220. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64221. /**
  64222. * Gets or Sets the current geometry buffer associated to the scene.
  64223. */
  64224. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64225. /**
  64226. * Enables a GeometryBufferRender and associates it with the scene
  64227. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64228. * @returns the GeometryBufferRenderer
  64229. */
  64230. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64231. /**
  64232. * Disables the GeometryBufferRender associated with the scene
  64233. */
  64234. disableGeometryBufferRenderer(): void;
  64235. }
  64236. }
  64237. /**
  64238. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64239. * in several rendering techniques.
  64240. */
  64241. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64242. /**
  64243. * The component name helpful to identify the component in the list of scene components.
  64244. */
  64245. readonly name: string;
  64246. /**
  64247. * The scene the component belongs to.
  64248. */
  64249. scene: Scene;
  64250. /**
  64251. * Creates a new instance of the component for the given scene
  64252. * @param scene Defines the scene to register the component in
  64253. */
  64254. constructor(scene: Scene);
  64255. /**
  64256. * Registers the component in a given scene
  64257. */
  64258. register(): void;
  64259. /**
  64260. * Rebuilds the elements related to this component in case of
  64261. * context lost for instance.
  64262. */
  64263. rebuild(): void;
  64264. /**
  64265. * Disposes the component and the associated ressources
  64266. */
  64267. dispose(): void;
  64268. private _gatherRenderTargets;
  64269. }
  64270. }
  64271. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64272. /** @hidden */
  64273. export var motionBlurPixelShader: {
  64274. name: string;
  64275. shader: string;
  64276. };
  64277. }
  64278. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64279. import { Nullable } from "babylonjs/types";
  64280. import { Camera } from "babylonjs/Cameras/camera";
  64281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64282. import { Scene } from "babylonjs/scene";
  64283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64284. import "babylonjs/Animations/animatable";
  64285. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64286. import "babylonjs/Shaders/motionBlur.fragment";
  64287. import { Engine } from "babylonjs/Engines/engine";
  64288. /**
  64289. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64290. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64291. * As an example, all you have to do is to create the post-process:
  64292. * var mb = new BABYLON.MotionBlurPostProcess(
  64293. * 'mb', // The name of the effect.
  64294. * scene, // The scene containing the objects to blur according to their velocity.
  64295. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64296. * camera // The camera to apply the render pass to.
  64297. * );
  64298. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64299. */
  64300. export class MotionBlurPostProcess extends PostProcess {
  64301. /**
  64302. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64303. */
  64304. motionStrength: number;
  64305. /**
  64306. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64307. */
  64308. /**
  64309. * Sets the number of iterations to be used for motion blur quality
  64310. */
  64311. motionBlurSamples: number;
  64312. private _motionBlurSamples;
  64313. private _geometryBufferRenderer;
  64314. /**
  64315. * Creates a new instance MotionBlurPostProcess
  64316. * @param name The name of the effect.
  64317. * @param scene The scene containing the objects to blur according to their velocity.
  64318. * @param options The required width/height ratio to downsize to before computing the render pass.
  64319. * @param camera The camera to apply the render pass to.
  64320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64321. * @param engine The engine which the post process will be applied. (default: current engine)
  64322. * @param reusable If the post process can be reused on the same frame. (default: false)
  64323. * @param textureType Type of textures used when performing the post process. (default: 0)
  64324. * @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)
  64325. */
  64326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64327. /**
  64328. * Excludes the given skinned mesh from computing bones velocities.
  64329. * 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.
  64330. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64331. */
  64332. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64333. /**
  64334. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64335. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64336. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64337. */
  64338. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64339. /**
  64340. * Disposes the post process.
  64341. * @param camera The camera to dispose the post process on.
  64342. */
  64343. dispose(camera?: Camera): void;
  64344. }
  64345. }
  64346. declare module "babylonjs/Shaders/refraction.fragment" {
  64347. /** @hidden */
  64348. export var refractionPixelShader: {
  64349. name: string;
  64350. shader: string;
  64351. };
  64352. }
  64353. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64354. import { Color3 } from "babylonjs/Maths/math.color";
  64355. import { Camera } from "babylonjs/Cameras/camera";
  64356. import { Texture } from "babylonjs/Materials/Textures/texture";
  64357. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64358. import { Engine } from "babylonjs/Engines/engine";
  64359. import "babylonjs/Shaders/refraction.fragment";
  64360. /**
  64361. * Post process which applies a refractin texture
  64362. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64363. */
  64364. export class RefractionPostProcess extends PostProcess {
  64365. /** the base color of the refraction (used to taint the rendering) */
  64366. color: Color3;
  64367. /** simulated refraction depth */
  64368. depth: number;
  64369. /** the coefficient of the base color (0 to remove base color tainting) */
  64370. colorLevel: number;
  64371. private _refTexture;
  64372. private _ownRefractionTexture;
  64373. /**
  64374. * Gets or sets the refraction texture
  64375. * Please note that you are responsible for disposing the texture if you set it manually
  64376. */
  64377. refractionTexture: Texture;
  64378. /**
  64379. * Initializes the RefractionPostProcess
  64380. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64381. * @param name The name of the effect.
  64382. * @param refractionTextureUrl Url of the refraction texture to use
  64383. * @param color the base color of the refraction (used to taint the rendering)
  64384. * @param depth simulated refraction depth
  64385. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64386. * @param camera The camera to apply the render pass to.
  64387. * @param options The required width/height ratio to downsize to before computing the render pass.
  64388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64389. * @param engine The engine which the post process will be applied. (default: current engine)
  64390. * @param reusable If the post process can be reused on the same frame. (default: false)
  64391. */
  64392. constructor(name: string, refractionTextureUrl: string,
  64393. /** the base color of the refraction (used to taint the rendering) */
  64394. color: Color3,
  64395. /** simulated refraction depth */
  64396. depth: number,
  64397. /** the coefficient of the base color (0 to remove base color tainting) */
  64398. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64399. /**
  64400. * Disposes of the post process
  64401. * @param camera Camera to dispose post process on
  64402. */
  64403. dispose(camera: Camera): void;
  64404. }
  64405. }
  64406. declare module "babylonjs/Shaders/sharpen.fragment" {
  64407. /** @hidden */
  64408. export var sharpenPixelShader: {
  64409. name: string;
  64410. shader: string;
  64411. };
  64412. }
  64413. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64414. import { Nullable } from "babylonjs/types";
  64415. import { Camera } from "babylonjs/Cameras/camera";
  64416. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64417. import "babylonjs/Shaders/sharpen.fragment";
  64418. import { Engine } from "babylonjs/Engines/engine";
  64419. /**
  64420. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64422. */
  64423. export class SharpenPostProcess extends PostProcess {
  64424. /**
  64425. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64426. */
  64427. colorAmount: number;
  64428. /**
  64429. * How much sharpness should be applied (default: 0.3)
  64430. */
  64431. edgeAmount: number;
  64432. /**
  64433. * Creates a new instance ConvolutionPostProcess
  64434. * @param name The name of the effect.
  64435. * @param options The required width/height ratio to downsize to before computing the render pass.
  64436. * @param camera The camera to apply the render pass to.
  64437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64438. * @param engine The engine which the post process will be applied. (default: current engine)
  64439. * @param reusable If the post process can be reused on the same frame. (default: false)
  64440. * @param textureType Type of textures used when performing the post process. (default: 0)
  64441. * @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)
  64442. */
  64443. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64444. }
  64445. }
  64446. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64447. import { Nullable } from "babylonjs/types";
  64448. import { Camera } from "babylonjs/Cameras/camera";
  64449. import { Engine } from "babylonjs/Engines/engine";
  64450. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64451. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64452. /**
  64453. * PostProcessRenderPipeline
  64454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64455. */
  64456. export class PostProcessRenderPipeline {
  64457. private engine;
  64458. private _renderEffects;
  64459. private _renderEffectsForIsolatedPass;
  64460. /**
  64461. * List of inspectable custom properties (used by the Inspector)
  64462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64463. */
  64464. inspectableCustomProperties: IInspectable[];
  64465. /**
  64466. * @hidden
  64467. */
  64468. protected _cameras: Camera[];
  64469. /** @hidden */
  64470. _name: string;
  64471. /**
  64472. * Gets pipeline name
  64473. */
  64474. readonly name: string;
  64475. /** Gets the list of attached cameras */
  64476. readonly cameras: Camera[];
  64477. /**
  64478. * Initializes a PostProcessRenderPipeline
  64479. * @param engine engine to add the pipeline to
  64480. * @param name name of the pipeline
  64481. */
  64482. constructor(engine: Engine, name: string);
  64483. /**
  64484. * Gets the class name
  64485. * @returns "PostProcessRenderPipeline"
  64486. */
  64487. getClassName(): string;
  64488. /**
  64489. * If all the render effects in the pipeline are supported
  64490. */
  64491. readonly isSupported: boolean;
  64492. /**
  64493. * Adds an effect to the pipeline
  64494. * @param renderEffect the effect to add
  64495. */
  64496. addEffect(renderEffect: PostProcessRenderEffect): void;
  64497. /** @hidden */
  64498. _rebuild(): void;
  64499. /** @hidden */
  64500. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64501. /** @hidden */
  64502. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64503. /** @hidden */
  64504. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64505. /** @hidden */
  64506. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64507. /** @hidden */
  64508. _attachCameras(cameras: Camera, unique: boolean): void;
  64509. /** @hidden */
  64510. _attachCameras(cameras: Camera[], unique: boolean): void;
  64511. /** @hidden */
  64512. _detachCameras(cameras: Camera): void;
  64513. /** @hidden */
  64514. _detachCameras(cameras: Nullable<Camera[]>): void;
  64515. /** @hidden */
  64516. _update(): void;
  64517. /** @hidden */
  64518. _reset(): void;
  64519. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64520. /**
  64521. * Disposes of the pipeline
  64522. */
  64523. dispose(): void;
  64524. }
  64525. }
  64526. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64527. import { Camera } from "babylonjs/Cameras/camera";
  64528. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64529. /**
  64530. * PostProcessRenderPipelineManager class
  64531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64532. */
  64533. export class PostProcessRenderPipelineManager {
  64534. private _renderPipelines;
  64535. /**
  64536. * Initializes a PostProcessRenderPipelineManager
  64537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64538. */
  64539. constructor();
  64540. /**
  64541. * Gets the list of supported render pipelines
  64542. */
  64543. readonly supportedPipelines: PostProcessRenderPipeline[];
  64544. /**
  64545. * Adds a pipeline to the manager
  64546. * @param renderPipeline The pipeline to add
  64547. */
  64548. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64549. /**
  64550. * Attaches a camera to the pipeline
  64551. * @param renderPipelineName The name of the pipeline to attach to
  64552. * @param cameras the camera to attach
  64553. * @param unique if the camera can be attached multiple times to the pipeline
  64554. */
  64555. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64556. /**
  64557. * Detaches a camera from the pipeline
  64558. * @param renderPipelineName The name of the pipeline to detach from
  64559. * @param cameras the camera to detach
  64560. */
  64561. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64562. /**
  64563. * Enables an effect by name on a pipeline
  64564. * @param renderPipelineName the name of the pipeline to enable the effect in
  64565. * @param renderEffectName the name of the effect to enable
  64566. * @param cameras the cameras that the effect should be enabled on
  64567. */
  64568. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64569. /**
  64570. * Disables an effect by name on a pipeline
  64571. * @param renderPipelineName the name of the pipeline to disable the effect in
  64572. * @param renderEffectName the name of the effect to disable
  64573. * @param cameras the cameras that the effect should be disabled on
  64574. */
  64575. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64576. /**
  64577. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64578. */
  64579. update(): void;
  64580. /** @hidden */
  64581. _rebuild(): void;
  64582. /**
  64583. * Disposes of the manager and pipelines
  64584. */
  64585. dispose(): void;
  64586. }
  64587. }
  64588. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64589. import { ISceneComponent } from "babylonjs/sceneComponent";
  64590. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64591. import { Scene } from "babylonjs/scene";
  64592. module "babylonjs/scene" {
  64593. interface Scene {
  64594. /** @hidden (Backing field) */
  64595. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64596. /**
  64597. * Gets the postprocess render pipeline manager
  64598. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64599. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64600. */
  64601. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64602. }
  64603. }
  64604. /**
  64605. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64606. */
  64607. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64608. /**
  64609. * The component name helpfull to identify the component in the list of scene components.
  64610. */
  64611. readonly name: string;
  64612. /**
  64613. * The scene the component belongs to.
  64614. */
  64615. scene: Scene;
  64616. /**
  64617. * Creates a new instance of the component for the given scene
  64618. * @param scene Defines the scene to register the component in
  64619. */
  64620. constructor(scene: Scene);
  64621. /**
  64622. * Registers the component in a given scene
  64623. */
  64624. register(): void;
  64625. /**
  64626. * Rebuilds the elements related to this component in case of
  64627. * context lost for instance.
  64628. */
  64629. rebuild(): void;
  64630. /**
  64631. * Disposes the component and the associated ressources
  64632. */
  64633. dispose(): void;
  64634. private _gatherRenderTargets;
  64635. }
  64636. }
  64637. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64638. import { Nullable } from "babylonjs/types";
  64639. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64640. import { Camera } from "babylonjs/Cameras/camera";
  64641. import { IDisposable } from "babylonjs/scene";
  64642. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64643. import { Scene } from "babylonjs/scene";
  64644. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64645. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64646. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64647. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64648. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64649. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64650. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64651. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64652. import { Animation } from "babylonjs/Animations/animation";
  64653. /**
  64654. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64655. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64656. */
  64657. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64658. private _scene;
  64659. private _camerasToBeAttached;
  64660. /**
  64661. * ID of the sharpen post process,
  64662. */
  64663. private readonly SharpenPostProcessId;
  64664. /**
  64665. * @ignore
  64666. * ID of the image processing post process;
  64667. */
  64668. readonly ImageProcessingPostProcessId: string;
  64669. /**
  64670. * @ignore
  64671. * ID of the Fast Approximate Anti-Aliasing post process;
  64672. */
  64673. readonly FxaaPostProcessId: string;
  64674. /**
  64675. * ID of the chromatic aberration post process,
  64676. */
  64677. private readonly ChromaticAberrationPostProcessId;
  64678. /**
  64679. * ID of the grain post process
  64680. */
  64681. private readonly GrainPostProcessId;
  64682. /**
  64683. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64684. */
  64685. sharpen: SharpenPostProcess;
  64686. private _sharpenEffect;
  64687. private bloom;
  64688. /**
  64689. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64690. */
  64691. depthOfField: DepthOfFieldEffect;
  64692. /**
  64693. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64694. */
  64695. fxaa: FxaaPostProcess;
  64696. /**
  64697. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64698. */
  64699. imageProcessing: ImageProcessingPostProcess;
  64700. /**
  64701. * Chromatic aberration post process which will shift rgb colors in the image
  64702. */
  64703. chromaticAberration: ChromaticAberrationPostProcess;
  64704. private _chromaticAberrationEffect;
  64705. /**
  64706. * Grain post process which add noise to the image
  64707. */
  64708. grain: GrainPostProcess;
  64709. private _grainEffect;
  64710. /**
  64711. * Glow post process which adds a glow to emissive areas of the image
  64712. */
  64713. private _glowLayer;
  64714. /**
  64715. * Animations which can be used to tweak settings over a period of time
  64716. */
  64717. animations: Animation[];
  64718. private _imageProcessingConfigurationObserver;
  64719. private _sharpenEnabled;
  64720. private _bloomEnabled;
  64721. private _depthOfFieldEnabled;
  64722. private _depthOfFieldBlurLevel;
  64723. private _fxaaEnabled;
  64724. private _imageProcessingEnabled;
  64725. private _defaultPipelineTextureType;
  64726. private _bloomScale;
  64727. private _chromaticAberrationEnabled;
  64728. private _grainEnabled;
  64729. private _buildAllowed;
  64730. /**
  64731. * Gets active scene
  64732. */
  64733. readonly scene: Scene;
  64734. /**
  64735. * Enable or disable the sharpen process from the pipeline
  64736. */
  64737. sharpenEnabled: boolean;
  64738. private _resizeObserver;
  64739. private _hardwareScaleLevel;
  64740. private _bloomKernel;
  64741. /**
  64742. * Specifies the size of the bloom blur kernel, relative to the final output size
  64743. */
  64744. bloomKernel: number;
  64745. /**
  64746. * Specifies the weight of the bloom in the final rendering
  64747. */
  64748. private _bloomWeight;
  64749. /**
  64750. * Specifies the luma threshold for the area that will be blurred by the bloom
  64751. */
  64752. private _bloomThreshold;
  64753. private _hdr;
  64754. /**
  64755. * The strength of the bloom.
  64756. */
  64757. bloomWeight: number;
  64758. /**
  64759. * The strength of the bloom.
  64760. */
  64761. bloomThreshold: number;
  64762. /**
  64763. * The scale of the bloom, lower value will provide better performance.
  64764. */
  64765. bloomScale: number;
  64766. /**
  64767. * Enable or disable the bloom from the pipeline
  64768. */
  64769. bloomEnabled: boolean;
  64770. private _rebuildBloom;
  64771. /**
  64772. * If the depth of field is enabled.
  64773. */
  64774. depthOfFieldEnabled: boolean;
  64775. /**
  64776. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64777. */
  64778. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64779. /**
  64780. * If the anti aliasing is enabled.
  64781. */
  64782. fxaaEnabled: boolean;
  64783. private _samples;
  64784. /**
  64785. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64786. */
  64787. samples: number;
  64788. /**
  64789. * If image processing is enabled.
  64790. */
  64791. imageProcessingEnabled: boolean;
  64792. /**
  64793. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64794. */
  64795. glowLayerEnabled: boolean;
  64796. /**
  64797. * Gets the glow layer (or null if not defined)
  64798. */
  64799. readonly glowLayer: Nullable<GlowLayer>;
  64800. /**
  64801. * Enable or disable the chromaticAberration process from the pipeline
  64802. */
  64803. chromaticAberrationEnabled: boolean;
  64804. /**
  64805. * Enable or disable the grain process from the pipeline
  64806. */
  64807. grainEnabled: boolean;
  64808. /**
  64809. * @constructor
  64810. * @param name - The rendering pipeline name (default: "")
  64811. * @param hdr - If high dynamic range textures should be used (default: true)
  64812. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64813. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64814. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64815. */
  64816. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64817. /**
  64818. * Get the class name
  64819. * @returns "DefaultRenderingPipeline"
  64820. */
  64821. getClassName(): string;
  64822. /**
  64823. * Force the compilation of the entire pipeline.
  64824. */
  64825. prepare(): void;
  64826. private _hasCleared;
  64827. private _prevPostProcess;
  64828. private _prevPrevPostProcess;
  64829. private _setAutoClearAndTextureSharing;
  64830. private _depthOfFieldSceneObserver;
  64831. private _buildPipeline;
  64832. private _disposePostProcesses;
  64833. /**
  64834. * Adds a camera to the pipeline
  64835. * @param camera the camera to be added
  64836. */
  64837. addCamera(camera: Camera): void;
  64838. /**
  64839. * Removes a camera from the pipeline
  64840. * @param camera the camera to remove
  64841. */
  64842. removeCamera(camera: Camera): void;
  64843. /**
  64844. * Dispose of the pipeline and stop all post processes
  64845. */
  64846. dispose(): void;
  64847. /**
  64848. * Serialize the rendering pipeline (Used when exporting)
  64849. * @returns the serialized object
  64850. */
  64851. serialize(): any;
  64852. /**
  64853. * Parse the serialized pipeline
  64854. * @param source Source pipeline.
  64855. * @param scene The scene to load the pipeline to.
  64856. * @param rootUrl The URL of the serialized pipeline.
  64857. * @returns An instantiated pipeline from the serialized object.
  64858. */
  64859. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64860. }
  64861. }
  64862. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64863. /** @hidden */
  64864. export var lensHighlightsPixelShader: {
  64865. name: string;
  64866. shader: string;
  64867. };
  64868. }
  64869. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64870. /** @hidden */
  64871. export var depthOfFieldPixelShader: {
  64872. name: string;
  64873. shader: string;
  64874. };
  64875. }
  64876. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64877. import { Camera } from "babylonjs/Cameras/camera";
  64878. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64879. import { Scene } from "babylonjs/scene";
  64880. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64881. import "babylonjs/Shaders/chromaticAberration.fragment";
  64882. import "babylonjs/Shaders/lensHighlights.fragment";
  64883. import "babylonjs/Shaders/depthOfField.fragment";
  64884. /**
  64885. * BABYLON.JS Chromatic Aberration GLSL Shader
  64886. * Author: Olivier Guyot
  64887. * Separates very slightly R, G and B colors on the edges of the screen
  64888. * Inspired by Francois Tarlier & Martins Upitis
  64889. */
  64890. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64891. /**
  64892. * @ignore
  64893. * The chromatic aberration PostProcess id in the pipeline
  64894. */
  64895. LensChromaticAberrationEffect: string;
  64896. /**
  64897. * @ignore
  64898. * The highlights enhancing PostProcess id in the pipeline
  64899. */
  64900. HighlightsEnhancingEffect: string;
  64901. /**
  64902. * @ignore
  64903. * The depth-of-field PostProcess id in the pipeline
  64904. */
  64905. LensDepthOfFieldEffect: string;
  64906. private _scene;
  64907. private _depthTexture;
  64908. private _grainTexture;
  64909. private _chromaticAberrationPostProcess;
  64910. private _highlightsPostProcess;
  64911. private _depthOfFieldPostProcess;
  64912. private _edgeBlur;
  64913. private _grainAmount;
  64914. private _chromaticAberration;
  64915. private _distortion;
  64916. private _highlightsGain;
  64917. private _highlightsThreshold;
  64918. private _dofDistance;
  64919. private _dofAperture;
  64920. private _dofDarken;
  64921. private _dofPentagon;
  64922. private _blurNoise;
  64923. /**
  64924. * @constructor
  64925. *
  64926. * Effect parameters are as follow:
  64927. * {
  64928. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64929. * edge_blur: number; // from 0 to x (1 for realism)
  64930. * distortion: number; // from 0 to x (1 for realism)
  64931. * grain_amount: number; // from 0 to 1
  64932. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64933. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64934. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64935. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64936. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64937. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64938. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64939. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64940. * }
  64941. * Note: if an effect parameter is unset, effect is disabled
  64942. *
  64943. * @param name The rendering pipeline name
  64944. * @param parameters - An object containing all parameters (see above)
  64945. * @param scene The scene linked to this pipeline
  64946. * @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)
  64947. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64948. */
  64949. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64950. /**
  64951. * Get the class name
  64952. * @returns "LensRenderingPipeline"
  64953. */
  64954. getClassName(): string;
  64955. /**
  64956. * Gets associated scene
  64957. */
  64958. readonly scene: Scene;
  64959. /**
  64960. * Gets or sets the edge blur
  64961. */
  64962. edgeBlur: number;
  64963. /**
  64964. * Gets or sets the grain amount
  64965. */
  64966. grainAmount: number;
  64967. /**
  64968. * Gets or sets the chromatic aberration amount
  64969. */
  64970. chromaticAberration: number;
  64971. /**
  64972. * Gets or sets the depth of field aperture
  64973. */
  64974. dofAperture: number;
  64975. /**
  64976. * Gets or sets the edge distortion
  64977. */
  64978. edgeDistortion: number;
  64979. /**
  64980. * Gets or sets the depth of field distortion
  64981. */
  64982. dofDistortion: number;
  64983. /**
  64984. * Gets or sets the darken out of focus amount
  64985. */
  64986. darkenOutOfFocus: number;
  64987. /**
  64988. * Gets or sets a boolean indicating if blur noise is enabled
  64989. */
  64990. blurNoise: boolean;
  64991. /**
  64992. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64993. */
  64994. pentagonBokeh: boolean;
  64995. /**
  64996. * Gets or sets the highlight grain amount
  64997. */
  64998. highlightsGain: number;
  64999. /**
  65000. * Gets or sets the highlight threshold
  65001. */
  65002. highlightsThreshold: number;
  65003. /**
  65004. * Sets the amount of blur at the edges
  65005. * @param amount blur amount
  65006. */
  65007. setEdgeBlur(amount: number): void;
  65008. /**
  65009. * Sets edge blur to 0
  65010. */
  65011. disableEdgeBlur(): void;
  65012. /**
  65013. * Sets the amout of grain
  65014. * @param amount Amount of grain
  65015. */
  65016. setGrainAmount(amount: number): void;
  65017. /**
  65018. * Set grain amount to 0
  65019. */
  65020. disableGrain(): void;
  65021. /**
  65022. * Sets the chromatic aberration amount
  65023. * @param amount amount of chromatic aberration
  65024. */
  65025. setChromaticAberration(amount: number): void;
  65026. /**
  65027. * Sets chromatic aberration amount to 0
  65028. */
  65029. disableChromaticAberration(): void;
  65030. /**
  65031. * Sets the EdgeDistortion amount
  65032. * @param amount amount of EdgeDistortion
  65033. */
  65034. setEdgeDistortion(amount: number): void;
  65035. /**
  65036. * Sets edge distortion to 0
  65037. */
  65038. disableEdgeDistortion(): void;
  65039. /**
  65040. * Sets the FocusDistance amount
  65041. * @param amount amount of FocusDistance
  65042. */
  65043. setFocusDistance(amount: number): void;
  65044. /**
  65045. * Disables depth of field
  65046. */
  65047. disableDepthOfField(): void;
  65048. /**
  65049. * Sets the Aperture amount
  65050. * @param amount amount of Aperture
  65051. */
  65052. setAperture(amount: number): void;
  65053. /**
  65054. * Sets the DarkenOutOfFocus amount
  65055. * @param amount amount of DarkenOutOfFocus
  65056. */
  65057. setDarkenOutOfFocus(amount: number): void;
  65058. private _pentagonBokehIsEnabled;
  65059. /**
  65060. * Creates a pentagon bokeh effect
  65061. */
  65062. enablePentagonBokeh(): void;
  65063. /**
  65064. * Disables the pentagon bokeh effect
  65065. */
  65066. disablePentagonBokeh(): void;
  65067. /**
  65068. * Enables noise blur
  65069. */
  65070. enableNoiseBlur(): void;
  65071. /**
  65072. * Disables noise blur
  65073. */
  65074. disableNoiseBlur(): void;
  65075. /**
  65076. * Sets the HighlightsGain amount
  65077. * @param amount amount of HighlightsGain
  65078. */
  65079. setHighlightsGain(amount: number): void;
  65080. /**
  65081. * Sets the HighlightsThreshold amount
  65082. * @param amount amount of HighlightsThreshold
  65083. */
  65084. setHighlightsThreshold(amount: number): void;
  65085. /**
  65086. * Disables highlights
  65087. */
  65088. disableHighlights(): void;
  65089. /**
  65090. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65091. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65092. */
  65093. dispose(disableDepthRender?: boolean): void;
  65094. private _createChromaticAberrationPostProcess;
  65095. private _createHighlightsPostProcess;
  65096. private _createDepthOfFieldPostProcess;
  65097. private _createGrainTexture;
  65098. }
  65099. }
  65100. declare module "babylonjs/Shaders/ssao2.fragment" {
  65101. /** @hidden */
  65102. export var ssao2PixelShader: {
  65103. name: string;
  65104. shader: string;
  65105. };
  65106. }
  65107. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65108. /** @hidden */
  65109. export var ssaoCombinePixelShader: {
  65110. name: string;
  65111. shader: string;
  65112. };
  65113. }
  65114. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65115. import { Camera } from "babylonjs/Cameras/camera";
  65116. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65117. import { Scene } from "babylonjs/scene";
  65118. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65119. import "babylonjs/Shaders/ssao2.fragment";
  65120. import "babylonjs/Shaders/ssaoCombine.fragment";
  65121. /**
  65122. * Render pipeline to produce ssao effect
  65123. */
  65124. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65125. /**
  65126. * @ignore
  65127. * The PassPostProcess id in the pipeline that contains the original scene color
  65128. */
  65129. SSAOOriginalSceneColorEffect: string;
  65130. /**
  65131. * @ignore
  65132. * The SSAO PostProcess id in the pipeline
  65133. */
  65134. SSAORenderEffect: string;
  65135. /**
  65136. * @ignore
  65137. * The horizontal blur PostProcess id in the pipeline
  65138. */
  65139. SSAOBlurHRenderEffect: string;
  65140. /**
  65141. * @ignore
  65142. * The vertical blur PostProcess id in the pipeline
  65143. */
  65144. SSAOBlurVRenderEffect: string;
  65145. /**
  65146. * @ignore
  65147. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65148. */
  65149. SSAOCombineRenderEffect: string;
  65150. /**
  65151. * The output strength of the SSAO post-process. Default value is 1.0.
  65152. */
  65153. totalStrength: number;
  65154. /**
  65155. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65156. */
  65157. maxZ: number;
  65158. /**
  65159. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65160. */
  65161. minZAspect: number;
  65162. private _samples;
  65163. /**
  65164. * Number of samples used for the SSAO calculations. Default value is 8
  65165. */
  65166. samples: number;
  65167. private _textureSamples;
  65168. /**
  65169. * Number of samples to use for antialiasing
  65170. */
  65171. textureSamples: number;
  65172. /**
  65173. * Ratio object used for SSAO ratio and blur ratio
  65174. */
  65175. private _ratio;
  65176. /**
  65177. * Dynamically generated sphere sampler.
  65178. */
  65179. private _sampleSphere;
  65180. /**
  65181. * Blur filter offsets
  65182. */
  65183. private _samplerOffsets;
  65184. private _expensiveBlur;
  65185. /**
  65186. * If bilateral blur should be used
  65187. */
  65188. expensiveBlur: boolean;
  65189. /**
  65190. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65191. */
  65192. radius: number;
  65193. /**
  65194. * The base color of the SSAO post-process
  65195. * The final result is "base + ssao" between [0, 1]
  65196. */
  65197. base: number;
  65198. /**
  65199. * Support test.
  65200. */
  65201. static readonly IsSupported: boolean;
  65202. private _scene;
  65203. private _depthTexture;
  65204. private _normalTexture;
  65205. private _randomTexture;
  65206. private _originalColorPostProcess;
  65207. private _ssaoPostProcess;
  65208. private _blurHPostProcess;
  65209. private _blurVPostProcess;
  65210. private _ssaoCombinePostProcess;
  65211. /**
  65212. * Gets active scene
  65213. */
  65214. readonly scene: Scene;
  65215. /**
  65216. * @constructor
  65217. * @param name The rendering pipeline name
  65218. * @param scene The scene linked to this pipeline
  65219. * @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 }
  65220. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65221. */
  65222. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65223. /**
  65224. * Get the class name
  65225. * @returns "SSAO2RenderingPipeline"
  65226. */
  65227. getClassName(): string;
  65228. /**
  65229. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65230. */
  65231. dispose(disableGeometryBufferRenderer?: boolean): void;
  65232. private _createBlurPostProcess;
  65233. /** @hidden */
  65234. _rebuild(): void;
  65235. private _bits;
  65236. private _radicalInverse_VdC;
  65237. private _hammersley;
  65238. private _hemisphereSample_uniform;
  65239. private _generateHemisphere;
  65240. private _createSSAOPostProcess;
  65241. private _createSSAOCombinePostProcess;
  65242. private _createRandomTexture;
  65243. /**
  65244. * Serialize the rendering pipeline (Used when exporting)
  65245. * @returns the serialized object
  65246. */
  65247. serialize(): any;
  65248. /**
  65249. * Parse the serialized pipeline
  65250. * @param source Source pipeline.
  65251. * @param scene The scene to load the pipeline to.
  65252. * @param rootUrl The URL of the serialized pipeline.
  65253. * @returns An instantiated pipeline from the serialized object.
  65254. */
  65255. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65256. }
  65257. }
  65258. declare module "babylonjs/Shaders/ssao.fragment" {
  65259. /** @hidden */
  65260. export var ssaoPixelShader: {
  65261. name: string;
  65262. shader: string;
  65263. };
  65264. }
  65265. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65266. import { Camera } from "babylonjs/Cameras/camera";
  65267. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65268. import { Scene } from "babylonjs/scene";
  65269. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65270. import "babylonjs/Shaders/ssao.fragment";
  65271. import "babylonjs/Shaders/ssaoCombine.fragment";
  65272. /**
  65273. * Render pipeline to produce ssao effect
  65274. */
  65275. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65276. /**
  65277. * @ignore
  65278. * The PassPostProcess id in the pipeline that contains the original scene color
  65279. */
  65280. SSAOOriginalSceneColorEffect: string;
  65281. /**
  65282. * @ignore
  65283. * The SSAO PostProcess id in the pipeline
  65284. */
  65285. SSAORenderEffect: string;
  65286. /**
  65287. * @ignore
  65288. * The horizontal blur PostProcess id in the pipeline
  65289. */
  65290. SSAOBlurHRenderEffect: string;
  65291. /**
  65292. * @ignore
  65293. * The vertical blur PostProcess id in the pipeline
  65294. */
  65295. SSAOBlurVRenderEffect: string;
  65296. /**
  65297. * @ignore
  65298. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65299. */
  65300. SSAOCombineRenderEffect: string;
  65301. /**
  65302. * The output strength of the SSAO post-process. Default value is 1.0.
  65303. */
  65304. totalStrength: number;
  65305. /**
  65306. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65307. */
  65308. radius: number;
  65309. /**
  65310. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65311. * Must not be equal to fallOff and superior to fallOff.
  65312. * Default value is 0.0075
  65313. */
  65314. area: number;
  65315. /**
  65316. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65317. * Must not be equal to area and inferior to area.
  65318. * Default value is 0.000001
  65319. */
  65320. fallOff: number;
  65321. /**
  65322. * The base color of the SSAO post-process
  65323. * The final result is "base + ssao" between [0, 1]
  65324. */
  65325. base: number;
  65326. private _scene;
  65327. private _depthTexture;
  65328. private _randomTexture;
  65329. private _originalColorPostProcess;
  65330. private _ssaoPostProcess;
  65331. private _blurHPostProcess;
  65332. private _blurVPostProcess;
  65333. private _ssaoCombinePostProcess;
  65334. private _firstUpdate;
  65335. /**
  65336. * Gets active scene
  65337. */
  65338. readonly scene: Scene;
  65339. /**
  65340. * @constructor
  65341. * @param name - The rendering pipeline name
  65342. * @param scene - The scene linked to this pipeline
  65343. * @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 }
  65344. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65345. */
  65346. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65347. /**
  65348. * Get the class name
  65349. * @returns "SSAORenderingPipeline"
  65350. */
  65351. getClassName(): string;
  65352. /**
  65353. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65354. */
  65355. dispose(disableDepthRender?: boolean): void;
  65356. private _createBlurPostProcess;
  65357. /** @hidden */
  65358. _rebuild(): void;
  65359. private _createSSAOPostProcess;
  65360. private _createSSAOCombinePostProcess;
  65361. private _createRandomTexture;
  65362. }
  65363. }
  65364. declare module "babylonjs/Shaders/standard.fragment" {
  65365. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65366. /** @hidden */
  65367. export var standardPixelShader: {
  65368. name: string;
  65369. shader: string;
  65370. };
  65371. }
  65372. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65373. import { Nullable } from "babylonjs/types";
  65374. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65375. import { Camera } from "babylonjs/Cameras/camera";
  65376. import { Texture } from "babylonjs/Materials/Textures/texture";
  65377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65378. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65379. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65380. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65381. import { IDisposable } from "babylonjs/scene";
  65382. import { SpotLight } from "babylonjs/Lights/spotLight";
  65383. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65384. import { Scene } from "babylonjs/scene";
  65385. import { Animation } from "babylonjs/Animations/animation";
  65386. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65387. import "babylonjs/Shaders/standard.fragment";
  65388. /**
  65389. * Standard rendering pipeline
  65390. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65391. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65392. */
  65393. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65394. /**
  65395. * Public members
  65396. */
  65397. /**
  65398. * Post-process which contains the original scene color before the pipeline applies all the effects
  65399. */
  65400. originalPostProcess: Nullable<PostProcess>;
  65401. /**
  65402. * Post-process used to down scale an image x4
  65403. */
  65404. downSampleX4PostProcess: Nullable<PostProcess>;
  65405. /**
  65406. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65407. */
  65408. brightPassPostProcess: Nullable<PostProcess>;
  65409. /**
  65410. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65411. */
  65412. blurHPostProcesses: PostProcess[];
  65413. /**
  65414. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65415. */
  65416. blurVPostProcesses: PostProcess[];
  65417. /**
  65418. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65419. */
  65420. textureAdderPostProcess: Nullable<PostProcess>;
  65421. /**
  65422. * Post-process used to create volumetric lighting effect
  65423. */
  65424. volumetricLightPostProcess: Nullable<PostProcess>;
  65425. /**
  65426. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65427. */
  65428. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65429. /**
  65430. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65431. */
  65432. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65433. /**
  65434. * Post-process used to merge the volumetric light effect and the real scene color
  65435. */
  65436. volumetricLightMergePostProces: Nullable<PostProcess>;
  65437. /**
  65438. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65439. */
  65440. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65441. /**
  65442. * Base post-process used to calculate the average luminance of the final image for HDR
  65443. */
  65444. luminancePostProcess: Nullable<PostProcess>;
  65445. /**
  65446. * Post-processes used to create down sample post-processes in order to get
  65447. * the average luminance of the final image for HDR
  65448. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65449. */
  65450. luminanceDownSamplePostProcesses: PostProcess[];
  65451. /**
  65452. * Post-process used to create a HDR effect (light adaptation)
  65453. */
  65454. hdrPostProcess: Nullable<PostProcess>;
  65455. /**
  65456. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65457. */
  65458. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65459. /**
  65460. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65461. */
  65462. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65463. /**
  65464. * Post-process used to merge the final HDR post-process and the real scene color
  65465. */
  65466. hdrFinalPostProcess: Nullable<PostProcess>;
  65467. /**
  65468. * Post-process used to create a lens flare effect
  65469. */
  65470. lensFlarePostProcess: Nullable<PostProcess>;
  65471. /**
  65472. * Post-process that merges the result of the lens flare post-process and the real scene color
  65473. */
  65474. lensFlareComposePostProcess: Nullable<PostProcess>;
  65475. /**
  65476. * Post-process used to create a motion blur effect
  65477. */
  65478. motionBlurPostProcess: Nullable<PostProcess>;
  65479. /**
  65480. * Post-process used to create a depth of field effect
  65481. */
  65482. depthOfFieldPostProcess: Nullable<PostProcess>;
  65483. /**
  65484. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65485. */
  65486. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65487. /**
  65488. * Represents the brightness threshold in order to configure the illuminated surfaces
  65489. */
  65490. brightThreshold: number;
  65491. /**
  65492. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65493. */
  65494. blurWidth: number;
  65495. /**
  65496. * Sets if the blur for highlighted surfaces must be only horizontal
  65497. */
  65498. horizontalBlur: boolean;
  65499. /**
  65500. * Gets the overall exposure used by the pipeline
  65501. */
  65502. /**
  65503. * Sets the overall exposure used by the pipeline
  65504. */
  65505. exposure: number;
  65506. /**
  65507. * Texture used typically to simulate "dirty" on camera lens
  65508. */
  65509. lensTexture: Nullable<Texture>;
  65510. /**
  65511. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65512. */
  65513. volumetricLightCoefficient: number;
  65514. /**
  65515. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65516. */
  65517. volumetricLightPower: number;
  65518. /**
  65519. * Used the set the blur intensity to smooth the volumetric lights
  65520. */
  65521. volumetricLightBlurScale: number;
  65522. /**
  65523. * Light (spot or directional) used to generate the volumetric lights rays
  65524. * The source light must have a shadow generate so the pipeline can get its
  65525. * depth map
  65526. */
  65527. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65528. /**
  65529. * For eye adaptation, represents the minimum luminance the eye can see
  65530. */
  65531. hdrMinimumLuminance: number;
  65532. /**
  65533. * For eye adaptation, represents the decrease luminance speed
  65534. */
  65535. hdrDecreaseRate: number;
  65536. /**
  65537. * For eye adaptation, represents the increase luminance speed
  65538. */
  65539. hdrIncreaseRate: number;
  65540. /**
  65541. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65542. */
  65543. /**
  65544. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65545. */
  65546. hdrAutoExposure: boolean;
  65547. /**
  65548. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65549. */
  65550. lensColorTexture: Nullable<Texture>;
  65551. /**
  65552. * The overall strengh for the lens flare effect
  65553. */
  65554. lensFlareStrength: number;
  65555. /**
  65556. * Dispersion coefficient for lens flare ghosts
  65557. */
  65558. lensFlareGhostDispersal: number;
  65559. /**
  65560. * Main lens flare halo width
  65561. */
  65562. lensFlareHaloWidth: number;
  65563. /**
  65564. * Based on the lens distortion effect, defines how much the lens flare result
  65565. * is distorted
  65566. */
  65567. lensFlareDistortionStrength: number;
  65568. /**
  65569. * Configures the blur intensity used for for lens flare (halo)
  65570. */
  65571. lensFlareBlurWidth: number;
  65572. /**
  65573. * Lens star texture must be used to simulate rays on the flares and is available
  65574. * in the documentation
  65575. */
  65576. lensStarTexture: Nullable<Texture>;
  65577. /**
  65578. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65579. * flare effect by taking account of the dirt texture
  65580. */
  65581. lensFlareDirtTexture: Nullable<Texture>;
  65582. /**
  65583. * Represents the focal length for the depth of field effect
  65584. */
  65585. depthOfFieldDistance: number;
  65586. /**
  65587. * Represents the blur intensity for the blurred part of the depth of field effect
  65588. */
  65589. depthOfFieldBlurWidth: number;
  65590. /**
  65591. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65592. */
  65593. /**
  65594. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65595. */
  65596. motionStrength: number;
  65597. /**
  65598. * Gets wether or not the motion blur post-process is object based or screen based.
  65599. */
  65600. /**
  65601. * Sets wether or not the motion blur post-process should be object based or screen based
  65602. */
  65603. objectBasedMotionBlur: boolean;
  65604. /**
  65605. * List of animations for the pipeline (IAnimatable implementation)
  65606. */
  65607. animations: Animation[];
  65608. /**
  65609. * Private members
  65610. */
  65611. private _scene;
  65612. private _currentDepthOfFieldSource;
  65613. private _basePostProcess;
  65614. private _fixedExposure;
  65615. private _currentExposure;
  65616. private _hdrAutoExposure;
  65617. private _hdrCurrentLuminance;
  65618. private _motionStrength;
  65619. private _isObjectBasedMotionBlur;
  65620. private _floatTextureType;
  65621. private _camerasToBeAttached;
  65622. private _ratio;
  65623. private _bloomEnabled;
  65624. private _depthOfFieldEnabled;
  65625. private _vlsEnabled;
  65626. private _lensFlareEnabled;
  65627. private _hdrEnabled;
  65628. private _motionBlurEnabled;
  65629. private _fxaaEnabled;
  65630. private _motionBlurSamples;
  65631. private _volumetricLightStepsCount;
  65632. private _samples;
  65633. /**
  65634. * @ignore
  65635. * Specifies if the bloom pipeline is enabled
  65636. */
  65637. BloomEnabled: boolean;
  65638. /**
  65639. * @ignore
  65640. * Specifies if the depth of field pipeline is enabed
  65641. */
  65642. DepthOfFieldEnabled: boolean;
  65643. /**
  65644. * @ignore
  65645. * Specifies if the lens flare pipeline is enabed
  65646. */
  65647. LensFlareEnabled: boolean;
  65648. /**
  65649. * @ignore
  65650. * Specifies if the HDR pipeline is enabled
  65651. */
  65652. HDREnabled: boolean;
  65653. /**
  65654. * @ignore
  65655. * Specifies if the volumetric lights scattering effect is enabled
  65656. */
  65657. VLSEnabled: boolean;
  65658. /**
  65659. * @ignore
  65660. * Specifies if the motion blur effect is enabled
  65661. */
  65662. MotionBlurEnabled: boolean;
  65663. /**
  65664. * Specifies if anti-aliasing is enabled
  65665. */
  65666. fxaaEnabled: boolean;
  65667. /**
  65668. * Specifies the number of steps used to calculate the volumetric lights
  65669. * Typically in interval [50, 200]
  65670. */
  65671. volumetricLightStepsCount: number;
  65672. /**
  65673. * Specifies the number of samples used for the motion blur effect
  65674. * Typically in interval [16, 64]
  65675. */
  65676. motionBlurSamples: number;
  65677. /**
  65678. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65679. */
  65680. samples: number;
  65681. /**
  65682. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65683. * @constructor
  65684. * @param name The rendering pipeline name
  65685. * @param scene The scene linked to this pipeline
  65686. * @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)
  65687. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65688. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65689. */
  65690. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65691. private _buildPipeline;
  65692. private _createDownSampleX4PostProcess;
  65693. private _createBrightPassPostProcess;
  65694. private _createBlurPostProcesses;
  65695. private _createTextureAdderPostProcess;
  65696. private _createVolumetricLightPostProcess;
  65697. private _createLuminancePostProcesses;
  65698. private _createHdrPostProcess;
  65699. private _createLensFlarePostProcess;
  65700. private _createDepthOfFieldPostProcess;
  65701. private _createMotionBlurPostProcess;
  65702. private _getDepthTexture;
  65703. private _disposePostProcesses;
  65704. /**
  65705. * Dispose of the pipeline and stop all post processes
  65706. */
  65707. dispose(): void;
  65708. /**
  65709. * Serialize the rendering pipeline (Used when exporting)
  65710. * @returns the serialized object
  65711. */
  65712. serialize(): any;
  65713. /**
  65714. * Parse the serialized pipeline
  65715. * @param source Source pipeline.
  65716. * @param scene The scene to load the pipeline to.
  65717. * @param rootUrl The URL of the serialized pipeline.
  65718. * @returns An instantiated pipeline from the serialized object.
  65719. */
  65720. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65721. /**
  65722. * Luminance steps
  65723. */
  65724. static LuminanceSteps: number;
  65725. }
  65726. }
  65727. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65728. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65729. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65730. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65731. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65732. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65733. }
  65734. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65735. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65736. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65737. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65738. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65739. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65740. }
  65741. declare module "babylonjs/Shaders/tonemap.fragment" {
  65742. /** @hidden */
  65743. export var tonemapPixelShader: {
  65744. name: string;
  65745. shader: string;
  65746. };
  65747. }
  65748. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65749. import { Camera } from "babylonjs/Cameras/camera";
  65750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65751. import "babylonjs/Shaders/tonemap.fragment";
  65752. import { Engine } from "babylonjs/Engines/engine";
  65753. /** Defines operator used for tonemapping */
  65754. export enum TonemappingOperator {
  65755. /** Hable */
  65756. Hable = 0,
  65757. /** Reinhard */
  65758. Reinhard = 1,
  65759. /** HejiDawson */
  65760. HejiDawson = 2,
  65761. /** Photographic */
  65762. Photographic = 3
  65763. }
  65764. /**
  65765. * Defines a post process to apply tone mapping
  65766. */
  65767. export class TonemapPostProcess extends PostProcess {
  65768. private _operator;
  65769. /** Defines the required exposure adjustement */
  65770. exposureAdjustment: number;
  65771. /**
  65772. * Creates a new TonemapPostProcess
  65773. * @param name defines the name of the postprocess
  65774. * @param _operator defines the operator to use
  65775. * @param exposureAdjustment defines the required exposure adjustement
  65776. * @param camera defines the camera to use (can be null)
  65777. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65778. * @param engine defines the hosting engine (can be ignore if camera is set)
  65779. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65780. */
  65781. constructor(name: string, _operator: TonemappingOperator,
  65782. /** Defines the required exposure adjustement */
  65783. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65784. }
  65785. }
  65786. declare module "babylonjs/Shaders/depth.vertex" {
  65787. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65788. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65789. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65790. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65792. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65793. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65794. /** @hidden */
  65795. export var depthVertexShader: {
  65796. name: string;
  65797. shader: string;
  65798. };
  65799. }
  65800. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65801. /** @hidden */
  65802. export var volumetricLightScatteringPixelShader: {
  65803. name: string;
  65804. shader: string;
  65805. };
  65806. }
  65807. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65808. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65809. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65811. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65813. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65814. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65815. /** @hidden */
  65816. export var volumetricLightScatteringPassVertexShader: {
  65817. name: string;
  65818. shader: string;
  65819. };
  65820. }
  65821. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65822. /** @hidden */
  65823. export var volumetricLightScatteringPassPixelShader: {
  65824. name: string;
  65825. shader: string;
  65826. };
  65827. }
  65828. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65829. import { Vector3 } from "babylonjs/Maths/math.vector";
  65830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65831. import { Mesh } from "babylonjs/Meshes/mesh";
  65832. import { Camera } from "babylonjs/Cameras/camera";
  65833. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65835. import { Scene } from "babylonjs/scene";
  65836. import "babylonjs/Meshes/Builders/planeBuilder";
  65837. import "babylonjs/Shaders/depth.vertex";
  65838. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65839. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65840. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65841. import { Engine } from "babylonjs/Engines/engine";
  65842. /**
  65843. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65844. */
  65845. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65846. private _volumetricLightScatteringPass;
  65847. private _volumetricLightScatteringRTT;
  65848. private _viewPort;
  65849. private _screenCoordinates;
  65850. private _cachedDefines;
  65851. /**
  65852. * If not undefined, the mesh position is computed from the attached node position
  65853. */
  65854. attachedNode: {
  65855. position: Vector3;
  65856. };
  65857. /**
  65858. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65859. */
  65860. customMeshPosition: Vector3;
  65861. /**
  65862. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65863. */
  65864. useCustomMeshPosition: boolean;
  65865. /**
  65866. * If the post-process should inverse the light scattering direction
  65867. */
  65868. invert: boolean;
  65869. /**
  65870. * The internal mesh used by the post-process
  65871. */
  65872. mesh: Mesh;
  65873. /**
  65874. * @hidden
  65875. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65876. */
  65877. useDiffuseColor: boolean;
  65878. /**
  65879. * Array containing the excluded meshes not rendered in the internal pass
  65880. */
  65881. excludedMeshes: AbstractMesh[];
  65882. /**
  65883. * Controls the overall intensity of the post-process
  65884. */
  65885. exposure: number;
  65886. /**
  65887. * Dissipates each sample's contribution in range [0, 1]
  65888. */
  65889. decay: number;
  65890. /**
  65891. * Controls the overall intensity of each sample
  65892. */
  65893. weight: number;
  65894. /**
  65895. * Controls the density of each sample
  65896. */
  65897. density: number;
  65898. /**
  65899. * @constructor
  65900. * @param name The post-process name
  65901. * @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)
  65902. * @param camera The camera that the post-process will be attached to
  65903. * @param mesh The mesh used to create the light scattering
  65904. * @param samples The post-process quality, default 100
  65905. * @param samplingModeThe post-process filtering mode
  65906. * @param engine The babylon engine
  65907. * @param reusable If the post-process is reusable
  65908. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65909. */
  65910. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65911. /**
  65912. * Returns the string "VolumetricLightScatteringPostProcess"
  65913. * @returns "VolumetricLightScatteringPostProcess"
  65914. */
  65915. getClassName(): string;
  65916. private _isReady;
  65917. /**
  65918. * Sets the new light position for light scattering effect
  65919. * @param position The new custom light position
  65920. */
  65921. setCustomMeshPosition(position: Vector3): void;
  65922. /**
  65923. * Returns the light position for light scattering effect
  65924. * @return Vector3 The custom light position
  65925. */
  65926. getCustomMeshPosition(): Vector3;
  65927. /**
  65928. * Disposes the internal assets and detaches the post-process from the camera
  65929. */
  65930. dispose(camera: Camera): void;
  65931. /**
  65932. * Returns the render target texture used by the post-process
  65933. * @return the render target texture used by the post-process
  65934. */
  65935. getPass(): RenderTargetTexture;
  65936. private _meshExcluded;
  65937. private _createPass;
  65938. private _updateMeshScreenCoordinates;
  65939. /**
  65940. * Creates a default mesh for the Volumeric Light Scattering post-process
  65941. * @param name The mesh name
  65942. * @param scene The scene where to create the mesh
  65943. * @return the default mesh
  65944. */
  65945. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65946. }
  65947. }
  65948. declare module "babylonjs/PostProcesses/index" {
  65949. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65950. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65951. export * from "babylonjs/PostProcesses/bloomEffect";
  65952. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65953. export * from "babylonjs/PostProcesses/blurPostProcess";
  65954. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65955. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65956. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65957. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65958. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65959. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65960. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65961. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65962. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65963. export * from "babylonjs/PostProcesses/filterPostProcess";
  65964. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65965. export * from "babylonjs/PostProcesses/grainPostProcess";
  65966. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65967. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65968. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65969. export * from "babylonjs/PostProcesses/passPostProcess";
  65970. export * from "babylonjs/PostProcesses/postProcess";
  65971. export * from "babylonjs/PostProcesses/postProcessManager";
  65972. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65973. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65974. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65975. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65976. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65977. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65978. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65979. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65980. }
  65981. declare module "babylonjs/Probes/index" {
  65982. export * from "babylonjs/Probes/reflectionProbe";
  65983. }
  65984. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65985. import { Scene } from "babylonjs/scene";
  65986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65987. import { SmartArray } from "babylonjs/Misc/smartArray";
  65988. import { ISceneComponent } from "babylonjs/sceneComponent";
  65989. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65990. import "babylonjs/Meshes/Builders/boxBuilder";
  65991. import "babylonjs/Shaders/color.fragment";
  65992. import "babylonjs/Shaders/color.vertex";
  65993. import { Color3 } from "babylonjs/Maths/math.color";
  65994. module "babylonjs/scene" {
  65995. interface Scene {
  65996. /** @hidden (Backing field) */
  65997. _boundingBoxRenderer: BoundingBoxRenderer;
  65998. /** @hidden (Backing field) */
  65999. _forceShowBoundingBoxes: boolean;
  66000. /**
  66001. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66002. */
  66003. forceShowBoundingBoxes: boolean;
  66004. /**
  66005. * Gets the bounding box renderer associated with the scene
  66006. * @returns a BoundingBoxRenderer
  66007. */
  66008. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66009. }
  66010. }
  66011. module "babylonjs/Meshes/abstractMesh" {
  66012. interface AbstractMesh {
  66013. /** @hidden (Backing field) */
  66014. _showBoundingBox: boolean;
  66015. /**
  66016. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66017. */
  66018. showBoundingBox: boolean;
  66019. }
  66020. }
  66021. /**
  66022. * Component responsible of rendering the bounding box of the meshes in a scene.
  66023. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66024. */
  66025. export class BoundingBoxRenderer implements ISceneComponent {
  66026. /**
  66027. * The component name helpfull to identify the component in the list of scene components.
  66028. */
  66029. readonly name: string;
  66030. /**
  66031. * The scene the component belongs to.
  66032. */
  66033. scene: Scene;
  66034. /**
  66035. * Color of the bounding box lines placed in front of an object
  66036. */
  66037. frontColor: Color3;
  66038. /**
  66039. * Color of the bounding box lines placed behind an object
  66040. */
  66041. backColor: Color3;
  66042. /**
  66043. * Defines if the renderer should show the back lines or not
  66044. */
  66045. showBackLines: boolean;
  66046. /**
  66047. * @hidden
  66048. */
  66049. renderList: SmartArray<BoundingBox>;
  66050. private _colorShader;
  66051. private _vertexBuffers;
  66052. private _indexBuffer;
  66053. private _fillIndexBuffer;
  66054. private _fillIndexData;
  66055. /**
  66056. * Instantiates a new bounding box renderer in a scene.
  66057. * @param scene the scene the renderer renders in
  66058. */
  66059. constructor(scene: Scene);
  66060. /**
  66061. * Registers the component in a given scene
  66062. */
  66063. register(): void;
  66064. private _evaluateSubMesh;
  66065. private _activeMesh;
  66066. private _prepareRessources;
  66067. private _createIndexBuffer;
  66068. /**
  66069. * Rebuilds the elements related to this component in case of
  66070. * context lost for instance.
  66071. */
  66072. rebuild(): void;
  66073. /**
  66074. * @hidden
  66075. */
  66076. reset(): void;
  66077. /**
  66078. * Render the bounding boxes of a specific rendering group
  66079. * @param renderingGroupId defines the rendering group to render
  66080. */
  66081. render(renderingGroupId: number): void;
  66082. /**
  66083. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66084. * @param mesh Define the mesh to render the occlusion bounding box for
  66085. */
  66086. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66087. /**
  66088. * Dispose and release the resources attached to this renderer.
  66089. */
  66090. dispose(): void;
  66091. }
  66092. }
  66093. declare module "babylonjs/Shaders/depth.fragment" {
  66094. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66095. /** @hidden */
  66096. export var depthPixelShader: {
  66097. name: string;
  66098. shader: string;
  66099. };
  66100. }
  66101. declare module "babylonjs/Rendering/depthRenderer" {
  66102. import { Nullable } from "babylonjs/types";
  66103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66104. import { Scene } from "babylonjs/scene";
  66105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66106. import { Camera } from "babylonjs/Cameras/camera";
  66107. import "babylonjs/Shaders/depth.fragment";
  66108. import "babylonjs/Shaders/depth.vertex";
  66109. /**
  66110. * This represents a depth renderer in Babylon.
  66111. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66112. */
  66113. export class DepthRenderer {
  66114. private _scene;
  66115. private _depthMap;
  66116. private _effect;
  66117. private readonly _storeNonLinearDepth;
  66118. private readonly _clearColor;
  66119. /** Get if the depth renderer is using packed depth or not */
  66120. readonly isPacked: boolean;
  66121. private _cachedDefines;
  66122. private _camera;
  66123. /**
  66124. * Specifiess that the depth renderer will only be used within
  66125. * the camera it is created for.
  66126. * This can help forcing its rendering during the camera processing.
  66127. */
  66128. useOnlyInActiveCamera: boolean;
  66129. /** @hidden */
  66130. static _SceneComponentInitialization: (scene: Scene) => void;
  66131. /**
  66132. * Instantiates a depth renderer
  66133. * @param scene The scene the renderer belongs to
  66134. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66135. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66136. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66137. */
  66138. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66139. /**
  66140. * Creates the depth rendering effect and checks if the effect is ready.
  66141. * @param subMesh The submesh to be used to render the depth map of
  66142. * @param useInstances If multiple world instances should be used
  66143. * @returns if the depth renderer is ready to render the depth map
  66144. */
  66145. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66146. /**
  66147. * Gets the texture which the depth map will be written to.
  66148. * @returns The depth map texture
  66149. */
  66150. getDepthMap(): RenderTargetTexture;
  66151. /**
  66152. * Disposes of the depth renderer.
  66153. */
  66154. dispose(): void;
  66155. }
  66156. }
  66157. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66158. import { Nullable } from "babylonjs/types";
  66159. import { Scene } from "babylonjs/scene";
  66160. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66161. import { Camera } from "babylonjs/Cameras/camera";
  66162. import { ISceneComponent } from "babylonjs/sceneComponent";
  66163. module "babylonjs/scene" {
  66164. interface Scene {
  66165. /** @hidden (Backing field) */
  66166. _depthRenderer: {
  66167. [id: string]: DepthRenderer;
  66168. };
  66169. /**
  66170. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66171. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66172. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66173. * @returns the created depth renderer
  66174. */
  66175. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66176. /**
  66177. * Disables a depth renderer for a given camera
  66178. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66179. */
  66180. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66181. }
  66182. }
  66183. /**
  66184. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66185. * in several rendering techniques.
  66186. */
  66187. export class DepthRendererSceneComponent implements ISceneComponent {
  66188. /**
  66189. * The component name helpfull to identify the component in the list of scene components.
  66190. */
  66191. readonly name: string;
  66192. /**
  66193. * The scene the component belongs to.
  66194. */
  66195. scene: Scene;
  66196. /**
  66197. * Creates a new instance of the component for the given scene
  66198. * @param scene Defines the scene to register the component in
  66199. */
  66200. constructor(scene: Scene);
  66201. /**
  66202. * Registers the component in a given scene
  66203. */
  66204. register(): void;
  66205. /**
  66206. * Rebuilds the elements related to this component in case of
  66207. * context lost for instance.
  66208. */
  66209. rebuild(): void;
  66210. /**
  66211. * Disposes the component and the associated ressources
  66212. */
  66213. dispose(): void;
  66214. private _gatherRenderTargets;
  66215. private _gatherActiveCameraRenderTargets;
  66216. }
  66217. }
  66218. declare module "babylonjs/Shaders/outline.fragment" {
  66219. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66220. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66221. /** @hidden */
  66222. export var outlinePixelShader: {
  66223. name: string;
  66224. shader: string;
  66225. };
  66226. }
  66227. declare module "babylonjs/Shaders/outline.vertex" {
  66228. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66229. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66231. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66232. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66233. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66234. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66235. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66236. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66237. /** @hidden */
  66238. export var outlineVertexShader: {
  66239. name: string;
  66240. shader: string;
  66241. };
  66242. }
  66243. declare module "babylonjs/Rendering/outlineRenderer" {
  66244. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66245. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66246. import { Scene } from "babylonjs/scene";
  66247. import { ISceneComponent } from "babylonjs/sceneComponent";
  66248. import "babylonjs/Shaders/outline.fragment";
  66249. import "babylonjs/Shaders/outline.vertex";
  66250. module "babylonjs/scene" {
  66251. interface Scene {
  66252. /** @hidden */
  66253. _outlineRenderer: OutlineRenderer;
  66254. /**
  66255. * Gets the outline renderer associated with the scene
  66256. * @returns a OutlineRenderer
  66257. */
  66258. getOutlineRenderer(): OutlineRenderer;
  66259. }
  66260. }
  66261. module "babylonjs/Meshes/abstractMesh" {
  66262. interface AbstractMesh {
  66263. /** @hidden (Backing field) */
  66264. _renderOutline: boolean;
  66265. /**
  66266. * Gets or sets a boolean indicating if the outline must be rendered as well
  66267. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66268. */
  66269. renderOutline: boolean;
  66270. /** @hidden (Backing field) */
  66271. _renderOverlay: boolean;
  66272. /**
  66273. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66274. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66275. */
  66276. renderOverlay: boolean;
  66277. }
  66278. }
  66279. /**
  66280. * This class is responsible to draw bothe outline/overlay of meshes.
  66281. * It should not be used directly but through the available method on mesh.
  66282. */
  66283. export class OutlineRenderer implements ISceneComponent {
  66284. /**
  66285. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66286. */
  66287. private static _StencilReference;
  66288. /**
  66289. * The name of the component. Each component must have a unique name.
  66290. */
  66291. name: string;
  66292. /**
  66293. * The scene the component belongs to.
  66294. */
  66295. scene: Scene;
  66296. /**
  66297. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66298. */
  66299. zOffset: number;
  66300. private _engine;
  66301. private _effect;
  66302. private _cachedDefines;
  66303. private _savedDepthWrite;
  66304. /**
  66305. * Instantiates a new outline renderer. (There could be only one per scene).
  66306. * @param scene Defines the scene it belongs to
  66307. */
  66308. constructor(scene: Scene);
  66309. /**
  66310. * Register the component to one instance of a scene.
  66311. */
  66312. register(): void;
  66313. /**
  66314. * Rebuilds the elements related to this component in case of
  66315. * context lost for instance.
  66316. */
  66317. rebuild(): void;
  66318. /**
  66319. * Disposes the component and the associated ressources.
  66320. */
  66321. dispose(): void;
  66322. /**
  66323. * Renders the outline in the canvas.
  66324. * @param subMesh Defines the sumesh to render
  66325. * @param batch Defines the batch of meshes in case of instances
  66326. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66327. */
  66328. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66329. /**
  66330. * Returns whether or not the outline renderer is ready for a given submesh.
  66331. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66332. * @param subMesh Defines the submesh to check readyness for
  66333. * @param useInstances Defines wheter wee are trying to render instances or not
  66334. * @returns true if ready otherwise false
  66335. */
  66336. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66337. private _beforeRenderingMesh;
  66338. private _afterRenderingMesh;
  66339. }
  66340. }
  66341. declare module "babylonjs/Rendering/index" {
  66342. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66343. export * from "babylonjs/Rendering/depthRenderer";
  66344. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66345. export * from "babylonjs/Rendering/edgesRenderer";
  66346. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66347. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66348. export * from "babylonjs/Rendering/outlineRenderer";
  66349. export * from "babylonjs/Rendering/renderingGroup";
  66350. export * from "babylonjs/Rendering/renderingManager";
  66351. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66352. }
  66353. declare module "babylonjs/Sprites/spritePackedManager" {
  66354. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66355. import { Scene } from "babylonjs/scene";
  66356. /**
  66357. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66358. * @see http://doc.babylonjs.com/babylon101/sprites
  66359. */
  66360. export class SpritePackedManager extends SpriteManager {
  66361. /** defines the packed manager's name */
  66362. name: string;
  66363. /**
  66364. * Creates a new sprite manager from a packed sprite sheet
  66365. * @param name defines the manager's name
  66366. * @param imgUrl defines the sprite sheet url
  66367. * @param capacity defines the maximum allowed number of sprites
  66368. * @param scene defines the hosting scene
  66369. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66370. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66371. * @param samplingMode defines the smapling mode to use with spritesheet
  66372. * @param fromPacked set to true; do not alter
  66373. */
  66374. constructor(
  66375. /** defines the packed manager's name */
  66376. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66377. }
  66378. }
  66379. declare module "babylonjs/Sprites/index" {
  66380. export * from "babylonjs/Sprites/sprite";
  66381. export * from "babylonjs/Sprites/spriteManager";
  66382. export * from "babylonjs/Sprites/spritePackedManager";
  66383. export * from "babylonjs/Sprites/spriteSceneComponent";
  66384. }
  66385. declare module "babylonjs/States/index" {
  66386. export * from "babylonjs/States/alphaCullingState";
  66387. export * from "babylonjs/States/depthCullingState";
  66388. export * from "babylonjs/States/stencilState";
  66389. }
  66390. declare module "babylonjs/Misc/assetsManager" {
  66391. import { Scene } from "babylonjs/scene";
  66392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66394. import { Skeleton } from "babylonjs/Bones/skeleton";
  66395. import { Observable } from "babylonjs/Misc/observable";
  66396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66397. import { Texture } from "babylonjs/Materials/Textures/texture";
  66398. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66399. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66400. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66401. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66402. /**
  66403. * Defines the list of states available for a task inside a AssetsManager
  66404. */
  66405. export enum AssetTaskState {
  66406. /**
  66407. * Initialization
  66408. */
  66409. INIT = 0,
  66410. /**
  66411. * Running
  66412. */
  66413. RUNNING = 1,
  66414. /**
  66415. * Done
  66416. */
  66417. DONE = 2,
  66418. /**
  66419. * Error
  66420. */
  66421. ERROR = 3
  66422. }
  66423. /**
  66424. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66425. */
  66426. export abstract class AbstractAssetTask {
  66427. /**
  66428. * Task name
  66429. */ name: string;
  66430. /**
  66431. * Callback called when the task is successful
  66432. */
  66433. onSuccess: (task: any) => void;
  66434. /**
  66435. * Callback called when the task is not successful
  66436. */
  66437. onError: (task: any, message?: string, exception?: any) => void;
  66438. /**
  66439. * Creates a new AssetsManager
  66440. * @param name defines the name of the task
  66441. */
  66442. constructor(
  66443. /**
  66444. * Task name
  66445. */ name: string);
  66446. private _isCompleted;
  66447. private _taskState;
  66448. private _errorObject;
  66449. /**
  66450. * Get if the task is completed
  66451. */
  66452. readonly isCompleted: boolean;
  66453. /**
  66454. * Gets the current state of the task
  66455. */
  66456. readonly taskState: AssetTaskState;
  66457. /**
  66458. * Gets the current error object (if task is in error)
  66459. */
  66460. readonly errorObject: {
  66461. message?: string;
  66462. exception?: any;
  66463. };
  66464. /**
  66465. * Internal only
  66466. * @hidden
  66467. */
  66468. _setErrorObject(message?: string, exception?: any): void;
  66469. /**
  66470. * Execute the current task
  66471. * @param scene defines the scene where you want your assets to be loaded
  66472. * @param onSuccess is a callback called when the task is successfully executed
  66473. * @param onError is a callback called if an error occurs
  66474. */
  66475. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66476. /**
  66477. * Execute the current task
  66478. * @param scene defines the scene where you want your assets to be loaded
  66479. * @param onSuccess is a callback called when the task is successfully executed
  66480. * @param onError is a callback called if an error occurs
  66481. */
  66482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66483. /**
  66484. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66485. * This can be used with failed tasks that have the reason for failure fixed.
  66486. */
  66487. reset(): void;
  66488. private onErrorCallback;
  66489. private onDoneCallback;
  66490. }
  66491. /**
  66492. * Define the interface used by progress events raised during assets loading
  66493. */
  66494. export interface IAssetsProgressEvent {
  66495. /**
  66496. * Defines the number of remaining tasks to process
  66497. */
  66498. remainingCount: number;
  66499. /**
  66500. * Defines the total number of tasks
  66501. */
  66502. totalCount: number;
  66503. /**
  66504. * Defines the task that was just processed
  66505. */
  66506. task: AbstractAssetTask;
  66507. }
  66508. /**
  66509. * Class used to share progress information about assets loading
  66510. */
  66511. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66512. /**
  66513. * Defines the number of remaining tasks to process
  66514. */
  66515. remainingCount: number;
  66516. /**
  66517. * Defines the total number of tasks
  66518. */
  66519. totalCount: number;
  66520. /**
  66521. * Defines the task that was just processed
  66522. */
  66523. task: AbstractAssetTask;
  66524. /**
  66525. * Creates a AssetsProgressEvent
  66526. * @param remainingCount defines the number of remaining tasks to process
  66527. * @param totalCount defines the total number of tasks
  66528. * @param task defines the task that was just processed
  66529. */
  66530. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66531. }
  66532. /**
  66533. * Define a task used by AssetsManager to load meshes
  66534. */
  66535. export class MeshAssetTask extends AbstractAssetTask {
  66536. /**
  66537. * Defines the name of the task
  66538. */
  66539. name: string;
  66540. /**
  66541. * Defines the list of mesh's names you want to load
  66542. */
  66543. meshesNames: any;
  66544. /**
  66545. * Defines the root url to use as a base to load your meshes and associated resources
  66546. */
  66547. rootUrl: string;
  66548. /**
  66549. * Defines the filename of the scene to load from
  66550. */
  66551. sceneFilename: string;
  66552. /**
  66553. * Gets the list of loaded meshes
  66554. */
  66555. loadedMeshes: Array<AbstractMesh>;
  66556. /**
  66557. * Gets the list of loaded particle systems
  66558. */
  66559. loadedParticleSystems: Array<IParticleSystem>;
  66560. /**
  66561. * Gets the list of loaded skeletons
  66562. */
  66563. loadedSkeletons: Array<Skeleton>;
  66564. /**
  66565. * Gets the list of loaded animation groups
  66566. */
  66567. loadedAnimationGroups: Array<AnimationGroup>;
  66568. /**
  66569. * Callback called when the task is successful
  66570. */
  66571. onSuccess: (task: MeshAssetTask) => void;
  66572. /**
  66573. * Callback called when the task is successful
  66574. */
  66575. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66576. /**
  66577. * Creates a new MeshAssetTask
  66578. * @param name defines the name of the task
  66579. * @param meshesNames defines the list of mesh's names you want to load
  66580. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66581. * @param sceneFilename defines the filename of the scene to load from
  66582. */
  66583. constructor(
  66584. /**
  66585. * Defines the name of the task
  66586. */
  66587. name: string,
  66588. /**
  66589. * Defines the list of mesh's names you want to load
  66590. */
  66591. meshesNames: any,
  66592. /**
  66593. * Defines the root url to use as a base to load your meshes and associated resources
  66594. */
  66595. rootUrl: string,
  66596. /**
  66597. * Defines the filename of the scene to load from
  66598. */
  66599. sceneFilename: string);
  66600. /**
  66601. * Execute the current task
  66602. * @param scene defines the scene where you want your assets to be loaded
  66603. * @param onSuccess is a callback called when the task is successfully executed
  66604. * @param onError is a callback called if an error occurs
  66605. */
  66606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66607. }
  66608. /**
  66609. * Define a task used by AssetsManager to load text content
  66610. */
  66611. export class TextFileAssetTask extends AbstractAssetTask {
  66612. /**
  66613. * Defines the name of the task
  66614. */
  66615. name: string;
  66616. /**
  66617. * Defines the location of the file to load
  66618. */
  66619. url: string;
  66620. /**
  66621. * Gets the loaded text string
  66622. */
  66623. text: string;
  66624. /**
  66625. * Callback called when the task is successful
  66626. */
  66627. onSuccess: (task: TextFileAssetTask) => void;
  66628. /**
  66629. * Callback called when the task is successful
  66630. */
  66631. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66632. /**
  66633. * Creates a new TextFileAssetTask object
  66634. * @param name defines the name of the task
  66635. * @param url defines the location of the file to load
  66636. */
  66637. constructor(
  66638. /**
  66639. * Defines the name of the task
  66640. */
  66641. name: string,
  66642. /**
  66643. * Defines the location of the file to load
  66644. */
  66645. url: string);
  66646. /**
  66647. * Execute the current task
  66648. * @param scene defines the scene where you want your assets to be loaded
  66649. * @param onSuccess is a callback called when the task is successfully executed
  66650. * @param onError is a callback called if an error occurs
  66651. */
  66652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66653. }
  66654. /**
  66655. * Define a task used by AssetsManager to load binary data
  66656. */
  66657. export class BinaryFileAssetTask extends AbstractAssetTask {
  66658. /**
  66659. * Defines the name of the task
  66660. */
  66661. name: string;
  66662. /**
  66663. * Defines the location of the file to load
  66664. */
  66665. url: string;
  66666. /**
  66667. * Gets the lodaded data (as an array buffer)
  66668. */
  66669. data: ArrayBuffer;
  66670. /**
  66671. * Callback called when the task is successful
  66672. */
  66673. onSuccess: (task: BinaryFileAssetTask) => void;
  66674. /**
  66675. * Callback called when the task is successful
  66676. */
  66677. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66678. /**
  66679. * Creates a new BinaryFileAssetTask object
  66680. * @param name defines the name of the new task
  66681. * @param url defines the location of the file to load
  66682. */
  66683. constructor(
  66684. /**
  66685. * Defines the name of the task
  66686. */
  66687. name: string,
  66688. /**
  66689. * Defines the location of the file to load
  66690. */
  66691. url: string);
  66692. /**
  66693. * Execute the current task
  66694. * @param scene defines the scene where you want your assets to be loaded
  66695. * @param onSuccess is a callback called when the task is successfully executed
  66696. * @param onError is a callback called if an error occurs
  66697. */
  66698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66699. }
  66700. /**
  66701. * Define a task used by AssetsManager to load images
  66702. */
  66703. export class ImageAssetTask extends AbstractAssetTask {
  66704. /**
  66705. * Defines the name of the task
  66706. */
  66707. name: string;
  66708. /**
  66709. * Defines the location of the image to load
  66710. */
  66711. url: string;
  66712. /**
  66713. * Gets the loaded images
  66714. */
  66715. image: HTMLImageElement;
  66716. /**
  66717. * Callback called when the task is successful
  66718. */
  66719. onSuccess: (task: ImageAssetTask) => void;
  66720. /**
  66721. * Callback called when the task is successful
  66722. */
  66723. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66724. /**
  66725. * Creates a new ImageAssetTask
  66726. * @param name defines the name of the task
  66727. * @param url defines the location of the image to load
  66728. */
  66729. constructor(
  66730. /**
  66731. * Defines the name of the task
  66732. */
  66733. name: string,
  66734. /**
  66735. * Defines the location of the image to load
  66736. */
  66737. url: string);
  66738. /**
  66739. * Execute the current task
  66740. * @param scene defines the scene where you want your assets to be loaded
  66741. * @param onSuccess is a callback called when the task is successfully executed
  66742. * @param onError is a callback called if an error occurs
  66743. */
  66744. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66745. }
  66746. /**
  66747. * Defines the interface used by texture loading tasks
  66748. */
  66749. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66750. /**
  66751. * Gets the loaded texture
  66752. */
  66753. texture: TEX;
  66754. }
  66755. /**
  66756. * Define a task used by AssetsManager to load 2D textures
  66757. */
  66758. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66759. /**
  66760. * Defines the name of the task
  66761. */
  66762. name: string;
  66763. /**
  66764. * Defines the location of the file to load
  66765. */
  66766. url: string;
  66767. /**
  66768. * Defines if mipmap should not be generated (default is false)
  66769. */
  66770. noMipmap?: boolean | undefined;
  66771. /**
  66772. * Defines if texture must be inverted on Y axis (default is false)
  66773. */
  66774. invertY?: boolean | undefined;
  66775. /**
  66776. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66777. */
  66778. samplingMode: number;
  66779. /**
  66780. * Gets the loaded texture
  66781. */
  66782. texture: Texture;
  66783. /**
  66784. * Callback called when the task is successful
  66785. */
  66786. onSuccess: (task: TextureAssetTask) => void;
  66787. /**
  66788. * Callback called when the task is successful
  66789. */
  66790. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66791. /**
  66792. * Creates a new TextureAssetTask object
  66793. * @param name defines the name of the task
  66794. * @param url defines the location of the file to load
  66795. * @param noMipmap defines if mipmap should not be generated (default is false)
  66796. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66797. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66798. */
  66799. constructor(
  66800. /**
  66801. * Defines the name of the task
  66802. */
  66803. name: string,
  66804. /**
  66805. * Defines the location of the file to load
  66806. */
  66807. url: string,
  66808. /**
  66809. * Defines if mipmap should not be generated (default is false)
  66810. */
  66811. noMipmap?: boolean | undefined,
  66812. /**
  66813. * Defines if texture must be inverted on Y axis (default is false)
  66814. */
  66815. invertY?: boolean | undefined,
  66816. /**
  66817. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66818. */
  66819. samplingMode?: number);
  66820. /**
  66821. * Execute the current task
  66822. * @param scene defines the scene where you want your assets to be loaded
  66823. * @param onSuccess is a callback called when the task is successfully executed
  66824. * @param onError is a callback called if an error occurs
  66825. */
  66826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66827. }
  66828. /**
  66829. * Define a task used by AssetsManager to load cube textures
  66830. */
  66831. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66832. /**
  66833. * Defines the name of the task
  66834. */
  66835. name: string;
  66836. /**
  66837. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66838. */
  66839. url: string;
  66840. /**
  66841. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66842. */
  66843. extensions?: string[] | undefined;
  66844. /**
  66845. * Defines if mipmaps should not be generated (default is false)
  66846. */
  66847. noMipmap?: boolean | undefined;
  66848. /**
  66849. * Defines the explicit list of files (undefined by default)
  66850. */
  66851. files?: string[] | undefined;
  66852. /**
  66853. * Gets the loaded texture
  66854. */
  66855. texture: CubeTexture;
  66856. /**
  66857. * Callback called when the task is successful
  66858. */
  66859. onSuccess: (task: CubeTextureAssetTask) => void;
  66860. /**
  66861. * Callback called when the task is successful
  66862. */
  66863. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66864. /**
  66865. * Creates a new CubeTextureAssetTask
  66866. * @param name defines the name of the task
  66867. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66868. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66869. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66870. * @param files defines the explicit list of files (undefined by default)
  66871. */
  66872. constructor(
  66873. /**
  66874. * Defines the name of the task
  66875. */
  66876. name: string,
  66877. /**
  66878. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66879. */
  66880. url: string,
  66881. /**
  66882. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66883. */
  66884. extensions?: string[] | undefined,
  66885. /**
  66886. * Defines if mipmaps should not be generated (default is false)
  66887. */
  66888. noMipmap?: boolean | undefined,
  66889. /**
  66890. * Defines the explicit list of files (undefined by default)
  66891. */
  66892. files?: string[] | undefined);
  66893. /**
  66894. * Execute the current task
  66895. * @param scene defines the scene where you want your assets to be loaded
  66896. * @param onSuccess is a callback called when the task is successfully executed
  66897. * @param onError is a callback called if an error occurs
  66898. */
  66899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66900. }
  66901. /**
  66902. * Define a task used by AssetsManager to load HDR cube textures
  66903. */
  66904. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66905. /**
  66906. * Defines the name of the task
  66907. */
  66908. name: string;
  66909. /**
  66910. * Defines the location of the file to load
  66911. */
  66912. url: string;
  66913. /**
  66914. * Defines the desired size (the more it increases the longer the generation will be)
  66915. */
  66916. size: number;
  66917. /**
  66918. * Defines if mipmaps should not be generated (default is false)
  66919. */
  66920. noMipmap: boolean;
  66921. /**
  66922. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66923. */
  66924. generateHarmonics: boolean;
  66925. /**
  66926. * 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)
  66927. */
  66928. gammaSpace: boolean;
  66929. /**
  66930. * Internal Use Only
  66931. */
  66932. reserved: boolean;
  66933. /**
  66934. * Gets the loaded texture
  66935. */
  66936. texture: HDRCubeTexture;
  66937. /**
  66938. * Callback called when the task is successful
  66939. */
  66940. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66941. /**
  66942. * Callback called when the task is successful
  66943. */
  66944. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66945. /**
  66946. * Creates a new HDRCubeTextureAssetTask object
  66947. * @param name defines the name of the task
  66948. * @param url defines the location of the file to load
  66949. * @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.
  66950. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66951. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66952. * @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)
  66953. * @param reserved Internal use only
  66954. */
  66955. constructor(
  66956. /**
  66957. * Defines the name of the task
  66958. */
  66959. name: string,
  66960. /**
  66961. * Defines the location of the file to load
  66962. */
  66963. url: string,
  66964. /**
  66965. * Defines the desired size (the more it increases the longer the generation will be)
  66966. */
  66967. size: number,
  66968. /**
  66969. * Defines if mipmaps should not be generated (default is false)
  66970. */
  66971. noMipmap?: boolean,
  66972. /**
  66973. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66974. */
  66975. generateHarmonics?: boolean,
  66976. /**
  66977. * 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)
  66978. */
  66979. gammaSpace?: boolean,
  66980. /**
  66981. * Internal Use Only
  66982. */
  66983. reserved?: boolean);
  66984. /**
  66985. * Execute the current task
  66986. * @param scene defines the scene where you want your assets to be loaded
  66987. * @param onSuccess is a callback called when the task is successfully executed
  66988. * @param onError is a callback called if an error occurs
  66989. */
  66990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66991. }
  66992. /**
  66993. * Define a task used by AssetsManager to load Equirectangular cube textures
  66994. */
  66995. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66996. /**
  66997. * Defines the name of the task
  66998. */
  66999. name: string;
  67000. /**
  67001. * Defines the location of the file to load
  67002. */
  67003. url: string;
  67004. /**
  67005. * Defines the desired size (the more it increases the longer the generation will be)
  67006. */
  67007. size: number;
  67008. /**
  67009. * Defines if mipmaps should not be generated (default is false)
  67010. */
  67011. noMipmap: boolean;
  67012. /**
  67013. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67014. * but the standard material would require them in Gamma space) (default is true)
  67015. */
  67016. gammaSpace: boolean;
  67017. /**
  67018. * Gets the loaded texture
  67019. */
  67020. texture: EquiRectangularCubeTexture;
  67021. /**
  67022. * Callback called when the task is successful
  67023. */
  67024. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67025. /**
  67026. * Callback called when the task is successful
  67027. */
  67028. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67029. /**
  67030. * Creates a new EquiRectangularCubeTextureAssetTask object
  67031. * @param name defines the name of the task
  67032. * @param url defines the location of the file to load
  67033. * @param size defines the desired size (the more it increases the longer the generation will be)
  67034. * If the size is omitted this implies you are using a preprocessed cubemap.
  67035. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67036. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67037. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67038. * (default is true)
  67039. */
  67040. constructor(
  67041. /**
  67042. * Defines the name of the task
  67043. */
  67044. name: string,
  67045. /**
  67046. * Defines the location of the file to load
  67047. */
  67048. url: string,
  67049. /**
  67050. * Defines the desired size (the more it increases the longer the generation will be)
  67051. */
  67052. size: number,
  67053. /**
  67054. * Defines if mipmaps should not be generated (default is false)
  67055. */
  67056. noMipmap?: boolean,
  67057. /**
  67058. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67059. * but the standard material would require them in Gamma space) (default is true)
  67060. */
  67061. gammaSpace?: boolean);
  67062. /**
  67063. * Execute the current task
  67064. * @param scene defines the scene where you want your assets to be loaded
  67065. * @param onSuccess is a callback called when the task is successfully executed
  67066. * @param onError is a callback called if an error occurs
  67067. */
  67068. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67069. }
  67070. /**
  67071. * This class can be used to easily import assets into a scene
  67072. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67073. */
  67074. export class AssetsManager {
  67075. private _scene;
  67076. private _isLoading;
  67077. protected _tasks: AbstractAssetTask[];
  67078. protected _waitingTasksCount: number;
  67079. protected _totalTasksCount: number;
  67080. /**
  67081. * Callback called when all tasks are processed
  67082. */
  67083. onFinish: (tasks: AbstractAssetTask[]) => void;
  67084. /**
  67085. * Callback called when a task is successful
  67086. */
  67087. onTaskSuccess: (task: AbstractAssetTask) => void;
  67088. /**
  67089. * Callback called when a task had an error
  67090. */
  67091. onTaskError: (task: AbstractAssetTask) => void;
  67092. /**
  67093. * Callback called when a task is done (whatever the result is)
  67094. */
  67095. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67096. /**
  67097. * Observable called when all tasks are processed
  67098. */
  67099. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67100. /**
  67101. * Observable called when a task had an error
  67102. */
  67103. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67104. /**
  67105. * Observable called when all tasks were executed
  67106. */
  67107. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67108. /**
  67109. * Observable called when a task is done (whatever the result is)
  67110. */
  67111. onProgressObservable: Observable<IAssetsProgressEvent>;
  67112. /**
  67113. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67115. */
  67116. useDefaultLoadingScreen: boolean;
  67117. /**
  67118. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67119. * when all assets have been downloaded.
  67120. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67121. */
  67122. autoHideLoadingUI: boolean;
  67123. /**
  67124. * Creates a new AssetsManager
  67125. * @param scene defines the scene to work on
  67126. */
  67127. constructor(scene: Scene);
  67128. /**
  67129. * Add a MeshAssetTask to the list of active tasks
  67130. * @param taskName defines the name of the new task
  67131. * @param meshesNames defines the name of meshes to load
  67132. * @param rootUrl defines the root url to use to locate files
  67133. * @param sceneFilename defines the filename of the scene file
  67134. * @returns a new MeshAssetTask object
  67135. */
  67136. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67137. /**
  67138. * Add a TextFileAssetTask to the list of active tasks
  67139. * @param taskName defines the name of the new task
  67140. * @param url defines the url of the file to load
  67141. * @returns a new TextFileAssetTask object
  67142. */
  67143. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67144. /**
  67145. * Add a BinaryFileAssetTask to the list of active tasks
  67146. * @param taskName defines the name of the new task
  67147. * @param url defines the url of the file to load
  67148. * @returns a new BinaryFileAssetTask object
  67149. */
  67150. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67151. /**
  67152. * Add a ImageAssetTask to the list of active tasks
  67153. * @param taskName defines the name of the new task
  67154. * @param url defines the url of the file to load
  67155. * @returns a new ImageAssetTask object
  67156. */
  67157. addImageTask(taskName: string, url: string): ImageAssetTask;
  67158. /**
  67159. * Add a TextureAssetTask to the list of active tasks
  67160. * @param taskName defines the name of the new task
  67161. * @param url defines the url of the file to load
  67162. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67163. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67164. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67165. * @returns a new TextureAssetTask object
  67166. */
  67167. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67168. /**
  67169. * Add a CubeTextureAssetTask to the list of active tasks
  67170. * @param taskName defines the name of the new task
  67171. * @param url defines the url of the file to load
  67172. * @param extensions defines the extension to use to load the cube map (can be null)
  67173. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67174. * @param files defines the list of files to load (can be null)
  67175. * @returns a new CubeTextureAssetTask object
  67176. */
  67177. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67178. /**
  67179. *
  67180. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67181. * @param taskName defines the name of the new task
  67182. * @param url defines the url of the file to load
  67183. * @param size defines the size you want for the cubemap (can be null)
  67184. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67185. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67186. * @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)
  67187. * @param reserved Internal use only
  67188. * @returns a new HDRCubeTextureAssetTask object
  67189. */
  67190. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67191. /**
  67192. *
  67193. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67194. * @param taskName defines the name of the new task
  67195. * @param url defines the url of the file to load
  67196. * @param size defines the size you want for the cubemap (can be null)
  67197. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67198. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67199. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67200. * @returns a new EquiRectangularCubeTextureAssetTask object
  67201. */
  67202. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67203. /**
  67204. * Remove a task from the assets manager.
  67205. * @param task the task to remove
  67206. */
  67207. removeTask(task: AbstractAssetTask): void;
  67208. private _decreaseWaitingTasksCount;
  67209. private _runTask;
  67210. /**
  67211. * Reset the AssetsManager and remove all tasks
  67212. * @return the current instance of the AssetsManager
  67213. */
  67214. reset(): AssetsManager;
  67215. /**
  67216. * Start the loading process
  67217. * @return the current instance of the AssetsManager
  67218. */
  67219. load(): AssetsManager;
  67220. /**
  67221. * Start the loading process as an async operation
  67222. * @return a promise returning the list of failed tasks
  67223. */
  67224. loadAsync(): Promise<void>;
  67225. }
  67226. }
  67227. declare module "babylonjs/Misc/deferred" {
  67228. /**
  67229. * Wrapper class for promise with external resolve and reject.
  67230. */
  67231. export class Deferred<T> {
  67232. /**
  67233. * The promise associated with this deferred object.
  67234. */
  67235. readonly promise: Promise<T>;
  67236. private _resolve;
  67237. private _reject;
  67238. /**
  67239. * The resolve method of the promise associated with this deferred object.
  67240. */
  67241. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67242. /**
  67243. * The reject method of the promise associated with this deferred object.
  67244. */
  67245. readonly reject: (reason?: any) => void;
  67246. /**
  67247. * Constructor for this deferred object.
  67248. */
  67249. constructor();
  67250. }
  67251. }
  67252. declare module "babylonjs/Misc/meshExploder" {
  67253. import { Mesh } from "babylonjs/Meshes/mesh";
  67254. /**
  67255. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67256. */
  67257. export class MeshExploder {
  67258. private _centerMesh;
  67259. private _meshes;
  67260. private _meshesOrigins;
  67261. private _toCenterVectors;
  67262. private _scaledDirection;
  67263. private _newPosition;
  67264. private _centerPosition;
  67265. /**
  67266. * Explodes meshes from a center mesh.
  67267. * @param meshes The meshes to explode.
  67268. * @param centerMesh The mesh to be center of explosion.
  67269. */
  67270. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67271. private _setCenterMesh;
  67272. /**
  67273. * Get class name
  67274. * @returns "MeshExploder"
  67275. */
  67276. getClassName(): string;
  67277. /**
  67278. * "Exploded meshes"
  67279. * @returns Array of meshes with the centerMesh at index 0.
  67280. */
  67281. getMeshes(): Array<Mesh>;
  67282. /**
  67283. * Explodes meshes giving a specific direction
  67284. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67285. */
  67286. explode(direction?: number): void;
  67287. }
  67288. }
  67289. declare module "babylonjs/Misc/filesInput" {
  67290. import { Engine } from "babylonjs/Engines/engine";
  67291. import { Scene } from "babylonjs/scene";
  67292. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67293. /**
  67294. * Class used to help managing file picking and drag'n'drop
  67295. */
  67296. export class FilesInput {
  67297. /**
  67298. * List of files ready to be loaded
  67299. */
  67300. static readonly FilesToLoad: {
  67301. [key: string]: File;
  67302. };
  67303. /**
  67304. * Callback called when a file is processed
  67305. */
  67306. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67307. private _engine;
  67308. private _currentScene;
  67309. private _sceneLoadedCallback;
  67310. private _progressCallback;
  67311. private _additionalRenderLoopLogicCallback;
  67312. private _textureLoadingCallback;
  67313. private _startingProcessingFilesCallback;
  67314. private _onReloadCallback;
  67315. private _errorCallback;
  67316. private _elementToMonitor;
  67317. private _sceneFileToLoad;
  67318. private _filesToLoad;
  67319. /**
  67320. * Creates a new FilesInput
  67321. * @param engine defines the rendering engine
  67322. * @param scene defines the hosting scene
  67323. * @param sceneLoadedCallback callback called when scene is loaded
  67324. * @param progressCallback callback called to track progress
  67325. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67326. * @param textureLoadingCallback callback called when a texture is loading
  67327. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67328. * @param onReloadCallback callback called when a reload is requested
  67329. * @param errorCallback callback call if an error occurs
  67330. */
  67331. 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);
  67332. private _dragEnterHandler;
  67333. private _dragOverHandler;
  67334. private _dropHandler;
  67335. /**
  67336. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67337. * @param elementToMonitor defines the DOM element to track
  67338. */
  67339. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67340. /**
  67341. * Release all associated resources
  67342. */
  67343. dispose(): void;
  67344. private renderFunction;
  67345. private drag;
  67346. private drop;
  67347. private _traverseFolder;
  67348. private _processFiles;
  67349. /**
  67350. * Load files from a drop event
  67351. * @param event defines the drop event to use as source
  67352. */
  67353. loadFiles(event: any): void;
  67354. private _processReload;
  67355. /**
  67356. * Reload the current scene from the loaded files
  67357. */
  67358. reload(): void;
  67359. }
  67360. }
  67361. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67362. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67363. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67364. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67365. }
  67366. declare module "babylonjs/Misc/sceneOptimizer" {
  67367. import { Scene, IDisposable } from "babylonjs/scene";
  67368. import { Observable } from "babylonjs/Misc/observable";
  67369. /**
  67370. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67372. */
  67373. export class SceneOptimization {
  67374. /**
  67375. * Defines the priority of this optimization (0 by default which means first in the list)
  67376. */
  67377. priority: number;
  67378. /**
  67379. * Gets a string describing the action executed by the current optimization
  67380. * @returns description string
  67381. */
  67382. getDescription(): string;
  67383. /**
  67384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67385. * @param scene defines the current scene where to apply this optimization
  67386. * @param optimizer defines the current optimizer
  67387. * @returns true if everything that can be done was applied
  67388. */
  67389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67390. /**
  67391. * Creates the SceneOptimization object
  67392. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67393. * @param desc defines the description associated with the optimization
  67394. */
  67395. constructor(
  67396. /**
  67397. * Defines the priority of this optimization (0 by default which means first in the list)
  67398. */
  67399. priority?: number);
  67400. }
  67401. /**
  67402. * Defines an optimization used to reduce the size of render target textures
  67403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67404. */
  67405. export class TextureOptimization extends SceneOptimization {
  67406. /**
  67407. * Defines the priority of this optimization (0 by default which means first in the list)
  67408. */
  67409. priority: number;
  67410. /**
  67411. * 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
  67412. */
  67413. maximumSize: number;
  67414. /**
  67415. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67416. */
  67417. step: number;
  67418. /**
  67419. * Gets a string describing the action executed by the current optimization
  67420. * @returns description string
  67421. */
  67422. getDescription(): string;
  67423. /**
  67424. * Creates the TextureOptimization object
  67425. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67426. * @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
  67427. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67428. */
  67429. constructor(
  67430. /**
  67431. * Defines the priority of this optimization (0 by default which means first in the list)
  67432. */
  67433. priority?: number,
  67434. /**
  67435. * 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
  67436. */
  67437. maximumSize?: number,
  67438. /**
  67439. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67440. */
  67441. step?: number);
  67442. /**
  67443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67444. * @param scene defines the current scene where to apply this optimization
  67445. * @param optimizer defines the current optimizer
  67446. * @returns true if everything that can be done was applied
  67447. */
  67448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67449. }
  67450. /**
  67451. * Defines an optimization used to increase or decrease the rendering resolution
  67452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67453. */
  67454. export class HardwareScalingOptimization extends SceneOptimization {
  67455. /**
  67456. * Defines the priority of this optimization (0 by default which means first in the list)
  67457. */
  67458. priority: number;
  67459. /**
  67460. * Defines the maximum scale to use (2 by default)
  67461. */
  67462. maximumScale: number;
  67463. /**
  67464. * Defines the step to use between two passes (0.5 by default)
  67465. */
  67466. step: number;
  67467. private _currentScale;
  67468. private _directionOffset;
  67469. /**
  67470. * Gets a string describing the action executed by the current optimization
  67471. * @return description string
  67472. */
  67473. getDescription(): string;
  67474. /**
  67475. * Creates the HardwareScalingOptimization object
  67476. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67477. * @param maximumScale defines the maximum scale to use (2 by default)
  67478. * @param step defines the step to use between two passes (0.5 by default)
  67479. */
  67480. constructor(
  67481. /**
  67482. * Defines the priority of this optimization (0 by default which means first in the list)
  67483. */
  67484. priority?: number,
  67485. /**
  67486. * Defines the maximum scale to use (2 by default)
  67487. */
  67488. maximumScale?: number,
  67489. /**
  67490. * Defines the step to use between two passes (0.5 by default)
  67491. */
  67492. step?: number);
  67493. /**
  67494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67495. * @param scene defines the current scene where to apply this optimization
  67496. * @param optimizer defines the current optimizer
  67497. * @returns true if everything that can be done was applied
  67498. */
  67499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67500. }
  67501. /**
  67502. * Defines an optimization used to remove shadows
  67503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67504. */
  67505. export class ShadowsOptimization extends SceneOptimization {
  67506. /**
  67507. * Gets a string describing the action executed by the current optimization
  67508. * @return description string
  67509. */
  67510. getDescription(): string;
  67511. /**
  67512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67513. * @param scene defines the current scene where to apply this optimization
  67514. * @param optimizer defines the current optimizer
  67515. * @returns true if everything that can be done was applied
  67516. */
  67517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67518. }
  67519. /**
  67520. * Defines an optimization used to turn post-processes off
  67521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67522. */
  67523. export class PostProcessesOptimization extends SceneOptimization {
  67524. /**
  67525. * Gets a string describing the action executed by the current optimization
  67526. * @return description string
  67527. */
  67528. getDescription(): string;
  67529. /**
  67530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67531. * @param scene defines the current scene where to apply this optimization
  67532. * @param optimizer defines the current optimizer
  67533. * @returns true if everything that can be done was applied
  67534. */
  67535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67536. }
  67537. /**
  67538. * Defines an optimization used to turn lens flares off
  67539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67540. */
  67541. export class LensFlaresOptimization extends SceneOptimization {
  67542. /**
  67543. * Gets a string describing the action executed by the current optimization
  67544. * @return description string
  67545. */
  67546. getDescription(): string;
  67547. /**
  67548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67549. * @param scene defines the current scene where to apply this optimization
  67550. * @param optimizer defines the current optimizer
  67551. * @returns true if everything that can be done was applied
  67552. */
  67553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67554. }
  67555. /**
  67556. * Defines an optimization based on user defined callback.
  67557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67558. */
  67559. export class CustomOptimization extends SceneOptimization {
  67560. /**
  67561. * Callback called to apply the custom optimization.
  67562. */
  67563. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67564. /**
  67565. * Callback called to get custom description
  67566. */
  67567. onGetDescription: () => string;
  67568. /**
  67569. * Gets a string describing the action executed by the current optimization
  67570. * @returns description string
  67571. */
  67572. getDescription(): string;
  67573. /**
  67574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67575. * @param scene defines the current scene where to apply this optimization
  67576. * @param optimizer defines the current optimizer
  67577. * @returns true if everything that can be done was applied
  67578. */
  67579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67580. }
  67581. /**
  67582. * Defines an optimization used to turn particles off
  67583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67584. */
  67585. export class ParticlesOptimization extends SceneOptimization {
  67586. /**
  67587. * Gets a string describing the action executed by the current optimization
  67588. * @return description string
  67589. */
  67590. getDescription(): string;
  67591. /**
  67592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67593. * @param scene defines the current scene where to apply this optimization
  67594. * @param optimizer defines the current optimizer
  67595. * @returns true if everything that can be done was applied
  67596. */
  67597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67598. }
  67599. /**
  67600. * Defines an optimization used to turn render targets off
  67601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67602. */
  67603. export class RenderTargetsOptimization extends SceneOptimization {
  67604. /**
  67605. * Gets a string describing the action executed by the current optimization
  67606. * @return description string
  67607. */
  67608. getDescription(): string;
  67609. /**
  67610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67611. * @param scene defines the current scene where to apply this optimization
  67612. * @param optimizer defines the current optimizer
  67613. * @returns true if everything that can be done was applied
  67614. */
  67615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67616. }
  67617. /**
  67618. * Defines an optimization used to merge meshes with compatible materials
  67619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67620. */
  67621. export class MergeMeshesOptimization extends SceneOptimization {
  67622. private static _UpdateSelectionTree;
  67623. /**
  67624. * Gets or sets a boolean which defines if optimization octree has to be updated
  67625. */
  67626. /**
  67627. * Gets or sets a boolean which defines if optimization octree has to be updated
  67628. */
  67629. static UpdateSelectionTree: boolean;
  67630. /**
  67631. * Gets a string describing the action executed by the current optimization
  67632. * @return description string
  67633. */
  67634. getDescription(): string;
  67635. private _canBeMerged;
  67636. /**
  67637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67638. * @param scene defines the current scene where to apply this optimization
  67639. * @param optimizer defines the current optimizer
  67640. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67641. * @returns true if everything that can be done was applied
  67642. */
  67643. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67644. }
  67645. /**
  67646. * Defines a list of options used by SceneOptimizer
  67647. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67648. */
  67649. export class SceneOptimizerOptions {
  67650. /**
  67651. * Defines the target frame rate to reach (60 by default)
  67652. */
  67653. targetFrameRate: number;
  67654. /**
  67655. * Defines the interval between two checkes (2000ms by default)
  67656. */
  67657. trackerDuration: number;
  67658. /**
  67659. * Gets the list of optimizations to apply
  67660. */
  67661. optimizations: SceneOptimization[];
  67662. /**
  67663. * Creates a new list of options used by SceneOptimizer
  67664. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67665. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67666. */
  67667. constructor(
  67668. /**
  67669. * Defines the target frame rate to reach (60 by default)
  67670. */
  67671. targetFrameRate?: number,
  67672. /**
  67673. * Defines the interval between two checkes (2000ms by default)
  67674. */
  67675. trackerDuration?: number);
  67676. /**
  67677. * Add a new optimization
  67678. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67679. * @returns the current SceneOptimizerOptions
  67680. */
  67681. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67682. /**
  67683. * Add a new custom optimization
  67684. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67685. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67686. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67687. * @returns the current SceneOptimizerOptions
  67688. */
  67689. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67690. /**
  67691. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67692. * @param targetFrameRate defines the target frame rate (60 by default)
  67693. * @returns a SceneOptimizerOptions object
  67694. */
  67695. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67696. /**
  67697. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67698. * @param targetFrameRate defines the target frame rate (60 by default)
  67699. * @returns a SceneOptimizerOptions object
  67700. */
  67701. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67702. /**
  67703. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67704. * @param targetFrameRate defines the target frame rate (60 by default)
  67705. * @returns a SceneOptimizerOptions object
  67706. */
  67707. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67708. }
  67709. /**
  67710. * Class used to run optimizations in order to reach a target frame rate
  67711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67712. */
  67713. export class SceneOptimizer implements IDisposable {
  67714. private _isRunning;
  67715. private _options;
  67716. private _scene;
  67717. private _currentPriorityLevel;
  67718. private _targetFrameRate;
  67719. private _trackerDuration;
  67720. private _currentFrameRate;
  67721. private _sceneDisposeObserver;
  67722. private _improvementMode;
  67723. /**
  67724. * Defines an observable called when the optimizer reaches the target frame rate
  67725. */
  67726. onSuccessObservable: Observable<SceneOptimizer>;
  67727. /**
  67728. * Defines an observable called when the optimizer enables an optimization
  67729. */
  67730. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67731. /**
  67732. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67733. */
  67734. onFailureObservable: Observable<SceneOptimizer>;
  67735. /**
  67736. * Gets a boolean indicating if the optimizer is in improvement mode
  67737. */
  67738. readonly isInImprovementMode: boolean;
  67739. /**
  67740. * Gets the current priority level (0 at start)
  67741. */
  67742. readonly currentPriorityLevel: number;
  67743. /**
  67744. * Gets the current frame rate checked by the SceneOptimizer
  67745. */
  67746. readonly currentFrameRate: number;
  67747. /**
  67748. * Gets or sets the current target frame rate (60 by default)
  67749. */
  67750. /**
  67751. * Gets or sets the current target frame rate (60 by default)
  67752. */
  67753. targetFrameRate: number;
  67754. /**
  67755. * Gets or sets the current interval between two checks (every 2000ms by default)
  67756. */
  67757. /**
  67758. * Gets or sets the current interval between two checks (every 2000ms by default)
  67759. */
  67760. trackerDuration: number;
  67761. /**
  67762. * Gets the list of active optimizations
  67763. */
  67764. readonly optimizations: SceneOptimization[];
  67765. /**
  67766. * Creates a new SceneOptimizer
  67767. * @param scene defines the scene to work on
  67768. * @param options defines the options to use with the SceneOptimizer
  67769. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67770. * @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)
  67771. */
  67772. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67773. /**
  67774. * Stops the current optimizer
  67775. */
  67776. stop(): void;
  67777. /**
  67778. * Reset the optimizer to initial step (current priority level = 0)
  67779. */
  67780. reset(): void;
  67781. /**
  67782. * Start the optimizer. By default it will try to reach a specific framerate
  67783. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67784. */
  67785. start(): void;
  67786. private _checkCurrentState;
  67787. /**
  67788. * Release all resources
  67789. */
  67790. dispose(): void;
  67791. /**
  67792. * Helper function to create a SceneOptimizer with one single line of code
  67793. * @param scene defines the scene to work on
  67794. * @param options defines the options to use with the SceneOptimizer
  67795. * @param onSuccess defines a callback to call on success
  67796. * @param onFailure defines a callback to call on failure
  67797. * @returns the new SceneOptimizer object
  67798. */
  67799. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67800. }
  67801. }
  67802. declare module "babylonjs/Misc/sceneSerializer" {
  67803. import { Scene } from "babylonjs/scene";
  67804. /**
  67805. * Class used to serialize a scene into a string
  67806. */
  67807. export class SceneSerializer {
  67808. /**
  67809. * Clear cache used by a previous serialization
  67810. */
  67811. static ClearCache(): void;
  67812. /**
  67813. * Serialize a scene into a JSON compatible object
  67814. * @param scene defines the scene to serialize
  67815. * @returns a JSON compatible object
  67816. */
  67817. static Serialize(scene: Scene): any;
  67818. /**
  67819. * Serialize a mesh into a JSON compatible object
  67820. * @param toSerialize defines the mesh to serialize
  67821. * @param withParents defines if parents must be serialized as well
  67822. * @param withChildren defines if children must be serialized as well
  67823. * @returns a JSON compatible object
  67824. */
  67825. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67826. }
  67827. }
  67828. declare module "babylonjs/Misc/textureTools" {
  67829. import { Texture } from "babylonjs/Materials/Textures/texture";
  67830. /**
  67831. * Class used to host texture specific utilities
  67832. */
  67833. export class TextureTools {
  67834. /**
  67835. * Uses the GPU to create a copy texture rescaled at a given size
  67836. * @param texture Texture to copy from
  67837. * @param width defines the desired width
  67838. * @param height defines the desired height
  67839. * @param useBilinearMode defines if bilinear mode has to be used
  67840. * @return the generated texture
  67841. */
  67842. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67843. }
  67844. }
  67845. declare module "babylonjs/Misc/videoRecorder" {
  67846. import { Nullable } from "babylonjs/types";
  67847. import { Engine } from "babylonjs/Engines/engine";
  67848. /**
  67849. * This represents the different options available for the video capture.
  67850. */
  67851. export interface VideoRecorderOptions {
  67852. /** Defines the mime type of the video. */
  67853. mimeType: string;
  67854. /** Defines the FPS the video should be recorded at. */
  67855. fps: number;
  67856. /** Defines the chunk size for the recording data. */
  67857. recordChunckSize: number;
  67858. /** The audio tracks to attach to the recording. */
  67859. audioTracks?: MediaStreamTrack[];
  67860. }
  67861. /**
  67862. * This can help with recording videos from BabylonJS.
  67863. * This is based on the available WebRTC functionalities of the browser.
  67864. *
  67865. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67866. */
  67867. export class VideoRecorder {
  67868. private static readonly _defaultOptions;
  67869. /**
  67870. * Returns whether or not the VideoRecorder is available in your browser.
  67871. * @param engine Defines the Babylon Engine.
  67872. * @returns true if supported otherwise false.
  67873. */
  67874. static IsSupported(engine: Engine): boolean;
  67875. private readonly _options;
  67876. private _canvas;
  67877. private _mediaRecorder;
  67878. private _recordedChunks;
  67879. private _fileName;
  67880. private _resolve;
  67881. private _reject;
  67882. /**
  67883. * True when a recording is already in progress.
  67884. */
  67885. readonly isRecording: boolean;
  67886. /**
  67887. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67888. * @param engine Defines the BabylonJS Engine you wish to record.
  67889. * @param options Defines options that can be used to customize the capture.
  67890. */
  67891. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67892. /**
  67893. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67894. */
  67895. stopRecording(): void;
  67896. /**
  67897. * Starts recording the canvas for a max duration specified in parameters.
  67898. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67899. * If null no automatic download will start and you can rely on the promise to get the data back.
  67900. * @param maxDuration Defines the maximum recording time in seconds.
  67901. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67902. * @return A promise callback at the end of the recording with the video data in Blob.
  67903. */
  67904. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67905. /**
  67906. * Releases internal resources used during the recording.
  67907. */
  67908. dispose(): void;
  67909. private _handleDataAvailable;
  67910. private _handleError;
  67911. private _handleStop;
  67912. }
  67913. }
  67914. declare module "babylonjs/Misc/screenshotTools" {
  67915. import { Camera } from "babylonjs/Cameras/camera";
  67916. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67917. import { Engine } from "babylonjs/Engines/engine";
  67918. /**
  67919. * Class containing a set of static utilities functions for screenshots
  67920. */
  67921. export class ScreenshotTools {
  67922. /**
  67923. * Captures a screenshot of the current rendering
  67924. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67925. * @param engine defines the rendering engine
  67926. * @param camera defines the source camera
  67927. * @param size This parameter can be set to a single number or to an object with the
  67928. * following (optional) properties: precision, width, height. If a single number is passed,
  67929. * it will be used for both width and height. If an object is passed, the screenshot size
  67930. * will be derived from the parameters. The precision property is a multiplier allowing
  67931. * rendering at a higher or lower resolution
  67932. * @param successCallback defines the callback receives a single parameter which contains the
  67933. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67934. * src parameter of an <img> to display it
  67935. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67936. * Check your browser for supported MIME types
  67937. */
  67938. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67939. /**
  67940. * Captures a screenshot of the current rendering
  67941. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67942. * @param engine defines the rendering engine
  67943. * @param camera defines the source camera
  67944. * @param size This parameter can be set to a single number or to an object with the
  67945. * following (optional) properties: precision, width, height. If a single number is passed,
  67946. * it will be used for both width and height. If an object is passed, the screenshot size
  67947. * will be derived from the parameters. The precision property is a multiplier allowing
  67948. * rendering at a higher or lower resolution
  67949. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67950. * Check your browser for supported MIME types
  67951. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67952. * to the src parameter of an <img> to display it
  67953. */
  67954. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67955. /**
  67956. * Generates an image screenshot from the specified camera.
  67957. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67958. * @param engine The engine to use for rendering
  67959. * @param camera The camera to use for rendering
  67960. * @param size This parameter can be set to a single number or to an object with the
  67961. * following (optional) properties: precision, width, height. If a single number is passed,
  67962. * it will be used for both width and height. If an object is passed, the screenshot size
  67963. * will be derived from the parameters. The precision property is a multiplier allowing
  67964. * rendering at a higher or lower resolution
  67965. * @param successCallback The callback receives a single parameter which contains the
  67966. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67967. * src parameter of an <img> to display it
  67968. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67969. * Check your browser for supported MIME types
  67970. * @param samples Texture samples (default: 1)
  67971. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67972. * @param fileName A name for for the downloaded file.
  67973. */
  67974. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67975. /**
  67976. * Generates an image screenshot from the specified camera.
  67977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67978. * @param engine The engine to use for rendering
  67979. * @param camera The camera to use for rendering
  67980. * @param size This parameter can be set to a single number or to an object with the
  67981. * following (optional) properties: precision, width, height. If a single number is passed,
  67982. * it will be used for both width and height. If an object is passed, the screenshot size
  67983. * will be derived from the parameters. The precision property is a multiplier allowing
  67984. * rendering at a higher or lower resolution
  67985. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67986. * Check your browser for supported MIME types
  67987. * @param samples Texture samples (default: 1)
  67988. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67989. * @param fileName A name for for the downloaded file.
  67990. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67991. * to the src parameter of an <img> to display it
  67992. */
  67993. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67994. /**
  67995. * Gets height and width for screenshot size
  67996. * @private
  67997. */
  67998. private static _getScreenshotSize;
  67999. }
  68000. }
  68001. declare module "babylonjs/Misc/dataReader" {
  68002. /**
  68003. * Interface for a data buffer
  68004. */
  68005. export interface IDataBuffer {
  68006. /**
  68007. * Reads bytes from the data buffer.
  68008. * @param byteOffset The byte offset to read
  68009. * @param byteLength The byte length to read
  68010. * @returns A promise that resolves when the bytes are read
  68011. */
  68012. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68013. /**
  68014. * The byte length of the buffer.
  68015. */
  68016. readonly byteLength: number;
  68017. }
  68018. /**
  68019. * Utility class for reading from a data buffer
  68020. */
  68021. export class DataReader {
  68022. /**
  68023. * The data buffer associated with this data reader.
  68024. */
  68025. readonly buffer: IDataBuffer;
  68026. /**
  68027. * The current byte offset from the beginning of the data buffer.
  68028. */
  68029. byteOffset: number;
  68030. private _dataView;
  68031. private _dataByteOffset;
  68032. /**
  68033. * Constructor
  68034. * @param buffer The buffer to read
  68035. */
  68036. constructor(buffer: IDataBuffer);
  68037. /**
  68038. * Loads the given byte length.
  68039. * @param byteLength The byte length to load
  68040. * @returns A promise that resolves when the load is complete
  68041. */
  68042. loadAsync(byteLength: number): Promise<void>;
  68043. /**
  68044. * Read a unsigned 32-bit integer from the currently loaded data range.
  68045. * @returns The 32-bit integer read
  68046. */
  68047. readUint32(): number;
  68048. /**
  68049. * Read a byte array from the currently loaded data range.
  68050. * @param byteLength The byte length to read
  68051. * @returns The byte array read
  68052. */
  68053. readUint8Array(byteLength: number): Uint8Array;
  68054. /**
  68055. * Read a string from the currently loaded data range.
  68056. * @param byteLength The byte length to read
  68057. * @returns The string read
  68058. */
  68059. readString(byteLength: number): string;
  68060. /**
  68061. * Skips the given byte length the currently loaded data range.
  68062. * @param byteLength The byte length to skip
  68063. */
  68064. skipBytes(byteLength: number): void;
  68065. }
  68066. }
  68067. declare module "babylonjs/Misc/index" {
  68068. export * from "babylonjs/Misc/andOrNotEvaluator";
  68069. export * from "babylonjs/Misc/assetsManager";
  68070. export * from "babylonjs/Misc/dds";
  68071. export * from "babylonjs/Misc/decorators";
  68072. export * from "babylonjs/Misc/deferred";
  68073. export * from "babylonjs/Misc/environmentTextureTools";
  68074. export * from "babylonjs/Misc/meshExploder";
  68075. export * from "babylonjs/Misc/filesInput";
  68076. export * from "babylonjs/Misc/HighDynamicRange/index";
  68077. export * from "babylonjs/Misc/khronosTextureContainer";
  68078. export * from "babylonjs/Misc/observable";
  68079. export * from "babylonjs/Misc/performanceMonitor";
  68080. export * from "babylonjs/Misc/promise";
  68081. export * from "babylonjs/Misc/sceneOptimizer";
  68082. export * from "babylonjs/Misc/sceneSerializer";
  68083. export * from "babylonjs/Misc/smartArray";
  68084. export * from "babylonjs/Misc/stringDictionary";
  68085. export * from "babylonjs/Misc/tags";
  68086. export * from "babylonjs/Misc/textureTools";
  68087. export * from "babylonjs/Misc/tga";
  68088. export * from "babylonjs/Misc/tools";
  68089. export * from "babylonjs/Misc/videoRecorder";
  68090. export * from "babylonjs/Misc/virtualJoystick";
  68091. export * from "babylonjs/Misc/workerPool";
  68092. export * from "babylonjs/Misc/logger";
  68093. export * from "babylonjs/Misc/typeStore";
  68094. export * from "babylonjs/Misc/filesInputStore";
  68095. export * from "babylonjs/Misc/deepCopier";
  68096. export * from "babylonjs/Misc/pivotTools";
  68097. export * from "babylonjs/Misc/precisionDate";
  68098. export * from "babylonjs/Misc/screenshotTools";
  68099. export * from "babylonjs/Misc/typeStore";
  68100. export * from "babylonjs/Misc/webRequest";
  68101. export * from "babylonjs/Misc/iInspectable";
  68102. export * from "babylonjs/Misc/brdfTextureTools";
  68103. export * from "babylonjs/Misc/rgbdTextureTools";
  68104. export * from "babylonjs/Misc/gradients";
  68105. export * from "babylonjs/Misc/perfCounter";
  68106. export * from "babylonjs/Misc/fileRequest";
  68107. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68108. export * from "babylonjs/Misc/retryStrategy";
  68109. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68110. export * from "babylonjs/Misc/canvasGenerator";
  68111. export * from "babylonjs/Misc/fileTools";
  68112. export * from "babylonjs/Misc/stringTools";
  68113. export * from "babylonjs/Misc/dataReader";
  68114. }
  68115. declare module "babylonjs/index" {
  68116. export * from "babylonjs/abstractScene";
  68117. export * from "babylonjs/Actions/index";
  68118. export * from "babylonjs/Animations/index";
  68119. export * from "babylonjs/assetContainer";
  68120. export * from "babylonjs/Audio/index";
  68121. export * from "babylonjs/Behaviors/index";
  68122. export * from "babylonjs/Bones/index";
  68123. export * from "babylonjs/Cameras/index";
  68124. export * from "babylonjs/Collisions/index";
  68125. export * from "babylonjs/Culling/index";
  68126. export * from "babylonjs/Debug/index";
  68127. export * from "babylonjs/Engines/index";
  68128. export * from "babylonjs/Events/index";
  68129. export * from "babylonjs/Gamepads/index";
  68130. export * from "babylonjs/Gizmos/index";
  68131. export * from "babylonjs/Helpers/index";
  68132. export * from "babylonjs/Instrumentation/index";
  68133. export * from "babylonjs/Layers/index";
  68134. export * from "babylonjs/LensFlares/index";
  68135. export * from "babylonjs/Lights/index";
  68136. export * from "babylonjs/Loading/index";
  68137. export * from "babylonjs/Materials/index";
  68138. export * from "babylonjs/Maths/index";
  68139. export * from "babylonjs/Meshes/index";
  68140. export * from "babylonjs/Morph/index";
  68141. export * from "babylonjs/Navigation/index";
  68142. export * from "babylonjs/node";
  68143. export * from "babylonjs/Offline/index";
  68144. export * from "babylonjs/Particles/index";
  68145. export * from "babylonjs/Physics/index";
  68146. export * from "babylonjs/PostProcesses/index";
  68147. export * from "babylonjs/Probes/index";
  68148. export * from "babylonjs/Rendering/index";
  68149. export * from "babylonjs/scene";
  68150. export * from "babylonjs/sceneComponent";
  68151. export * from "babylonjs/Sprites/index";
  68152. export * from "babylonjs/States/index";
  68153. export * from "babylonjs/Misc/index";
  68154. export * from "babylonjs/types";
  68155. }
  68156. declare module "babylonjs/Animations/pathCursor" {
  68157. import { Vector3 } from "babylonjs/Maths/math.vector";
  68158. import { Path2 } from "babylonjs/Maths/math.path";
  68159. /**
  68160. * A cursor which tracks a point on a path
  68161. */
  68162. export class PathCursor {
  68163. private path;
  68164. /**
  68165. * Stores path cursor callbacks for when an onchange event is triggered
  68166. */
  68167. private _onchange;
  68168. /**
  68169. * The value of the path cursor
  68170. */
  68171. value: number;
  68172. /**
  68173. * The animation array of the path cursor
  68174. */
  68175. animations: Animation[];
  68176. /**
  68177. * Initializes the path cursor
  68178. * @param path The path to track
  68179. */
  68180. constructor(path: Path2);
  68181. /**
  68182. * Gets the cursor point on the path
  68183. * @returns A point on the path cursor at the cursor location
  68184. */
  68185. getPoint(): Vector3;
  68186. /**
  68187. * Moves the cursor ahead by the step amount
  68188. * @param step The amount to move the cursor forward
  68189. * @returns This path cursor
  68190. */
  68191. moveAhead(step?: number): PathCursor;
  68192. /**
  68193. * Moves the cursor behind by the step amount
  68194. * @param step The amount to move the cursor back
  68195. * @returns This path cursor
  68196. */
  68197. moveBack(step?: number): PathCursor;
  68198. /**
  68199. * Moves the cursor by the step amount
  68200. * If the step amount is greater than one, an exception is thrown
  68201. * @param step The amount to move the cursor
  68202. * @returns This path cursor
  68203. */
  68204. move(step: number): PathCursor;
  68205. /**
  68206. * Ensures that the value is limited between zero and one
  68207. * @returns This path cursor
  68208. */
  68209. private ensureLimits;
  68210. /**
  68211. * Runs onchange callbacks on change (used by the animation engine)
  68212. * @returns This path cursor
  68213. */
  68214. private raiseOnChange;
  68215. /**
  68216. * Executes a function on change
  68217. * @param f A path cursor onchange callback
  68218. * @returns This path cursor
  68219. */
  68220. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68221. }
  68222. }
  68223. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68224. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68225. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68226. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68227. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68228. }
  68229. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68230. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68231. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68232. }
  68233. declare module "babylonjs/Engines/Processors/index" {
  68234. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68235. export * from "babylonjs/Engines/Processors/Expressions/index";
  68236. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68237. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68238. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68239. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68240. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68241. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68242. }
  68243. declare module "babylonjs/Legacy/legacy" {
  68244. import * as Babylon from "babylonjs/index";
  68245. export * from "babylonjs/index";
  68246. }
  68247. declare module "babylonjs/Shaders/blur.fragment" {
  68248. /** @hidden */
  68249. export var blurPixelShader: {
  68250. name: string;
  68251. shader: string;
  68252. };
  68253. }
  68254. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68255. /** @hidden */
  68256. export var pointCloudVertexDeclaration: {
  68257. name: string;
  68258. shader: string;
  68259. };
  68260. }
  68261. declare module "babylonjs" {
  68262. export * from "babylonjs/Legacy/legacy";
  68263. }
  68264. declare module BABYLON {
  68265. /** Alias type for value that can be null */
  68266. export type Nullable<T> = T | null;
  68267. /**
  68268. * Alias type for number that are floats
  68269. * @ignorenaming
  68270. */
  68271. export type float = number;
  68272. /**
  68273. * Alias type for number that are doubles.
  68274. * @ignorenaming
  68275. */
  68276. export type double = number;
  68277. /**
  68278. * Alias type for number that are integer
  68279. * @ignorenaming
  68280. */
  68281. export type int = number;
  68282. /** Alias type for number array or Float32Array */
  68283. export type FloatArray = number[] | Float32Array;
  68284. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68285. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68286. /**
  68287. * Alias for types that can be used by a Buffer or VertexBuffer.
  68288. */
  68289. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68290. /**
  68291. * Alias type for primitive types
  68292. * @ignorenaming
  68293. */
  68294. type Primitive = undefined | null | boolean | string | number | Function;
  68295. /**
  68296. * Type modifier to make all the properties of an object Readonly
  68297. */
  68298. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68299. /**
  68300. * Type modifier to make all the properties of an object Readonly recursively
  68301. */
  68302. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68303. /**
  68304. * Type modifier to make object properties readonly.
  68305. */
  68306. export type DeepImmutableObject<T> = {
  68307. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68308. };
  68309. /** @hidden */
  68310. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /**
  68315. * A class serves as a medium between the observable and its observers
  68316. */
  68317. export class EventState {
  68318. /**
  68319. * Create a new EventState
  68320. * @param mask defines the mask associated with this state
  68321. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68322. * @param target defines the original target of the state
  68323. * @param currentTarget defines the current target of the state
  68324. */
  68325. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68326. /**
  68327. * Initialize the current event state
  68328. * @param mask defines the mask associated with this state
  68329. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68330. * @param target defines the original target of the state
  68331. * @param currentTarget defines the current target of the state
  68332. * @returns the current event state
  68333. */
  68334. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68335. /**
  68336. * An Observer can set this property to true to prevent subsequent observers of being notified
  68337. */
  68338. skipNextObservers: boolean;
  68339. /**
  68340. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68341. */
  68342. mask: number;
  68343. /**
  68344. * The object that originally notified the event
  68345. */
  68346. target?: any;
  68347. /**
  68348. * The current object in the bubbling phase
  68349. */
  68350. currentTarget?: any;
  68351. /**
  68352. * This will be populated with the return value of the last function that was executed.
  68353. * If it is the first function in the callback chain it will be the event data.
  68354. */
  68355. lastReturnValue?: any;
  68356. }
  68357. /**
  68358. * Represent an Observer registered to a given Observable object.
  68359. */
  68360. export class Observer<T> {
  68361. /**
  68362. * Defines the callback to call when the observer is notified
  68363. */
  68364. callback: (eventData: T, eventState: EventState) => void;
  68365. /**
  68366. * Defines the mask of the observer (used to filter notifications)
  68367. */
  68368. mask: number;
  68369. /**
  68370. * Defines the current scope used to restore the JS context
  68371. */
  68372. scope: any;
  68373. /** @hidden */
  68374. _willBeUnregistered: boolean;
  68375. /**
  68376. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68377. */
  68378. unregisterOnNextCall: boolean;
  68379. /**
  68380. * Creates a new observer
  68381. * @param callback defines the callback to call when the observer is notified
  68382. * @param mask defines the mask of the observer (used to filter notifications)
  68383. * @param scope defines the current scope used to restore the JS context
  68384. */
  68385. constructor(
  68386. /**
  68387. * Defines the callback to call when the observer is notified
  68388. */
  68389. callback: (eventData: T, eventState: EventState) => void,
  68390. /**
  68391. * Defines the mask of the observer (used to filter notifications)
  68392. */
  68393. mask: number,
  68394. /**
  68395. * Defines the current scope used to restore the JS context
  68396. */
  68397. scope?: any);
  68398. }
  68399. /**
  68400. * Represent a list of observers registered to multiple Observables object.
  68401. */
  68402. export class MultiObserver<T> {
  68403. private _observers;
  68404. private _observables;
  68405. /**
  68406. * Release associated resources
  68407. */
  68408. dispose(): void;
  68409. /**
  68410. * Raise a callback when one of the observable will notify
  68411. * @param observables defines a list of observables to watch
  68412. * @param callback defines the callback to call on notification
  68413. * @param mask defines the mask used to filter notifications
  68414. * @param scope defines the current scope used to restore the JS context
  68415. * @returns the new MultiObserver
  68416. */
  68417. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68418. }
  68419. /**
  68420. * The Observable class is a simple implementation of the Observable pattern.
  68421. *
  68422. * 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.
  68423. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68424. * 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).
  68425. * 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.
  68426. */
  68427. export class Observable<T> {
  68428. private _observers;
  68429. private _eventState;
  68430. private _onObserverAdded;
  68431. /**
  68432. * Gets the list of observers
  68433. */
  68434. readonly observers: Array<Observer<T>>;
  68435. /**
  68436. * Creates a new observable
  68437. * @param onObserverAdded defines a callback to call when a new observer is added
  68438. */
  68439. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68440. /**
  68441. * Create a new Observer with the specified callback
  68442. * @param callback the callback that will be executed for that Observer
  68443. * @param mask the mask used to filter observers
  68444. * @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.
  68445. * @param scope optional scope for the callback to be called from
  68446. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68447. * @returns the new observer created for the callback
  68448. */
  68449. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68450. /**
  68451. * Create a new Observer with the specified callback and unregisters after the next notification
  68452. * @param callback the callback that will be executed for that Observer
  68453. * @returns the new observer created for the callback
  68454. */
  68455. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68456. /**
  68457. * Remove an Observer from the Observable object
  68458. * @param observer the instance of the Observer to remove
  68459. * @returns false if it doesn't belong to this Observable
  68460. */
  68461. remove(observer: Nullable<Observer<T>>): boolean;
  68462. /**
  68463. * Remove a callback from the Observable object
  68464. * @param callback the callback to remove
  68465. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68466. * @returns false if it doesn't belong to this Observable
  68467. */
  68468. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68469. private _deferUnregister;
  68470. private _remove;
  68471. /**
  68472. * Moves the observable to the top of the observer list making it get called first when notified
  68473. * @param observer the observer to move
  68474. */
  68475. makeObserverTopPriority(observer: Observer<T>): void;
  68476. /**
  68477. * Moves the observable to the bottom of the observer list making it get called last when notified
  68478. * @param observer the observer to move
  68479. */
  68480. makeObserverBottomPriority(observer: Observer<T>): void;
  68481. /**
  68482. * Notify all Observers by calling their respective callback with the given data
  68483. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68484. * @param eventData defines the data to send to all observers
  68485. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68486. * @param target defines the original target of the state
  68487. * @param currentTarget defines the current target of the state
  68488. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68489. */
  68490. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68491. /**
  68492. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68493. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68494. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68495. * and it is crucial that all callbacks will be executed.
  68496. * The order of the callbacks is kept, callbacks are not executed parallel.
  68497. *
  68498. * @param eventData The data to be sent to each callback
  68499. * @param mask is used to filter observers defaults to -1
  68500. * @param target defines the callback target (see EventState)
  68501. * @param currentTarget defines he current object in the bubbling phase
  68502. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68503. */
  68504. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68505. /**
  68506. * Notify a specific observer
  68507. * @param observer defines the observer to notify
  68508. * @param eventData defines the data to be sent to each callback
  68509. * @param mask is used to filter observers defaults to -1
  68510. */
  68511. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68512. /**
  68513. * Gets a boolean indicating if the observable has at least one observer
  68514. * @returns true is the Observable has at least one Observer registered
  68515. */
  68516. hasObservers(): boolean;
  68517. /**
  68518. * Clear the list of observers
  68519. */
  68520. clear(): void;
  68521. /**
  68522. * Clone the current observable
  68523. * @returns a new observable
  68524. */
  68525. clone(): Observable<T>;
  68526. /**
  68527. * Does this observable handles observer registered with a given mask
  68528. * @param mask defines the mask to be tested
  68529. * @return whether or not one observer registered with the given mask is handeled
  68530. **/
  68531. hasSpecificMask(mask?: number): boolean;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /**
  68536. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68537. * Babylon.js
  68538. */
  68539. export class DomManagement {
  68540. /**
  68541. * Checks if the window object exists
  68542. * @returns true if the window object exists
  68543. */
  68544. static IsWindowObjectExist(): boolean;
  68545. /**
  68546. * Checks if the navigator object exists
  68547. * @returns true if the navigator object exists
  68548. */
  68549. static IsNavigatorAvailable(): boolean;
  68550. /**
  68551. * Extracts text content from a DOM element hierarchy
  68552. * @param element defines the root element
  68553. * @returns a string
  68554. */
  68555. static GetDOMTextContent(element: HTMLElement): string;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. /**
  68560. * Logger used througouht the application to allow configuration of
  68561. * the log level required for the messages.
  68562. */
  68563. export class Logger {
  68564. /**
  68565. * No log
  68566. */
  68567. static readonly NoneLogLevel: number;
  68568. /**
  68569. * Only message logs
  68570. */
  68571. static readonly MessageLogLevel: number;
  68572. /**
  68573. * Only warning logs
  68574. */
  68575. static readonly WarningLogLevel: number;
  68576. /**
  68577. * Only error logs
  68578. */
  68579. static readonly ErrorLogLevel: number;
  68580. /**
  68581. * All logs
  68582. */
  68583. static readonly AllLogLevel: number;
  68584. private static _LogCache;
  68585. /**
  68586. * Gets a value indicating the number of loading errors
  68587. * @ignorenaming
  68588. */
  68589. static errorsCount: number;
  68590. /**
  68591. * Callback called when a new log is added
  68592. */
  68593. static OnNewCacheEntry: (entry: string) => void;
  68594. private static _AddLogEntry;
  68595. private static _FormatMessage;
  68596. private static _LogDisabled;
  68597. private static _LogEnabled;
  68598. private static _WarnDisabled;
  68599. private static _WarnEnabled;
  68600. private static _ErrorDisabled;
  68601. private static _ErrorEnabled;
  68602. /**
  68603. * Log a message to the console
  68604. */
  68605. static Log: (message: string) => void;
  68606. /**
  68607. * Write a warning message to the console
  68608. */
  68609. static Warn: (message: string) => void;
  68610. /**
  68611. * Write an error message to the console
  68612. */
  68613. static Error: (message: string) => void;
  68614. /**
  68615. * Gets current log cache (list of logs)
  68616. */
  68617. static readonly LogCache: string;
  68618. /**
  68619. * Clears the log cache
  68620. */
  68621. static ClearLogCache(): void;
  68622. /**
  68623. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68624. */
  68625. static LogLevels: number;
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /** @hidden */
  68630. export class _TypeStore {
  68631. /** @hidden */
  68632. static RegisteredTypes: {
  68633. [key: string]: Object;
  68634. };
  68635. /** @hidden */
  68636. static GetClass(fqdn: string): any;
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /**
  68641. * Helper to manipulate strings
  68642. */
  68643. export class StringTools {
  68644. /**
  68645. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68646. * @param str Source string
  68647. * @param suffix Suffix to search for in the source string
  68648. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68649. */
  68650. static EndsWith(str: string, suffix: string): boolean;
  68651. /**
  68652. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68653. * @param str Source string
  68654. * @param suffix Suffix to search for in the source string
  68655. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68656. */
  68657. static StartsWith(str: string, suffix: string): boolean;
  68658. /**
  68659. * Decodes a buffer into a string
  68660. * @param buffer The buffer to decode
  68661. * @returns The decoded string
  68662. */
  68663. static Decode(buffer: Uint8Array | Uint16Array): string;
  68664. /**
  68665. * Encode a buffer to a base64 string
  68666. * @param buffer defines the buffer to encode
  68667. * @returns the encoded string
  68668. */
  68669. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68670. }
  68671. }
  68672. declare module BABYLON {
  68673. /**
  68674. * Class containing a set of static utilities functions for deep copy.
  68675. */
  68676. export class DeepCopier {
  68677. /**
  68678. * Tries to copy an object by duplicating every property
  68679. * @param source defines the source object
  68680. * @param destination defines the target object
  68681. * @param doNotCopyList defines a list of properties to avoid
  68682. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68683. */
  68684. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68685. }
  68686. }
  68687. declare module BABYLON {
  68688. /**
  68689. * Class containing a set of static utilities functions for precision date
  68690. */
  68691. export class PrecisionDate {
  68692. /**
  68693. * Gets either window.performance.now() if supported or Date.now() else
  68694. */
  68695. static readonly Now: number;
  68696. }
  68697. }
  68698. declare module BABYLON {
  68699. /** @hidden */
  68700. export class _DevTools {
  68701. static WarnImport(name: string): string;
  68702. }
  68703. }
  68704. declare module BABYLON {
  68705. /**
  68706. * Interface used to define the mechanism to get data from the network
  68707. */
  68708. export interface IWebRequest {
  68709. /**
  68710. * Returns client's response url
  68711. */
  68712. responseURL: string;
  68713. /**
  68714. * Returns client's status
  68715. */
  68716. status: number;
  68717. /**
  68718. * Returns client's status as a text
  68719. */
  68720. statusText: string;
  68721. }
  68722. }
  68723. declare module BABYLON {
  68724. /**
  68725. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68726. */
  68727. export class WebRequest implements IWebRequest {
  68728. private _xhr;
  68729. /**
  68730. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68731. * i.e. when loading files, where the server/service expects an Authorization header
  68732. */
  68733. static CustomRequestHeaders: {
  68734. [key: string]: string;
  68735. };
  68736. /**
  68737. * Add callback functions in this array to update all the requests before they get sent to the network
  68738. */
  68739. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68740. private _injectCustomRequestHeaders;
  68741. /**
  68742. * Gets or sets a function to be called when loading progress changes
  68743. */
  68744. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68745. /**
  68746. * Returns client's state
  68747. */
  68748. readonly readyState: number;
  68749. /**
  68750. * Returns client's status
  68751. */
  68752. readonly status: number;
  68753. /**
  68754. * Returns client's status as a text
  68755. */
  68756. readonly statusText: string;
  68757. /**
  68758. * Returns client's response
  68759. */
  68760. readonly response: any;
  68761. /**
  68762. * Returns client's response url
  68763. */
  68764. readonly responseURL: string;
  68765. /**
  68766. * Returns client's response as text
  68767. */
  68768. readonly responseText: string;
  68769. /**
  68770. * Gets or sets the expected response type
  68771. */
  68772. responseType: XMLHttpRequestResponseType;
  68773. /** @hidden */
  68774. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68775. /** @hidden */
  68776. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68777. /**
  68778. * Cancels any network activity
  68779. */
  68780. abort(): void;
  68781. /**
  68782. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68783. * @param body defines an optional request body
  68784. */
  68785. send(body?: Document | BodyInit | null): void;
  68786. /**
  68787. * Sets the request method, request URL
  68788. * @param method defines the method to use (GET, POST, etc..)
  68789. * @param url defines the url to connect with
  68790. */
  68791. open(method: string, url: string): void;
  68792. /**
  68793. * Sets the value of a request header.
  68794. * @param name The name of the header whose value is to be set
  68795. * @param value The value to set as the body of the header
  68796. */
  68797. setRequestHeader(name: string, value: string): void;
  68798. /**
  68799. * Get the string containing the text of a particular header's value.
  68800. * @param name The name of the header
  68801. * @returns The string containing the text of the given header name
  68802. */
  68803. getResponseHeader(name: string): Nullable<string>;
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /**
  68808. * File request interface
  68809. */
  68810. export interface IFileRequest {
  68811. /**
  68812. * Raised when the request is complete (success or error).
  68813. */
  68814. onCompleteObservable: Observable<IFileRequest>;
  68815. /**
  68816. * Aborts the request for a file.
  68817. */
  68818. abort: () => void;
  68819. }
  68820. }
  68821. declare module BABYLON {
  68822. /**
  68823. * Define options used to create a render target texture
  68824. */
  68825. export class RenderTargetCreationOptions {
  68826. /**
  68827. * Specifies is mipmaps must be generated
  68828. */
  68829. generateMipMaps?: boolean;
  68830. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68831. generateDepthBuffer?: boolean;
  68832. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68833. generateStencilBuffer?: boolean;
  68834. /** Defines texture type (int by default) */
  68835. type?: number;
  68836. /** Defines sampling mode (trilinear by default) */
  68837. samplingMode?: number;
  68838. /** Defines format (RGBA by default) */
  68839. format?: number;
  68840. }
  68841. }
  68842. declare module BABYLON {
  68843. /**
  68844. * @hidden
  68845. **/
  68846. export class _TimeToken {
  68847. _startTimeQuery: Nullable<WebGLQuery>;
  68848. _endTimeQuery: Nullable<WebGLQuery>;
  68849. _timeElapsedQuery: Nullable<WebGLQuery>;
  68850. _timeElapsedQueryEnded: boolean;
  68851. }
  68852. }
  68853. declare module BABYLON {
  68854. /** Defines the cross module used constants to avoid circular dependncies */
  68855. export class Constants {
  68856. /** Defines that alpha blending is disabled */
  68857. static readonly ALPHA_DISABLE: number;
  68858. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68859. static readonly ALPHA_ADD: number;
  68860. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68861. static readonly ALPHA_COMBINE: number;
  68862. /** Defines that alpha blending to DEST - SRC * DEST */
  68863. static readonly ALPHA_SUBTRACT: number;
  68864. /** Defines that alpha blending to SRC * DEST */
  68865. static readonly ALPHA_MULTIPLY: number;
  68866. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68867. static readonly ALPHA_MAXIMIZED: number;
  68868. /** Defines that alpha blending to SRC + DEST */
  68869. static readonly ALPHA_ONEONE: number;
  68870. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68871. static readonly ALPHA_PREMULTIPLIED: number;
  68872. /**
  68873. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68874. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68875. */
  68876. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68877. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68878. static readonly ALPHA_INTERPOLATE: number;
  68879. /**
  68880. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68881. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68882. */
  68883. static readonly ALPHA_SCREENMODE: number;
  68884. /**
  68885. * Defines that alpha blending to SRC + DST
  68886. * Alpha will be set to SRC ALPHA + DST ALPHA
  68887. */
  68888. static readonly ALPHA_ONEONE_ONEONE: number;
  68889. /**
  68890. * Defines that alpha blending to SRC * DST ALPHA + DST
  68891. * Alpha will be set to 0
  68892. */
  68893. static readonly ALPHA_ALPHATOCOLOR: number;
  68894. /**
  68895. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68896. */
  68897. static readonly ALPHA_REVERSEONEMINUS: number;
  68898. /**
  68899. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68900. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68901. */
  68902. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68903. /**
  68904. * Defines that alpha blending to SRC + DST
  68905. * Alpha will be set to SRC ALPHA
  68906. */
  68907. static readonly ALPHA_ONEONE_ONEZERO: number;
  68908. /** Defines that alpha blending equation a SUM */
  68909. static readonly ALPHA_EQUATION_ADD: number;
  68910. /** Defines that alpha blending equation a SUBSTRACTION */
  68911. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68912. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68913. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68914. /** Defines that alpha blending equation a MAX operation */
  68915. static readonly ALPHA_EQUATION_MAX: number;
  68916. /** Defines that alpha blending equation a MIN operation */
  68917. static readonly ALPHA_EQUATION_MIN: number;
  68918. /**
  68919. * Defines that alpha blending equation a DARKEN operation:
  68920. * It takes the min of the src and sums the alpha channels.
  68921. */
  68922. static readonly ALPHA_EQUATION_DARKEN: number;
  68923. /** Defines that the ressource is not delayed*/
  68924. static readonly DELAYLOADSTATE_NONE: number;
  68925. /** Defines that the ressource was successfully delay loaded */
  68926. static readonly DELAYLOADSTATE_LOADED: number;
  68927. /** Defines that the ressource is currently delay loading */
  68928. static readonly DELAYLOADSTATE_LOADING: number;
  68929. /** Defines that the ressource is delayed and has not started loading */
  68930. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68931. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68932. static readonly NEVER: number;
  68933. /** 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 */
  68934. static readonly ALWAYS: number;
  68935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68936. static readonly LESS: number;
  68937. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68938. static readonly EQUAL: number;
  68939. /** 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 */
  68940. static readonly LEQUAL: number;
  68941. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68942. static readonly GREATER: number;
  68943. /** 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 */
  68944. static readonly GEQUAL: number;
  68945. /** 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 */
  68946. static readonly NOTEQUAL: number;
  68947. /** Passed to stencilOperation to specify that stencil value must be kept */
  68948. static readonly KEEP: number;
  68949. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68950. static readonly REPLACE: number;
  68951. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68952. static readonly INCR: number;
  68953. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68954. static readonly DECR: number;
  68955. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68956. static readonly INVERT: number;
  68957. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68958. static readonly INCR_WRAP: number;
  68959. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68960. static readonly DECR_WRAP: number;
  68961. /** Texture is not repeating outside of 0..1 UVs */
  68962. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68963. /** Texture is repeating outside of 0..1 UVs */
  68964. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68965. /** Texture is repeating and mirrored */
  68966. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68967. /** ALPHA */
  68968. static readonly TEXTUREFORMAT_ALPHA: number;
  68969. /** LUMINANCE */
  68970. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68971. /** LUMINANCE_ALPHA */
  68972. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68973. /** RGB */
  68974. static readonly TEXTUREFORMAT_RGB: number;
  68975. /** RGBA */
  68976. static readonly TEXTUREFORMAT_RGBA: number;
  68977. /** RED */
  68978. static readonly TEXTUREFORMAT_RED: number;
  68979. /** RED (2nd reference) */
  68980. static readonly TEXTUREFORMAT_R: number;
  68981. /** RG */
  68982. static readonly TEXTUREFORMAT_RG: number;
  68983. /** RED_INTEGER */
  68984. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68985. /** RED_INTEGER (2nd reference) */
  68986. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68987. /** RG_INTEGER */
  68988. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68989. /** RGB_INTEGER */
  68990. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68991. /** RGBA_INTEGER */
  68992. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68993. /** UNSIGNED_BYTE */
  68994. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68995. /** UNSIGNED_BYTE (2nd reference) */
  68996. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68997. /** FLOAT */
  68998. static readonly TEXTURETYPE_FLOAT: number;
  68999. /** HALF_FLOAT */
  69000. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69001. /** BYTE */
  69002. static readonly TEXTURETYPE_BYTE: number;
  69003. /** SHORT */
  69004. static readonly TEXTURETYPE_SHORT: number;
  69005. /** UNSIGNED_SHORT */
  69006. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69007. /** INT */
  69008. static readonly TEXTURETYPE_INT: number;
  69009. /** UNSIGNED_INT */
  69010. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69011. /** UNSIGNED_SHORT_4_4_4_4 */
  69012. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69013. /** UNSIGNED_SHORT_5_5_5_1 */
  69014. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69015. /** UNSIGNED_SHORT_5_6_5 */
  69016. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69017. /** UNSIGNED_INT_2_10_10_10_REV */
  69018. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69019. /** UNSIGNED_INT_24_8 */
  69020. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69021. /** UNSIGNED_INT_10F_11F_11F_REV */
  69022. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69023. /** UNSIGNED_INT_5_9_9_9_REV */
  69024. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69025. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69026. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69027. /** nearest is mag = nearest and min = nearest and mip = linear */
  69028. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69029. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69030. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69031. /** Trilinear is mag = linear and min = linear and mip = linear */
  69032. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69033. /** nearest is mag = nearest and min = nearest and mip = linear */
  69034. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69036. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69037. /** Trilinear is mag = linear and min = linear and mip = linear */
  69038. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69039. /** mag = nearest and min = nearest and mip = nearest */
  69040. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69041. /** mag = nearest and min = linear and mip = nearest */
  69042. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69043. /** mag = nearest and min = linear and mip = linear */
  69044. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69045. /** mag = nearest and min = linear and mip = none */
  69046. static readonly TEXTURE_NEAREST_LINEAR: number;
  69047. /** mag = nearest and min = nearest and mip = none */
  69048. static readonly TEXTURE_NEAREST_NEAREST: number;
  69049. /** mag = linear and min = nearest and mip = nearest */
  69050. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69051. /** mag = linear and min = nearest and mip = linear */
  69052. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69053. /** mag = linear and min = linear and mip = none */
  69054. static readonly TEXTURE_LINEAR_LINEAR: number;
  69055. /** mag = linear and min = nearest and mip = none */
  69056. static readonly TEXTURE_LINEAR_NEAREST: number;
  69057. /** Explicit coordinates mode */
  69058. static readonly TEXTURE_EXPLICIT_MODE: number;
  69059. /** Spherical coordinates mode */
  69060. static readonly TEXTURE_SPHERICAL_MODE: number;
  69061. /** Planar coordinates mode */
  69062. static readonly TEXTURE_PLANAR_MODE: number;
  69063. /** Cubic coordinates mode */
  69064. static readonly TEXTURE_CUBIC_MODE: number;
  69065. /** Projection coordinates mode */
  69066. static readonly TEXTURE_PROJECTION_MODE: number;
  69067. /** Skybox coordinates mode */
  69068. static readonly TEXTURE_SKYBOX_MODE: number;
  69069. /** Inverse Cubic coordinates mode */
  69070. static readonly TEXTURE_INVCUBIC_MODE: number;
  69071. /** Equirectangular coordinates mode */
  69072. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69073. /** Equirectangular Fixed coordinates mode */
  69074. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69075. /** Equirectangular Fixed Mirrored coordinates mode */
  69076. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69077. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69078. static readonly SCALEMODE_FLOOR: number;
  69079. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69080. static readonly SCALEMODE_NEAREST: number;
  69081. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69082. static readonly SCALEMODE_CEILING: number;
  69083. /**
  69084. * The dirty texture flag value
  69085. */
  69086. static readonly MATERIAL_TextureDirtyFlag: number;
  69087. /**
  69088. * The dirty light flag value
  69089. */
  69090. static readonly MATERIAL_LightDirtyFlag: number;
  69091. /**
  69092. * The dirty fresnel flag value
  69093. */
  69094. static readonly MATERIAL_FresnelDirtyFlag: number;
  69095. /**
  69096. * The dirty attribute flag value
  69097. */
  69098. static readonly MATERIAL_AttributesDirtyFlag: number;
  69099. /**
  69100. * The dirty misc flag value
  69101. */
  69102. static readonly MATERIAL_MiscDirtyFlag: number;
  69103. /**
  69104. * The all dirty flag value
  69105. */
  69106. static readonly MATERIAL_AllDirtyFlag: number;
  69107. /**
  69108. * Returns the triangle fill mode
  69109. */
  69110. static readonly MATERIAL_TriangleFillMode: number;
  69111. /**
  69112. * Returns the wireframe mode
  69113. */
  69114. static readonly MATERIAL_WireFrameFillMode: number;
  69115. /**
  69116. * Returns the point fill mode
  69117. */
  69118. static readonly MATERIAL_PointFillMode: number;
  69119. /**
  69120. * Returns the point list draw mode
  69121. */
  69122. static readonly MATERIAL_PointListDrawMode: number;
  69123. /**
  69124. * Returns the line list draw mode
  69125. */
  69126. static readonly MATERIAL_LineListDrawMode: number;
  69127. /**
  69128. * Returns the line loop draw mode
  69129. */
  69130. static readonly MATERIAL_LineLoopDrawMode: number;
  69131. /**
  69132. * Returns the line strip draw mode
  69133. */
  69134. static readonly MATERIAL_LineStripDrawMode: number;
  69135. /**
  69136. * Returns the triangle strip draw mode
  69137. */
  69138. static readonly MATERIAL_TriangleStripDrawMode: number;
  69139. /**
  69140. * Returns the triangle fan draw mode
  69141. */
  69142. static readonly MATERIAL_TriangleFanDrawMode: number;
  69143. /**
  69144. * Stores the clock-wise side orientation
  69145. */
  69146. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69147. /**
  69148. * Stores the counter clock-wise side orientation
  69149. */
  69150. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69151. /**
  69152. * Nothing
  69153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69154. */
  69155. static readonly ACTION_NothingTrigger: number;
  69156. /**
  69157. * On pick
  69158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69159. */
  69160. static readonly ACTION_OnPickTrigger: number;
  69161. /**
  69162. * On left pick
  69163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69164. */
  69165. static readonly ACTION_OnLeftPickTrigger: number;
  69166. /**
  69167. * On right pick
  69168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69169. */
  69170. static readonly ACTION_OnRightPickTrigger: number;
  69171. /**
  69172. * On center pick
  69173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69174. */
  69175. static readonly ACTION_OnCenterPickTrigger: number;
  69176. /**
  69177. * On pick down
  69178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69179. */
  69180. static readonly ACTION_OnPickDownTrigger: number;
  69181. /**
  69182. * On double pick
  69183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69184. */
  69185. static readonly ACTION_OnDoublePickTrigger: number;
  69186. /**
  69187. * On pick up
  69188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69189. */
  69190. static readonly ACTION_OnPickUpTrigger: number;
  69191. /**
  69192. * On pick out.
  69193. * This trigger will only be raised if you also declared a OnPickDown
  69194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69195. */
  69196. static readonly ACTION_OnPickOutTrigger: number;
  69197. /**
  69198. * On long press
  69199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69200. */
  69201. static readonly ACTION_OnLongPressTrigger: number;
  69202. /**
  69203. * On pointer over
  69204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69205. */
  69206. static readonly ACTION_OnPointerOverTrigger: number;
  69207. /**
  69208. * On pointer out
  69209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69210. */
  69211. static readonly ACTION_OnPointerOutTrigger: number;
  69212. /**
  69213. * On every frame
  69214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69215. */
  69216. static readonly ACTION_OnEveryFrameTrigger: number;
  69217. /**
  69218. * On intersection enter
  69219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69220. */
  69221. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69222. /**
  69223. * On intersection exit
  69224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69225. */
  69226. static readonly ACTION_OnIntersectionExitTrigger: number;
  69227. /**
  69228. * On key down
  69229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69230. */
  69231. static readonly ACTION_OnKeyDownTrigger: number;
  69232. /**
  69233. * On key up
  69234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69235. */
  69236. static readonly ACTION_OnKeyUpTrigger: number;
  69237. /**
  69238. * Billboard mode will only apply to Y axis
  69239. */
  69240. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69241. /**
  69242. * Billboard mode will apply to all axes
  69243. */
  69244. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69245. /**
  69246. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69247. */
  69248. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69249. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69250. * Test order :
  69251. * Is the bounding sphere outside the frustum ?
  69252. * If not, are the bounding box vertices outside the frustum ?
  69253. * It not, then the cullable object is in the frustum.
  69254. */
  69255. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69256. /** Culling strategy : Bounding Sphere Only.
  69257. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69258. * It's also less accurate than the standard because some not visible objects can still be selected.
  69259. * Test : is the bounding sphere outside the frustum ?
  69260. * If not, then the cullable object is in the frustum.
  69261. */
  69262. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69263. /** Culling strategy : Optimistic Inclusion.
  69264. * This in an inclusion test first, then the standard exclusion test.
  69265. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69266. * 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.
  69267. * Anyway, it's as accurate as the standard strategy.
  69268. * Test :
  69269. * Is the cullable object bounding sphere center in the frustum ?
  69270. * If not, apply the default culling strategy.
  69271. */
  69272. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69273. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69274. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69275. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69276. * 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.
  69277. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69278. * Test :
  69279. * Is the cullable object bounding sphere center in the frustum ?
  69280. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69281. */
  69282. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69283. /**
  69284. * No logging while loading
  69285. */
  69286. static readonly SCENELOADER_NO_LOGGING: number;
  69287. /**
  69288. * Minimal logging while loading
  69289. */
  69290. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69291. /**
  69292. * Summary logging while loading
  69293. */
  69294. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69295. /**
  69296. * Detailled logging while loading
  69297. */
  69298. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69299. }
  69300. }
  69301. declare module BABYLON {
  69302. /**
  69303. * This represents the required contract to create a new type of texture loader.
  69304. */
  69305. export interface IInternalTextureLoader {
  69306. /**
  69307. * Defines wether the loader supports cascade loading the different faces.
  69308. */
  69309. supportCascades: boolean;
  69310. /**
  69311. * This returns if the loader support the current file information.
  69312. * @param extension defines the file extension of the file being loaded
  69313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69314. * @param fallback defines the fallback internal texture if any
  69315. * @param isBase64 defines whether the texture is encoded as a base64
  69316. * @param isBuffer defines whether the texture data are stored as a buffer
  69317. * @returns true if the loader can load the specified file
  69318. */
  69319. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69320. /**
  69321. * Transform the url before loading if required.
  69322. * @param rootUrl the url of the texture
  69323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69324. * @returns the transformed texture
  69325. */
  69326. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69327. /**
  69328. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69329. * @param rootUrl the url of the texture
  69330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69331. * @returns the fallback texture
  69332. */
  69333. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69334. /**
  69335. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69336. * @param data contains the texture data
  69337. * @param texture defines the BabylonJS internal texture
  69338. * @param createPolynomials will be true if polynomials have been requested
  69339. * @param onLoad defines the callback to trigger once the texture is ready
  69340. * @param onError defines the callback to trigger in case of error
  69341. */
  69342. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69343. /**
  69344. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69345. * @param data contains the texture data
  69346. * @param texture defines the BabylonJS internal texture
  69347. * @param callback defines the method to call once ready to upload
  69348. */
  69349. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69350. }
  69351. }
  69352. declare module BABYLON {
  69353. /**
  69354. * Class used to store and describe the pipeline context associated with an effect
  69355. */
  69356. export interface IPipelineContext {
  69357. /**
  69358. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69359. */
  69360. isAsync: boolean;
  69361. /**
  69362. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69363. */
  69364. isReady: boolean;
  69365. /** @hidden */
  69366. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /**
  69371. * Class used to store gfx data (like WebGLBuffer)
  69372. */
  69373. export class DataBuffer {
  69374. /**
  69375. * Gets or sets the number of objects referencing this buffer
  69376. */
  69377. references: number;
  69378. /** Gets or sets the size of the underlying buffer */
  69379. capacity: number;
  69380. /**
  69381. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69382. */
  69383. is32Bits: boolean;
  69384. /**
  69385. * Gets the underlying buffer
  69386. */
  69387. readonly underlyingResource: any;
  69388. }
  69389. }
  69390. declare module BABYLON {
  69391. /** @hidden */
  69392. export interface IShaderProcessor {
  69393. attributeProcessor?: (attribute: string) => string;
  69394. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69395. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69396. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69397. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69398. lineProcessor?: (line: string, isFragment: boolean) => string;
  69399. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69400. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69401. }
  69402. }
  69403. declare module BABYLON {
  69404. /** @hidden */
  69405. export interface ProcessingOptions {
  69406. defines: string[];
  69407. indexParameters: any;
  69408. isFragment: boolean;
  69409. shouldUseHighPrecisionShader: boolean;
  69410. supportsUniformBuffers: boolean;
  69411. shadersRepository: string;
  69412. includesShadersStore: {
  69413. [key: string]: string;
  69414. };
  69415. processor?: IShaderProcessor;
  69416. version: string;
  69417. platformName: string;
  69418. lookForClosingBracketForUniformBuffer?: boolean;
  69419. }
  69420. }
  69421. declare module BABYLON {
  69422. /** @hidden */
  69423. export class ShaderCodeNode {
  69424. line: string;
  69425. children: ShaderCodeNode[];
  69426. additionalDefineKey?: string;
  69427. additionalDefineValue?: string;
  69428. isValid(preprocessors: {
  69429. [key: string]: string;
  69430. }): boolean;
  69431. process(preprocessors: {
  69432. [key: string]: string;
  69433. }, options: ProcessingOptions): string;
  69434. }
  69435. }
  69436. declare module BABYLON {
  69437. /** @hidden */
  69438. export class ShaderCodeCursor {
  69439. private _lines;
  69440. lineIndex: number;
  69441. readonly currentLine: string;
  69442. readonly canRead: boolean;
  69443. lines: string[];
  69444. }
  69445. }
  69446. declare module BABYLON {
  69447. /** @hidden */
  69448. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69449. process(preprocessors: {
  69450. [key: string]: string;
  69451. }, options: ProcessingOptions): string;
  69452. }
  69453. }
  69454. declare module BABYLON {
  69455. /** @hidden */
  69456. export class ShaderDefineExpression {
  69457. isTrue(preprocessors: {
  69458. [key: string]: string;
  69459. }): boolean;
  69460. }
  69461. }
  69462. declare module BABYLON {
  69463. /** @hidden */
  69464. export class ShaderCodeTestNode extends ShaderCodeNode {
  69465. testExpression: ShaderDefineExpression;
  69466. isValid(preprocessors: {
  69467. [key: string]: string;
  69468. }): boolean;
  69469. }
  69470. }
  69471. declare module BABYLON {
  69472. /** @hidden */
  69473. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69474. define: string;
  69475. not: boolean;
  69476. constructor(define: string, not?: boolean);
  69477. isTrue(preprocessors: {
  69478. [key: string]: string;
  69479. }): boolean;
  69480. }
  69481. }
  69482. declare module BABYLON {
  69483. /** @hidden */
  69484. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69485. leftOperand: ShaderDefineExpression;
  69486. rightOperand: ShaderDefineExpression;
  69487. isTrue(preprocessors: {
  69488. [key: string]: string;
  69489. }): boolean;
  69490. }
  69491. }
  69492. declare module BABYLON {
  69493. /** @hidden */
  69494. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69495. leftOperand: ShaderDefineExpression;
  69496. rightOperand: ShaderDefineExpression;
  69497. isTrue(preprocessors: {
  69498. [key: string]: string;
  69499. }): boolean;
  69500. }
  69501. }
  69502. declare module BABYLON {
  69503. /** @hidden */
  69504. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69505. define: string;
  69506. operand: string;
  69507. testValue: string;
  69508. constructor(define: string, operand: string, testValue: string);
  69509. isTrue(preprocessors: {
  69510. [key: string]: string;
  69511. }): boolean;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /**
  69516. * Class used to enable access to offline support
  69517. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69518. */
  69519. export interface IOfflineProvider {
  69520. /**
  69521. * Gets a boolean indicating if scene must be saved in the database
  69522. */
  69523. enableSceneOffline: boolean;
  69524. /**
  69525. * Gets a boolean indicating if textures must be saved in the database
  69526. */
  69527. enableTexturesOffline: boolean;
  69528. /**
  69529. * Open the offline support and make it available
  69530. * @param successCallback defines the callback to call on success
  69531. * @param errorCallback defines the callback to call on error
  69532. */
  69533. open(successCallback: () => void, errorCallback: () => void): void;
  69534. /**
  69535. * Loads an image from the offline support
  69536. * @param url defines the url to load from
  69537. * @param image defines the target DOM image
  69538. */
  69539. loadImage(url: string, image: HTMLImageElement): void;
  69540. /**
  69541. * Loads a file from offline support
  69542. * @param url defines the URL to load from
  69543. * @param sceneLoaded defines a callback to call on success
  69544. * @param progressCallBack defines a callback to call when progress changed
  69545. * @param errorCallback defines a callback to call on error
  69546. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69547. */
  69548. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69549. }
  69550. }
  69551. declare module BABYLON {
  69552. /**
  69553. * Class used to help managing file picking and drag'n'drop
  69554. * File Storage
  69555. */
  69556. export class FilesInputStore {
  69557. /**
  69558. * List of files ready to be loaded
  69559. */
  69560. static FilesToLoad: {
  69561. [key: string]: File;
  69562. };
  69563. }
  69564. }
  69565. declare module BABYLON {
  69566. /**
  69567. * Class used to define a retry strategy when error happens while loading assets
  69568. */
  69569. export class RetryStrategy {
  69570. /**
  69571. * Function used to defines an exponential back off strategy
  69572. * @param maxRetries defines the maximum number of retries (3 by default)
  69573. * @param baseInterval defines the interval between retries
  69574. * @returns the strategy function to use
  69575. */
  69576. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69577. }
  69578. }
  69579. declare module BABYLON {
  69580. /**
  69581. * @ignore
  69582. * Application error to support additional information when loading a file
  69583. */
  69584. export abstract class BaseError extends Error {
  69585. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69586. }
  69587. }
  69588. declare module BABYLON {
  69589. /** @ignore */
  69590. export class LoadFileError extends BaseError {
  69591. request?: WebRequest;
  69592. file?: File;
  69593. /**
  69594. * Creates a new LoadFileError
  69595. * @param message defines the message of the error
  69596. * @param request defines the optional web request
  69597. * @param file defines the optional file
  69598. */
  69599. constructor(message: string, object?: WebRequest | File);
  69600. }
  69601. /** @ignore */
  69602. export class RequestFileError extends BaseError {
  69603. request: WebRequest;
  69604. /**
  69605. * Creates a new LoadFileError
  69606. * @param message defines the message of the error
  69607. * @param request defines the optional web request
  69608. */
  69609. constructor(message: string, request: WebRequest);
  69610. }
  69611. /** @ignore */
  69612. export class ReadFileError extends BaseError {
  69613. file: File;
  69614. /**
  69615. * Creates a new ReadFileError
  69616. * @param message defines the message of the error
  69617. * @param file defines the optional file
  69618. */
  69619. constructor(message: string, file: File);
  69620. }
  69621. /**
  69622. * @hidden
  69623. */
  69624. export class FileTools {
  69625. /**
  69626. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69627. */
  69628. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69629. /**
  69630. * Gets or sets the base URL to use to load assets
  69631. */
  69632. static BaseUrl: string;
  69633. /**
  69634. * Default behaviour for cors in the application.
  69635. * It can be a string if the expected behavior is identical in the entire app.
  69636. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69637. */
  69638. static CorsBehavior: string | ((url: string | string[]) => string);
  69639. /**
  69640. * Gets or sets a function used to pre-process url before using them to load assets
  69641. */
  69642. static PreprocessUrl: (url: string) => string;
  69643. /**
  69644. * Removes unwanted characters from an url
  69645. * @param url defines the url to clean
  69646. * @returns the cleaned url
  69647. */
  69648. private static _CleanUrl;
  69649. /**
  69650. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69651. * @param url define the url we are trying
  69652. * @param element define the dom element where to configure the cors policy
  69653. */
  69654. static SetCorsBehavior(url: string | string[], element: {
  69655. crossOrigin: string | null;
  69656. }): void;
  69657. /**
  69658. * Loads an image as an HTMLImageElement.
  69659. * @param input url string, ArrayBuffer, or Blob to load
  69660. * @param onLoad callback called when the image successfully loads
  69661. * @param onError callback called when the image fails to load
  69662. * @param offlineProvider offline provider for caching
  69663. * @param mimeType optional mime type
  69664. * @returns the HTMLImageElement of the loaded image
  69665. */
  69666. 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>;
  69667. /**
  69668. * Reads a file from a File object
  69669. * @param file defines the file to load
  69670. * @param onSuccess defines the callback to call when data is loaded
  69671. * @param onProgress defines the callback to call during loading process
  69672. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69673. * @param onError defines the callback to call when an error occurs
  69674. * @returns a file request object
  69675. */
  69676. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69677. /**
  69678. * Loads a file from a url
  69679. * @param url url to load
  69680. * @param onSuccess callback called when the file successfully loads
  69681. * @param onProgress callback called while file is loading (if the server supports this mode)
  69682. * @param offlineProvider defines the offline provider for caching
  69683. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69684. * @param onError callback called when the file fails to load
  69685. * @returns a file request object
  69686. */
  69687. 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;
  69688. /**
  69689. * Loads a file
  69690. * @param url url to load
  69691. * @param onSuccess callback called when the file successfully loads
  69692. * @param onProgress callback called while file is loading (if the server supports this mode)
  69693. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69694. * @param onError callback called when the file fails to load
  69695. * @param onOpened callback called when the web request is opened
  69696. * @returns a file request object
  69697. */
  69698. 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;
  69699. /**
  69700. * Checks if the loaded document was accessed via `file:`-Protocol.
  69701. * @returns boolean
  69702. */
  69703. static IsFileURL(): boolean;
  69704. }
  69705. }
  69706. declare module BABYLON {
  69707. /** @hidden */
  69708. export class ShaderProcessor {
  69709. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69710. private static _ProcessPrecision;
  69711. private static _ExtractOperation;
  69712. private static _BuildSubExpression;
  69713. private static _BuildExpression;
  69714. private static _MoveCursorWithinIf;
  69715. private static _MoveCursor;
  69716. private static _EvaluatePreProcessors;
  69717. private static _PreparePreProcessors;
  69718. private static _ProcessShaderConversion;
  69719. private static _ProcessIncludes;
  69720. }
  69721. }
  69722. declare module BABYLON {
  69723. /**
  69724. * @hidden
  69725. */
  69726. export interface IColor4Like {
  69727. r: float;
  69728. g: float;
  69729. b: float;
  69730. a: float;
  69731. }
  69732. /**
  69733. * @hidden
  69734. */
  69735. export interface IColor3Like {
  69736. r: float;
  69737. g: float;
  69738. b: float;
  69739. }
  69740. /**
  69741. * @hidden
  69742. */
  69743. export interface IVector4Like {
  69744. x: float;
  69745. y: float;
  69746. z: float;
  69747. w: float;
  69748. }
  69749. /**
  69750. * @hidden
  69751. */
  69752. export interface IVector3Like {
  69753. x: float;
  69754. y: float;
  69755. z: float;
  69756. }
  69757. /**
  69758. * @hidden
  69759. */
  69760. export interface IVector2Like {
  69761. x: float;
  69762. y: float;
  69763. }
  69764. /**
  69765. * @hidden
  69766. */
  69767. export interface IMatrixLike {
  69768. toArray(): DeepImmutable<Float32Array>;
  69769. updateFlag: int;
  69770. }
  69771. /**
  69772. * @hidden
  69773. */
  69774. export interface IViewportLike {
  69775. x: float;
  69776. y: float;
  69777. width: float;
  69778. height: float;
  69779. }
  69780. /**
  69781. * @hidden
  69782. */
  69783. export interface IPlaneLike {
  69784. normal: IVector3Like;
  69785. d: float;
  69786. normalize(): void;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Interface used to define common properties for effect fallbacks
  69792. */
  69793. export interface IEffectFallbacks {
  69794. /**
  69795. * Removes the defines that should be removed when falling back.
  69796. * @param currentDefines defines the current define statements for the shader.
  69797. * @param effect defines the current effect we try to compile
  69798. * @returns The resulting defines with defines of the current rank removed.
  69799. */
  69800. reduce(currentDefines: string, effect: Effect): string;
  69801. /**
  69802. * Removes the fallback from the bound mesh.
  69803. */
  69804. unBindMesh(): void;
  69805. /**
  69806. * Checks to see if more fallbacks are still availible.
  69807. */
  69808. hasMoreFallbacks: boolean;
  69809. }
  69810. }
  69811. declare module BABYLON {
  69812. /**
  69813. * Class used to evalaute queries containing `and` and `or` operators
  69814. */
  69815. export class AndOrNotEvaluator {
  69816. /**
  69817. * Evaluate a query
  69818. * @param query defines the query to evaluate
  69819. * @param evaluateCallback defines the callback used to filter result
  69820. * @returns true if the query matches
  69821. */
  69822. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69823. private static _HandleParenthesisContent;
  69824. private static _SimplifyNegation;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /**
  69829. * Class used to store custom tags
  69830. */
  69831. export class Tags {
  69832. /**
  69833. * Adds support for tags on the given object
  69834. * @param obj defines the object to use
  69835. */
  69836. static EnableFor(obj: any): void;
  69837. /**
  69838. * Removes tags support
  69839. * @param obj defines the object to use
  69840. */
  69841. static DisableFor(obj: any): void;
  69842. /**
  69843. * Gets a boolean indicating if the given object has tags
  69844. * @param obj defines the object to use
  69845. * @returns a boolean
  69846. */
  69847. static HasTags(obj: any): boolean;
  69848. /**
  69849. * Gets the tags available on a given object
  69850. * @param obj defines the object to use
  69851. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69852. * @returns the tags
  69853. */
  69854. static GetTags(obj: any, asString?: boolean): any;
  69855. /**
  69856. * Adds tags to an object
  69857. * @param obj defines the object to use
  69858. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69859. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69860. */
  69861. static AddTagsTo(obj: any, tagsString: string): void;
  69862. /**
  69863. * @hidden
  69864. */
  69865. static _AddTagTo(obj: any, tag: string): void;
  69866. /**
  69867. * Removes specific tags from a specific object
  69868. * @param obj defines the object to use
  69869. * @param tagsString defines the tags to remove
  69870. */
  69871. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69872. /**
  69873. * @hidden
  69874. */
  69875. static _RemoveTagFrom(obj: any, tag: string): void;
  69876. /**
  69877. * Defines if tags hosted on an object match a given query
  69878. * @param obj defines the object to use
  69879. * @param tagsQuery defines the tag query
  69880. * @returns a boolean
  69881. */
  69882. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69883. }
  69884. }
  69885. declare module BABYLON {
  69886. /**
  69887. * Scalar computation library
  69888. */
  69889. export class Scalar {
  69890. /**
  69891. * Two pi constants convenient for computation.
  69892. */
  69893. static TwoPi: number;
  69894. /**
  69895. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69896. * @param a number
  69897. * @param b number
  69898. * @param epsilon (default = 1.401298E-45)
  69899. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69900. */
  69901. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69902. /**
  69903. * Returns a string : the upper case translation of the number i to hexadecimal.
  69904. * @param i number
  69905. * @returns the upper case translation of the number i to hexadecimal.
  69906. */
  69907. static ToHex(i: number): string;
  69908. /**
  69909. * Returns -1 if value is negative and +1 is value is positive.
  69910. * @param value the value
  69911. * @returns the value itself if it's equal to zero.
  69912. */
  69913. static Sign(value: number): number;
  69914. /**
  69915. * Returns the value itself if it's between min and max.
  69916. * Returns min if the value is lower than min.
  69917. * Returns max if the value is greater than max.
  69918. * @param value the value to clmap
  69919. * @param min the min value to clamp to (default: 0)
  69920. * @param max the max value to clamp to (default: 1)
  69921. * @returns the clamped value
  69922. */
  69923. static Clamp(value: number, min?: number, max?: number): number;
  69924. /**
  69925. * the log2 of value.
  69926. * @param value the value to compute log2 of
  69927. * @returns the log2 of value.
  69928. */
  69929. static Log2(value: number): number;
  69930. /**
  69931. * Loops the value, so that it is never larger than length and never smaller than 0.
  69932. *
  69933. * This is similar to the modulo operator but it works with floating point numbers.
  69934. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69935. * With t = 5 and length = 2.5, the result would be 0.0.
  69936. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69937. * @param value the value
  69938. * @param length the length
  69939. * @returns the looped value
  69940. */
  69941. static Repeat(value: number, length: number): number;
  69942. /**
  69943. * Normalize the value between 0.0 and 1.0 using min and max values
  69944. * @param value value to normalize
  69945. * @param min max to normalize between
  69946. * @param max min to normalize between
  69947. * @returns the normalized value
  69948. */
  69949. static Normalize(value: number, min: number, max: number): number;
  69950. /**
  69951. * Denormalize the value from 0.0 and 1.0 using min and max values
  69952. * @param normalized value to denormalize
  69953. * @param min max to denormalize between
  69954. * @param max min to denormalize between
  69955. * @returns the denormalized value
  69956. */
  69957. static Denormalize(normalized: number, min: number, max: number): number;
  69958. /**
  69959. * Calculates the shortest difference between two given angles given in degrees.
  69960. * @param current current angle in degrees
  69961. * @param target target angle in degrees
  69962. * @returns the delta
  69963. */
  69964. static DeltaAngle(current: number, target: number): number;
  69965. /**
  69966. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69967. * @param tx value
  69968. * @param length length
  69969. * @returns The returned value will move back and forth between 0 and length
  69970. */
  69971. static PingPong(tx: number, length: number): number;
  69972. /**
  69973. * Interpolates between min and max with smoothing at the limits.
  69974. *
  69975. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69976. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69977. * @param from from
  69978. * @param to to
  69979. * @param tx value
  69980. * @returns the smooth stepped value
  69981. */
  69982. static SmoothStep(from: number, to: number, tx: number): number;
  69983. /**
  69984. * Moves a value current towards target.
  69985. *
  69986. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69987. * Negative values of maxDelta pushes the value away from target.
  69988. * @param current current value
  69989. * @param target target value
  69990. * @param maxDelta max distance to move
  69991. * @returns resulting value
  69992. */
  69993. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69994. /**
  69995. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69996. *
  69997. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69998. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69999. * @param current current value
  70000. * @param target target value
  70001. * @param maxDelta max distance to move
  70002. * @returns resulting angle
  70003. */
  70004. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70005. /**
  70006. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70007. * @param start start value
  70008. * @param end target value
  70009. * @param amount amount to lerp between
  70010. * @returns the lerped value
  70011. */
  70012. static Lerp(start: number, end: number, amount: number): number;
  70013. /**
  70014. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70015. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70016. * @param start start value
  70017. * @param end target value
  70018. * @param amount amount to lerp between
  70019. * @returns the lerped value
  70020. */
  70021. static LerpAngle(start: number, end: number, amount: number): number;
  70022. /**
  70023. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70024. * @param a start value
  70025. * @param b target value
  70026. * @param value value between a and b
  70027. * @returns the inverseLerp value
  70028. */
  70029. static InverseLerp(a: number, b: number, value: number): number;
  70030. /**
  70031. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70032. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70033. * @param value1 spline value
  70034. * @param tangent1 spline value
  70035. * @param value2 spline value
  70036. * @param tangent2 spline value
  70037. * @param amount input value
  70038. * @returns hermite result
  70039. */
  70040. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70041. /**
  70042. * Returns a random float number between and min and max values
  70043. * @param min min value of random
  70044. * @param max max value of random
  70045. * @returns random value
  70046. */
  70047. static RandomRange(min: number, max: number): number;
  70048. /**
  70049. * This function returns percentage of a number in a given range.
  70050. *
  70051. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70052. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70053. * @param number to convert to percentage
  70054. * @param min min range
  70055. * @param max max range
  70056. * @returns the percentage
  70057. */
  70058. static RangeToPercent(number: number, min: number, max: number): number;
  70059. /**
  70060. * This function returns number that corresponds to the percentage in a given range.
  70061. *
  70062. * PercentToRange(0.34,0,100) will return 34.
  70063. * @param percent to convert to number
  70064. * @param min min range
  70065. * @param max max range
  70066. * @returns the number
  70067. */
  70068. static PercentToRange(percent: number, min: number, max: number): number;
  70069. /**
  70070. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70071. * @param angle The angle to normalize in radian.
  70072. * @return The converted angle.
  70073. */
  70074. static NormalizeRadians(angle: number): number;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /**
  70079. * Constant used to convert a value to gamma space
  70080. * @ignorenaming
  70081. */
  70082. export const ToGammaSpace: number;
  70083. /**
  70084. * Constant used to convert a value to linear space
  70085. * @ignorenaming
  70086. */
  70087. export const ToLinearSpace = 2.2;
  70088. /**
  70089. * Constant used to define the minimal number value in Babylon.js
  70090. * @ignorenaming
  70091. */
  70092. let Epsilon: number;
  70093. }
  70094. declare module BABYLON {
  70095. /**
  70096. * Class used to represent a viewport on screen
  70097. */
  70098. export class Viewport {
  70099. /** viewport left coordinate */
  70100. x: number;
  70101. /** viewport top coordinate */
  70102. y: number;
  70103. /**viewport width */
  70104. width: number;
  70105. /** viewport height */
  70106. height: number;
  70107. /**
  70108. * Creates a Viewport object located at (x, y) and sized (width, height)
  70109. * @param x defines viewport left coordinate
  70110. * @param y defines viewport top coordinate
  70111. * @param width defines the viewport width
  70112. * @param height defines the viewport height
  70113. */
  70114. constructor(
  70115. /** viewport left coordinate */
  70116. x: number,
  70117. /** viewport top coordinate */
  70118. y: number,
  70119. /**viewport width */
  70120. width: number,
  70121. /** viewport height */
  70122. height: number);
  70123. /**
  70124. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70125. * @param renderWidth defines the rendering width
  70126. * @param renderHeight defines the rendering height
  70127. * @returns a new Viewport
  70128. */
  70129. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70130. /**
  70131. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70132. * @param renderWidth defines the rendering width
  70133. * @param renderHeight defines the rendering height
  70134. * @param ref defines the target viewport
  70135. * @returns the current viewport
  70136. */
  70137. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70138. /**
  70139. * Returns a new Viewport copied from the current one
  70140. * @returns a new Viewport
  70141. */
  70142. clone(): Viewport;
  70143. }
  70144. }
  70145. declare module BABYLON {
  70146. /**
  70147. * Class containing a set of static utilities functions for arrays.
  70148. */
  70149. export class ArrayTools {
  70150. /**
  70151. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70152. * @param size the number of element to construct and put in the array
  70153. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70154. * @returns a new array filled with new objects
  70155. */
  70156. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70157. }
  70158. }
  70159. declare module BABYLON {
  70160. /**
  70161. * Class representing a vector containing 2 coordinates
  70162. */
  70163. export class Vector2 {
  70164. /** defines the first coordinate */
  70165. x: number;
  70166. /** defines the second coordinate */
  70167. y: number;
  70168. /**
  70169. * Creates a new Vector2 from the given x and y coordinates
  70170. * @param x defines the first coordinate
  70171. * @param y defines the second coordinate
  70172. */
  70173. constructor(
  70174. /** defines the first coordinate */
  70175. x?: number,
  70176. /** defines the second coordinate */
  70177. y?: number);
  70178. /**
  70179. * Gets a string with the Vector2 coordinates
  70180. * @returns a string with the Vector2 coordinates
  70181. */
  70182. toString(): string;
  70183. /**
  70184. * Gets class name
  70185. * @returns the string "Vector2"
  70186. */
  70187. getClassName(): string;
  70188. /**
  70189. * Gets current vector hash code
  70190. * @returns the Vector2 hash code as a number
  70191. */
  70192. getHashCode(): number;
  70193. /**
  70194. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70195. * @param array defines the source array
  70196. * @param index defines the offset in source array
  70197. * @returns the current Vector2
  70198. */
  70199. toArray(array: FloatArray, index?: number): Vector2;
  70200. /**
  70201. * Copy the current vector to an array
  70202. * @returns a new array with 2 elements: the Vector2 coordinates.
  70203. */
  70204. asArray(): number[];
  70205. /**
  70206. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70207. * @param source defines the source Vector2
  70208. * @returns the current updated Vector2
  70209. */
  70210. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70211. /**
  70212. * Sets the Vector2 coordinates with the given floats
  70213. * @param x defines the first coordinate
  70214. * @param y defines the second coordinate
  70215. * @returns the current updated Vector2
  70216. */
  70217. copyFromFloats(x: number, y: number): Vector2;
  70218. /**
  70219. * Sets the Vector2 coordinates with the given floats
  70220. * @param x defines the first coordinate
  70221. * @param y defines the second coordinate
  70222. * @returns the current updated Vector2
  70223. */
  70224. set(x: number, y: number): Vector2;
  70225. /**
  70226. * Add another vector with the current one
  70227. * @param otherVector defines the other vector
  70228. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70229. */
  70230. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70231. /**
  70232. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70233. * @param otherVector defines the other vector
  70234. * @param result defines the target vector
  70235. * @returns the unmodified current Vector2
  70236. */
  70237. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70238. /**
  70239. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70240. * @param otherVector defines the other vector
  70241. * @returns the current updated Vector2
  70242. */
  70243. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70244. /**
  70245. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70246. * @param otherVector defines the other vector
  70247. * @returns a new Vector2
  70248. */
  70249. addVector3(otherVector: Vector3): Vector2;
  70250. /**
  70251. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70252. * @param otherVector defines the other vector
  70253. * @returns a new Vector2
  70254. */
  70255. subtract(otherVector: Vector2): Vector2;
  70256. /**
  70257. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70258. * @param otherVector defines the other vector
  70259. * @param result defines the target vector
  70260. * @returns the unmodified current Vector2
  70261. */
  70262. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70263. /**
  70264. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70265. * @param otherVector defines the other vector
  70266. * @returns the current updated Vector2
  70267. */
  70268. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70269. /**
  70270. * Multiplies in place the current Vector2 coordinates by the given ones
  70271. * @param otherVector defines the other vector
  70272. * @returns the current updated Vector2
  70273. */
  70274. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70275. /**
  70276. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70277. * @param otherVector defines the other vector
  70278. * @returns a new Vector2
  70279. */
  70280. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70281. /**
  70282. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70283. * @param otherVector defines the other vector
  70284. * @param result defines the target vector
  70285. * @returns the unmodified current Vector2
  70286. */
  70287. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70288. /**
  70289. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70290. * @param x defines the first coordinate
  70291. * @param y defines the second coordinate
  70292. * @returns a new Vector2
  70293. */
  70294. multiplyByFloats(x: number, y: number): Vector2;
  70295. /**
  70296. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70297. * @param otherVector defines the other vector
  70298. * @returns a new Vector2
  70299. */
  70300. divide(otherVector: Vector2): Vector2;
  70301. /**
  70302. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70303. * @param otherVector defines the other vector
  70304. * @param result defines the target vector
  70305. * @returns the unmodified current Vector2
  70306. */
  70307. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70308. /**
  70309. * Divides the current Vector2 coordinates by the given ones
  70310. * @param otherVector defines the other vector
  70311. * @returns the current updated Vector2
  70312. */
  70313. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70314. /**
  70315. * Gets a new Vector2 with current Vector2 negated coordinates
  70316. * @returns a new Vector2
  70317. */
  70318. negate(): Vector2;
  70319. /**
  70320. * Multiply the Vector2 coordinates by scale
  70321. * @param scale defines the scaling factor
  70322. * @returns the current updated Vector2
  70323. */
  70324. scaleInPlace(scale: number): Vector2;
  70325. /**
  70326. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70327. * @param scale defines the scaling factor
  70328. * @returns a new Vector2
  70329. */
  70330. scale(scale: number): Vector2;
  70331. /**
  70332. * Scale the current Vector2 values by a factor to a given Vector2
  70333. * @param scale defines the scale factor
  70334. * @param result defines the Vector2 object where to store the result
  70335. * @returns the unmodified current Vector2
  70336. */
  70337. scaleToRef(scale: number, result: Vector2): Vector2;
  70338. /**
  70339. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70340. * @param scale defines the scale factor
  70341. * @param result defines the Vector2 object where to store the result
  70342. * @returns the unmodified current Vector2
  70343. */
  70344. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70345. /**
  70346. * Gets a boolean if two vectors are equals
  70347. * @param otherVector defines the other vector
  70348. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70349. */
  70350. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70351. /**
  70352. * Gets a boolean if two vectors are equals (using an epsilon value)
  70353. * @param otherVector defines the other vector
  70354. * @param epsilon defines the minimal distance to consider equality
  70355. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70356. */
  70357. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70358. /**
  70359. * Gets a new Vector2 from current Vector2 floored values
  70360. * @returns a new Vector2
  70361. */
  70362. floor(): Vector2;
  70363. /**
  70364. * Gets a new Vector2 from current Vector2 floored values
  70365. * @returns a new Vector2
  70366. */
  70367. fract(): Vector2;
  70368. /**
  70369. * Gets the length of the vector
  70370. * @returns the vector length (float)
  70371. */
  70372. length(): number;
  70373. /**
  70374. * Gets the vector squared length
  70375. * @returns the vector squared length (float)
  70376. */
  70377. lengthSquared(): number;
  70378. /**
  70379. * Normalize the vector
  70380. * @returns the current updated Vector2
  70381. */
  70382. normalize(): Vector2;
  70383. /**
  70384. * Gets a new Vector2 copied from the Vector2
  70385. * @returns a new Vector2
  70386. */
  70387. clone(): Vector2;
  70388. /**
  70389. * Gets a new Vector2(0, 0)
  70390. * @returns a new Vector2
  70391. */
  70392. static Zero(): Vector2;
  70393. /**
  70394. * Gets a new Vector2(1, 1)
  70395. * @returns a new Vector2
  70396. */
  70397. static One(): Vector2;
  70398. /**
  70399. * Gets a new Vector2 set from the given index element of the given array
  70400. * @param array defines the data source
  70401. * @param offset defines the offset in the data source
  70402. * @returns a new Vector2
  70403. */
  70404. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70405. /**
  70406. * Sets "result" from the given index element of the given array
  70407. * @param array defines the data source
  70408. * @param offset defines the offset in the data source
  70409. * @param result defines the target vector
  70410. */
  70411. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70412. /**
  70413. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70414. * @param value1 defines 1st point of control
  70415. * @param value2 defines 2nd point of control
  70416. * @param value3 defines 3rd point of control
  70417. * @param value4 defines 4th point of control
  70418. * @param amount defines the interpolation factor
  70419. * @returns a new Vector2
  70420. */
  70421. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70422. /**
  70423. * 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".
  70424. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70425. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70426. * @param value defines the value to clamp
  70427. * @param min defines the lower limit
  70428. * @param max defines the upper limit
  70429. * @returns a new Vector2
  70430. */
  70431. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70432. /**
  70433. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70434. * @param value1 defines the 1st control point
  70435. * @param tangent1 defines the outgoing tangent
  70436. * @param value2 defines the 2nd control point
  70437. * @param tangent2 defines the incoming tangent
  70438. * @param amount defines the interpolation factor
  70439. * @returns a new Vector2
  70440. */
  70441. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70442. /**
  70443. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70444. * @param start defines the start vector
  70445. * @param end defines the end vector
  70446. * @param amount defines the interpolation factor
  70447. * @returns a new Vector2
  70448. */
  70449. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70450. /**
  70451. * Gets the dot product of the vector "left" and the vector "right"
  70452. * @param left defines first vector
  70453. * @param right defines second vector
  70454. * @returns the dot product (float)
  70455. */
  70456. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70457. /**
  70458. * Returns a new Vector2 equal to the normalized given vector
  70459. * @param vector defines the vector to normalize
  70460. * @returns a new Vector2
  70461. */
  70462. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70463. /**
  70464. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70465. * @param left defines 1st vector
  70466. * @param right defines 2nd vector
  70467. * @returns a new Vector2
  70468. */
  70469. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70470. /**
  70471. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70472. * @param left defines 1st vector
  70473. * @param right defines 2nd vector
  70474. * @returns a new Vector2
  70475. */
  70476. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70477. /**
  70478. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70479. * @param vector defines the vector to transform
  70480. * @param transformation defines the matrix to apply
  70481. * @returns a new Vector2
  70482. */
  70483. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70484. /**
  70485. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70486. * @param vector defines the vector to transform
  70487. * @param transformation defines the matrix to apply
  70488. * @param result defines the target vector
  70489. */
  70490. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70491. /**
  70492. * Determines if a given vector is included in a triangle
  70493. * @param p defines the vector to test
  70494. * @param p0 defines 1st triangle point
  70495. * @param p1 defines 2nd triangle point
  70496. * @param p2 defines 3rd triangle point
  70497. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70498. */
  70499. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70500. /**
  70501. * Gets the distance between the vectors "value1" and "value2"
  70502. * @param value1 defines first vector
  70503. * @param value2 defines second vector
  70504. * @returns the distance between vectors
  70505. */
  70506. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70507. /**
  70508. * Returns the squared distance between the vectors "value1" and "value2"
  70509. * @param value1 defines first vector
  70510. * @param value2 defines second vector
  70511. * @returns the squared distance between vectors
  70512. */
  70513. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70514. /**
  70515. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70516. * @param value1 defines first vector
  70517. * @param value2 defines second vector
  70518. * @returns a new Vector2
  70519. */
  70520. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70521. /**
  70522. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70523. * @param p defines the middle point
  70524. * @param segA defines one point of the segment
  70525. * @param segB defines the other point of the segment
  70526. * @returns the shortest distance
  70527. */
  70528. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70529. }
  70530. /**
  70531. * Classed used to store (x,y,z) vector representation
  70532. * A Vector3 is the main object used in 3D geometry
  70533. * It can represent etiher the coordinates of a point the space, either a direction
  70534. * Reminder: js uses a left handed forward facing system
  70535. */
  70536. export class Vector3 {
  70537. /**
  70538. * Defines the first coordinates (on X axis)
  70539. */
  70540. x: number;
  70541. /**
  70542. * Defines the second coordinates (on Y axis)
  70543. */
  70544. y: number;
  70545. /**
  70546. * Defines the third coordinates (on Z axis)
  70547. */
  70548. z: number;
  70549. private static _UpReadOnly;
  70550. private static _ZeroReadOnly;
  70551. /**
  70552. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70553. * @param x defines the first coordinates (on X axis)
  70554. * @param y defines the second coordinates (on Y axis)
  70555. * @param z defines the third coordinates (on Z axis)
  70556. */
  70557. constructor(
  70558. /**
  70559. * Defines the first coordinates (on X axis)
  70560. */
  70561. x?: number,
  70562. /**
  70563. * Defines the second coordinates (on Y axis)
  70564. */
  70565. y?: number,
  70566. /**
  70567. * Defines the third coordinates (on Z axis)
  70568. */
  70569. z?: number);
  70570. /**
  70571. * Creates a string representation of the Vector3
  70572. * @returns a string with the Vector3 coordinates.
  70573. */
  70574. toString(): string;
  70575. /**
  70576. * Gets the class name
  70577. * @returns the string "Vector3"
  70578. */
  70579. getClassName(): string;
  70580. /**
  70581. * Creates the Vector3 hash code
  70582. * @returns a number which tends to be unique between Vector3 instances
  70583. */
  70584. getHashCode(): number;
  70585. /**
  70586. * Creates an array containing three elements : the coordinates of the Vector3
  70587. * @returns a new array of numbers
  70588. */
  70589. asArray(): number[];
  70590. /**
  70591. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70592. * @param array defines the destination array
  70593. * @param index defines the offset in the destination array
  70594. * @returns the current Vector3
  70595. */
  70596. toArray(array: FloatArray, index?: number): Vector3;
  70597. /**
  70598. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70599. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70600. */
  70601. toQuaternion(): Quaternion;
  70602. /**
  70603. * Adds the given vector to the current Vector3
  70604. * @param otherVector defines the second operand
  70605. * @returns the current updated Vector3
  70606. */
  70607. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70608. /**
  70609. * Adds the given coordinates to the current Vector3
  70610. * @param x defines the x coordinate of the operand
  70611. * @param y defines the y coordinate of the operand
  70612. * @param z defines the z coordinate of the operand
  70613. * @returns the current updated Vector3
  70614. */
  70615. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70616. /**
  70617. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70618. * @param otherVector defines the second operand
  70619. * @returns the resulting Vector3
  70620. */
  70621. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70622. /**
  70623. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70624. * @param otherVector defines the second operand
  70625. * @param result defines the Vector3 object where to store the result
  70626. * @returns the current Vector3
  70627. */
  70628. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70629. /**
  70630. * Subtract the given vector from the current Vector3
  70631. * @param otherVector defines the second operand
  70632. * @returns the current updated Vector3
  70633. */
  70634. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70635. /**
  70636. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70637. * @param otherVector defines the second operand
  70638. * @returns the resulting Vector3
  70639. */
  70640. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70641. /**
  70642. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70643. * @param otherVector defines the second operand
  70644. * @param result defines the Vector3 object where to store the result
  70645. * @returns the current Vector3
  70646. */
  70647. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70648. /**
  70649. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70650. * @param x defines the x coordinate of the operand
  70651. * @param y defines the y coordinate of the operand
  70652. * @param z defines the z coordinate of the operand
  70653. * @returns the resulting Vector3
  70654. */
  70655. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70656. /**
  70657. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70658. * @param x defines the x coordinate of the operand
  70659. * @param y defines the y coordinate of the operand
  70660. * @param z defines the z coordinate of the operand
  70661. * @param result defines the Vector3 object where to store the result
  70662. * @returns the current Vector3
  70663. */
  70664. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70665. /**
  70666. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70667. * @returns a new Vector3
  70668. */
  70669. negate(): Vector3;
  70670. /**
  70671. * Multiplies the Vector3 coordinates by the float "scale"
  70672. * @param scale defines the multiplier factor
  70673. * @returns the current updated Vector3
  70674. */
  70675. scaleInPlace(scale: number): Vector3;
  70676. /**
  70677. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70678. * @param scale defines the multiplier factor
  70679. * @returns a new Vector3
  70680. */
  70681. scale(scale: number): Vector3;
  70682. /**
  70683. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70684. * @param scale defines the multiplier factor
  70685. * @param result defines the Vector3 object where to store the result
  70686. * @returns the current Vector3
  70687. */
  70688. scaleToRef(scale: number, result: Vector3): Vector3;
  70689. /**
  70690. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70691. * @param scale defines the scale factor
  70692. * @param result defines the Vector3 object where to store the result
  70693. * @returns the unmodified current Vector3
  70694. */
  70695. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70696. /**
  70697. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70698. * @param otherVector defines the second operand
  70699. * @returns true if both vectors are equals
  70700. */
  70701. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70702. /**
  70703. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70704. * @param otherVector defines the second operand
  70705. * @param epsilon defines the minimal distance to define values as equals
  70706. * @returns true if both vectors are distant less than epsilon
  70707. */
  70708. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70709. /**
  70710. * Returns true if the current Vector3 coordinates equals the given floats
  70711. * @param x defines the x coordinate of the operand
  70712. * @param y defines the y coordinate of the operand
  70713. * @param z defines the z coordinate of the operand
  70714. * @returns true if both vectors are equals
  70715. */
  70716. equalsToFloats(x: number, y: number, z: number): boolean;
  70717. /**
  70718. * Multiplies the current Vector3 coordinates by the given ones
  70719. * @param otherVector defines the second operand
  70720. * @returns the current updated Vector3
  70721. */
  70722. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70723. /**
  70724. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70725. * @param otherVector defines the second operand
  70726. * @returns the new Vector3
  70727. */
  70728. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70729. /**
  70730. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70731. * @param otherVector defines the second operand
  70732. * @param result defines the Vector3 object where to store the result
  70733. * @returns the current Vector3
  70734. */
  70735. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70736. /**
  70737. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70738. * @param x defines the x coordinate of the operand
  70739. * @param y defines the y coordinate of the operand
  70740. * @param z defines the z coordinate of the operand
  70741. * @returns the new Vector3
  70742. */
  70743. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70744. /**
  70745. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70746. * @param otherVector defines the second operand
  70747. * @returns the new Vector3
  70748. */
  70749. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70750. /**
  70751. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70752. * @param otherVector defines the second operand
  70753. * @param result defines the Vector3 object where to store the result
  70754. * @returns the current Vector3
  70755. */
  70756. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70757. /**
  70758. * Divides the current Vector3 coordinates by the given ones.
  70759. * @param otherVector defines the second operand
  70760. * @returns the current updated Vector3
  70761. */
  70762. divideInPlace(otherVector: Vector3): Vector3;
  70763. /**
  70764. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70765. * @param other defines the second operand
  70766. * @returns the current updated Vector3
  70767. */
  70768. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70769. /**
  70770. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70771. * @param other defines the second operand
  70772. * @returns the current updated Vector3
  70773. */
  70774. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70775. /**
  70776. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70777. * @param x defines the x coordinate of the operand
  70778. * @param y defines the y coordinate of the operand
  70779. * @param z defines the z coordinate of the operand
  70780. * @returns the current updated Vector3
  70781. */
  70782. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70783. /**
  70784. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70785. * @param x defines the x coordinate of the operand
  70786. * @param y defines the y coordinate of the operand
  70787. * @param z defines the z coordinate of the operand
  70788. * @returns the current updated Vector3
  70789. */
  70790. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70791. /**
  70792. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70793. * Check if is non uniform within a certain amount of decimal places to account for this
  70794. * @param epsilon the amount the values can differ
  70795. * @returns if the the vector is non uniform to a certain number of decimal places
  70796. */
  70797. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70798. /**
  70799. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70800. */
  70801. readonly isNonUniform: boolean;
  70802. /**
  70803. * Gets a new Vector3 from current Vector3 floored values
  70804. * @returns a new Vector3
  70805. */
  70806. floor(): Vector3;
  70807. /**
  70808. * Gets a new Vector3 from current Vector3 floored values
  70809. * @returns a new Vector3
  70810. */
  70811. fract(): Vector3;
  70812. /**
  70813. * Gets the length of the Vector3
  70814. * @returns the length of the Vector3
  70815. */
  70816. length(): number;
  70817. /**
  70818. * Gets the squared length of the Vector3
  70819. * @returns squared length of the Vector3
  70820. */
  70821. lengthSquared(): number;
  70822. /**
  70823. * Normalize the current Vector3.
  70824. * Please note that this is an in place operation.
  70825. * @returns the current updated Vector3
  70826. */
  70827. normalize(): Vector3;
  70828. /**
  70829. * Reorders the x y z properties of the vector in place
  70830. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70831. * @returns the current updated vector
  70832. */
  70833. reorderInPlace(order: string): this;
  70834. /**
  70835. * Rotates the vector around 0,0,0 by a quaternion
  70836. * @param quaternion the rotation quaternion
  70837. * @param result vector to store the result
  70838. * @returns the resulting vector
  70839. */
  70840. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70841. /**
  70842. * Rotates a vector around a given point
  70843. * @param quaternion the rotation quaternion
  70844. * @param point the point to rotate around
  70845. * @param result vector to store the result
  70846. * @returns the resulting vector
  70847. */
  70848. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70849. /**
  70850. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70851. * The cross product is then orthogonal to both current and "other"
  70852. * @param other defines the right operand
  70853. * @returns the cross product
  70854. */
  70855. cross(other: Vector3): Vector3;
  70856. /**
  70857. * Normalize the current Vector3 with the given input length.
  70858. * Please note that this is an in place operation.
  70859. * @param len the length of the vector
  70860. * @returns the current updated Vector3
  70861. */
  70862. normalizeFromLength(len: number): Vector3;
  70863. /**
  70864. * Normalize the current Vector3 to a new vector
  70865. * @returns the new Vector3
  70866. */
  70867. normalizeToNew(): Vector3;
  70868. /**
  70869. * Normalize the current Vector3 to the reference
  70870. * @param reference define the Vector3 to update
  70871. * @returns the updated Vector3
  70872. */
  70873. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70874. /**
  70875. * Creates a new Vector3 copied from the current Vector3
  70876. * @returns the new Vector3
  70877. */
  70878. clone(): Vector3;
  70879. /**
  70880. * Copies the given vector coordinates to the current Vector3 ones
  70881. * @param source defines the source Vector3
  70882. * @returns the current updated Vector3
  70883. */
  70884. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70885. /**
  70886. * Copies the given floats to the current Vector3 coordinates
  70887. * @param x defines the x coordinate of the operand
  70888. * @param y defines the y coordinate of the operand
  70889. * @param z defines the z coordinate of the operand
  70890. * @returns the current updated Vector3
  70891. */
  70892. copyFromFloats(x: number, y: number, z: number): Vector3;
  70893. /**
  70894. * Copies the given floats to the current Vector3 coordinates
  70895. * @param x defines the x coordinate of the operand
  70896. * @param y defines the y coordinate of the operand
  70897. * @param z defines the z coordinate of the operand
  70898. * @returns the current updated Vector3
  70899. */
  70900. set(x: number, y: number, z: number): Vector3;
  70901. /**
  70902. * Copies the given float to the current Vector3 coordinates
  70903. * @param v defines the x, y and z coordinates of the operand
  70904. * @returns the current updated Vector3
  70905. */
  70906. setAll(v: number): Vector3;
  70907. /**
  70908. * Get the clip factor between two vectors
  70909. * @param vector0 defines the first operand
  70910. * @param vector1 defines the second operand
  70911. * @param axis defines the axis to use
  70912. * @param size defines the size along the axis
  70913. * @returns the clip factor
  70914. */
  70915. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70916. /**
  70917. * Get angle between two vectors
  70918. * @param vector0 angle between vector0 and vector1
  70919. * @param vector1 angle between vector0 and vector1
  70920. * @param normal direction of the normal
  70921. * @return the angle between vector0 and vector1
  70922. */
  70923. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70924. /**
  70925. * Returns a new Vector3 set from the index "offset" of the given array
  70926. * @param array defines the source array
  70927. * @param offset defines the offset in the source array
  70928. * @returns the new Vector3
  70929. */
  70930. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70931. /**
  70932. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70933. * This function is deprecated. Use FromArray instead
  70934. * @param array defines the source array
  70935. * @param offset defines the offset in the source array
  70936. * @returns the new Vector3
  70937. */
  70938. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70939. /**
  70940. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70941. * @param array defines the source array
  70942. * @param offset defines the offset in the source array
  70943. * @param result defines the Vector3 where to store the result
  70944. */
  70945. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70946. /**
  70947. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70948. * This function is deprecated. Use FromArrayToRef instead.
  70949. * @param array defines the source array
  70950. * @param offset defines the offset in the source array
  70951. * @param result defines the Vector3 where to store the result
  70952. */
  70953. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70954. /**
  70955. * Sets the given vector "result" with the given floats.
  70956. * @param x defines the x coordinate of the source
  70957. * @param y defines the y coordinate of the source
  70958. * @param z defines the z coordinate of the source
  70959. * @param result defines the Vector3 where to store the result
  70960. */
  70961. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70962. /**
  70963. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70964. * @returns a new empty Vector3
  70965. */
  70966. static Zero(): Vector3;
  70967. /**
  70968. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70969. * @returns a new unit Vector3
  70970. */
  70971. static One(): Vector3;
  70972. /**
  70973. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70974. * @returns a new up Vector3
  70975. */
  70976. static Up(): Vector3;
  70977. /**
  70978. * Gets a up Vector3 that must not be updated
  70979. */
  70980. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70981. /**
  70982. * Gets a zero Vector3 that must not be updated
  70983. */
  70984. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70985. /**
  70986. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70987. * @returns a new down Vector3
  70988. */
  70989. static Down(): Vector3;
  70990. /**
  70991. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70992. * @returns a new forward Vector3
  70993. */
  70994. static Forward(): Vector3;
  70995. /**
  70996. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70997. * @returns a new forward Vector3
  70998. */
  70999. static Backward(): Vector3;
  71000. /**
  71001. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71002. * @returns a new right Vector3
  71003. */
  71004. static Right(): Vector3;
  71005. /**
  71006. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71007. * @returns a new left Vector3
  71008. */
  71009. static Left(): Vector3;
  71010. /**
  71011. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71012. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71013. * @param vector defines the Vector3 to transform
  71014. * @param transformation defines the transformation matrix
  71015. * @returns the transformed Vector3
  71016. */
  71017. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71018. /**
  71019. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71020. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71021. * @param vector defines the Vector3 to transform
  71022. * @param transformation defines the transformation matrix
  71023. * @param result defines the Vector3 where to store the result
  71024. */
  71025. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71026. /**
  71027. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71028. * This method computes tranformed coordinates only, not transformed direction vectors
  71029. * @param x define the x coordinate of the source vector
  71030. * @param y define the y coordinate of the source vector
  71031. * @param z define the z coordinate of the source vector
  71032. * @param transformation defines the transformation matrix
  71033. * @param result defines the Vector3 where to store the result
  71034. */
  71035. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71036. /**
  71037. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71038. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71039. * @param vector defines the Vector3 to transform
  71040. * @param transformation defines the transformation matrix
  71041. * @returns the new Vector3
  71042. */
  71043. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71044. /**
  71045. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71046. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71047. * @param vector defines the Vector3 to transform
  71048. * @param transformation defines the transformation matrix
  71049. * @param result defines the Vector3 where to store the result
  71050. */
  71051. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71052. /**
  71053. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71054. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71055. * @param x define the x coordinate of the source vector
  71056. * @param y define the y coordinate of the source vector
  71057. * @param z define the z coordinate of the source vector
  71058. * @param transformation defines the transformation matrix
  71059. * @param result defines the Vector3 where to store the result
  71060. */
  71061. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71062. /**
  71063. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71064. * @param value1 defines the first control point
  71065. * @param value2 defines the second control point
  71066. * @param value3 defines the third control point
  71067. * @param value4 defines the fourth control point
  71068. * @param amount defines the amount on the spline to use
  71069. * @returns the new Vector3
  71070. */
  71071. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71072. /**
  71073. * 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"
  71074. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71075. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71076. * @param value defines the current value
  71077. * @param min defines the lower range value
  71078. * @param max defines the upper range value
  71079. * @returns the new Vector3
  71080. */
  71081. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71082. /**
  71083. * 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"
  71084. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71085. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71086. * @param value defines the current value
  71087. * @param min defines the lower range value
  71088. * @param max defines the upper range value
  71089. * @param result defines the Vector3 where to store the result
  71090. */
  71091. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71092. /**
  71093. * Checks if a given vector is inside a specific range
  71094. * @param v defines the vector to test
  71095. * @param min defines the minimum range
  71096. * @param max defines the maximum range
  71097. */
  71098. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71099. /**
  71100. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71101. * @param value1 defines the first control point
  71102. * @param tangent1 defines the first tangent vector
  71103. * @param value2 defines the second control point
  71104. * @param tangent2 defines the second tangent vector
  71105. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71106. * @returns the new Vector3
  71107. */
  71108. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71109. /**
  71110. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71111. * @param start defines the start value
  71112. * @param end defines the end value
  71113. * @param amount max defines amount between both (between 0 and 1)
  71114. * @returns the new Vector3
  71115. */
  71116. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71117. /**
  71118. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71119. * @param start defines the start value
  71120. * @param end defines the end value
  71121. * @param amount max defines amount between both (between 0 and 1)
  71122. * @param result defines the Vector3 where to store the result
  71123. */
  71124. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71125. /**
  71126. * Returns the dot product (float) between the vectors "left" and "right"
  71127. * @param left defines the left operand
  71128. * @param right defines the right operand
  71129. * @returns the dot product
  71130. */
  71131. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71132. /**
  71133. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71134. * The cross product is then orthogonal to both "left" and "right"
  71135. * @param left defines the left operand
  71136. * @param right defines the right operand
  71137. * @returns the cross product
  71138. */
  71139. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71140. /**
  71141. * Sets the given vector "result" with the cross product of "left" and "right"
  71142. * The cross product is then orthogonal to both "left" and "right"
  71143. * @param left defines the left operand
  71144. * @param right defines the right operand
  71145. * @param result defines the Vector3 where to store the result
  71146. */
  71147. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71148. /**
  71149. * Returns a new Vector3 as the normalization of the given vector
  71150. * @param vector defines the Vector3 to normalize
  71151. * @returns the new Vector3
  71152. */
  71153. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71154. /**
  71155. * Sets the given vector "result" with the normalization of the given first vector
  71156. * @param vector defines the Vector3 to normalize
  71157. * @param result defines the Vector3 where to store the result
  71158. */
  71159. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71160. /**
  71161. * Project a Vector3 onto screen space
  71162. * @param vector defines the Vector3 to project
  71163. * @param world defines the world matrix to use
  71164. * @param transform defines the transform (view x projection) matrix to use
  71165. * @param viewport defines the screen viewport to use
  71166. * @returns the new Vector3
  71167. */
  71168. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71169. /** @hidden */
  71170. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71171. /**
  71172. * Unproject from screen space to object space
  71173. * @param source defines the screen space Vector3 to use
  71174. * @param viewportWidth defines the current width of the viewport
  71175. * @param viewportHeight defines the current height of the viewport
  71176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71177. * @param transform defines the transform (view x projection) matrix to use
  71178. * @returns the new Vector3
  71179. */
  71180. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71181. /**
  71182. * Unproject from screen space to object space
  71183. * @param source defines the screen space Vector3 to use
  71184. * @param viewportWidth defines the current width of the viewport
  71185. * @param viewportHeight defines the current height of the viewport
  71186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71187. * @param view defines the view matrix to use
  71188. * @param projection defines the projection matrix to use
  71189. * @returns the new Vector3
  71190. */
  71191. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71192. /**
  71193. * Unproject from screen space to object space
  71194. * @param source defines the screen space Vector3 to use
  71195. * @param viewportWidth defines the current width of the viewport
  71196. * @param viewportHeight defines the current height of the viewport
  71197. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71198. * @param view defines the view matrix to use
  71199. * @param projection defines the projection matrix to use
  71200. * @param result defines the Vector3 where to store the result
  71201. */
  71202. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71203. /**
  71204. * Unproject from screen space to object space
  71205. * @param sourceX defines the screen space x coordinate to use
  71206. * @param sourceY defines the screen space y coordinate to use
  71207. * @param sourceZ defines the screen space z coordinate to use
  71208. * @param viewportWidth defines the current width of the viewport
  71209. * @param viewportHeight defines the current height of the viewport
  71210. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71211. * @param view defines the view matrix to use
  71212. * @param projection defines the projection matrix to use
  71213. * @param result defines the Vector3 where to store the result
  71214. */
  71215. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71216. /**
  71217. * Gets the minimal coordinate values between two Vector3
  71218. * @param left defines the first operand
  71219. * @param right defines the second operand
  71220. * @returns the new Vector3
  71221. */
  71222. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71223. /**
  71224. * Gets the maximal coordinate values between two Vector3
  71225. * @param left defines the first operand
  71226. * @param right defines the second operand
  71227. * @returns the new Vector3
  71228. */
  71229. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71230. /**
  71231. * Returns the distance between the vectors "value1" and "value2"
  71232. * @param value1 defines the first operand
  71233. * @param value2 defines the second operand
  71234. * @returns the distance
  71235. */
  71236. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71237. /**
  71238. * Returns the squared distance between the vectors "value1" and "value2"
  71239. * @param value1 defines the first operand
  71240. * @param value2 defines the second operand
  71241. * @returns the squared distance
  71242. */
  71243. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71244. /**
  71245. * Returns a new Vector3 located at the center between "value1" and "value2"
  71246. * @param value1 defines the first operand
  71247. * @param value2 defines the second operand
  71248. * @returns the new Vector3
  71249. */
  71250. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71251. /**
  71252. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71253. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71254. * to something in order to rotate it from its local system to the given target system
  71255. * Note: axis1, axis2 and axis3 are normalized during this operation
  71256. * @param axis1 defines the first axis
  71257. * @param axis2 defines the second axis
  71258. * @param axis3 defines the third axis
  71259. * @returns a new Vector3
  71260. */
  71261. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71262. /**
  71263. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71264. * @param axis1 defines the first axis
  71265. * @param axis2 defines the second axis
  71266. * @param axis3 defines the third axis
  71267. * @param ref defines the Vector3 where to store the result
  71268. */
  71269. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71270. }
  71271. /**
  71272. * Vector4 class created for EulerAngle class conversion to Quaternion
  71273. */
  71274. export class Vector4 {
  71275. /** x value of the vector */
  71276. x: number;
  71277. /** y value of the vector */
  71278. y: number;
  71279. /** z value of the vector */
  71280. z: number;
  71281. /** w value of the vector */
  71282. w: number;
  71283. /**
  71284. * Creates a Vector4 object from the given floats.
  71285. * @param x x value of the vector
  71286. * @param y y value of the vector
  71287. * @param z z value of the vector
  71288. * @param w w value of the vector
  71289. */
  71290. constructor(
  71291. /** x value of the vector */
  71292. x: number,
  71293. /** y value of the vector */
  71294. y: number,
  71295. /** z value of the vector */
  71296. z: number,
  71297. /** w value of the vector */
  71298. w: number);
  71299. /**
  71300. * Returns the string with the Vector4 coordinates.
  71301. * @returns a string containing all the vector values
  71302. */
  71303. toString(): string;
  71304. /**
  71305. * Returns the string "Vector4".
  71306. * @returns "Vector4"
  71307. */
  71308. getClassName(): string;
  71309. /**
  71310. * Returns the Vector4 hash code.
  71311. * @returns a unique hash code
  71312. */
  71313. getHashCode(): number;
  71314. /**
  71315. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71316. * @returns the resulting array
  71317. */
  71318. asArray(): number[];
  71319. /**
  71320. * Populates the given array from the given index with the Vector4 coordinates.
  71321. * @param array array to populate
  71322. * @param index index of the array to start at (default: 0)
  71323. * @returns the Vector4.
  71324. */
  71325. toArray(array: FloatArray, index?: number): Vector4;
  71326. /**
  71327. * Adds the given vector to the current Vector4.
  71328. * @param otherVector the vector to add
  71329. * @returns the updated Vector4.
  71330. */
  71331. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71332. /**
  71333. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71334. * @param otherVector the vector to add
  71335. * @returns the resulting vector
  71336. */
  71337. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71338. /**
  71339. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71340. * @param otherVector the vector to add
  71341. * @param result the vector to store the result
  71342. * @returns the current Vector4.
  71343. */
  71344. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71345. /**
  71346. * Subtract in place the given vector from the current Vector4.
  71347. * @param otherVector the vector to subtract
  71348. * @returns the updated Vector4.
  71349. */
  71350. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71351. /**
  71352. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71353. * @param otherVector the vector to add
  71354. * @returns the new vector with the result
  71355. */
  71356. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71357. /**
  71358. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71359. * @param otherVector the vector to subtract
  71360. * @param result the vector to store the result
  71361. * @returns the current Vector4.
  71362. */
  71363. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71364. /**
  71365. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71366. */
  71367. /**
  71368. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71369. * @param x value to subtract
  71370. * @param y value to subtract
  71371. * @param z value to subtract
  71372. * @param w value to subtract
  71373. * @returns new vector containing the result
  71374. */
  71375. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71376. /**
  71377. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71378. * @param x value to subtract
  71379. * @param y value to subtract
  71380. * @param z value to subtract
  71381. * @param w value to subtract
  71382. * @param result the vector to store the result in
  71383. * @returns the current Vector4.
  71384. */
  71385. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71386. /**
  71387. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71388. * @returns a new vector with the negated values
  71389. */
  71390. negate(): Vector4;
  71391. /**
  71392. * Multiplies the current Vector4 coordinates by scale (float).
  71393. * @param scale the number to scale with
  71394. * @returns the updated Vector4.
  71395. */
  71396. scaleInPlace(scale: number): Vector4;
  71397. /**
  71398. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71399. * @param scale the number to scale with
  71400. * @returns a new vector with the result
  71401. */
  71402. scale(scale: number): Vector4;
  71403. /**
  71404. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71405. * @param scale the number to scale with
  71406. * @param result a vector to store the result in
  71407. * @returns the current Vector4.
  71408. */
  71409. scaleToRef(scale: number, result: Vector4): Vector4;
  71410. /**
  71411. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71412. * @param scale defines the scale factor
  71413. * @param result defines the Vector4 object where to store the result
  71414. * @returns the unmodified current Vector4
  71415. */
  71416. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71417. /**
  71418. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71419. * @param otherVector the vector to compare against
  71420. * @returns true if they are equal
  71421. */
  71422. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71423. /**
  71424. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71425. * @param otherVector vector to compare against
  71426. * @param epsilon (Default: very small number)
  71427. * @returns true if they are equal
  71428. */
  71429. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71430. /**
  71431. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71432. * @param x x value to compare against
  71433. * @param y y value to compare against
  71434. * @param z z value to compare against
  71435. * @param w w value to compare against
  71436. * @returns true if equal
  71437. */
  71438. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71439. /**
  71440. * Multiplies in place the current Vector4 by the given one.
  71441. * @param otherVector vector to multiple with
  71442. * @returns the updated Vector4.
  71443. */
  71444. multiplyInPlace(otherVector: Vector4): Vector4;
  71445. /**
  71446. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71447. * @param otherVector vector to multiple with
  71448. * @returns resulting new vector
  71449. */
  71450. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71451. /**
  71452. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71453. * @param otherVector vector to multiple with
  71454. * @param result vector to store the result
  71455. * @returns the current Vector4.
  71456. */
  71457. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71458. /**
  71459. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71460. * @param x x value multiply with
  71461. * @param y y value multiply with
  71462. * @param z z value multiply with
  71463. * @param w w value multiply with
  71464. * @returns resulting new vector
  71465. */
  71466. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71467. /**
  71468. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71469. * @param otherVector vector to devide with
  71470. * @returns resulting new vector
  71471. */
  71472. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71473. /**
  71474. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71475. * @param otherVector vector to devide with
  71476. * @param result vector to store the result
  71477. * @returns the current Vector4.
  71478. */
  71479. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71480. /**
  71481. * Divides the current Vector3 coordinates by the given ones.
  71482. * @param otherVector vector to devide with
  71483. * @returns the updated Vector3.
  71484. */
  71485. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71486. /**
  71487. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71488. * @param other defines the second operand
  71489. * @returns the current updated Vector4
  71490. */
  71491. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71492. /**
  71493. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71494. * @param other defines the second operand
  71495. * @returns the current updated Vector4
  71496. */
  71497. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71498. /**
  71499. * Gets a new Vector4 from current Vector4 floored values
  71500. * @returns a new Vector4
  71501. */
  71502. floor(): Vector4;
  71503. /**
  71504. * Gets a new Vector4 from current Vector3 floored values
  71505. * @returns a new Vector4
  71506. */
  71507. fract(): Vector4;
  71508. /**
  71509. * Returns the Vector4 length (float).
  71510. * @returns the length
  71511. */
  71512. length(): number;
  71513. /**
  71514. * Returns the Vector4 squared length (float).
  71515. * @returns the length squared
  71516. */
  71517. lengthSquared(): number;
  71518. /**
  71519. * Normalizes in place the Vector4.
  71520. * @returns the updated Vector4.
  71521. */
  71522. normalize(): Vector4;
  71523. /**
  71524. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71525. * @returns this converted to a new vector3
  71526. */
  71527. toVector3(): Vector3;
  71528. /**
  71529. * Returns a new Vector4 copied from the current one.
  71530. * @returns the new cloned vector
  71531. */
  71532. clone(): Vector4;
  71533. /**
  71534. * Updates the current Vector4 with the given one coordinates.
  71535. * @param source the source vector to copy from
  71536. * @returns the updated Vector4.
  71537. */
  71538. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71539. /**
  71540. * Updates the current Vector4 coordinates with the given floats.
  71541. * @param x float to copy from
  71542. * @param y float to copy from
  71543. * @param z float to copy from
  71544. * @param w float to copy from
  71545. * @returns the updated Vector4.
  71546. */
  71547. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71548. /**
  71549. * Updates the current Vector4 coordinates with the given floats.
  71550. * @param x float to set from
  71551. * @param y float to set from
  71552. * @param z float to set from
  71553. * @param w float to set from
  71554. * @returns the updated Vector4.
  71555. */
  71556. set(x: number, y: number, z: number, w: number): Vector4;
  71557. /**
  71558. * Copies the given float to the current Vector3 coordinates
  71559. * @param v defines the x, y, z and w coordinates of the operand
  71560. * @returns the current updated Vector3
  71561. */
  71562. setAll(v: number): Vector4;
  71563. /**
  71564. * Returns a new Vector4 set from the starting index of the given array.
  71565. * @param array the array to pull values from
  71566. * @param offset the offset into the array to start at
  71567. * @returns the new vector
  71568. */
  71569. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71570. /**
  71571. * Updates the given vector "result" from the starting index of the given array.
  71572. * @param array the array to pull values from
  71573. * @param offset the offset into the array to start at
  71574. * @param result the vector to store the result in
  71575. */
  71576. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71577. /**
  71578. * Updates the given vector "result" from the starting index of the given Float32Array.
  71579. * @param array the array to pull values from
  71580. * @param offset the offset into the array to start at
  71581. * @param result the vector to store the result in
  71582. */
  71583. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71584. /**
  71585. * Updates the given vector "result" coordinates from the given floats.
  71586. * @param x float to set from
  71587. * @param y float to set from
  71588. * @param z float to set from
  71589. * @param w float to set from
  71590. * @param result the vector to the floats in
  71591. */
  71592. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71593. /**
  71594. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71595. * @returns the new vector
  71596. */
  71597. static Zero(): Vector4;
  71598. /**
  71599. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71600. * @returns the new vector
  71601. */
  71602. static One(): Vector4;
  71603. /**
  71604. * Returns a new normalized Vector4 from the given one.
  71605. * @param vector the vector to normalize
  71606. * @returns the vector
  71607. */
  71608. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71609. /**
  71610. * Updates the given vector "result" from the normalization of the given one.
  71611. * @param vector the vector to normalize
  71612. * @param result the vector to store the result in
  71613. */
  71614. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71615. /**
  71616. * Returns a vector with the minimum values from the left and right vectors
  71617. * @param left left vector to minimize
  71618. * @param right right vector to minimize
  71619. * @returns a new vector with the minimum of the left and right vector values
  71620. */
  71621. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71622. /**
  71623. * Returns a vector with the maximum values from the left and right vectors
  71624. * @param left left vector to maximize
  71625. * @param right right vector to maximize
  71626. * @returns a new vector with the maximum of the left and right vector values
  71627. */
  71628. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71629. /**
  71630. * Returns the distance (float) between the vectors "value1" and "value2".
  71631. * @param value1 value to calulate the distance between
  71632. * @param value2 value to calulate the distance between
  71633. * @return the distance between the two vectors
  71634. */
  71635. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71636. /**
  71637. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71638. * @param value1 value to calulate the distance between
  71639. * @param value2 value to calulate the distance between
  71640. * @return the distance between the two vectors squared
  71641. */
  71642. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71643. /**
  71644. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71645. * @param value1 value to calulate the center between
  71646. * @param value2 value to calulate the center between
  71647. * @return the center between the two vectors
  71648. */
  71649. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71650. /**
  71651. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71652. * This methods computes transformed normalized direction vectors only.
  71653. * @param vector the vector to transform
  71654. * @param transformation the transformation matrix to apply
  71655. * @returns the new vector
  71656. */
  71657. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71658. /**
  71659. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71660. * This methods computes transformed normalized direction vectors only.
  71661. * @param vector the vector to transform
  71662. * @param transformation the transformation matrix to apply
  71663. * @param result the vector to store the result in
  71664. */
  71665. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71666. /**
  71667. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71668. * This methods computes transformed normalized direction vectors only.
  71669. * @param x value to transform
  71670. * @param y value to transform
  71671. * @param z value to transform
  71672. * @param w value to transform
  71673. * @param transformation the transformation matrix to apply
  71674. * @param result the vector to store the results in
  71675. */
  71676. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71677. /**
  71678. * Creates a new Vector4 from a Vector3
  71679. * @param source defines the source data
  71680. * @param w defines the 4th component (default is 0)
  71681. * @returns a new Vector4
  71682. */
  71683. static FromVector3(source: Vector3, w?: number): Vector4;
  71684. }
  71685. /**
  71686. * Class used to store quaternion data
  71687. * @see https://en.wikipedia.org/wiki/Quaternion
  71688. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71689. */
  71690. export class Quaternion {
  71691. /** defines the first component (0 by default) */
  71692. x: number;
  71693. /** defines the second component (0 by default) */
  71694. y: number;
  71695. /** defines the third component (0 by default) */
  71696. z: number;
  71697. /** defines the fourth component (1.0 by default) */
  71698. w: number;
  71699. /**
  71700. * Creates a new Quaternion from the given floats
  71701. * @param x defines the first component (0 by default)
  71702. * @param y defines the second component (0 by default)
  71703. * @param z defines the third component (0 by default)
  71704. * @param w defines the fourth component (1.0 by default)
  71705. */
  71706. constructor(
  71707. /** defines the first component (0 by default) */
  71708. x?: number,
  71709. /** defines the second component (0 by default) */
  71710. y?: number,
  71711. /** defines the third component (0 by default) */
  71712. z?: number,
  71713. /** defines the fourth component (1.0 by default) */
  71714. w?: number);
  71715. /**
  71716. * Gets a string representation for the current quaternion
  71717. * @returns a string with the Quaternion coordinates
  71718. */
  71719. toString(): string;
  71720. /**
  71721. * Gets the class name of the quaternion
  71722. * @returns the string "Quaternion"
  71723. */
  71724. getClassName(): string;
  71725. /**
  71726. * Gets a hash code for this quaternion
  71727. * @returns the quaternion hash code
  71728. */
  71729. getHashCode(): number;
  71730. /**
  71731. * Copy the quaternion to an array
  71732. * @returns a new array populated with 4 elements from the quaternion coordinates
  71733. */
  71734. asArray(): number[];
  71735. /**
  71736. * Check if two quaternions are equals
  71737. * @param otherQuaternion defines the second operand
  71738. * @return true if the current quaternion and the given one coordinates are strictly equals
  71739. */
  71740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71741. /**
  71742. * Clone the current quaternion
  71743. * @returns a new quaternion copied from the current one
  71744. */
  71745. clone(): Quaternion;
  71746. /**
  71747. * Copy a quaternion to the current one
  71748. * @param other defines the other quaternion
  71749. * @returns the updated current quaternion
  71750. */
  71751. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71752. /**
  71753. * Updates the current quaternion with the given float coordinates
  71754. * @param x defines the x coordinate
  71755. * @param y defines the y coordinate
  71756. * @param z defines the z coordinate
  71757. * @param w defines the w coordinate
  71758. * @returns the updated current quaternion
  71759. */
  71760. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71761. /**
  71762. * Updates the current quaternion from the given float coordinates
  71763. * @param x defines the x coordinate
  71764. * @param y defines the y coordinate
  71765. * @param z defines the z coordinate
  71766. * @param w defines the w coordinate
  71767. * @returns the updated current quaternion
  71768. */
  71769. set(x: number, y: number, z: number, w: number): Quaternion;
  71770. /**
  71771. * Adds two quaternions
  71772. * @param other defines the second operand
  71773. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71774. */
  71775. add(other: DeepImmutable<Quaternion>): Quaternion;
  71776. /**
  71777. * Add a quaternion to the current one
  71778. * @param other defines the quaternion to add
  71779. * @returns the current quaternion
  71780. */
  71781. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71782. /**
  71783. * Subtract two quaternions
  71784. * @param other defines the second operand
  71785. * @returns a new quaternion as the subtraction result of the given one from the current one
  71786. */
  71787. subtract(other: Quaternion): Quaternion;
  71788. /**
  71789. * Multiplies the current quaternion by a scale factor
  71790. * @param value defines the scale factor
  71791. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71792. */
  71793. scale(value: number): Quaternion;
  71794. /**
  71795. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71796. * @param scale defines the scale factor
  71797. * @param result defines the Quaternion object where to store the result
  71798. * @returns the unmodified current quaternion
  71799. */
  71800. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71801. /**
  71802. * Multiplies in place the current quaternion by a scale factor
  71803. * @param value defines the scale factor
  71804. * @returns the current modified quaternion
  71805. */
  71806. scaleInPlace(value: number): Quaternion;
  71807. /**
  71808. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71809. * @param scale defines the scale factor
  71810. * @param result defines the Quaternion object where to store the result
  71811. * @returns the unmodified current quaternion
  71812. */
  71813. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71814. /**
  71815. * Multiplies two quaternions
  71816. * @param q1 defines the second operand
  71817. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71818. */
  71819. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71820. /**
  71821. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71822. * @param q1 defines the second operand
  71823. * @param result defines the target quaternion
  71824. * @returns the current quaternion
  71825. */
  71826. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71827. /**
  71828. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71829. * @param q1 defines the second operand
  71830. * @returns the currentupdated quaternion
  71831. */
  71832. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71833. /**
  71834. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71835. * @param ref defines the target quaternion
  71836. * @returns the current quaternion
  71837. */
  71838. conjugateToRef(ref: Quaternion): Quaternion;
  71839. /**
  71840. * Conjugates in place (1-q) the current quaternion
  71841. * @returns the current updated quaternion
  71842. */
  71843. conjugateInPlace(): Quaternion;
  71844. /**
  71845. * Conjugates in place (1-q) the current quaternion
  71846. * @returns a new quaternion
  71847. */
  71848. conjugate(): Quaternion;
  71849. /**
  71850. * Gets length of current quaternion
  71851. * @returns the quaternion length (float)
  71852. */
  71853. length(): number;
  71854. /**
  71855. * Normalize in place the current quaternion
  71856. * @returns the current updated quaternion
  71857. */
  71858. normalize(): Quaternion;
  71859. /**
  71860. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71861. * @param order is a reserved parameter and is ignore for now
  71862. * @returns a new Vector3 containing the Euler angles
  71863. */
  71864. toEulerAngles(order?: string): Vector3;
  71865. /**
  71866. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71867. * @param result defines the vector which will be filled with the Euler angles
  71868. * @param order is a reserved parameter and is ignore for now
  71869. * @returns the current unchanged quaternion
  71870. */
  71871. toEulerAnglesToRef(result: Vector3): Quaternion;
  71872. /**
  71873. * Updates the given rotation matrix with the current quaternion values
  71874. * @param result defines the target matrix
  71875. * @returns the current unchanged quaternion
  71876. */
  71877. toRotationMatrix(result: Matrix): Quaternion;
  71878. /**
  71879. * Updates the current quaternion from the given rotation matrix values
  71880. * @param matrix defines the source matrix
  71881. * @returns the current updated quaternion
  71882. */
  71883. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71884. /**
  71885. * Creates a new quaternion from a rotation matrix
  71886. * @param matrix defines the source matrix
  71887. * @returns a new quaternion created from the given rotation matrix values
  71888. */
  71889. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71890. /**
  71891. * Updates the given quaternion with the given rotation matrix values
  71892. * @param matrix defines the source matrix
  71893. * @param result defines the target quaternion
  71894. */
  71895. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71896. /**
  71897. * Returns the dot product (float) between the quaternions "left" and "right"
  71898. * @param left defines the left operand
  71899. * @param right defines the right operand
  71900. * @returns the dot product
  71901. */
  71902. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71903. /**
  71904. * Checks if the two quaternions are close to each other
  71905. * @param quat0 defines the first quaternion to check
  71906. * @param quat1 defines the second quaternion to check
  71907. * @returns true if the two quaternions are close to each other
  71908. */
  71909. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71910. /**
  71911. * Creates an empty quaternion
  71912. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71913. */
  71914. static Zero(): Quaternion;
  71915. /**
  71916. * Inverse a given quaternion
  71917. * @param q defines the source quaternion
  71918. * @returns a new quaternion as the inverted current quaternion
  71919. */
  71920. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71921. /**
  71922. * Inverse a given quaternion
  71923. * @param q defines the source quaternion
  71924. * @param result the quaternion the result will be stored in
  71925. * @returns the result quaternion
  71926. */
  71927. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71928. /**
  71929. * Creates an identity quaternion
  71930. * @returns the identity quaternion
  71931. */
  71932. static Identity(): Quaternion;
  71933. /**
  71934. * Gets a boolean indicating if the given quaternion is identity
  71935. * @param quaternion defines the quaternion to check
  71936. * @returns true if the quaternion is identity
  71937. */
  71938. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71939. /**
  71940. * Creates a quaternion from a rotation around an axis
  71941. * @param axis defines the axis to use
  71942. * @param angle defines the angle to use
  71943. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71944. */
  71945. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71946. /**
  71947. * Creates a rotation around an axis and stores it into the given quaternion
  71948. * @param axis defines the axis to use
  71949. * @param angle defines the angle to use
  71950. * @param result defines the target quaternion
  71951. * @returns the target quaternion
  71952. */
  71953. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71954. /**
  71955. * Creates a new quaternion from data stored into an array
  71956. * @param array defines the data source
  71957. * @param offset defines the offset in the source array where the data starts
  71958. * @returns a new quaternion
  71959. */
  71960. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71961. /**
  71962. * Create a quaternion from Euler rotation angles
  71963. * @param x Pitch
  71964. * @param y Yaw
  71965. * @param z Roll
  71966. * @returns the new Quaternion
  71967. */
  71968. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71969. /**
  71970. * Updates a quaternion from Euler rotation angles
  71971. * @param x Pitch
  71972. * @param y Yaw
  71973. * @param z Roll
  71974. * @param result the quaternion to store the result
  71975. * @returns the updated quaternion
  71976. */
  71977. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71978. /**
  71979. * Create a quaternion from Euler rotation vector
  71980. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71981. * @returns the new Quaternion
  71982. */
  71983. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71984. /**
  71985. * Updates a quaternion from Euler rotation vector
  71986. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71987. * @param result the quaternion to store the result
  71988. * @returns the updated quaternion
  71989. */
  71990. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71991. /**
  71992. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71993. * @param yaw defines the rotation around Y axis
  71994. * @param pitch defines the rotation around X axis
  71995. * @param roll defines the rotation around Z axis
  71996. * @returns the new quaternion
  71997. */
  71998. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71999. /**
  72000. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72001. * @param yaw defines the rotation around Y axis
  72002. * @param pitch defines the rotation around X axis
  72003. * @param roll defines the rotation around Z axis
  72004. * @param result defines the target quaternion
  72005. */
  72006. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72007. /**
  72008. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72009. * @param alpha defines the rotation around first axis
  72010. * @param beta defines the rotation around second axis
  72011. * @param gamma defines the rotation around third axis
  72012. * @returns the new quaternion
  72013. */
  72014. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72015. /**
  72016. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72017. * @param alpha defines the rotation around first axis
  72018. * @param beta defines the rotation around second axis
  72019. * @param gamma defines the rotation around third axis
  72020. * @param result defines the target quaternion
  72021. */
  72022. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72023. /**
  72024. * 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)
  72025. * @param axis1 defines the first axis
  72026. * @param axis2 defines the second axis
  72027. * @param axis3 defines the third axis
  72028. * @returns the new quaternion
  72029. */
  72030. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72031. /**
  72032. * 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
  72033. * @param axis1 defines the first axis
  72034. * @param axis2 defines the second axis
  72035. * @param axis3 defines the third axis
  72036. * @param ref defines the target quaternion
  72037. */
  72038. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72039. /**
  72040. * Interpolates between two quaternions
  72041. * @param left defines first quaternion
  72042. * @param right defines second quaternion
  72043. * @param amount defines the gradient to use
  72044. * @returns the new interpolated quaternion
  72045. */
  72046. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72047. /**
  72048. * Interpolates between two quaternions and stores it into a target quaternion
  72049. * @param left defines first quaternion
  72050. * @param right defines second quaternion
  72051. * @param amount defines the gradient to use
  72052. * @param result defines the target quaternion
  72053. */
  72054. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72055. /**
  72056. * Interpolate between two quaternions using Hermite interpolation
  72057. * @param value1 defines first quaternion
  72058. * @param tangent1 defines the incoming tangent
  72059. * @param value2 defines second quaternion
  72060. * @param tangent2 defines the outgoing tangent
  72061. * @param amount defines the target quaternion
  72062. * @returns the new interpolated quaternion
  72063. */
  72064. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72065. }
  72066. /**
  72067. * Class used to store matrix data (4x4)
  72068. */
  72069. export class Matrix {
  72070. private static _updateFlagSeed;
  72071. private static _identityReadOnly;
  72072. private _isIdentity;
  72073. private _isIdentityDirty;
  72074. private _isIdentity3x2;
  72075. private _isIdentity3x2Dirty;
  72076. /**
  72077. * Gets the update flag of the matrix which is an unique number for the matrix.
  72078. * It will be incremented every time the matrix data change.
  72079. * You can use it to speed the comparison between two versions of the same matrix.
  72080. */
  72081. updateFlag: number;
  72082. private readonly _m;
  72083. /**
  72084. * Gets the internal data of the matrix
  72085. */
  72086. readonly m: DeepImmutable<Float32Array>;
  72087. /** @hidden */
  72088. _markAsUpdated(): void;
  72089. /** @hidden */
  72090. private _updateIdentityStatus;
  72091. /**
  72092. * Creates an empty matrix (filled with zeros)
  72093. */
  72094. constructor();
  72095. /**
  72096. * Check if the current matrix is identity
  72097. * @returns true is the matrix is the identity matrix
  72098. */
  72099. isIdentity(): boolean;
  72100. /**
  72101. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72102. * @returns true is the matrix is the identity matrix
  72103. */
  72104. isIdentityAs3x2(): boolean;
  72105. /**
  72106. * Gets the determinant of the matrix
  72107. * @returns the matrix determinant
  72108. */
  72109. determinant(): number;
  72110. /**
  72111. * Returns the matrix as a Float32Array
  72112. * @returns the matrix underlying array
  72113. */
  72114. toArray(): DeepImmutable<Float32Array>;
  72115. /**
  72116. * Returns the matrix as a Float32Array
  72117. * @returns the matrix underlying array.
  72118. */
  72119. asArray(): DeepImmutable<Float32Array>;
  72120. /**
  72121. * Inverts the current matrix in place
  72122. * @returns the current inverted matrix
  72123. */
  72124. invert(): Matrix;
  72125. /**
  72126. * Sets all the matrix elements to zero
  72127. * @returns the current matrix
  72128. */
  72129. reset(): Matrix;
  72130. /**
  72131. * Adds the current matrix with a second one
  72132. * @param other defines the matrix to add
  72133. * @returns a new matrix as the addition of the current matrix and the given one
  72134. */
  72135. add(other: DeepImmutable<Matrix>): Matrix;
  72136. /**
  72137. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72138. * @param other defines the matrix to add
  72139. * @param result defines the target matrix
  72140. * @returns the current matrix
  72141. */
  72142. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72143. /**
  72144. * Adds in place the given matrix to the current matrix
  72145. * @param other defines the second operand
  72146. * @returns the current updated matrix
  72147. */
  72148. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72149. /**
  72150. * Sets the given matrix to the current inverted Matrix
  72151. * @param other defines the target matrix
  72152. * @returns the unmodified current matrix
  72153. */
  72154. invertToRef(other: Matrix): Matrix;
  72155. /**
  72156. * add a value at the specified position in the current Matrix
  72157. * @param index the index of the value within the matrix. between 0 and 15.
  72158. * @param value the value to be added
  72159. * @returns the current updated matrix
  72160. */
  72161. addAtIndex(index: number, value: number): Matrix;
  72162. /**
  72163. * mutiply the specified position in the current Matrix by a value
  72164. * @param index the index of the value within the matrix. between 0 and 15.
  72165. * @param value the value to be added
  72166. * @returns the current updated matrix
  72167. */
  72168. multiplyAtIndex(index: number, value: number): Matrix;
  72169. /**
  72170. * Inserts the translation vector (using 3 floats) in the current matrix
  72171. * @param x defines the 1st component of the translation
  72172. * @param y defines the 2nd component of the translation
  72173. * @param z defines the 3rd component of the translation
  72174. * @returns the current updated matrix
  72175. */
  72176. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72177. /**
  72178. * Adds the translation vector (using 3 floats) in the current matrix
  72179. * @param x defines the 1st component of the translation
  72180. * @param y defines the 2nd component of the translation
  72181. * @param z defines the 3rd component of the translation
  72182. * @returns the current updated matrix
  72183. */
  72184. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72185. /**
  72186. * Inserts the translation vector in the current matrix
  72187. * @param vector3 defines the translation to insert
  72188. * @returns the current updated matrix
  72189. */
  72190. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72191. /**
  72192. * Gets the translation value of the current matrix
  72193. * @returns a new Vector3 as the extracted translation from the matrix
  72194. */
  72195. getTranslation(): Vector3;
  72196. /**
  72197. * Fill a Vector3 with the extracted translation from the matrix
  72198. * @param result defines the Vector3 where to store the translation
  72199. * @returns the current matrix
  72200. */
  72201. getTranslationToRef(result: Vector3): Matrix;
  72202. /**
  72203. * Remove rotation and scaling part from the matrix
  72204. * @returns the updated matrix
  72205. */
  72206. removeRotationAndScaling(): Matrix;
  72207. /**
  72208. * Multiply two matrices
  72209. * @param other defines the second operand
  72210. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72211. */
  72212. multiply(other: DeepImmutable<Matrix>): Matrix;
  72213. /**
  72214. * Copy the current matrix from the given one
  72215. * @param other defines the source matrix
  72216. * @returns the current updated matrix
  72217. */
  72218. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72219. /**
  72220. * Populates the given array from the starting index with the current matrix values
  72221. * @param array defines the target array
  72222. * @param offset defines the offset in the target array where to start storing values
  72223. * @returns the current matrix
  72224. */
  72225. copyToArray(array: Float32Array, offset?: number): Matrix;
  72226. /**
  72227. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72228. * @param other defines the second operand
  72229. * @param result defines the matrix where to store the multiplication
  72230. * @returns the current matrix
  72231. */
  72232. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72233. /**
  72234. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72235. * @param other defines the second operand
  72236. * @param result defines the array where to store the multiplication
  72237. * @param offset defines the offset in the target array where to start storing values
  72238. * @returns the current matrix
  72239. */
  72240. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72241. /**
  72242. * Check equality between this matrix and a second one
  72243. * @param value defines the second matrix to compare
  72244. * @returns true is the current matrix and the given one values are strictly equal
  72245. */
  72246. equals(value: DeepImmutable<Matrix>): boolean;
  72247. /**
  72248. * Clone the current matrix
  72249. * @returns a new matrix from the current matrix
  72250. */
  72251. clone(): Matrix;
  72252. /**
  72253. * Returns the name of the current matrix class
  72254. * @returns the string "Matrix"
  72255. */
  72256. getClassName(): string;
  72257. /**
  72258. * Gets the hash code of the current matrix
  72259. * @returns the hash code
  72260. */
  72261. getHashCode(): number;
  72262. /**
  72263. * Decomposes the current Matrix into a translation, rotation and scaling components
  72264. * @param scale defines the scale vector3 given as a reference to update
  72265. * @param rotation defines the rotation quaternion given as a reference to update
  72266. * @param translation defines the translation vector3 given as a reference to update
  72267. * @returns true if operation was successful
  72268. */
  72269. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72270. /**
  72271. * Gets specific row of the matrix
  72272. * @param index defines the number of the row to get
  72273. * @returns the index-th row of the current matrix as a new Vector4
  72274. */
  72275. getRow(index: number): Nullable<Vector4>;
  72276. /**
  72277. * Sets the index-th row of the current matrix to the vector4 values
  72278. * @param index defines the number of the row to set
  72279. * @param row defines the target vector4
  72280. * @returns the updated current matrix
  72281. */
  72282. setRow(index: number, row: Vector4): Matrix;
  72283. /**
  72284. * Compute the transpose of the matrix
  72285. * @returns the new transposed matrix
  72286. */
  72287. transpose(): Matrix;
  72288. /**
  72289. * Compute the transpose of the matrix and store it in a given matrix
  72290. * @param result defines the target matrix
  72291. * @returns the current matrix
  72292. */
  72293. transposeToRef(result: Matrix): Matrix;
  72294. /**
  72295. * Sets the index-th row of the current matrix with the given 4 x float values
  72296. * @param index defines the row index
  72297. * @param x defines the x component to set
  72298. * @param y defines the y component to set
  72299. * @param z defines the z component to set
  72300. * @param w defines the w component to set
  72301. * @returns the updated current matrix
  72302. */
  72303. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72304. /**
  72305. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72306. * @param scale defines the scale factor
  72307. * @returns a new matrix
  72308. */
  72309. scale(scale: number): Matrix;
  72310. /**
  72311. * Scale the current matrix values by a factor to a given result matrix
  72312. * @param scale defines the scale factor
  72313. * @param result defines the matrix to store the result
  72314. * @returns the current matrix
  72315. */
  72316. scaleToRef(scale: number, result: Matrix): Matrix;
  72317. /**
  72318. * Scale the current matrix values by a factor and add the result to a given matrix
  72319. * @param scale defines the scale factor
  72320. * @param result defines the Matrix to store the result
  72321. * @returns the current matrix
  72322. */
  72323. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72324. /**
  72325. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72326. * @param ref matrix to store the result
  72327. */
  72328. toNormalMatrix(ref: Matrix): void;
  72329. /**
  72330. * Gets only rotation part of the current matrix
  72331. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72332. */
  72333. getRotationMatrix(): Matrix;
  72334. /**
  72335. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72336. * @param result defines the target matrix to store data to
  72337. * @returns the current matrix
  72338. */
  72339. getRotationMatrixToRef(result: Matrix): Matrix;
  72340. /**
  72341. * Toggles model matrix from being right handed to left handed in place and vice versa
  72342. */
  72343. toggleModelMatrixHandInPlace(): void;
  72344. /**
  72345. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72346. */
  72347. toggleProjectionMatrixHandInPlace(): void;
  72348. /**
  72349. * Creates a matrix from an array
  72350. * @param array defines the source array
  72351. * @param offset defines an offset in the source array
  72352. * @returns a new Matrix set from the starting index of the given array
  72353. */
  72354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72355. /**
  72356. * Copy the content of an array into a given matrix
  72357. * @param array defines the source array
  72358. * @param offset defines an offset in the source array
  72359. * @param result defines the target matrix
  72360. */
  72361. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72362. /**
  72363. * Stores an array into a matrix after having multiplied each component by a given factor
  72364. * @param array defines the source array
  72365. * @param offset defines the offset in the source array
  72366. * @param scale defines the scaling factor
  72367. * @param result defines the target matrix
  72368. */
  72369. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72370. /**
  72371. * Gets an identity matrix that must not be updated
  72372. */
  72373. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72374. /**
  72375. * Stores a list of values (16) inside a given matrix
  72376. * @param initialM11 defines 1st value of 1st row
  72377. * @param initialM12 defines 2nd value of 1st row
  72378. * @param initialM13 defines 3rd value of 1st row
  72379. * @param initialM14 defines 4th value of 1st row
  72380. * @param initialM21 defines 1st value of 2nd row
  72381. * @param initialM22 defines 2nd value of 2nd row
  72382. * @param initialM23 defines 3rd value of 2nd row
  72383. * @param initialM24 defines 4th value of 2nd row
  72384. * @param initialM31 defines 1st value of 3rd row
  72385. * @param initialM32 defines 2nd value of 3rd row
  72386. * @param initialM33 defines 3rd value of 3rd row
  72387. * @param initialM34 defines 4th value of 3rd row
  72388. * @param initialM41 defines 1st value of 4th row
  72389. * @param initialM42 defines 2nd value of 4th row
  72390. * @param initialM43 defines 3rd value of 4th row
  72391. * @param initialM44 defines 4th value of 4th row
  72392. * @param result defines the target matrix
  72393. */
  72394. 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;
  72395. /**
  72396. * Creates new matrix from a list of values (16)
  72397. * @param initialM11 defines 1st value of 1st row
  72398. * @param initialM12 defines 2nd value of 1st row
  72399. * @param initialM13 defines 3rd value of 1st row
  72400. * @param initialM14 defines 4th value of 1st row
  72401. * @param initialM21 defines 1st value of 2nd row
  72402. * @param initialM22 defines 2nd value of 2nd row
  72403. * @param initialM23 defines 3rd value of 2nd row
  72404. * @param initialM24 defines 4th value of 2nd row
  72405. * @param initialM31 defines 1st value of 3rd row
  72406. * @param initialM32 defines 2nd value of 3rd row
  72407. * @param initialM33 defines 3rd value of 3rd row
  72408. * @param initialM34 defines 4th value of 3rd row
  72409. * @param initialM41 defines 1st value of 4th row
  72410. * @param initialM42 defines 2nd value of 4th row
  72411. * @param initialM43 defines 3rd value of 4th row
  72412. * @param initialM44 defines 4th value of 4th row
  72413. * @returns the new matrix
  72414. */
  72415. 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;
  72416. /**
  72417. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72418. * @param scale defines the scale vector3
  72419. * @param rotation defines the rotation quaternion
  72420. * @param translation defines the translation vector3
  72421. * @returns a new matrix
  72422. */
  72423. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72424. /**
  72425. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72426. * @param scale defines the scale vector3
  72427. * @param rotation defines the rotation quaternion
  72428. * @param translation defines the translation vector3
  72429. * @param result defines the target matrix
  72430. */
  72431. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72432. /**
  72433. * Creates a new identity matrix
  72434. * @returns a new identity matrix
  72435. */
  72436. static Identity(): Matrix;
  72437. /**
  72438. * Creates a new identity matrix and stores the result in a given matrix
  72439. * @param result defines the target matrix
  72440. */
  72441. static IdentityToRef(result: Matrix): void;
  72442. /**
  72443. * Creates a new zero matrix
  72444. * @returns a new zero matrix
  72445. */
  72446. static Zero(): Matrix;
  72447. /**
  72448. * Creates a new rotation matrix for "angle" radians around the X axis
  72449. * @param angle defines the angle (in radians) to use
  72450. * @return the new matrix
  72451. */
  72452. static RotationX(angle: number): Matrix;
  72453. /**
  72454. * Creates a new matrix as the invert of a given matrix
  72455. * @param source defines the source matrix
  72456. * @returns the new matrix
  72457. */
  72458. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72459. /**
  72460. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72461. * @param angle defines the angle (in radians) to use
  72462. * @param result defines the target matrix
  72463. */
  72464. static RotationXToRef(angle: number, result: Matrix): void;
  72465. /**
  72466. * Creates a new rotation matrix for "angle" radians around the Y axis
  72467. * @param angle defines the angle (in radians) to use
  72468. * @return the new matrix
  72469. */
  72470. static RotationY(angle: number): Matrix;
  72471. /**
  72472. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72473. * @param angle defines the angle (in radians) to use
  72474. * @param result defines the target matrix
  72475. */
  72476. static RotationYToRef(angle: number, result: Matrix): void;
  72477. /**
  72478. * Creates a new rotation matrix for "angle" radians around the Z axis
  72479. * @param angle defines the angle (in radians) to use
  72480. * @return the new matrix
  72481. */
  72482. static RotationZ(angle: number): Matrix;
  72483. /**
  72484. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72485. * @param angle defines the angle (in radians) to use
  72486. * @param result defines the target matrix
  72487. */
  72488. static RotationZToRef(angle: number, result: Matrix): void;
  72489. /**
  72490. * Creates a new rotation matrix for "angle" radians around the given axis
  72491. * @param axis defines the axis to use
  72492. * @param angle defines the angle (in radians) to use
  72493. * @return the new matrix
  72494. */
  72495. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72496. /**
  72497. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72498. * @param axis defines the axis to use
  72499. * @param angle defines the angle (in radians) to use
  72500. * @param result defines the target matrix
  72501. */
  72502. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72503. /**
  72504. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72505. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72506. * @param from defines the vector to align
  72507. * @param to defines the vector to align to
  72508. * @param result defines the target matrix
  72509. */
  72510. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72511. /**
  72512. * Creates a rotation matrix
  72513. * @param yaw defines the yaw angle in radians (Y axis)
  72514. * @param pitch defines the pitch angle in radians (X axis)
  72515. * @param roll defines the roll angle in radians (X axis)
  72516. * @returns the new rotation matrix
  72517. */
  72518. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72519. /**
  72520. * Creates a rotation matrix and stores it in a given matrix
  72521. * @param yaw defines the yaw angle in radians (Y axis)
  72522. * @param pitch defines the pitch angle in radians (X axis)
  72523. * @param roll defines the roll angle in radians (X axis)
  72524. * @param result defines the target matrix
  72525. */
  72526. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72527. /**
  72528. * Creates a scaling matrix
  72529. * @param x defines the scale factor on X axis
  72530. * @param y defines the scale factor on Y axis
  72531. * @param z defines the scale factor on Z axis
  72532. * @returns the new matrix
  72533. */
  72534. static Scaling(x: number, y: number, z: number): Matrix;
  72535. /**
  72536. * Creates a scaling matrix and stores it in a given matrix
  72537. * @param x defines the scale factor on X axis
  72538. * @param y defines the scale factor on Y axis
  72539. * @param z defines the scale factor on Z axis
  72540. * @param result defines the target matrix
  72541. */
  72542. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72543. /**
  72544. * Creates a translation matrix
  72545. * @param x defines the translation on X axis
  72546. * @param y defines the translation on Y axis
  72547. * @param z defines the translationon Z axis
  72548. * @returns the new matrix
  72549. */
  72550. static Translation(x: number, y: number, z: number): Matrix;
  72551. /**
  72552. * Creates a translation matrix and stores it in a given matrix
  72553. * @param x defines the translation on X axis
  72554. * @param y defines the translation on Y axis
  72555. * @param z defines the translationon Z axis
  72556. * @param result defines the target matrix
  72557. */
  72558. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72559. /**
  72560. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72561. * @param startValue defines the start value
  72562. * @param endValue defines the end value
  72563. * @param gradient defines the gradient factor
  72564. * @returns the new matrix
  72565. */
  72566. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72567. /**
  72568. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72569. * @param startValue defines the start value
  72570. * @param endValue defines the end value
  72571. * @param gradient defines the gradient factor
  72572. * @param result defines the Matrix object where to store data
  72573. */
  72574. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72575. /**
  72576. * Builds a new matrix whose values are computed by:
  72577. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72578. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72579. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72580. * @param startValue defines the first matrix
  72581. * @param endValue defines the second matrix
  72582. * @param gradient defines the gradient between the two matrices
  72583. * @returns the new matrix
  72584. */
  72585. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72586. /**
  72587. * Update a matrix to values which are computed by:
  72588. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72589. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72590. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72591. * @param startValue defines the first matrix
  72592. * @param endValue defines the second matrix
  72593. * @param gradient defines the gradient between the two matrices
  72594. * @param result defines the target matrix
  72595. */
  72596. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72597. /**
  72598. * 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"
  72599. * This function works in left handed mode
  72600. * @param eye defines the final position of the entity
  72601. * @param target defines where the entity should look at
  72602. * @param up defines the up vector for the entity
  72603. * @returns the new matrix
  72604. */
  72605. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72606. /**
  72607. * 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".
  72608. * This function works in left handed mode
  72609. * @param eye defines the final position of the entity
  72610. * @param target defines where the entity should look at
  72611. * @param up defines the up vector for the entity
  72612. * @param result defines the target matrix
  72613. */
  72614. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72615. /**
  72616. * 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"
  72617. * This function works in right handed mode
  72618. * @param eye defines the final position of the entity
  72619. * @param target defines where the entity should look at
  72620. * @param up defines the up vector for the entity
  72621. * @returns the new matrix
  72622. */
  72623. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72624. /**
  72625. * 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".
  72626. * This function works in right handed mode
  72627. * @param eye defines the final position of the entity
  72628. * @param target defines where the entity should look at
  72629. * @param up defines the up vector for the entity
  72630. * @param result defines the target matrix
  72631. */
  72632. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72633. /**
  72634. * Create a left-handed orthographic projection matrix
  72635. * @param width defines the viewport width
  72636. * @param height defines the viewport height
  72637. * @param znear defines the near clip plane
  72638. * @param zfar defines the far clip plane
  72639. * @returns a new matrix as a left-handed orthographic projection matrix
  72640. */
  72641. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72642. /**
  72643. * Store a left-handed orthographic projection to a given matrix
  72644. * @param width defines the viewport width
  72645. * @param height defines the viewport height
  72646. * @param znear defines the near clip plane
  72647. * @param zfar defines the far clip plane
  72648. * @param result defines the target matrix
  72649. */
  72650. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72651. /**
  72652. * Create a left-handed orthographic projection matrix
  72653. * @param left defines the viewport left coordinate
  72654. * @param right defines the viewport right coordinate
  72655. * @param bottom defines the viewport bottom coordinate
  72656. * @param top defines the viewport top coordinate
  72657. * @param znear defines the near clip plane
  72658. * @param zfar defines the far clip plane
  72659. * @returns a new matrix as a left-handed orthographic projection matrix
  72660. */
  72661. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72662. /**
  72663. * Stores a left-handed orthographic projection into a given matrix
  72664. * @param left defines the viewport left coordinate
  72665. * @param right defines the viewport right coordinate
  72666. * @param bottom defines the viewport bottom coordinate
  72667. * @param top defines the viewport top coordinate
  72668. * @param znear defines the near clip plane
  72669. * @param zfar defines the far clip plane
  72670. * @param result defines the target matrix
  72671. */
  72672. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72673. /**
  72674. * Creates a right-handed orthographic projection matrix
  72675. * @param left defines the viewport left coordinate
  72676. * @param right defines the viewport right coordinate
  72677. * @param bottom defines the viewport bottom coordinate
  72678. * @param top defines the viewport top coordinate
  72679. * @param znear defines the near clip plane
  72680. * @param zfar defines the far clip plane
  72681. * @returns a new matrix as a right-handed orthographic projection matrix
  72682. */
  72683. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72684. /**
  72685. * Stores a right-handed orthographic projection into a given matrix
  72686. * @param left defines the viewport left coordinate
  72687. * @param right defines the viewport right coordinate
  72688. * @param bottom defines the viewport bottom coordinate
  72689. * @param top defines the viewport top coordinate
  72690. * @param znear defines the near clip plane
  72691. * @param zfar defines the far clip plane
  72692. * @param result defines the target matrix
  72693. */
  72694. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72695. /**
  72696. * Creates a left-handed perspective projection matrix
  72697. * @param width defines the viewport width
  72698. * @param height defines the viewport height
  72699. * @param znear defines the near clip plane
  72700. * @param zfar defines the far clip plane
  72701. * @returns a new matrix as a left-handed perspective projection matrix
  72702. */
  72703. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72704. /**
  72705. * Creates a left-handed perspective projection matrix
  72706. * @param fov defines the horizontal field of view
  72707. * @param aspect defines the aspect ratio
  72708. * @param znear defines the near clip plane
  72709. * @param zfar defines the far clip plane
  72710. * @returns a new matrix as a left-handed perspective projection matrix
  72711. */
  72712. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72713. /**
  72714. * Stores a left-handed perspective projection into a given matrix
  72715. * @param fov defines the horizontal field of view
  72716. * @param aspect defines the aspect ratio
  72717. * @param znear defines the near clip plane
  72718. * @param zfar defines the far clip plane
  72719. * @param result defines the target matrix
  72720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72721. */
  72722. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72723. /**
  72724. * Creates a right-handed perspective projection matrix
  72725. * @param fov defines the horizontal field of view
  72726. * @param aspect defines the aspect ratio
  72727. * @param znear defines the near clip plane
  72728. * @param zfar defines the far clip plane
  72729. * @returns a new matrix as a right-handed perspective projection matrix
  72730. */
  72731. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72732. /**
  72733. * Stores a right-handed perspective projection into a given matrix
  72734. * @param fov defines the horizontal field of view
  72735. * @param aspect defines the aspect ratio
  72736. * @param znear defines the near clip plane
  72737. * @param zfar defines the far clip plane
  72738. * @param result defines the target matrix
  72739. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72740. */
  72741. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72742. /**
  72743. * Stores a perspective projection for WebVR info a given matrix
  72744. * @param fov defines the field of view
  72745. * @param znear defines the near clip plane
  72746. * @param zfar defines the far clip plane
  72747. * @param result defines the target matrix
  72748. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72749. */
  72750. static PerspectiveFovWebVRToRef(fov: {
  72751. upDegrees: number;
  72752. downDegrees: number;
  72753. leftDegrees: number;
  72754. rightDegrees: number;
  72755. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72756. /**
  72757. * Computes a complete transformation matrix
  72758. * @param viewport defines the viewport to use
  72759. * @param world defines the world matrix
  72760. * @param view defines the view matrix
  72761. * @param projection defines the projection matrix
  72762. * @param zmin defines the near clip plane
  72763. * @param zmax defines the far clip plane
  72764. * @returns the transformation matrix
  72765. */
  72766. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72767. /**
  72768. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72769. * @param matrix defines the matrix to use
  72770. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72771. */
  72772. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72773. /**
  72774. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72775. * @param matrix defines the matrix to use
  72776. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72777. */
  72778. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72779. /**
  72780. * Compute the transpose of a given matrix
  72781. * @param matrix defines the matrix to transpose
  72782. * @returns the new matrix
  72783. */
  72784. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72785. /**
  72786. * Compute the transpose of a matrix and store it in a target matrix
  72787. * @param matrix defines the matrix to transpose
  72788. * @param result defines the target matrix
  72789. */
  72790. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72791. /**
  72792. * Computes a reflection matrix from a plane
  72793. * @param plane defines the reflection plane
  72794. * @returns a new matrix
  72795. */
  72796. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72797. /**
  72798. * Computes a reflection matrix from a plane
  72799. * @param plane defines the reflection plane
  72800. * @param result defines the target matrix
  72801. */
  72802. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72803. /**
  72804. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72805. * @param xaxis defines the value of the 1st axis
  72806. * @param yaxis defines the value of the 2nd axis
  72807. * @param zaxis defines the value of the 3rd axis
  72808. * @param result defines the target matrix
  72809. */
  72810. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72811. /**
  72812. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72813. * @param quat defines the quaternion to use
  72814. * @param result defines the target matrix
  72815. */
  72816. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72817. }
  72818. /**
  72819. * @hidden
  72820. */
  72821. export class TmpVectors {
  72822. static Vector2: Vector2[];
  72823. static Vector3: Vector3[];
  72824. static Vector4: Vector4[];
  72825. static Quaternion: Quaternion[];
  72826. static Matrix: Matrix[];
  72827. }
  72828. }
  72829. declare module BABYLON {
  72830. /**
  72831. * Defines potential orientation for back face culling
  72832. */
  72833. export enum Orientation {
  72834. /**
  72835. * Clockwise
  72836. */
  72837. CW = 0,
  72838. /** Counter clockwise */
  72839. CCW = 1
  72840. }
  72841. /** Class used to represent a Bezier curve */
  72842. export class BezierCurve {
  72843. /**
  72844. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72845. * @param t defines the time
  72846. * @param x1 defines the left coordinate on X axis
  72847. * @param y1 defines the left coordinate on Y axis
  72848. * @param x2 defines the right coordinate on X axis
  72849. * @param y2 defines the right coordinate on Y axis
  72850. * @returns the interpolated value
  72851. */
  72852. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72853. }
  72854. /**
  72855. * Defines angle representation
  72856. */
  72857. export class Angle {
  72858. private _radians;
  72859. /**
  72860. * Creates an Angle object of "radians" radians (float).
  72861. * @param radians the angle in radians
  72862. */
  72863. constructor(radians: number);
  72864. /**
  72865. * Get value in degrees
  72866. * @returns the Angle value in degrees (float)
  72867. */
  72868. degrees(): number;
  72869. /**
  72870. * Get value in radians
  72871. * @returns the Angle value in radians (float)
  72872. */
  72873. radians(): number;
  72874. /**
  72875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72876. * @param a defines first vector
  72877. * @param b defines second vector
  72878. * @returns a new Angle
  72879. */
  72880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72881. /**
  72882. * Gets a new Angle object from the given float in radians
  72883. * @param radians defines the angle value in radians
  72884. * @returns a new Angle
  72885. */
  72886. static FromRadians(radians: number): Angle;
  72887. /**
  72888. * Gets a new Angle object from the given float in degrees
  72889. * @param degrees defines the angle value in degrees
  72890. * @returns a new Angle
  72891. */
  72892. static FromDegrees(degrees: number): Angle;
  72893. }
  72894. /**
  72895. * This represents an arc in a 2d space.
  72896. */
  72897. export class Arc2 {
  72898. /** Defines the start point of the arc */
  72899. startPoint: Vector2;
  72900. /** Defines the mid point of the arc */
  72901. midPoint: Vector2;
  72902. /** Defines the end point of the arc */
  72903. endPoint: Vector2;
  72904. /**
  72905. * Defines the center point of the arc.
  72906. */
  72907. centerPoint: Vector2;
  72908. /**
  72909. * Defines the radius of the arc.
  72910. */
  72911. radius: number;
  72912. /**
  72913. * Defines the angle of the arc (from mid point to end point).
  72914. */
  72915. angle: Angle;
  72916. /**
  72917. * Defines the start angle of the arc (from start point to middle point).
  72918. */
  72919. startAngle: Angle;
  72920. /**
  72921. * Defines the orientation of the arc (clock wise/counter clock wise).
  72922. */
  72923. orientation: Orientation;
  72924. /**
  72925. * Creates an Arc object from the three given points : start, middle and end.
  72926. * @param startPoint Defines the start point of the arc
  72927. * @param midPoint Defines the midlle point of the arc
  72928. * @param endPoint Defines the end point of the arc
  72929. */
  72930. constructor(
  72931. /** Defines the start point of the arc */
  72932. startPoint: Vector2,
  72933. /** Defines the mid point of the arc */
  72934. midPoint: Vector2,
  72935. /** Defines the end point of the arc */
  72936. endPoint: Vector2);
  72937. }
  72938. /**
  72939. * Represents a 2D path made up of multiple 2D points
  72940. */
  72941. export class Path2 {
  72942. private _points;
  72943. private _length;
  72944. /**
  72945. * If the path start and end point are the same
  72946. */
  72947. closed: boolean;
  72948. /**
  72949. * Creates a Path2 object from the starting 2D coordinates x and y.
  72950. * @param x the starting points x value
  72951. * @param y the starting points y value
  72952. */
  72953. constructor(x: number, y: number);
  72954. /**
  72955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72956. * @param x the added points x value
  72957. * @param y the added points y value
  72958. * @returns the updated Path2.
  72959. */
  72960. addLineTo(x: number, y: number): Path2;
  72961. /**
  72962. * 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.
  72963. * @param midX middle point x value
  72964. * @param midY middle point y value
  72965. * @param endX end point x value
  72966. * @param endY end point y value
  72967. * @param numberOfSegments (default: 36)
  72968. * @returns the updated Path2.
  72969. */
  72970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72971. /**
  72972. * Closes the Path2.
  72973. * @returns the Path2.
  72974. */
  72975. close(): Path2;
  72976. /**
  72977. * Gets the sum of the distance between each sequential point in the path
  72978. * @returns the Path2 total length (float).
  72979. */
  72980. length(): number;
  72981. /**
  72982. * Gets the points which construct the path
  72983. * @returns the Path2 internal array of points.
  72984. */
  72985. getPoints(): Vector2[];
  72986. /**
  72987. * Retreives the point at the distance aways from the starting point
  72988. * @param normalizedLengthPosition the length along the path to retreive the point from
  72989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72990. */
  72991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72992. /**
  72993. * Creates a new path starting from an x and y position
  72994. * @param x starting x value
  72995. * @param y starting y value
  72996. * @returns a new Path2 starting at the coordinates (x, y).
  72997. */
  72998. static StartingAt(x: number, y: number): Path2;
  72999. }
  73000. /**
  73001. * Represents a 3D path made up of multiple 3D points
  73002. */
  73003. export class Path3D {
  73004. /**
  73005. * an array of Vector3, the curve axis of the Path3D
  73006. */
  73007. path: Vector3[];
  73008. private _curve;
  73009. private _distances;
  73010. private _tangents;
  73011. private _normals;
  73012. private _binormals;
  73013. private _raw;
  73014. private _alignTangentsWithPath;
  73015. private readonly _pointAtData;
  73016. /**
  73017. * new Path3D(path, normal, raw)
  73018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73020. * @param path an array of Vector3, the curve axis of the Path3D
  73021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73023. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73024. */
  73025. constructor(
  73026. /**
  73027. * an array of Vector3, the curve axis of the Path3D
  73028. */
  73029. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73030. /**
  73031. * Returns the Path3D array of successive Vector3 designing its curve.
  73032. * @returns the Path3D array of successive Vector3 designing its curve.
  73033. */
  73034. getCurve(): Vector3[];
  73035. /**
  73036. * Returns the Path3D array of successive Vector3 designing its curve.
  73037. * @returns the Path3D array of successive Vector3 designing its curve.
  73038. */
  73039. getPoints(): Vector3[];
  73040. /**
  73041. * @returns the computed length (float) of the path.
  73042. */
  73043. length(): number;
  73044. /**
  73045. * Returns an array populated with tangent vectors on each Path3D curve point.
  73046. * @returns an array populated with tangent vectors on each Path3D curve point.
  73047. */
  73048. getTangents(): Vector3[];
  73049. /**
  73050. * Returns an array populated with normal vectors on each Path3D curve point.
  73051. * @returns an array populated with normal vectors on each Path3D curve point.
  73052. */
  73053. getNormals(): Vector3[];
  73054. /**
  73055. * Returns an array populated with binormal vectors on each Path3D curve point.
  73056. * @returns an array populated with binormal vectors on each Path3D curve point.
  73057. */
  73058. getBinormals(): Vector3[];
  73059. /**
  73060. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73061. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73062. */
  73063. getDistances(): number[];
  73064. /**
  73065. * Returns an interpolated point along this path
  73066. * @param position the position of the point along this path, from 0.0 to 1.0
  73067. * @returns a new Vector3 as the point
  73068. */
  73069. getPointAt(position: number): Vector3;
  73070. /**
  73071. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73072. * @param position the position of the point along this path, from 0.0 to 1.0
  73073. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73074. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73075. */
  73076. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73077. /**
  73078. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73079. * @param position the position of the point along this path, from 0.0 to 1.0
  73080. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73081. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73082. */
  73083. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73084. /**
  73085. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73086. * @param position the position of the point along this path, from 0.0 to 1.0
  73087. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73088. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73089. */
  73090. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73091. /**
  73092. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73093. * @param position the position of the point along this path, from 0.0 to 1.0
  73094. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73095. */
  73096. getDistanceAt(position: number): number;
  73097. /**
  73098. * Returns the array index of the previous point of an interpolated point along this path
  73099. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73100. * @returns the array index
  73101. */
  73102. getPreviousPointIndexAt(position: number): number;
  73103. /**
  73104. * 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)
  73105. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73106. * @returns the sub position
  73107. */
  73108. getSubPositionAt(position: number): number;
  73109. /**
  73110. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73111. * @param target the vector of which to get the closest position to
  73112. * @returns the position of the closest virtual point on this path to the target vector
  73113. */
  73114. getClosestPositionTo(target: Vector3): number;
  73115. /**
  73116. * Returns a sub path (slice) of this path
  73117. * @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
  73118. * @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
  73119. * @returns a sub path (slice) of this path
  73120. */
  73121. slice(start?: number, end?: number): Path3D;
  73122. /**
  73123. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73124. * @param path path which all values are copied into the curves points
  73125. * @param firstNormal which should be projected onto the curve
  73126. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73127. * @returns the same object updated.
  73128. */
  73129. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73130. private _compute;
  73131. private _getFirstNonNullVector;
  73132. private _getLastNonNullVector;
  73133. private _normalVector;
  73134. /**
  73135. * Updates the point at data for an interpolated point along this curve
  73136. * @param position the position of the point along this curve, from 0.0 to 1.0
  73137. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73138. * @returns the (updated) point at data
  73139. */
  73140. private _updatePointAtData;
  73141. /**
  73142. * Updates the point at data from the specified parameters
  73143. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73144. * @param point the interpolated point
  73145. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73146. */
  73147. private _setPointAtData;
  73148. /**
  73149. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73150. */
  73151. private _updateInterpolationMatrix;
  73152. }
  73153. /**
  73154. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73155. * A Curve3 is designed from a series of successive Vector3.
  73156. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73157. */
  73158. export class Curve3 {
  73159. private _points;
  73160. private _length;
  73161. /**
  73162. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73163. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73164. * @param v1 (Vector3) the control point
  73165. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73166. * @param nbPoints (integer) the wanted number of points in the curve
  73167. * @returns the created Curve3
  73168. */
  73169. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73170. /**
  73171. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73172. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73173. * @param v1 (Vector3) the first control point
  73174. * @param v2 (Vector3) the second control point
  73175. * @param v3 (Vector3) the end point of the Cubic Bezier
  73176. * @param nbPoints (integer) the wanted number of points in the curve
  73177. * @returns the created Curve3
  73178. */
  73179. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73180. /**
  73181. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73182. * @param p1 (Vector3) the origin point of the Hermite Spline
  73183. * @param t1 (Vector3) the tangent vector at the origin point
  73184. * @param p2 (Vector3) the end point of the Hermite Spline
  73185. * @param t2 (Vector3) the tangent vector at the end point
  73186. * @param nbPoints (integer) the wanted number of points in the curve
  73187. * @returns the created Curve3
  73188. */
  73189. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73190. /**
  73191. * Returns a Curve3 object along a CatmullRom Spline curve :
  73192. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73193. * @param nbPoints (integer) the wanted number of points between each curve control points
  73194. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73195. * @returns the created Curve3
  73196. */
  73197. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73198. /**
  73199. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73200. * A Curve3 is designed from a series of successive Vector3.
  73201. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73202. * @param points points which make up the curve
  73203. */
  73204. constructor(points: Vector3[]);
  73205. /**
  73206. * @returns the Curve3 stored array of successive Vector3
  73207. */
  73208. getPoints(): Vector3[];
  73209. /**
  73210. * @returns the computed length (float) of the curve.
  73211. */
  73212. length(): number;
  73213. /**
  73214. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73215. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73216. * curveA and curveB keep unchanged.
  73217. * @param curve the curve to continue from this curve
  73218. * @returns the newly constructed curve
  73219. */
  73220. continue(curve: DeepImmutable<Curve3>): Curve3;
  73221. private _computeLength;
  73222. }
  73223. }
  73224. declare module BABYLON {
  73225. /**
  73226. * This represents the main contract an easing function should follow.
  73227. * Easing functions are used throughout the animation system.
  73228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73229. */
  73230. export interface IEasingFunction {
  73231. /**
  73232. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73233. * of the easing function.
  73234. * The link below provides some of the most common examples of easing functions.
  73235. * @see https://easings.net/
  73236. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73237. * @returns the corresponding value on the curve defined by the easing function
  73238. */
  73239. ease(gradient: number): number;
  73240. }
  73241. /**
  73242. * Base class used for every default easing function.
  73243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73244. */
  73245. export class EasingFunction implements IEasingFunction {
  73246. /**
  73247. * Interpolation follows the mathematical formula associated with the easing function.
  73248. */
  73249. static readonly EASINGMODE_EASEIN: number;
  73250. /**
  73251. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73252. */
  73253. static readonly EASINGMODE_EASEOUT: number;
  73254. /**
  73255. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73256. */
  73257. static readonly EASINGMODE_EASEINOUT: number;
  73258. private _easingMode;
  73259. /**
  73260. * Sets the easing mode of the current function.
  73261. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73262. */
  73263. setEasingMode(easingMode: number): void;
  73264. /**
  73265. * Gets the current easing mode.
  73266. * @returns the easing mode
  73267. */
  73268. getEasingMode(): number;
  73269. /**
  73270. * @hidden
  73271. */
  73272. easeInCore(gradient: number): number;
  73273. /**
  73274. * Given an input gradient between 0 and 1, this returns the corresponding value
  73275. * of the easing function.
  73276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73277. * @returns the corresponding value on the curve defined by the easing function
  73278. */
  73279. ease(gradient: number): number;
  73280. }
  73281. /**
  73282. * Easing function with a circle shape (see link below).
  73283. * @see https://easings.net/#easeInCirc
  73284. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73285. */
  73286. export class CircleEase extends EasingFunction implements IEasingFunction {
  73287. /** @hidden */
  73288. easeInCore(gradient: number): number;
  73289. }
  73290. /**
  73291. * Easing function with a ease back shape (see link below).
  73292. * @see https://easings.net/#easeInBack
  73293. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73294. */
  73295. export class BackEase extends EasingFunction implements IEasingFunction {
  73296. /** Defines the amplitude of the function */
  73297. amplitude: number;
  73298. /**
  73299. * Instantiates a back ease easing
  73300. * @see https://easings.net/#easeInBack
  73301. * @param amplitude Defines the amplitude of the function
  73302. */
  73303. constructor(
  73304. /** Defines the amplitude of the function */
  73305. amplitude?: number);
  73306. /** @hidden */
  73307. easeInCore(gradient: number): number;
  73308. }
  73309. /**
  73310. * Easing function with a bouncing shape (see link below).
  73311. * @see https://easings.net/#easeInBounce
  73312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73313. */
  73314. export class BounceEase extends EasingFunction implements IEasingFunction {
  73315. /** Defines the number of bounces */
  73316. bounces: number;
  73317. /** Defines the amplitude of the bounce */
  73318. bounciness: number;
  73319. /**
  73320. * Instantiates a bounce easing
  73321. * @see https://easings.net/#easeInBounce
  73322. * @param bounces Defines the number of bounces
  73323. * @param bounciness Defines the amplitude of the bounce
  73324. */
  73325. constructor(
  73326. /** Defines the number of bounces */
  73327. bounces?: number,
  73328. /** Defines the amplitude of the bounce */
  73329. bounciness?: number);
  73330. /** @hidden */
  73331. easeInCore(gradient: number): number;
  73332. }
  73333. /**
  73334. * Easing function with a power of 3 shape (see link below).
  73335. * @see https://easings.net/#easeInCubic
  73336. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73337. */
  73338. export class CubicEase extends EasingFunction implements IEasingFunction {
  73339. /** @hidden */
  73340. easeInCore(gradient: number): number;
  73341. }
  73342. /**
  73343. * Easing function with an elastic shape (see link below).
  73344. * @see https://easings.net/#easeInElastic
  73345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73346. */
  73347. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73348. /** Defines the number of oscillations*/
  73349. oscillations: number;
  73350. /** Defines the amplitude of the oscillations*/
  73351. springiness: number;
  73352. /**
  73353. * Instantiates an elastic easing function
  73354. * @see https://easings.net/#easeInElastic
  73355. * @param oscillations Defines the number of oscillations
  73356. * @param springiness Defines the amplitude of the oscillations
  73357. */
  73358. constructor(
  73359. /** Defines the number of oscillations*/
  73360. oscillations?: number,
  73361. /** Defines the amplitude of the oscillations*/
  73362. springiness?: number);
  73363. /** @hidden */
  73364. easeInCore(gradient: number): number;
  73365. }
  73366. /**
  73367. * Easing function with an exponential shape (see link below).
  73368. * @see https://easings.net/#easeInExpo
  73369. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73370. */
  73371. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73372. /** Defines the exponent of the function */
  73373. exponent: number;
  73374. /**
  73375. * Instantiates an exponential easing function
  73376. * @see https://easings.net/#easeInExpo
  73377. * @param exponent Defines the exponent of the function
  73378. */
  73379. constructor(
  73380. /** Defines the exponent of the function */
  73381. exponent?: number);
  73382. /** @hidden */
  73383. easeInCore(gradient: number): number;
  73384. }
  73385. /**
  73386. * Easing function with a power shape (see link below).
  73387. * @see https://easings.net/#easeInQuad
  73388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73389. */
  73390. export class PowerEase extends EasingFunction implements IEasingFunction {
  73391. /** Defines the power of the function */
  73392. power: number;
  73393. /**
  73394. * Instantiates an power base easing function
  73395. * @see https://easings.net/#easeInQuad
  73396. * @param power Defines the power of the function
  73397. */
  73398. constructor(
  73399. /** Defines the power of the function */
  73400. power?: number);
  73401. /** @hidden */
  73402. easeInCore(gradient: number): number;
  73403. }
  73404. /**
  73405. * Easing function with a power of 2 shape (see link below).
  73406. * @see https://easings.net/#easeInQuad
  73407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73408. */
  73409. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73410. /** @hidden */
  73411. easeInCore(gradient: number): number;
  73412. }
  73413. /**
  73414. * Easing function with a power of 4 shape (see link below).
  73415. * @see https://easings.net/#easeInQuart
  73416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73417. */
  73418. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73419. /** @hidden */
  73420. easeInCore(gradient: number): number;
  73421. }
  73422. /**
  73423. * Easing function with a power of 5 shape (see link below).
  73424. * @see https://easings.net/#easeInQuint
  73425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73426. */
  73427. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73428. /** @hidden */
  73429. easeInCore(gradient: number): number;
  73430. }
  73431. /**
  73432. * Easing function with a sin shape (see link below).
  73433. * @see https://easings.net/#easeInSine
  73434. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73435. */
  73436. export class SineEase extends EasingFunction implements IEasingFunction {
  73437. /** @hidden */
  73438. easeInCore(gradient: number): number;
  73439. }
  73440. /**
  73441. * Easing function with a bezier shape (see link below).
  73442. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73444. */
  73445. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73446. /** Defines the x component of the start tangent in the bezier curve */
  73447. x1: number;
  73448. /** Defines the y component of the start tangent in the bezier curve */
  73449. y1: number;
  73450. /** Defines the x component of the end tangent in the bezier curve */
  73451. x2: number;
  73452. /** Defines the y component of the end tangent in the bezier curve */
  73453. y2: number;
  73454. /**
  73455. * Instantiates a bezier function
  73456. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73457. * @param x1 Defines the x component of the start tangent in the bezier curve
  73458. * @param y1 Defines the y component of the start tangent in the bezier curve
  73459. * @param x2 Defines the x component of the end tangent in the bezier curve
  73460. * @param y2 Defines the y component of the end tangent in the bezier curve
  73461. */
  73462. constructor(
  73463. /** Defines the x component of the start tangent in the bezier curve */
  73464. x1?: number,
  73465. /** Defines the y component of the start tangent in the bezier curve */
  73466. y1?: number,
  73467. /** Defines the x component of the end tangent in the bezier curve */
  73468. x2?: number,
  73469. /** Defines the y component of the end tangent in the bezier curve */
  73470. y2?: number);
  73471. /** @hidden */
  73472. easeInCore(gradient: number): number;
  73473. }
  73474. }
  73475. declare module BABYLON {
  73476. /**
  73477. * Class used to hold a RBG color
  73478. */
  73479. export class Color3 {
  73480. /**
  73481. * Defines the red component (between 0 and 1, default is 0)
  73482. */
  73483. r: number;
  73484. /**
  73485. * Defines the green component (between 0 and 1, default is 0)
  73486. */
  73487. g: number;
  73488. /**
  73489. * Defines the blue component (between 0 and 1, default is 0)
  73490. */
  73491. b: number;
  73492. /**
  73493. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73494. * @param r defines the red component (between 0 and 1, default is 0)
  73495. * @param g defines the green component (between 0 and 1, default is 0)
  73496. * @param b defines the blue component (between 0 and 1, default is 0)
  73497. */
  73498. constructor(
  73499. /**
  73500. * Defines the red component (between 0 and 1, default is 0)
  73501. */
  73502. r?: number,
  73503. /**
  73504. * Defines the green component (between 0 and 1, default is 0)
  73505. */
  73506. g?: number,
  73507. /**
  73508. * Defines the blue component (between 0 and 1, default is 0)
  73509. */
  73510. b?: number);
  73511. /**
  73512. * Creates a string with the Color3 current values
  73513. * @returns the string representation of the Color3 object
  73514. */
  73515. toString(): string;
  73516. /**
  73517. * Returns the string "Color3"
  73518. * @returns "Color3"
  73519. */
  73520. getClassName(): string;
  73521. /**
  73522. * Compute the Color3 hash code
  73523. * @returns an unique number that can be used to hash Color3 objects
  73524. */
  73525. getHashCode(): number;
  73526. /**
  73527. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73528. * @param array defines the array where to store the r,g,b components
  73529. * @param index defines an optional index in the target array to define where to start storing values
  73530. * @returns the current Color3 object
  73531. */
  73532. toArray(array: FloatArray, index?: number): Color3;
  73533. /**
  73534. * Returns a new Color4 object from the current Color3 and the given alpha
  73535. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73536. * @returns a new Color4 object
  73537. */
  73538. toColor4(alpha?: number): Color4;
  73539. /**
  73540. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73541. * @returns the new array
  73542. */
  73543. asArray(): number[];
  73544. /**
  73545. * Returns the luminance value
  73546. * @returns a float value
  73547. */
  73548. toLuminance(): number;
  73549. /**
  73550. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73551. * @param otherColor defines the second operand
  73552. * @returns the new Color3 object
  73553. */
  73554. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73555. /**
  73556. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73557. * @param otherColor defines the second operand
  73558. * @param result defines the Color3 object where to store the result
  73559. * @returns the current Color3
  73560. */
  73561. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73562. /**
  73563. * Determines equality between Color3 objects
  73564. * @param otherColor defines the second operand
  73565. * @returns true if the rgb values are equal to the given ones
  73566. */
  73567. equals(otherColor: DeepImmutable<Color3>): boolean;
  73568. /**
  73569. * Determines equality between the current Color3 object and a set of r,b,g values
  73570. * @param r defines the red component to check
  73571. * @param g defines the green component to check
  73572. * @param b defines the blue component to check
  73573. * @returns true if the rgb values are equal to the given ones
  73574. */
  73575. equalsFloats(r: number, g: number, b: number): boolean;
  73576. /**
  73577. * Multiplies in place each rgb value by scale
  73578. * @param scale defines the scaling factor
  73579. * @returns the updated Color3
  73580. */
  73581. scale(scale: number): Color3;
  73582. /**
  73583. * Multiplies the rgb values by scale and stores the result into "result"
  73584. * @param scale defines the scaling factor
  73585. * @param result defines the Color3 object where to store the result
  73586. * @returns the unmodified current Color3
  73587. */
  73588. scaleToRef(scale: number, result: Color3): Color3;
  73589. /**
  73590. * Scale the current Color3 values by a factor and add the result to a given Color3
  73591. * @param scale defines the scale factor
  73592. * @param result defines color to store the result into
  73593. * @returns the unmodified current Color3
  73594. */
  73595. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73596. /**
  73597. * Clamps the rgb values by the min and max values and stores the result into "result"
  73598. * @param min defines minimum clamping value (default is 0)
  73599. * @param max defines maximum clamping value (default is 1)
  73600. * @param result defines color to store the result into
  73601. * @returns the original Color3
  73602. */
  73603. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73604. /**
  73605. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73606. * @param otherColor defines the second operand
  73607. * @returns the new Color3
  73608. */
  73609. add(otherColor: DeepImmutable<Color3>): Color3;
  73610. /**
  73611. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73612. * @param otherColor defines the second operand
  73613. * @param result defines Color3 object to store the result into
  73614. * @returns the unmodified current Color3
  73615. */
  73616. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73617. /**
  73618. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73619. * @param otherColor defines the second operand
  73620. * @returns the new Color3
  73621. */
  73622. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73623. /**
  73624. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73625. * @param otherColor defines the second operand
  73626. * @param result defines Color3 object to store the result into
  73627. * @returns the unmodified current Color3
  73628. */
  73629. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73630. /**
  73631. * Copy the current object
  73632. * @returns a new Color3 copied the current one
  73633. */
  73634. clone(): Color3;
  73635. /**
  73636. * Copies the rgb values from the source in the current Color3
  73637. * @param source defines the source Color3 object
  73638. * @returns the updated Color3 object
  73639. */
  73640. copyFrom(source: DeepImmutable<Color3>): Color3;
  73641. /**
  73642. * Updates the Color3 rgb values from the given floats
  73643. * @param r defines the red component to read from
  73644. * @param g defines the green component to read from
  73645. * @param b defines the blue component to read from
  73646. * @returns the current Color3 object
  73647. */
  73648. copyFromFloats(r: number, g: number, b: number): Color3;
  73649. /**
  73650. * Updates the Color3 rgb values from the given floats
  73651. * @param r defines the red component to read from
  73652. * @param g defines the green component to read from
  73653. * @param b defines the blue component to read from
  73654. * @returns the current Color3 object
  73655. */
  73656. set(r: number, g: number, b: number): Color3;
  73657. /**
  73658. * Compute the Color3 hexadecimal code as a string
  73659. * @returns a string containing the hexadecimal representation of the Color3 object
  73660. */
  73661. toHexString(): string;
  73662. /**
  73663. * Computes a new Color3 converted from the current one to linear space
  73664. * @returns a new Color3 object
  73665. */
  73666. toLinearSpace(): Color3;
  73667. /**
  73668. * Converts current color in rgb space to HSV values
  73669. * @returns a new color3 representing the HSV values
  73670. */
  73671. toHSV(): Color3;
  73672. /**
  73673. * Converts current color in rgb space to HSV values
  73674. * @param result defines the Color3 where to store the HSV values
  73675. */
  73676. toHSVToRef(result: Color3): void;
  73677. /**
  73678. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73679. * @param convertedColor defines the Color3 object where to store the linear space version
  73680. * @returns the unmodified Color3
  73681. */
  73682. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73683. /**
  73684. * Computes a new Color3 converted from the current one to gamma space
  73685. * @returns a new Color3 object
  73686. */
  73687. toGammaSpace(): Color3;
  73688. /**
  73689. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73690. * @param convertedColor defines the Color3 object where to store the gamma space version
  73691. * @returns the unmodified Color3
  73692. */
  73693. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73694. private static _BlackReadOnly;
  73695. /**
  73696. * Convert Hue, saturation and value to a Color3 (RGB)
  73697. * @param hue defines the hue
  73698. * @param saturation defines the saturation
  73699. * @param value defines the value
  73700. * @param result defines the Color3 where to store the RGB values
  73701. */
  73702. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73703. /**
  73704. * Creates a new Color3 from the string containing valid hexadecimal values
  73705. * @param hex defines a string containing valid hexadecimal values
  73706. * @returns a new Color3 object
  73707. */
  73708. static FromHexString(hex: string): Color3;
  73709. /**
  73710. * Creates a new Color3 from the starting index of the given array
  73711. * @param array defines the source array
  73712. * @param offset defines an offset in the source array
  73713. * @returns a new Color3 object
  73714. */
  73715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73716. /**
  73717. * Creates a new Color3 from integer values (< 256)
  73718. * @param r defines the red component to read from (value between 0 and 255)
  73719. * @param g defines the green component to read from (value between 0 and 255)
  73720. * @param b defines the blue component to read from (value between 0 and 255)
  73721. * @returns a new Color3 object
  73722. */
  73723. static FromInts(r: number, g: number, b: number): Color3;
  73724. /**
  73725. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73726. * @param start defines the start Color3 value
  73727. * @param end defines the end Color3 value
  73728. * @param amount defines the gradient value between start and end
  73729. * @returns a new Color3 object
  73730. */
  73731. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73732. /**
  73733. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73734. * @param left defines the start value
  73735. * @param right defines the end value
  73736. * @param amount defines the gradient factor
  73737. * @param result defines the Color3 object where to store the result
  73738. */
  73739. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73740. /**
  73741. * Returns a Color3 value containing a red color
  73742. * @returns a new Color3 object
  73743. */
  73744. static Red(): Color3;
  73745. /**
  73746. * Returns a Color3 value containing a green color
  73747. * @returns a new Color3 object
  73748. */
  73749. static Green(): Color3;
  73750. /**
  73751. * Returns a Color3 value containing a blue color
  73752. * @returns a new Color3 object
  73753. */
  73754. static Blue(): Color3;
  73755. /**
  73756. * Returns a Color3 value containing a black color
  73757. * @returns a new Color3 object
  73758. */
  73759. static Black(): Color3;
  73760. /**
  73761. * Gets a Color3 value containing a black color that must not be updated
  73762. */
  73763. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73764. /**
  73765. * Returns a Color3 value containing a white color
  73766. * @returns a new Color3 object
  73767. */
  73768. static White(): Color3;
  73769. /**
  73770. * Returns a Color3 value containing a purple color
  73771. * @returns a new Color3 object
  73772. */
  73773. static Purple(): Color3;
  73774. /**
  73775. * Returns a Color3 value containing a magenta color
  73776. * @returns a new Color3 object
  73777. */
  73778. static Magenta(): Color3;
  73779. /**
  73780. * Returns a Color3 value containing a yellow color
  73781. * @returns a new Color3 object
  73782. */
  73783. static Yellow(): Color3;
  73784. /**
  73785. * Returns a Color3 value containing a gray color
  73786. * @returns a new Color3 object
  73787. */
  73788. static Gray(): Color3;
  73789. /**
  73790. * Returns a Color3 value containing a teal color
  73791. * @returns a new Color3 object
  73792. */
  73793. static Teal(): Color3;
  73794. /**
  73795. * Returns a Color3 value containing a random color
  73796. * @returns a new Color3 object
  73797. */
  73798. static Random(): Color3;
  73799. }
  73800. /**
  73801. * Class used to hold a RBGA color
  73802. */
  73803. export class Color4 {
  73804. /**
  73805. * Defines the red component (between 0 and 1, default is 0)
  73806. */
  73807. r: number;
  73808. /**
  73809. * Defines the green component (between 0 and 1, default is 0)
  73810. */
  73811. g: number;
  73812. /**
  73813. * Defines the blue component (between 0 and 1, default is 0)
  73814. */
  73815. b: number;
  73816. /**
  73817. * Defines the alpha component (between 0 and 1, default is 1)
  73818. */
  73819. a: number;
  73820. /**
  73821. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73822. * @param r defines the red component (between 0 and 1, default is 0)
  73823. * @param g defines the green component (between 0 and 1, default is 0)
  73824. * @param b defines the blue component (between 0 and 1, default is 0)
  73825. * @param a defines the alpha component (between 0 and 1, default is 1)
  73826. */
  73827. constructor(
  73828. /**
  73829. * Defines the red component (between 0 and 1, default is 0)
  73830. */
  73831. r?: number,
  73832. /**
  73833. * Defines the green component (between 0 and 1, default is 0)
  73834. */
  73835. g?: number,
  73836. /**
  73837. * Defines the blue component (between 0 and 1, default is 0)
  73838. */
  73839. b?: number,
  73840. /**
  73841. * Defines the alpha component (between 0 and 1, default is 1)
  73842. */
  73843. a?: number);
  73844. /**
  73845. * Adds in place the given Color4 values to the current Color4 object
  73846. * @param right defines the second operand
  73847. * @returns the current updated Color4 object
  73848. */
  73849. addInPlace(right: DeepImmutable<Color4>): Color4;
  73850. /**
  73851. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73852. * @returns the new array
  73853. */
  73854. asArray(): number[];
  73855. /**
  73856. * Stores from the starting index in the given array the Color4 successive values
  73857. * @param array defines the array where to store the r,g,b components
  73858. * @param index defines an optional index in the target array to define where to start storing values
  73859. * @returns the current Color4 object
  73860. */
  73861. toArray(array: number[], index?: number): Color4;
  73862. /**
  73863. * Determines equality between Color4 objects
  73864. * @param otherColor defines the second operand
  73865. * @returns true if the rgba values are equal to the given ones
  73866. */
  73867. equals(otherColor: DeepImmutable<Color4>): boolean;
  73868. /**
  73869. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73870. * @param right defines the second operand
  73871. * @returns a new Color4 object
  73872. */
  73873. add(right: DeepImmutable<Color4>): Color4;
  73874. /**
  73875. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73876. * @param right defines the second operand
  73877. * @returns a new Color4 object
  73878. */
  73879. subtract(right: DeepImmutable<Color4>): Color4;
  73880. /**
  73881. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73882. * @param right defines the second operand
  73883. * @param result defines the Color4 object where to store the result
  73884. * @returns the current Color4 object
  73885. */
  73886. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73887. /**
  73888. * Creates a new Color4 with the current Color4 values multiplied by scale
  73889. * @param scale defines the scaling factor to apply
  73890. * @returns a new Color4 object
  73891. */
  73892. scale(scale: number): Color4;
  73893. /**
  73894. * Multiplies the current Color4 values by scale and stores the result in "result"
  73895. * @param scale defines the scaling factor to apply
  73896. * @param result defines the Color4 object where to store the result
  73897. * @returns the current unmodified Color4
  73898. */
  73899. scaleToRef(scale: number, result: Color4): Color4;
  73900. /**
  73901. * Scale the current Color4 values by a factor and add the result to a given Color4
  73902. * @param scale defines the scale factor
  73903. * @param result defines the Color4 object where to store the result
  73904. * @returns the unmodified current Color4
  73905. */
  73906. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73907. /**
  73908. * Clamps the rgb values by the min and max values and stores the result into "result"
  73909. * @param min defines minimum clamping value (default is 0)
  73910. * @param max defines maximum clamping value (default is 1)
  73911. * @param result defines color to store the result into.
  73912. * @returns the cuurent Color4
  73913. */
  73914. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73915. /**
  73916. * Multipy an Color4 value by another and return a new Color4 object
  73917. * @param color defines the Color4 value to multiply by
  73918. * @returns a new Color4 object
  73919. */
  73920. multiply(color: Color4): Color4;
  73921. /**
  73922. * Multipy a Color4 value by another and push the result in a reference value
  73923. * @param color defines the Color4 value to multiply by
  73924. * @param result defines the Color4 to fill the result in
  73925. * @returns the result Color4
  73926. */
  73927. multiplyToRef(color: Color4, result: Color4): Color4;
  73928. /**
  73929. * Creates a string with the Color4 current values
  73930. * @returns the string representation of the Color4 object
  73931. */
  73932. toString(): string;
  73933. /**
  73934. * Returns the string "Color4"
  73935. * @returns "Color4"
  73936. */
  73937. getClassName(): string;
  73938. /**
  73939. * Compute the Color4 hash code
  73940. * @returns an unique number that can be used to hash Color4 objects
  73941. */
  73942. getHashCode(): number;
  73943. /**
  73944. * Creates a new Color4 copied from the current one
  73945. * @returns a new Color4 object
  73946. */
  73947. clone(): Color4;
  73948. /**
  73949. * Copies the given Color4 values into the current one
  73950. * @param source defines the source Color4 object
  73951. * @returns the current updated Color4 object
  73952. */
  73953. copyFrom(source: Color4): Color4;
  73954. /**
  73955. * Copies the given float values into the current one
  73956. * @param r defines the red component to read from
  73957. * @param g defines the green component to read from
  73958. * @param b defines the blue component to read from
  73959. * @param a defines the alpha component to read from
  73960. * @returns the current updated Color4 object
  73961. */
  73962. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73963. /**
  73964. * Copies the given float values into the current one
  73965. * @param r defines the red component to read from
  73966. * @param g defines the green component to read from
  73967. * @param b defines the blue component to read from
  73968. * @param a defines the alpha component to read from
  73969. * @returns the current updated Color4 object
  73970. */
  73971. set(r: number, g: number, b: number, a: number): Color4;
  73972. /**
  73973. * Compute the Color4 hexadecimal code as a string
  73974. * @returns a string containing the hexadecimal representation of the Color4 object
  73975. */
  73976. toHexString(): string;
  73977. /**
  73978. * Computes a new Color4 converted from the current one to linear space
  73979. * @returns a new Color4 object
  73980. */
  73981. toLinearSpace(): Color4;
  73982. /**
  73983. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73984. * @param convertedColor defines the Color4 object where to store the linear space version
  73985. * @returns the unmodified Color4
  73986. */
  73987. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73988. /**
  73989. * Computes a new Color4 converted from the current one to gamma space
  73990. * @returns a new Color4 object
  73991. */
  73992. toGammaSpace(): Color4;
  73993. /**
  73994. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73995. * @param convertedColor defines the Color4 object where to store the gamma space version
  73996. * @returns the unmodified Color4
  73997. */
  73998. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73999. /**
  74000. * Creates a new Color4 from the string containing valid hexadecimal values
  74001. * @param hex defines a string containing valid hexadecimal values
  74002. * @returns a new Color4 object
  74003. */
  74004. static FromHexString(hex: string): Color4;
  74005. /**
  74006. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74007. * @param left defines the start value
  74008. * @param right defines the end value
  74009. * @param amount defines the gradient factor
  74010. * @returns a new Color4 object
  74011. */
  74012. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74013. /**
  74014. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74015. * @param left defines the start value
  74016. * @param right defines the end value
  74017. * @param amount defines the gradient factor
  74018. * @param result defines the Color4 object where to store data
  74019. */
  74020. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74021. /**
  74022. * Creates a new Color4 from a Color3 and an alpha value
  74023. * @param color3 defines the source Color3 to read from
  74024. * @param alpha defines the alpha component (1.0 by default)
  74025. * @returns a new Color4 object
  74026. */
  74027. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74028. /**
  74029. * Creates a new Color4 from the starting index element of the given array
  74030. * @param array defines the source array to read from
  74031. * @param offset defines the offset in the source array
  74032. * @returns a new Color4 object
  74033. */
  74034. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74035. /**
  74036. * Creates a new Color3 from integer values (< 256)
  74037. * @param r defines the red component to read from (value between 0 and 255)
  74038. * @param g defines the green component to read from (value between 0 and 255)
  74039. * @param b defines the blue component to read from (value between 0 and 255)
  74040. * @param a defines the alpha component to read from (value between 0 and 255)
  74041. * @returns a new Color3 object
  74042. */
  74043. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74044. /**
  74045. * Check the content of a given array and convert it to an array containing RGBA data
  74046. * If the original array was already containing count * 4 values then it is returned directly
  74047. * @param colors defines the array to check
  74048. * @param count defines the number of RGBA data to expect
  74049. * @returns an array containing count * 4 values (RGBA)
  74050. */
  74051. static CheckColors4(colors: number[], count: number): number[];
  74052. }
  74053. /**
  74054. * @hidden
  74055. */
  74056. export class TmpColors {
  74057. static Color3: Color3[];
  74058. static Color4: Color4[];
  74059. }
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * Defines an interface which represents an animation key frame
  74064. */
  74065. export interface IAnimationKey {
  74066. /**
  74067. * Frame of the key frame
  74068. */
  74069. frame: number;
  74070. /**
  74071. * Value at the specifies key frame
  74072. */
  74073. value: any;
  74074. /**
  74075. * The input tangent for the cubic hermite spline
  74076. */
  74077. inTangent?: any;
  74078. /**
  74079. * The output tangent for the cubic hermite spline
  74080. */
  74081. outTangent?: any;
  74082. /**
  74083. * The animation interpolation type
  74084. */
  74085. interpolation?: AnimationKeyInterpolation;
  74086. }
  74087. /**
  74088. * Enum for the animation key frame interpolation type
  74089. */
  74090. export enum AnimationKeyInterpolation {
  74091. /**
  74092. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74093. */
  74094. STEP = 1
  74095. }
  74096. }
  74097. declare module BABYLON {
  74098. /**
  74099. * Represents the range of an animation
  74100. */
  74101. export class AnimationRange {
  74102. /**The name of the animation range**/
  74103. name: string;
  74104. /**The starting frame of the animation */
  74105. from: number;
  74106. /**The ending frame of the animation*/
  74107. to: number;
  74108. /**
  74109. * Initializes the range of an animation
  74110. * @param name The name of the animation range
  74111. * @param from The starting frame of the animation
  74112. * @param to The ending frame of the animation
  74113. */
  74114. constructor(
  74115. /**The name of the animation range**/
  74116. name: string,
  74117. /**The starting frame of the animation */
  74118. from: number,
  74119. /**The ending frame of the animation*/
  74120. to: number);
  74121. /**
  74122. * Makes a copy of the animation range
  74123. * @returns A copy of the animation range
  74124. */
  74125. clone(): AnimationRange;
  74126. }
  74127. }
  74128. declare module BABYLON {
  74129. /**
  74130. * Composed of a frame, and an action function
  74131. */
  74132. export class AnimationEvent {
  74133. /** The frame for which the event is triggered **/
  74134. frame: number;
  74135. /** The event to perform when triggered **/
  74136. action: (currentFrame: number) => void;
  74137. /** Specifies if the event should be triggered only once**/
  74138. onlyOnce?: boolean | undefined;
  74139. /**
  74140. * Specifies if the animation event is done
  74141. */
  74142. isDone: boolean;
  74143. /**
  74144. * Initializes the animation event
  74145. * @param frame The frame for which the event is triggered
  74146. * @param action The event to perform when triggered
  74147. * @param onlyOnce Specifies if the event should be triggered only once
  74148. */
  74149. constructor(
  74150. /** The frame for which the event is triggered **/
  74151. frame: number,
  74152. /** The event to perform when triggered **/
  74153. action: (currentFrame: number) => void,
  74154. /** Specifies if the event should be triggered only once**/
  74155. onlyOnce?: boolean | undefined);
  74156. /** @hidden */
  74157. _clone(): AnimationEvent;
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. /**
  74162. * Interface used to define a behavior
  74163. */
  74164. export interface Behavior<T> {
  74165. /** gets or sets behavior's name */
  74166. name: string;
  74167. /**
  74168. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74169. */
  74170. init(): void;
  74171. /**
  74172. * Called when the behavior is attached to a target
  74173. * @param target defines the target where the behavior is attached to
  74174. */
  74175. attach(target: T): void;
  74176. /**
  74177. * Called when the behavior is detached from its target
  74178. */
  74179. detach(): void;
  74180. }
  74181. /**
  74182. * Interface implemented by classes supporting behaviors
  74183. */
  74184. export interface IBehaviorAware<T> {
  74185. /**
  74186. * Attach a behavior
  74187. * @param behavior defines the behavior to attach
  74188. * @returns the current host
  74189. */
  74190. addBehavior(behavior: Behavior<T>): T;
  74191. /**
  74192. * Remove a behavior from the current object
  74193. * @param behavior defines the behavior to detach
  74194. * @returns the current host
  74195. */
  74196. removeBehavior(behavior: Behavior<T>): T;
  74197. /**
  74198. * Gets a behavior using its name to search
  74199. * @param name defines the name to search
  74200. * @returns the behavior or null if not found
  74201. */
  74202. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74203. }
  74204. }
  74205. declare module BABYLON {
  74206. /**
  74207. * Defines an array and its length.
  74208. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74209. */
  74210. export interface ISmartArrayLike<T> {
  74211. /**
  74212. * The data of the array.
  74213. */
  74214. data: Array<T>;
  74215. /**
  74216. * The active length of the array.
  74217. */
  74218. length: number;
  74219. }
  74220. /**
  74221. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74222. */
  74223. export class SmartArray<T> implements ISmartArrayLike<T> {
  74224. /**
  74225. * The full set of data from the array.
  74226. */
  74227. data: Array<T>;
  74228. /**
  74229. * The active length of the array.
  74230. */
  74231. length: number;
  74232. protected _id: number;
  74233. /**
  74234. * Instantiates a Smart Array.
  74235. * @param capacity defines the default capacity of the array.
  74236. */
  74237. constructor(capacity: number);
  74238. /**
  74239. * Pushes a value at the end of the active data.
  74240. * @param value defines the object to push in the array.
  74241. */
  74242. push(value: T): void;
  74243. /**
  74244. * Iterates over the active data and apply the lambda to them.
  74245. * @param func defines the action to apply on each value.
  74246. */
  74247. forEach(func: (content: T) => void): void;
  74248. /**
  74249. * Sorts the full sets of data.
  74250. * @param compareFn defines the comparison function to apply.
  74251. */
  74252. sort(compareFn: (a: T, b: T) => number): void;
  74253. /**
  74254. * Resets the active data to an empty array.
  74255. */
  74256. reset(): void;
  74257. /**
  74258. * Releases all the data from the array as well as the array.
  74259. */
  74260. dispose(): void;
  74261. /**
  74262. * Concats the active data with a given array.
  74263. * @param array defines the data to concatenate with.
  74264. */
  74265. concat(array: any): void;
  74266. /**
  74267. * Returns the position of a value in the active data.
  74268. * @param value defines the value to find the index for
  74269. * @returns the index if found in the active data otherwise -1
  74270. */
  74271. indexOf(value: T): number;
  74272. /**
  74273. * Returns whether an element is part of the active data.
  74274. * @param value defines the value to look for
  74275. * @returns true if found in the active data otherwise false
  74276. */
  74277. contains(value: T): boolean;
  74278. private static _GlobalId;
  74279. }
  74280. /**
  74281. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74282. * The data in this array can only be present once
  74283. */
  74284. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74285. private _duplicateId;
  74286. /**
  74287. * Pushes a value at the end of the active data.
  74288. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74289. * @param value defines the object to push in the array.
  74290. */
  74291. push(value: T): void;
  74292. /**
  74293. * Pushes a value at the end of the active data.
  74294. * If the data is already present, it won t be added again
  74295. * @param value defines the object to push in the array.
  74296. * @returns true if added false if it was already present
  74297. */
  74298. pushNoDuplicate(value: T): boolean;
  74299. /**
  74300. * Resets the active data to an empty array.
  74301. */
  74302. reset(): void;
  74303. /**
  74304. * Concats the active data with a given array.
  74305. * This ensures no dupplicate will be present in the result.
  74306. * @param array defines the data to concatenate with.
  74307. */
  74308. concatWithNoDuplicate(array: any): void;
  74309. }
  74310. }
  74311. declare module BABYLON {
  74312. /**
  74313. * @ignore
  74314. * This is a list of all the different input types that are available in the application.
  74315. * Fo instance: ArcRotateCameraGamepadInput...
  74316. */
  74317. export var CameraInputTypes: {};
  74318. /**
  74319. * This is the contract to implement in order to create a new input class.
  74320. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74321. */
  74322. export interface ICameraInput<TCamera extends Camera> {
  74323. /**
  74324. * Defines the camera the input is attached to.
  74325. */
  74326. camera: Nullable<TCamera>;
  74327. /**
  74328. * Gets the class name of the current intput.
  74329. * @returns the class name
  74330. */
  74331. getClassName(): string;
  74332. /**
  74333. * Get the friendly name associated with the input class.
  74334. * @returns the input friendly name
  74335. */
  74336. getSimpleName(): string;
  74337. /**
  74338. * Attach the input controls to a specific dom element to get the input from.
  74339. * @param element Defines the element the controls should be listened from
  74340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74341. */
  74342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74343. /**
  74344. * Detach the current controls from the specified dom element.
  74345. * @param element Defines the element to stop listening the inputs from
  74346. */
  74347. detachControl(element: Nullable<HTMLElement>): void;
  74348. /**
  74349. * Update the current camera state depending on the inputs that have been used this frame.
  74350. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74351. */
  74352. checkInputs?: () => void;
  74353. }
  74354. /**
  74355. * Represents a map of input types to input instance or input index to input instance.
  74356. */
  74357. export interface CameraInputsMap<TCamera extends Camera> {
  74358. /**
  74359. * Accessor to the input by input type.
  74360. */
  74361. [name: string]: ICameraInput<TCamera>;
  74362. /**
  74363. * Accessor to the input by input index.
  74364. */
  74365. [idx: number]: ICameraInput<TCamera>;
  74366. }
  74367. /**
  74368. * This represents the input manager used within a camera.
  74369. * It helps dealing with all the different kind of input attached to a camera.
  74370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74371. */
  74372. export class CameraInputsManager<TCamera extends Camera> {
  74373. /**
  74374. * Defines the list of inputs attahed to the camera.
  74375. */
  74376. attached: CameraInputsMap<TCamera>;
  74377. /**
  74378. * Defines the dom element the camera is collecting inputs from.
  74379. * This is null if the controls have not been attached.
  74380. */
  74381. attachedElement: Nullable<HTMLElement>;
  74382. /**
  74383. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74384. */
  74385. noPreventDefault: boolean;
  74386. /**
  74387. * Defined the camera the input manager belongs to.
  74388. */
  74389. camera: TCamera;
  74390. /**
  74391. * Update the current camera state depending on the inputs that have been used this frame.
  74392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74393. */
  74394. checkInputs: () => void;
  74395. /**
  74396. * Instantiate a new Camera Input Manager.
  74397. * @param camera Defines the camera the input manager blongs to
  74398. */
  74399. constructor(camera: TCamera);
  74400. /**
  74401. * Add an input method to a camera
  74402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74403. * @param input camera input method
  74404. */
  74405. add(input: ICameraInput<TCamera>): void;
  74406. /**
  74407. * Remove a specific input method from a camera
  74408. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74409. * @param inputToRemove camera input method
  74410. */
  74411. remove(inputToRemove: ICameraInput<TCamera>): void;
  74412. /**
  74413. * Remove a specific input type from a camera
  74414. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74415. * @param inputType the type of the input to remove
  74416. */
  74417. removeByType(inputType: string): void;
  74418. private _addCheckInputs;
  74419. /**
  74420. * Attach the input controls to the currently attached dom element to listen the events from.
  74421. * @param input Defines the input to attach
  74422. */
  74423. attachInput(input: ICameraInput<TCamera>): void;
  74424. /**
  74425. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74426. * @param element Defines the dom element to collect the events from
  74427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74428. */
  74429. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74430. /**
  74431. * Detach the current manager inputs controls from a specific dom element.
  74432. * @param element Defines the dom element to collect the events from
  74433. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74434. */
  74435. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74436. /**
  74437. * Rebuild the dynamic inputCheck function from the current list of
  74438. * defined inputs in the manager.
  74439. */
  74440. rebuildInputCheck(): void;
  74441. /**
  74442. * Remove all attached input methods from a camera
  74443. */
  74444. clear(): void;
  74445. /**
  74446. * Serialize the current input manager attached to a camera.
  74447. * This ensures than once parsed,
  74448. * the input associated to the camera will be identical to the current ones
  74449. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74450. */
  74451. serialize(serializedCamera: any): void;
  74452. /**
  74453. * Parses an input manager serialized JSON to restore the previous list of inputs
  74454. * and states associated to a camera.
  74455. * @param parsedCamera Defines the JSON to parse
  74456. */
  74457. parse(parsedCamera: any): void;
  74458. }
  74459. }
  74460. declare module BABYLON {
  74461. /**
  74462. * Class used to store data that will be store in GPU memory
  74463. */
  74464. export class Buffer {
  74465. private _engine;
  74466. private _buffer;
  74467. /** @hidden */
  74468. _data: Nullable<DataArray>;
  74469. private _updatable;
  74470. private _instanced;
  74471. private _divisor;
  74472. /**
  74473. * Gets the byte stride.
  74474. */
  74475. readonly byteStride: number;
  74476. /**
  74477. * Constructor
  74478. * @param engine the engine
  74479. * @param data the data to use for this buffer
  74480. * @param updatable whether the data is updatable
  74481. * @param stride the stride (optional)
  74482. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74483. * @param instanced whether the buffer is instanced (optional)
  74484. * @param useBytes set to true if the stride in in bytes (optional)
  74485. * @param divisor sets an optional divisor for instances (1 by default)
  74486. */
  74487. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74488. /**
  74489. * Create a new VertexBuffer based on the current buffer
  74490. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74491. * @param offset defines offset in the buffer (0 by default)
  74492. * @param size defines the size in floats of attributes (position is 3 for instance)
  74493. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74494. * @param instanced defines if the vertex buffer contains indexed data
  74495. * @param useBytes defines if the offset and stride are in bytes *
  74496. * @param divisor sets an optional divisor for instances (1 by default)
  74497. * @returns the new vertex buffer
  74498. */
  74499. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74500. /**
  74501. * Gets a boolean indicating if the Buffer is updatable?
  74502. * @returns true if the buffer is updatable
  74503. */
  74504. isUpdatable(): boolean;
  74505. /**
  74506. * Gets current buffer's data
  74507. * @returns a DataArray or null
  74508. */
  74509. getData(): Nullable<DataArray>;
  74510. /**
  74511. * Gets underlying native buffer
  74512. * @returns underlying native buffer
  74513. */
  74514. getBuffer(): Nullable<DataBuffer>;
  74515. /**
  74516. * Gets the stride in float32 units (i.e. byte stride / 4).
  74517. * May not be an integer if the byte stride is not divisible by 4.
  74518. * DEPRECATED. Use byteStride instead.
  74519. * @returns the stride in float32 units
  74520. */
  74521. getStrideSize(): number;
  74522. /**
  74523. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74524. * @param data defines the data to store
  74525. */
  74526. create(data?: Nullable<DataArray>): void;
  74527. /** @hidden */
  74528. _rebuild(): void;
  74529. /**
  74530. * Update current buffer data
  74531. * @param data defines the data to store
  74532. */
  74533. update(data: DataArray): void;
  74534. /**
  74535. * Updates the data directly.
  74536. * @param data the new data
  74537. * @param offset the new offset
  74538. * @param vertexCount the vertex count (optional)
  74539. * @param useBytes set to true if the offset is in bytes
  74540. */
  74541. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74542. /**
  74543. * Release all resources
  74544. */
  74545. dispose(): void;
  74546. }
  74547. /**
  74548. * Specialized buffer used to store vertex data
  74549. */
  74550. export class VertexBuffer {
  74551. /** @hidden */
  74552. _buffer: Buffer;
  74553. private _kind;
  74554. private _size;
  74555. private _ownsBuffer;
  74556. private _instanced;
  74557. private _instanceDivisor;
  74558. /**
  74559. * The byte type.
  74560. */
  74561. static readonly BYTE: number;
  74562. /**
  74563. * The unsigned byte type.
  74564. */
  74565. static readonly UNSIGNED_BYTE: number;
  74566. /**
  74567. * The short type.
  74568. */
  74569. static readonly SHORT: number;
  74570. /**
  74571. * The unsigned short type.
  74572. */
  74573. static readonly UNSIGNED_SHORT: number;
  74574. /**
  74575. * The integer type.
  74576. */
  74577. static readonly INT: number;
  74578. /**
  74579. * The unsigned integer type.
  74580. */
  74581. static readonly UNSIGNED_INT: number;
  74582. /**
  74583. * The float type.
  74584. */
  74585. static readonly FLOAT: number;
  74586. /**
  74587. * Gets or sets the instance divisor when in instanced mode
  74588. */
  74589. instanceDivisor: number;
  74590. /**
  74591. * Gets the byte stride.
  74592. */
  74593. readonly byteStride: number;
  74594. /**
  74595. * Gets the byte offset.
  74596. */
  74597. readonly byteOffset: number;
  74598. /**
  74599. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74600. */
  74601. readonly normalized: boolean;
  74602. /**
  74603. * Gets the data type of each component in the array.
  74604. */
  74605. readonly type: number;
  74606. /**
  74607. * Constructor
  74608. * @param engine the engine
  74609. * @param data the data to use for this vertex buffer
  74610. * @param kind the vertex buffer kind
  74611. * @param updatable whether the data is updatable
  74612. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74613. * @param stride the stride (optional)
  74614. * @param instanced whether the buffer is instanced (optional)
  74615. * @param offset the offset of the data (optional)
  74616. * @param size the number of components (optional)
  74617. * @param type the type of the component (optional)
  74618. * @param normalized whether the data contains normalized data (optional)
  74619. * @param useBytes set to true if stride and offset are in bytes (optional)
  74620. * @param divisor defines the instance divisor to use (1 by default)
  74621. */
  74622. 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);
  74623. /** @hidden */
  74624. _rebuild(): void;
  74625. /**
  74626. * Returns the kind of the VertexBuffer (string)
  74627. * @returns a string
  74628. */
  74629. getKind(): string;
  74630. /**
  74631. * Gets a boolean indicating if the VertexBuffer is updatable?
  74632. * @returns true if the buffer is updatable
  74633. */
  74634. isUpdatable(): boolean;
  74635. /**
  74636. * Gets current buffer's data
  74637. * @returns a DataArray or null
  74638. */
  74639. getData(): Nullable<DataArray>;
  74640. /**
  74641. * Gets underlying native buffer
  74642. * @returns underlying native buffer
  74643. */
  74644. getBuffer(): Nullable<DataBuffer>;
  74645. /**
  74646. * Gets the stride in float32 units (i.e. byte stride / 4).
  74647. * May not be an integer if the byte stride is not divisible by 4.
  74648. * DEPRECATED. Use byteStride instead.
  74649. * @returns the stride in float32 units
  74650. */
  74651. getStrideSize(): number;
  74652. /**
  74653. * Returns the offset as a multiple of the type byte length.
  74654. * DEPRECATED. Use byteOffset instead.
  74655. * @returns the offset in bytes
  74656. */
  74657. getOffset(): number;
  74658. /**
  74659. * Returns the number of components per vertex attribute (integer)
  74660. * @returns the size in float
  74661. */
  74662. getSize(): number;
  74663. /**
  74664. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74665. * @returns true if this buffer is instanced
  74666. */
  74667. getIsInstanced(): boolean;
  74668. /**
  74669. * Returns the instancing divisor, zero for non-instanced (integer).
  74670. * @returns a number
  74671. */
  74672. getInstanceDivisor(): number;
  74673. /**
  74674. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74675. * @param data defines the data to store
  74676. */
  74677. create(data?: DataArray): void;
  74678. /**
  74679. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74680. * This function will create a new buffer if the current one is not updatable
  74681. * @param data defines the data to store
  74682. */
  74683. update(data: DataArray): void;
  74684. /**
  74685. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74686. * Returns the directly updated WebGLBuffer.
  74687. * @param data the new data
  74688. * @param offset the new offset
  74689. * @param useBytes set to true if the offset is in bytes
  74690. */
  74691. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74692. /**
  74693. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74694. */
  74695. dispose(): void;
  74696. /**
  74697. * Enumerates each value of this vertex buffer as numbers.
  74698. * @param count the number of values to enumerate
  74699. * @param callback the callback function called for each value
  74700. */
  74701. forEach(count: number, callback: (value: number, index: number) => void): void;
  74702. /**
  74703. * Positions
  74704. */
  74705. static readonly PositionKind: string;
  74706. /**
  74707. * Normals
  74708. */
  74709. static readonly NormalKind: string;
  74710. /**
  74711. * Tangents
  74712. */
  74713. static readonly TangentKind: string;
  74714. /**
  74715. * Texture coordinates
  74716. */
  74717. static readonly UVKind: string;
  74718. /**
  74719. * Texture coordinates 2
  74720. */
  74721. static readonly UV2Kind: string;
  74722. /**
  74723. * Texture coordinates 3
  74724. */
  74725. static readonly UV3Kind: string;
  74726. /**
  74727. * Texture coordinates 4
  74728. */
  74729. static readonly UV4Kind: string;
  74730. /**
  74731. * Texture coordinates 5
  74732. */
  74733. static readonly UV5Kind: string;
  74734. /**
  74735. * Texture coordinates 6
  74736. */
  74737. static readonly UV6Kind: string;
  74738. /**
  74739. * Colors
  74740. */
  74741. static readonly ColorKind: string;
  74742. /**
  74743. * Matrix indices (for bones)
  74744. */
  74745. static readonly MatricesIndicesKind: string;
  74746. /**
  74747. * Matrix weights (for bones)
  74748. */
  74749. static readonly MatricesWeightsKind: string;
  74750. /**
  74751. * Additional matrix indices (for bones)
  74752. */
  74753. static readonly MatricesIndicesExtraKind: string;
  74754. /**
  74755. * Additional matrix weights (for bones)
  74756. */
  74757. static readonly MatricesWeightsExtraKind: string;
  74758. /**
  74759. * Deduces the stride given a kind.
  74760. * @param kind The kind string to deduce
  74761. * @returns The deduced stride
  74762. */
  74763. static DeduceStride(kind: string): number;
  74764. /**
  74765. * Gets the byte length of the given type.
  74766. * @param type the type
  74767. * @returns the number of bytes
  74768. */
  74769. static GetTypeByteLength(type: number): number;
  74770. /**
  74771. * Enumerates each value of the given parameters as numbers.
  74772. * @param data the data to enumerate
  74773. * @param byteOffset the byte offset of the data
  74774. * @param byteStride the byte stride of the data
  74775. * @param componentCount the number of components per element
  74776. * @param componentType the type of the component
  74777. * @param count the number of values to enumerate
  74778. * @param normalized whether the data is normalized
  74779. * @param callback the callback function called for each value
  74780. */
  74781. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74782. private static _GetFloatValue;
  74783. }
  74784. }
  74785. declare module BABYLON {
  74786. /**
  74787. * @hidden
  74788. */
  74789. export class IntersectionInfo {
  74790. bu: Nullable<number>;
  74791. bv: Nullable<number>;
  74792. distance: number;
  74793. faceId: number;
  74794. subMeshId: number;
  74795. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74796. }
  74797. }
  74798. declare module BABYLON {
  74799. /**
  74800. * Represens a plane by the equation ax + by + cz + d = 0
  74801. */
  74802. export class Plane {
  74803. private static _TmpMatrix;
  74804. /**
  74805. * Normal of the plane (a,b,c)
  74806. */
  74807. normal: Vector3;
  74808. /**
  74809. * d component of the plane
  74810. */
  74811. d: number;
  74812. /**
  74813. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74814. * @param a a component of the plane
  74815. * @param b b component of the plane
  74816. * @param c c component of the plane
  74817. * @param d d component of the plane
  74818. */
  74819. constructor(a: number, b: number, c: number, d: number);
  74820. /**
  74821. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74822. */
  74823. asArray(): number[];
  74824. /**
  74825. * @returns a new plane copied from the current Plane.
  74826. */
  74827. clone(): Plane;
  74828. /**
  74829. * @returns the string "Plane".
  74830. */
  74831. getClassName(): string;
  74832. /**
  74833. * @returns the Plane hash code.
  74834. */
  74835. getHashCode(): number;
  74836. /**
  74837. * Normalize the current Plane in place.
  74838. * @returns the updated Plane.
  74839. */
  74840. normalize(): Plane;
  74841. /**
  74842. * Applies a transformation the plane and returns the result
  74843. * @param transformation the transformation matrix to be applied to the plane
  74844. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74845. */
  74846. transform(transformation: DeepImmutable<Matrix>): Plane;
  74847. /**
  74848. * Calcualtte the dot product between the point and the plane normal
  74849. * @param point point to calculate the dot product with
  74850. * @returns the dot product (float) of the point coordinates and the plane normal.
  74851. */
  74852. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74853. /**
  74854. * Updates the current Plane from the plane defined by the three given points.
  74855. * @param point1 one of the points used to contruct the plane
  74856. * @param point2 one of the points used to contruct the plane
  74857. * @param point3 one of the points used to contruct the plane
  74858. * @returns the updated Plane.
  74859. */
  74860. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74861. /**
  74862. * Checks if the plane is facing a given direction
  74863. * @param direction the direction to check if the plane is facing
  74864. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74865. * @returns True is the vector "direction" is the same side than the plane normal.
  74866. */
  74867. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74868. /**
  74869. * Calculates the distance to a point
  74870. * @param point point to calculate distance to
  74871. * @returns the signed distance (float) from the given point to the Plane.
  74872. */
  74873. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74874. /**
  74875. * Creates a plane from an array
  74876. * @param array the array to create a plane from
  74877. * @returns a new Plane from the given array.
  74878. */
  74879. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74880. /**
  74881. * Creates a plane from three points
  74882. * @param point1 point used to create the plane
  74883. * @param point2 point used to create the plane
  74884. * @param point3 point used to create the plane
  74885. * @returns a new Plane defined by the three given points.
  74886. */
  74887. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74888. /**
  74889. * Creates a plane from an origin point and a normal
  74890. * @param origin origin of the plane to be constructed
  74891. * @param normal normal of the plane to be constructed
  74892. * @returns a new Plane the normal vector to this plane at the given origin point.
  74893. * Note : the vector "normal" is updated because normalized.
  74894. */
  74895. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74896. /**
  74897. * Calculates the distance from a plane and a point
  74898. * @param origin origin of the plane to be constructed
  74899. * @param normal normal of the plane to be constructed
  74900. * @param point point to calculate distance to
  74901. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74902. */
  74903. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74904. }
  74905. }
  74906. declare module BABYLON {
  74907. /**
  74908. * Class used to store bounding sphere information
  74909. */
  74910. export class BoundingSphere {
  74911. /**
  74912. * Gets the center of the bounding sphere in local space
  74913. */
  74914. readonly center: Vector3;
  74915. /**
  74916. * Radius of the bounding sphere in local space
  74917. */
  74918. radius: number;
  74919. /**
  74920. * Gets the center of the bounding sphere in world space
  74921. */
  74922. readonly centerWorld: Vector3;
  74923. /**
  74924. * Radius of the bounding sphere in world space
  74925. */
  74926. radiusWorld: number;
  74927. /**
  74928. * Gets the minimum vector in local space
  74929. */
  74930. readonly minimum: Vector3;
  74931. /**
  74932. * Gets the maximum vector in local space
  74933. */
  74934. readonly maximum: Vector3;
  74935. private _worldMatrix;
  74936. private static readonly TmpVector3;
  74937. /**
  74938. * Creates a new bounding sphere
  74939. * @param min defines the minimum vector (in local space)
  74940. * @param max defines the maximum vector (in local space)
  74941. * @param worldMatrix defines the new world matrix
  74942. */
  74943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74944. /**
  74945. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74946. * @param min defines the new minimum vector (in local space)
  74947. * @param max defines the new maximum vector (in local space)
  74948. * @param worldMatrix defines the new world matrix
  74949. */
  74950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74951. /**
  74952. * Scale the current bounding sphere by applying a scale factor
  74953. * @param factor defines the scale factor to apply
  74954. * @returns the current bounding box
  74955. */
  74956. scale(factor: number): BoundingSphere;
  74957. /**
  74958. * Gets the world matrix of the bounding box
  74959. * @returns a matrix
  74960. */
  74961. getWorldMatrix(): DeepImmutable<Matrix>;
  74962. /** @hidden */
  74963. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74964. /**
  74965. * Tests if the bounding sphere is intersecting the frustum planes
  74966. * @param frustumPlanes defines the frustum planes to test
  74967. * @returns true if there is an intersection
  74968. */
  74969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74970. /**
  74971. * Tests if the bounding sphere center is in between the frustum planes.
  74972. * Used for optimistic fast inclusion.
  74973. * @param frustumPlanes defines the frustum planes to test
  74974. * @returns true if the sphere center is in between the frustum planes
  74975. */
  74976. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74977. /**
  74978. * Tests if a point is inside the bounding sphere
  74979. * @param point defines the point to test
  74980. * @returns true if the point is inside the bounding sphere
  74981. */
  74982. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74983. /**
  74984. * Checks if two sphere intersct
  74985. * @param sphere0 sphere 0
  74986. * @param sphere1 sphere 1
  74987. * @returns true if the speres intersect
  74988. */
  74989. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74990. }
  74991. }
  74992. declare module BABYLON {
  74993. /**
  74994. * Class used to store bounding box information
  74995. */
  74996. export class BoundingBox implements ICullable {
  74997. /**
  74998. * Gets the 8 vectors representing the bounding box in local space
  74999. */
  75000. readonly vectors: Vector3[];
  75001. /**
  75002. * Gets the center of the bounding box in local space
  75003. */
  75004. readonly center: Vector3;
  75005. /**
  75006. * Gets the center of the bounding box in world space
  75007. */
  75008. readonly centerWorld: Vector3;
  75009. /**
  75010. * Gets the extend size in local space
  75011. */
  75012. readonly extendSize: Vector3;
  75013. /**
  75014. * Gets the extend size in world space
  75015. */
  75016. readonly extendSizeWorld: Vector3;
  75017. /**
  75018. * Gets the OBB (object bounding box) directions
  75019. */
  75020. readonly directions: Vector3[];
  75021. /**
  75022. * Gets the 8 vectors representing the bounding box in world space
  75023. */
  75024. readonly vectorsWorld: Vector3[];
  75025. /**
  75026. * Gets the minimum vector in world space
  75027. */
  75028. readonly minimumWorld: Vector3;
  75029. /**
  75030. * Gets the maximum vector in world space
  75031. */
  75032. readonly maximumWorld: Vector3;
  75033. /**
  75034. * Gets the minimum vector in local space
  75035. */
  75036. readonly minimum: Vector3;
  75037. /**
  75038. * Gets the maximum vector in local space
  75039. */
  75040. readonly maximum: Vector3;
  75041. private _worldMatrix;
  75042. private static readonly TmpVector3;
  75043. /**
  75044. * @hidden
  75045. */
  75046. _tag: number;
  75047. /**
  75048. * Creates a new bounding box
  75049. * @param min defines the minimum vector (in local space)
  75050. * @param max defines the maximum vector (in local space)
  75051. * @param worldMatrix defines the new world matrix
  75052. */
  75053. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75054. /**
  75055. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75056. * @param min defines the new minimum vector (in local space)
  75057. * @param max defines the new maximum vector (in local space)
  75058. * @param worldMatrix defines the new world matrix
  75059. */
  75060. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75061. /**
  75062. * Scale the current bounding box by applying a scale factor
  75063. * @param factor defines the scale factor to apply
  75064. * @returns the current bounding box
  75065. */
  75066. scale(factor: number): BoundingBox;
  75067. /**
  75068. * Gets the world matrix of the bounding box
  75069. * @returns a matrix
  75070. */
  75071. getWorldMatrix(): DeepImmutable<Matrix>;
  75072. /** @hidden */
  75073. _update(world: DeepImmutable<Matrix>): void;
  75074. /**
  75075. * Tests if the bounding box is intersecting the frustum planes
  75076. * @param frustumPlanes defines the frustum planes to test
  75077. * @returns true if there is an intersection
  75078. */
  75079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75080. /**
  75081. * Tests if the bounding box is entirely inside the frustum planes
  75082. * @param frustumPlanes defines the frustum planes to test
  75083. * @returns true if there is an inclusion
  75084. */
  75085. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75086. /**
  75087. * Tests if a point is inside the bounding box
  75088. * @param point defines the point to test
  75089. * @returns true if the point is inside the bounding box
  75090. */
  75091. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75092. /**
  75093. * Tests if the bounding box intersects with a bounding sphere
  75094. * @param sphere defines the sphere to test
  75095. * @returns true if there is an intersection
  75096. */
  75097. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75098. /**
  75099. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75100. * @param min defines the min vector to use
  75101. * @param max defines the max vector to use
  75102. * @returns true if there is an intersection
  75103. */
  75104. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75105. /**
  75106. * Tests if two bounding boxes are intersections
  75107. * @param box0 defines the first box to test
  75108. * @param box1 defines the second box to test
  75109. * @returns true if there is an intersection
  75110. */
  75111. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75112. /**
  75113. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75114. * @param minPoint defines the minimum vector of the bounding box
  75115. * @param maxPoint defines the maximum vector of the bounding box
  75116. * @param sphereCenter defines the sphere center
  75117. * @param sphereRadius defines the sphere radius
  75118. * @returns true if there is an intersection
  75119. */
  75120. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75121. /**
  75122. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75123. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75124. * @param frustumPlanes defines the frustum planes to test
  75125. * @return true if there is an inclusion
  75126. */
  75127. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75128. /**
  75129. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75130. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75131. * @param frustumPlanes defines the frustum planes to test
  75132. * @return true if there is an intersection
  75133. */
  75134. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75135. }
  75136. }
  75137. declare module BABYLON {
  75138. /** @hidden */
  75139. export class Collider {
  75140. /** Define if a collision was found */
  75141. collisionFound: boolean;
  75142. /**
  75143. * Define last intersection point in local space
  75144. */
  75145. intersectionPoint: Vector3;
  75146. /**
  75147. * Define last collided mesh
  75148. */
  75149. collidedMesh: Nullable<AbstractMesh>;
  75150. private _collisionPoint;
  75151. private _planeIntersectionPoint;
  75152. private _tempVector;
  75153. private _tempVector2;
  75154. private _tempVector3;
  75155. private _tempVector4;
  75156. private _edge;
  75157. private _baseToVertex;
  75158. private _destinationPoint;
  75159. private _slidePlaneNormal;
  75160. private _displacementVector;
  75161. /** @hidden */
  75162. _radius: Vector3;
  75163. /** @hidden */
  75164. _retry: number;
  75165. private _velocity;
  75166. private _basePoint;
  75167. private _epsilon;
  75168. /** @hidden */
  75169. _velocityWorldLength: number;
  75170. /** @hidden */
  75171. _basePointWorld: Vector3;
  75172. private _velocityWorld;
  75173. private _normalizedVelocity;
  75174. /** @hidden */
  75175. _initialVelocity: Vector3;
  75176. /** @hidden */
  75177. _initialPosition: Vector3;
  75178. private _nearestDistance;
  75179. private _collisionMask;
  75180. collisionMask: number;
  75181. /**
  75182. * Gets the plane normal used to compute the sliding response (in local space)
  75183. */
  75184. readonly slidePlaneNormal: Vector3;
  75185. /** @hidden */
  75186. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75187. /** @hidden */
  75188. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75189. /** @hidden */
  75190. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75191. /** @hidden */
  75192. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75193. /** @hidden */
  75194. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75195. /** @hidden */
  75196. _getResponse(pos: Vector3, vel: Vector3): void;
  75197. }
  75198. }
  75199. declare module BABYLON {
  75200. /**
  75201. * Interface for cullable objects
  75202. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75203. */
  75204. export interface ICullable {
  75205. /**
  75206. * Checks if the object or part of the object is in the frustum
  75207. * @param frustumPlanes Camera near/planes
  75208. * @returns true if the object is in frustum otherwise false
  75209. */
  75210. isInFrustum(frustumPlanes: Plane[]): boolean;
  75211. /**
  75212. * Checks if a cullable object (mesh...) is in the camera frustum
  75213. * Unlike isInFrustum this cheks the full bounding box
  75214. * @param frustumPlanes Camera near/planes
  75215. * @returns true if the object is in frustum otherwise false
  75216. */
  75217. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75218. }
  75219. /**
  75220. * Info for a bounding data of a mesh
  75221. */
  75222. export class BoundingInfo implements ICullable {
  75223. /**
  75224. * Bounding box for the mesh
  75225. */
  75226. readonly boundingBox: BoundingBox;
  75227. /**
  75228. * Bounding sphere for the mesh
  75229. */
  75230. readonly boundingSphere: BoundingSphere;
  75231. private _isLocked;
  75232. private static readonly TmpVector3;
  75233. /**
  75234. * Constructs bounding info
  75235. * @param minimum min vector of the bounding box/sphere
  75236. * @param maximum max vector of the bounding box/sphere
  75237. * @param worldMatrix defines the new world matrix
  75238. */
  75239. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75240. /**
  75241. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75242. * @param min defines the new minimum vector (in local space)
  75243. * @param max defines the new maximum vector (in local space)
  75244. * @param worldMatrix defines the new world matrix
  75245. */
  75246. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75247. /**
  75248. * min vector of the bounding box/sphere
  75249. */
  75250. readonly minimum: Vector3;
  75251. /**
  75252. * max vector of the bounding box/sphere
  75253. */
  75254. readonly maximum: Vector3;
  75255. /**
  75256. * If the info is locked and won't be updated to avoid perf overhead
  75257. */
  75258. isLocked: boolean;
  75259. /**
  75260. * Updates the bounding sphere and box
  75261. * @param world world matrix to be used to update
  75262. */
  75263. update(world: DeepImmutable<Matrix>): void;
  75264. /**
  75265. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75266. * @param center New center of the bounding info
  75267. * @param extend New extend of the bounding info
  75268. * @returns the current bounding info
  75269. */
  75270. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75271. /**
  75272. * Scale the current bounding info by applying a scale factor
  75273. * @param factor defines the scale factor to apply
  75274. * @returns the current bounding info
  75275. */
  75276. scale(factor: number): BoundingInfo;
  75277. /**
  75278. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75279. * @param frustumPlanes defines the frustum to test
  75280. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75281. * @returns true if the bounding info is in the frustum planes
  75282. */
  75283. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75284. /**
  75285. * Gets the world distance between the min and max points of the bounding box
  75286. */
  75287. readonly diagonalLength: number;
  75288. /**
  75289. * Checks if a cullable object (mesh...) is in the camera frustum
  75290. * Unlike isInFrustum this cheks the full bounding box
  75291. * @param frustumPlanes Camera near/planes
  75292. * @returns true if the object is in frustum otherwise false
  75293. */
  75294. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75295. /** @hidden */
  75296. _checkCollision(collider: Collider): boolean;
  75297. /**
  75298. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75299. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75300. * @param point the point to check intersection with
  75301. * @returns if the point intersects
  75302. */
  75303. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75304. /**
  75305. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75306. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75307. * @param boundingInfo the bounding info to check intersection with
  75308. * @param precise if the intersection should be done using OBB
  75309. * @returns if the bounding info intersects
  75310. */
  75311. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75312. }
  75313. }
  75314. declare module BABYLON {
  75315. /**
  75316. * Extracts minimum and maximum values from a list of indexed positions
  75317. * @param positions defines the positions to use
  75318. * @param indices defines the indices to the positions
  75319. * @param indexStart defines the start index
  75320. * @param indexCount defines the end index
  75321. * @param bias defines bias value to add to the result
  75322. * @return minimum and maximum values
  75323. */
  75324. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75325. minimum: Vector3;
  75326. maximum: Vector3;
  75327. };
  75328. /**
  75329. * Extracts minimum and maximum values from a list of positions
  75330. * @param positions defines the positions to use
  75331. * @param start defines the start index in the positions array
  75332. * @param count defines the number of positions to handle
  75333. * @param bias defines bias value to add to the result
  75334. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75335. * @return minimum and maximum values
  75336. */
  75337. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75338. minimum: Vector3;
  75339. maximum: Vector3;
  75340. };
  75341. }
  75342. declare module BABYLON {
  75343. /** @hidden */
  75344. export class WebGLDataBuffer extends DataBuffer {
  75345. private _buffer;
  75346. constructor(resource: WebGLBuffer);
  75347. readonly underlyingResource: any;
  75348. }
  75349. }
  75350. declare module BABYLON {
  75351. /** @hidden */
  75352. export class WebGLPipelineContext implements IPipelineContext {
  75353. engine: ThinEngine;
  75354. program: Nullable<WebGLProgram>;
  75355. context?: WebGLRenderingContext;
  75356. vertexShader?: WebGLShader;
  75357. fragmentShader?: WebGLShader;
  75358. isParallelCompiled: boolean;
  75359. onCompiled?: () => void;
  75360. transformFeedback?: WebGLTransformFeedback | null;
  75361. readonly isAsync: boolean;
  75362. readonly isReady: boolean;
  75363. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75364. }
  75365. }
  75366. declare module BABYLON {
  75367. interface ThinEngine {
  75368. /**
  75369. * Create an uniform buffer
  75370. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75371. * @param elements defines the content of the uniform buffer
  75372. * @returns the webGL uniform buffer
  75373. */
  75374. createUniformBuffer(elements: FloatArray): DataBuffer;
  75375. /**
  75376. * Create a dynamic uniform buffer
  75377. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75378. * @param elements defines the content of the uniform buffer
  75379. * @returns the webGL uniform buffer
  75380. */
  75381. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75382. /**
  75383. * Update an existing uniform buffer
  75384. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75385. * @param uniformBuffer defines the target uniform buffer
  75386. * @param elements defines the content to update
  75387. * @param offset defines the offset in the uniform buffer where update should start
  75388. * @param count defines the size of the data to update
  75389. */
  75390. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75391. /**
  75392. * Bind an uniform buffer to the current webGL context
  75393. * @param buffer defines the buffer to bind
  75394. */
  75395. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75396. /**
  75397. * Bind a buffer to the current webGL context at a given location
  75398. * @param buffer defines the buffer to bind
  75399. * @param location defines the index where to bind the buffer
  75400. */
  75401. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75402. /**
  75403. * Bind a specific block at a given index in a specific shader program
  75404. * @param pipelineContext defines the pipeline context to use
  75405. * @param blockName defines the block name
  75406. * @param index defines the index where to bind the block
  75407. */
  75408. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75409. }
  75410. }
  75411. declare module BABYLON {
  75412. /**
  75413. * Uniform buffer objects.
  75414. *
  75415. * Handles blocks of uniform on the GPU.
  75416. *
  75417. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75418. *
  75419. * For more information, please refer to :
  75420. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75421. */
  75422. export class UniformBuffer {
  75423. private _engine;
  75424. private _buffer;
  75425. private _data;
  75426. private _bufferData;
  75427. private _dynamic?;
  75428. private _uniformLocations;
  75429. private _uniformSizes;
  75430. private _uniformLocationPointer;
  75431. private _needSync;
  75432. private _noUBO;
  75433. private _currentEffect;
  75434. /** @hidden */
  75435. _alreadyBound: boolean;
  75436. private static _MAX_UNIFORM_SIZE;
  75437. private static _tempBuffer;
  75438. /**
  75439. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75440. * This is dynamic to allow compat with webgl 1 and 2.
  75441. * You will need to pass the name of the uniform as well as the value.
  75442. */
  75443. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75444. /**
  75445. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75446. * This is dynamic to allow compat with webgl 1 and 2.
  75447. * You will need to pass the name of the uniform as well as the value.
  75448. */
  75449. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75450. /**
  75451. * Lambda to Update a single float in a uniform buffer.
  75452. * This is dynamic to allow compat with webgl 1 and 2.
  75453. * You will need to pass the name of the uniform as well as the value.
  75454. */
  75455. updateFloat: (name: string, x: number) => void;
  75456. /**
  75457. * Lambda to Update a vec2 of float in a uniform buffer.
  75458. * This is dynamic to allow compat with webgl 1 and 2.
  75459. * You will need to pass the name of the uniform as well as the value.
  75460. */
  75461. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75462. /**
  75463. * Lambda to Update a vec3 of float in a uniform buffer.
  75464. * This is dynamic to allow compat with webgl 1 and 2.
  75465. * You will need to pass the name of the uniform as well as the value.
  75466. */
  75467. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75468. /**
  75469. * Lambda to Update a vec4 of float in a uniform buffer.
  75470. * This is dynamic to allow compat with webgl 1 and 2.
  75471. * You will need to pass the name of the uniform as well as the value.
  75472. */
  75473. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75474. /**
  75475. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75476. * This is dynamic to allow compat with webgl 1 and 2.
  75477. * You will need to pass the name of the uniform as well as the value.
  75478. */
  75479. updateMatrix: (name: string, mat: Matrix) => void;
  75480. /**
  75481. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75482. * This is dynamic to allow compat with webgl 1 and 2.
  75483. * You will need to pass the name of the uniform as well as the value.
  75484. */
  75485. updateVector3: (name: string, vector: Vector3) => void;
  75486. /**
  75487. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75488. * This is dynamic to allow compat with webgl 1 and 2.
  75489. * You will need to pass the name of the uniform as well as the value.
  75490. */
  75491. updateVector4: (name: string, vector: Vector4) => void;
  75492. /**
  75493. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75494. * This is dynamic to allow compat with webgl 1 and 2.
  75495. * You will need to pass the name of the uniform as well as the value.
  75496. */
  75497. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75498. /**
  75499. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75500. * This is dynamic to allow compat with webgl 1 and 2.
  75501. * You will need to pass the name of the uniform as well as the value.
  75502. */
  75503. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75504. /**
  75505. * Instantiates a new Uniform buffer objects.
  75506. *
  75507. * Handles blocks of uniform on the GPU.
  75508. *
  75509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75510. *
  75511. * For more information, please refer to :
  75512. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75513. * @param engine Define the engine the buffer is associated with
  75514. * @param data Define the data contained in the buffer
  75515. * @param dynamic Define if the buffer is updatable
  75516. */
  75517. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75518. /**
  75519. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75520. * or just falling back on setUniformXXX calls.
  75521. */
  75522. readonly useUbo: boolean;
  75523. /**
  75524. * Indicates if the WebGL underlying uniform buffer is in sync
  75525. * with the javascript cache data.
  75526. */
  75527. readonly isSync: boolean;
  75528. /**
  75529. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75530. * Also, a dynamic UniformBuffer will disable cache verification and always
  75531. * update the underlying WebGL uniform buffer to the GPU.
  75532. * @returns if Dynamic, otherwise false
  75533. */
  75534. isDynamic(): boolean;
  75535. /**
  75536. * The data cache on JS side.
  75537. * @returns the underlying data as a float array
  75538. */
  75539. getData(): Float32Array;
  75540. /**
  75541. * The underlying WebGL Uniform buffer.
  75542. * @returns the webgl buffer
  75543. */
  75544. getBuffer(): Nullable<DataBuffer>;
  75545. /**
  75546. * std140 layout specifies how to align data within an UBO structure.
  75547. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75548. * for specs.
  75549. */
  75550. private _fillAlignment;
  75551. /**
  75552. * Adds an uniform in the buffer.
  75553. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75554. * for the layout to be correct !
  75555. * @param name Name of the uniform, as used in the uniform block in the shader.
  75556. * @param size Data size, or data directly.
  75557. */
  75558. addUniform(name: string, size: number | number[]): void;
  75559. /**
  75560. * Adds a Matrix 4x4 to the uniform buffer.
  75561. * @param name Name of the uniform, as used in the uniform block in the shader.
  75562. * @param mat A 4x4 matrix.
  75563. */
  75564. addMatrix(name: string, mat: Matrix): void;
  75565. /**
  75566. * Adds a vec2 to the uniform buffer.
  75567. * @param name Name of the uniform, as used in the uniform block in the shader.
  75568. * @param x Define the x component value of the vec2
  75569. * @param y Define the y component value of the vec2
  75570. */
  75571. addFloat2(name: string, x: number, y: number): void;
  75572. /**
  75573. * Adds a vec3 to the uniform buffer.
  75574. * @param name Name of the uniform, as used in the uniform block in the shader.
  75575. * @param x Define the x component value of the vec3
  75576. * @param y Define the y component value of the vec3
  75577. * @param z Define the z component value of the vec3
  75578. */
  75579. addFloat3(name: string, x: number, y: number, z: number): void;
  75580. /**
  75581. * Adds a vec3 to the uniform buffer.
  75582. * @param name Name of the uniform, as used in the uniform block in the shader.
  75583. * @param color Define the vec3 from a Color
  75584. */
  75585. addColor3(name: string, color: Color3): void;
  75586. /**
  75587. * Adds a vec4 to the uniform buffer.
  75588. * @param name Name of the uniform, as used in the uniform block in the shader.
  75589. * @param color Define the rgb components from a Color
  75590. * @param alpha Define the a component of the vec4
  75591. */
  75592. addColor4(name: string, color: Color3, alpha: number): void;
  75593. /**
  75594. * Adds a vec3 to the uniform buffer.
  75595. * @param name Name of the uniform, as used in the uniform block in the shader.
  75596. * @param vector Define the vec3 components from a Vector
  75597. */
  75598. addVector3(name: string, vector: Vector3): void;
  75599. /**
  75600. * Adds a Matrix 3x3 to the uniform buffer.
  75601. * @param name Name of the uniform, as used in the uniform block in the shader.
  75602. */
  75603. addMatrix3x3(name: string): void;
  75604. /**
  75605. * Adds a Matrix 2x2 to the uniform buffer.
  75606. * @param name Name of the uniform, as used in the uniform block in the shader.
  75607. */
  75608. addMatrix2x2(name: string): void;
  75609. /**
  75610. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75611. */
  75612. create(): void;
  75613. /** @hidden */
  75614. _rebuild(): void;
  75615. /**
  75616. * Updates the WebGL Uniform Buffer on the GPU.
  75617. * If the `dynamic` flag is set to true, no cache comparison is done.
  75618. * Otherwise, the buffer will be updated only if the cache differs.
  75619. */
  75620. update(): void;
  75621. /**
  75622. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75623. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75624. * @param data Define the flattened data
  75625. * @param size Define the size of the data.
  75626. */
  75627. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75628. private _valueCache;
  75629. private _cacheMatrix;
  75630. private _updateMatrix3x3ForUniform;
  75631. private _updateMatrix3x3ForEffect;
  75632. private _updateMatrix2x2ForEffect;
  75633. private _updateMatrix2x2ForUniform;
  75634. private _updateFloatForEffect;
  75635. private _updateFloatForUniform;
  75636. private _updateFloat2ForEffect;
  75637. private _updateFloat2ForUniform;
  75638. private _updateFloat3ForEffect;
  75639. private _updateFloat3ForUniform;
  75640. private _updateFloat4ForEffect;
  75641. private _updateFloat4ForUniform;
  75642. private _updateMatrixForEffect;
  75643. private _updateMatrixForUniform;
  75644. private _updateVector3ForEffect;
  75645. private _updateVector3ForUniform;
  75646. private _updateVector4ForEffect;
  75647. private _updateVector4ForUniform;
  75648. private _updateColor3ForEffect;
  75649. private _updateColor3ForUniform;
  75650. private _updateColor4ForEffect;
  75651. private _updateColor4ForUniform;
  75652. /**
  75653. * Sets a sampler uniform on the effect.
  75654. * @param name Define the name of the sampler.
  75655. * @param texture Define the texture to set in the sampler
  75656. */
  75657. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75658. /**
  75659. * Directly updates the value of the uniform in the cache AND on the GPU.
  75660. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75661. * @param data Define the flattened data
  75662. */
  75663. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75664. /**
  75665. * Binds this uniform buffer to an effect.
  75666. * @param effect Define the effect to bind the buffer to
  75667. * @param name Name of the uniform block in the shader.
  75668. */
  75669. bindToEffect(effect: Effect, name: string): void;
  75670. /**
  75671. * Disposes the uniform buffer.
  75672. */
  75673. dispose(): void;
  75674. }
  75675. }
  75676. declare module BABYLON {
  75677. /**
  75678. * Enum that determines the text-wrapping mode to use.
  75679. */
  75680. export enum InspectableType {
  75681. /**
  75682. * Checkbox for booleans
  75683. */
  75684. Checkbox = 0,
  75685. /**
  75686. * Sliders for numbers
  75687. */
  75688. Slider = 1,
  75689. /**
  75690. * Vector3
  75691. */
  75692. Vector3 = 2,
  75693. /**
  75694. * Quaternions
  75695. */
  75696. Quaternion = 3,
  75697. /**
  75698. * Color3
  75699. */
  75700. Color3 = 4,
  75701. /**
  75702. * String
  75703. */
  75704. String = 5
  75705. }
  75706. /**
  75707. * Interface used to define custom inspectable properties.
  75708. * This interface is used by the inspector to display custom property grids
  75709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75710. */
  75711. export interface IInspectable {
  75712. /**
  75713. * Gets the label to display
  75714. */
  75715. label: string;
  75716. /**
  75717. * Gets the name of the property to edit
  75718. */
  75719. propertyName: string;
  75720. /**
  75721. * Gets the type of the editor to use
  75722. */
  75723. type: InspectableType;
  75724. /**
  75725. * Gets the minimum value of the property when using in "slider" mode
  75726. */
  75727. min?: number;
  75728. /**
  75729. * Gets the maximum value of the property when using in "slider" mode
  75730. */
  75731. max?: number;
  75732. /**
  75733. * Gets the setp to use when using in "slider" mode
  75734. */
  75735. step?: number;
  75736. }
  75737. }
  75738. declare module BABYLON {
  75739. /**
  75740. * Class used to provide helper for timing
  75741. */
  75742. export class TimingTools {
  75743. /**
  75744. * Polyfill for setImmediate
  75745. * @param action defines the action to execute after the current execution block
  75746. */
  75747. static SetImmediate(action: () => void): void;
  75748. }
  75749. }
  75750. declare module BABYLON {
  75751. /**
  75752. * Class used to enable instatition of objects by class name
  75753. */
  75754. export class InstantiationTools {
  75755. /**
  75756. * Use this object to register external classes like custom textures or material
  75757. * to allow the laoders to instantiate them
  75758. */
  75759. static RegisteredExternalClasses: {
  75760. [key: string]: Object;
  75761. };
  75762. /**
  75763. * Tries to instantiate a new object from a given class name
  75764. * @param className defines the class name to instantiate
  75765. * @returns the new object or null if the system was not able to do the instantiation
  75766. */
  75767. static Instantiate(className: string): any;
  75768. }
  75769. }
  75770. declare module BABYLON {
  75771. /**
  75772. * Define options used to create a depth texture
  75773. */
  75774. export class DepthTextureCreationOptions {
  75775. /** Specifies whether or not a stencil should be allocated in the texture */
  75776. generateStencil?: boolean;
  75777. /** Specifies whether or not bilinear filtering is enable on the texture */
  75778. bilinearFiltering?: boolean;
  75779. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75780. comparisonFunction?: number;
  75781. /** Specifies if the created texture is a cube texture */
  75782. isCube?: boolean;
  75783. }
  75784. }
  75785. declare module BABYLON {
  75786. interface ThinEngine {
  75787. /**
  75788. * Creates a depth stencil cube texture.
  75789. * This is only available in WebGL 2.
  75790. * @param size The size of face edge in the cube texture.
  75791. * @param options The options defining the cube texture.
  75792. * @returns The cube texture
  75793. */
  75794. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75795. /**
  75796. * Creates a cube texture
  75797. * @param rootUrl defines the url where the files to load is located
  75798. * @param scene defines the current scene
  75799. * @param files defines the list of files to load (1 per face)
  75800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75801. * @param onLoad defines an optional callback raised when the texture is loaded
  75802. * @param onError defines an optional callback raised if there is an issue to load the texture
  75803. * @param format defines the format of the data
  75804. * @param forcedExtension defines the extension to use to pick the right loader
  75805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75808. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75809. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75810. * @returns the cube texture as an InternalTexture
  75811. */
  75812. 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;
  75813. /**
  75814. * Creates a cube texture
  75815. * @param rootUrl defines the url where the files to load is located
  75816. * @param scene defines the current scene
  75817. * @param files defines the list of files to load (1 per face)
  75818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75819. * @param onLoad defines an optional callback raised when the texture is loaded
  75820. * @param onError defines an optional callback raised if there is an issue to load the texture
  75821. * @param format defines the format of the data
  75822. * @param forcedExtension defines the extension to use to pick the right loader
  75823. * @returns the cube texture as an InternalTexture
  75824. */
  75825. 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;
  75826. /**
  75827. * Creates a cube texture
  75828. * @param rootUrl defines the url where the files to load is located
  75829. * @param scene defines the current scene
  75830. * @param files defines the list of files to load (1 per face)
  75831. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75832. * @param onLoad defines an optional callback raised when the texture is loaded
  75833. * @param onError defines an optional callback raised if there is an issue to load the texture
  75834. * @param format defines the format of the data
  75835. * @param forcedExtension defines the extension to use to pick the right loader
  75836. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75837. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75838. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75839. * @returns the cube texture as an InternalTexture
  75840. */
  75841. 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;
  75842. /** @hidden */
  75843. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75844. /** @hidden */
  75845. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75846. /** @hidden */
  75847. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75848. /** @hidden */
  75849. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75850. /**
  75851. * @hidden
  75852. */
  75853. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75854. }
  75855. }
  75856. declare module BABYLON {
  75857. /**
  75858. * Class for creating a cube texture
  75859. */
  75860. export class CubeTexture extends BaseTexture {
  75861. private _delayedOnLoad;
  75862. /**
  75863. * The url of the texture
  75864. */
  75865. url: string;
  75866. /**
  75867. * Gets or sets the center of the bounding box associated with the cube texture.
  75868. * It must define where the camera used to render the texture was set
  75869. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75870. */
  75871. boundingBoxPosition: Vector3;
  75872. private _boundingBoxSize;
  75873. /**
  75874. * Gets or sets the size of the bounding box associated with the cube texture
  75875. * When defined, the cubemap will switch to local mode
  75876. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75877. * @example https://www.babylonjs-playground.com/#RNASML
  75878. */
  75879. /**
  75880. * Returns the bounding box size
  75881. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75882. */
  75883. boundingBoxSize: Vector3;
  75884. protected _rotationY: number;
  75885. /**
  75886. * Sets texture matrix rotation angle around Y axis in radians.
  75887. */
  75888. /**
  75889. * Gets texture matrix rotation angle around Y axis radians.
  75890. */
  75891. rotationY: number;
  75892. /**
  75893. * Are mip maps generated for this texture or not.
  75894. */
  75895. readonly noMipmap: boolean;
  75896. private _noMipmap;
  75897. private _files;
  75898. protected _forcedExtension: Nullable<string>;
  75899. private _extensions;
  75900. private _textureMatrix;
  75901. private _format;
  75902. private _createPolynomials;
  75903. /** @hidden */
  75904. _prefiltered: boolean;
  75905. /**
  75906. * Creates a cube texture from an array of image urls
  75907. * @param files defines an array of image urls
  75908. * @param scene defines the hosting scene
  75909. * @param noMipmap specifies if mip maps are not used
  75910. * @returns a cube texture
  75911. */
  75912. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75913. /**
  75914. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75915. * @param url defines the url of the prefiltered texture
  75916. * @param scene defines the scene the texture is attached to
  75917. * @param forcedExtension defines the extension of the file if different from the url
  75918. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75919. * @return the prefiltered texture
  75920. */
  75921. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75922. /**
  75923. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75924. * as prefiltered data.
  75925. * @param rootUrl defines the url of the texture or the root name of the six images
  75926. * @param scene defines the scene the texture is attached to
  75927. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75928. * @param noMipmap defines if mipmaps should be created or not
  75929. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75930. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75931. * @param onError defines a callback triggered in case of error during load
  75932. * @param format defines the internal format to use for the texture once loaded
  75933. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75934. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75935. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75936. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75937. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75938. * @return the cube texture
  75939. */
  75940. 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);
  75941. /**
  75942. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75943. */
  75944. readonly isPrefiltered: boolean;
  75945. /**
  75946. * Get the current class name of the texture useful for serialization or dynamic coding.
  75947. * @returns "CubeTexture"
  75948. */
  75949. getClassName(): string;
  75950. /**
  75951. * Update the url (and optional buffer) of this texture if url was null during construction.
  75952. * @param url the url of the texture
  75953. * @param forcedExtension defines the extension to use
  75954. * @param onLoad callback called when the texture is loaded (defaults to null)
  75955. */
  75956. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75957. /**
  75958. * Delays loading of the cube texture
  75959. * @param forcedExtension defines the extension to use
  75960. */
  75961. delayLoad(forcedExtension?: string): void;
  75962. /**
  75963. * Returns the reflection texture matrix
  75964. * @returns the reflection texture matrix
  75965. */
  75966. getReflectionTextureMatrix(): Matrix;
  75967. /**
  75968. * Sets the reflection texture matrix
  75969. * @param value Reflection texture matrix
  75970. */
  75971. setReflectionTextureMatrix(value: Matrix): void;
  75972. /**
  75973. * Parses text to create a cube texture
  75974. * @param parsedTexture define the serialized text to read from
  75975. * @param scene defines the hosting scene
  75976. * @param rootUrl defines the root url of the cube texture
  75977. * @returns a cube texture
  75978. */
  75979. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75980. /**
  75981. * Makes a clone, or deep copy, of the cube texture
  75982. * @returns a new cube texture
  75983. */
  75984. clone(): CubeTexture;
  75985. }
  75986. }
  75987. declare module BABYLON {
  75988. /**
  75989. * Manages the defines for the Material
  75990. */
  75991. export class MaterialDefines {
  75992. /** @hidden */
  75993. protected _keys: string[];
  75994. private _isDirty;
  75995. /** @hidden */
  75996. _renderId: number;
  75997. /** @hidden */
  75998. _areLightsDirty: boolean;
  75999. /** @hidden */
  76000. _areLightsDisposed: boolean;
  76001. /** @hidden */
  76002. _areAttributesDirty: boolean;
  76003. /** @hidden */
  76004. _areTexturesDirty: boolean;
  76005. /** @hidden */
  76006. _areFresnelDirty: boolean;
  76007. /** @hidden */
  76008. _areMiscDirty: boolean;
  76009. /** @hidden */
  76010. _areImageProcessingDirty: boolean;
  76011. /** @hidden */
  76012. _normals: boolean;
  76013. /** @hidden */
  76014. _uvs: boolean;
  76015. /** @hidden */
  76016. _needNormals: boolean;
  76017. /** @hidden */
  76018. _needUVs: boolean;
  76019. [id: string]: any;
  76020. /**
  76021. * Specifies if the material needs to be re-calculated
  76022. */
  76023. readonly isDirty: boolean;
  76024. /**
  76025. * Marks the material to indicate that it has been re-calculated
  76026. */
  76027. markAsProcessed(): void;
  76028. /**
  76029. * Marks the material to indicate that it needs to be re-calculated
  76030. */
  76031. markAsUnprocessed(): void;
  76032. /**
  76033. * Marks the material to indicate all of its defines need to be re-calculated
  76034. */
  76035. markAllAsDirty(): void;
  76036. /**
  76037. * Marks the material to indicate that image processing needs to be re-calculated
  76038. */
  76039. markAsImageProcessingDirty(): void;
  76040. /**
  76041. * Marks the material to indicate the lights need to be re-calculated
  76042. * @param disposed Defines whether the light is dirty due to dispose or not
  76043. */
  76044. markAsLightDirty(disposed?: boolean): void;
  76045. /**
  76046. * Marks the attribute state as changed
  76047. */
  76048. markAsAttributesDirty(): void;
  76049. /**
  76050. * Marks the texture state as changed
  76051. */
  76052. markAsTexturesDirty(): void;
  76053. /**
  76054. * Marks the fresnel state as changed
  76055. */
  76056. markAsFresnelDirty(): void;
  76057. /**
  76058. * Marks the misc state as changed
  76059. */
  76060. markAsMiscDirty(): void;
  76061. /**
  76062. * Rebuilds the material defines
  76063. */
  76064. rebuild(): void;
  76065. /**
  76066. * Specifies if two material defines are equal
  76067. * @param other - A material define instance to compare to
  76068. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76069. */
  76070. isEqual(other: MaterialDefines): boolean;
  76071. /**
  76072. * Clones this instance's defines to another instance
  76073. * @param other - material defines to clone values to
  76074. */
  76075. cloneTo(other: MaterialDefines): void;
  76076. /**
  76077. * Resets the material define values
  76078. */
  76079. reset(): void;
  76080. /**
  76081. * Converts the material define values to a string
  76082. * @returns - String of material define information
  76083. */
  76084. toString(): string;
  76085. }
  76086. }
  76087. declare module BABYLON {
  76088. /**
  76089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76091. * 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;
  76092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76093. */
  76094. export class ColorCurves {
  76095. private _dirty;
  76096. private _tempColor;
  76097. private _globalCurve;
  76098. private _highlightsCurve;
  76099. private _midtonesCurve;
  76100. private _shadowsCurve;
  76101. private _positiveCurve;
  76102. private _negativeCurve;
  76103. private _globalHue;
  76104. private _globalDensity;
  76105. private _globalSaturation;
  76106. private _globalExposure;
  76107. /**
  76108. * Gets the global Hue value.
  76109. * 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).
  76110. */
  76111. /**
  76112. * Sets the global Hue value.
  76113. * 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).
  76114. */
  76115. globalHue: number;
  76116. /**
  76117. * Gets the global Density value.
  76118. * 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.
  76119. * Values less than zero provide a filter of opposite hue.
  76120. */
  76121. /**
  76122. * Sets the global Density value.
  76123. * 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.
  76124. * Values less than zero provide a filter of opposite hue.
  76125. */
  76126. globalDensity: number;
  76127. /**
  76128. * Gets the global Saturation value.
  76129. * 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.
  76130. */
  76131. /**
  76132. * Sets the global Saturation value.
  76133. * 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.
  76134. */
  76135. globalSaturation: number;
  76136. /**
  76137. * Gets the global Exposure value.
  76138. * 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.
  76139. */
  76140. /**
  76141. * Sets the global Exposure value.
  76142. * 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.
  76143. */
  76144. globalExposure: number;
  76145. private _highlightsHue;
  76146. private _highlightsDensity;
  76147. private _highlightsSaturation;
  76148. private _highlightsExposure;
  76149. /**
  76150. * Gets the highlights Hue value.
  76151. * 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).
  76152. */
  76153. /**
  76154. * Sets the highlights Hue value.
  76155. * 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).
  76156. */
  76157. highlightsHue: number;
  76158. /**
  76159. * Gets the highlights Density value.
  76160. * 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.
  76161. * Values less than zero provide a filter of opposite hue.
  76162. */
  76163. /**
  76164. * Sets the highlights Density value.
  76165. * 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.
  76166. * Values less than zero provide a filter of opposite hue.
  76167. */
  76168. highlightsDensity: number;
  76169. /**
  76170. * Gets the highlights Saturation value.
  76171. * 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.
  76172. */
  76173. /**
  76174. * Sets the highlights Saturation value.
  76175. * 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.
  76176. */
  76177. highlightsSaturation: number;
  76178. /**
  76179. * Gets the highlights Exposure value.
  76180. * 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.
  76181. */
  76182. /**
  76183. * Sets the highlights Exposure value.
  76184. * 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.
  76185. */
  76186. highlightsExposure: number;
  76187. private _midtonesHue;
  76188. private _midtonesDensity;
  76189. private _midtonesSaturation;
  76190. private _midtonesExposure;
  76191. /**
  76192. * Gets the midtones Hue value.
  76193. * 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).
  76194. */
  76195. /**
  76196. * Sets the midtones Hue value.
  76197. * 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).
  76198. */
  76199. midtonesHue: number;
  76200. /**
  76201. * Gets the midtones Density value.
  76202. * 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.
  76203. * Values less than zero provide a filter of opposite hue.
  76204. */
  76205. /**
  76206. * Sets the midtones Density value.
  76207. * 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.
  76208. * Values less than zero provide a filter of opposite hue.
  76209. */
  76210. midtonesDensity: number;
  76211. /**
  76212. * Gets the midtones Saturation value.
  76213. * 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.
  76214. */
  76215. /**
  76216. * Sets the midtones Saturation value.
  76217. * 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.
  76218. */
  76219. midtonesSaturation: number;
  76220. /**
  76221. * Gets the midtones Exposure value.
  76222. * 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.
  76223. */
  76224. /**
  76225. * Sets the midtones Exposure value.
  76226. * 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.
  76227. */
  76228. midtonesExposure: number;
  76229. private _shadowsHue;
  76230. private _shadowsDensity;
  76231. private _shadowsSaturation;
  76232. private _shadowsExposure;
  76233. /**
  76234. * Gets the shadows Hue value.
  76235. * 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).
  76236. */
  76237. /**
  76238. * Sets the shadows Hue value.
  76239. * 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).
  76240. */
  76241. shadowsHue: number;
  76242. /**
  76243. * Gets the shadows Density value.
  76244. * 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.
  76245. * Values less than zero provide a filter of opposite hue.
  76246. */
  76247. /**
  76248. * Sets the shadows Density value.
  76249. * 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.
  76250. * Values less than zero provide a filter of opposite hue.
  76251. */
  76252. shadowsDensity: number;
  76253. /**
  76254. * Gets the shadows Saturation value.
  76255. * 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.
  76256. */
  76257. /**
  76258. * Sets the shadows Saturation value.
  76259. * 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.
  76260. */
  76261. shadowsSaturation: number;
  76262. /**
  76263. * Gets the shadows Exposure value.
  76264. * 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.
  76265. */
  76266. /**
  76267. * Sets the shadows Exposure value.
  76268. * 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.
  76269. */
  76270. shadowsExposure: number;
  76271. /**
  76272. * Returns the class name
  76273. * @returns The class name
  76274. */
  76275. getClassName(): string;
  76276. /**
  76277. * Binds the color curves to the shader.
  76278. * @param colorCurves The color curve to bind
  76279. * @param effect The effect to bind to
  76280. * @param positiveUniform The positive uniform shader parameter
  76281. * @param neutralUniform The neutral uniform shader parameter
  76282. * @param negativeUniform The negative uniform shader parameter
  76283. */
  76284. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76285. /**
  76286. * Prepare the list of uniforms associated with the ColorCurves effects.
  76287. * @param uniformsList The list of uniforms used in the effect
  76288. */
  76289. static PrepareUniforms(uniformsList: string[]): void;
  76290. /**
  76291. * Returns color grading data based on a hue, density, saturation and exposure value.
  76292. * @param filterHue The hue of the color filter.
  76293. * @param filterDensity The density of the color filter.
  76294. * @param saturation The saturation.
  76295. * @param exposure The exposure.
  76296. * @param result The result data container.
  76297. */
  76298. private getColorGradingDataToRef;
  76299. /**
  76300. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76301. * @param value The input slider value in range [-100,100].
  76302. * @returns Adjusted value.
  76303. */
  76304. private static applyColorGradingSliderNonlinear;
  76305. /**
  76306. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76307. * @param hue The hue (H) input.
  76308. * @param saturation The saturation (S) input.
  76309. * @param brightness The brightness (B) input.
  76310. * @result An RGBA color represented as Vector4.
  76311. */
  76312. private static fromHSBToRef;
  76313. /**
  76314. * Returns a value clamped between min and max
  76315. * @param value The value to clamp
  76316. * @param min The minimum of value
  76317. * @param max The maximum of value
  76318. * @returns The clamped value.
  76319. */
  76320. private static clamp;
  76321. /**
  76322. * Clones the current color curve instance.
  76323. * @return The cloned curves
  76324. */
  76325. clone(): ColorCurves;
  76326. /**
  76327. * Serializes the current color curve instance to a json representation.
  76328. * @return a JSON representation
  76329. */
  76330. serialize(): any;
  76331. /**
  76332. * Parses the color curve from a json representation.
  76333. * @param source the JSON source to parse
  76334. * @return The parsed curves
  76335. */
  76336. static Parse(source: any): ColorCurves;
  76337. }
  76338. }
  76339. declare module BABYLON {
  76340. /**
  76341. * Interface to follow in your material defines to integrate easily the
  76342. * Image proccessing functions.
  76343. * @hidden
  76344. */
  76345. export interface IImageProcessingConfigurationDefines {
  76346. IMAGEPROCESSING: boolean;
  76347. VIGNETTE: boolean;
  76348. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76349. VIGNETTEBLENDMODEOPAQUE: boolean;
  76350. TONEMAPPING: boolean;
  76351. TONEMAPPING_ACES: boolean;
  76352. CONTRAST: boolean;
  76353. EXPOSURE: boolean;
  76354. COLORCURVES: boolean;
  76355. COLORGRADING: boolean;
  76356. COLORGRADING3D: boolean;
  76357. SAMPLER3DGREENDEPTH: boolean;
  76358. SAMPLER3DBGRMAP: boolean;
  76359. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76360. }
  76361. /**
  76362. * @hidden
  76363. */
  76364. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76365. IMAGEPROCESSING: boolean;
  76366. VIGNETTE: boolean;
  76367. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76368. VIGNETTEBLENDMODEOPAQUE: boolean;
  76369. TONEMAPPING: boolean;
  76370. TONEMAPPING_ACES: boolean;
  76371. CONTRAST: boolean;
  76372. COLORCURVES: boolean;
  76373. COLORGRADING: boolean;
  76374. COLORGRADING3D: boolean;
  76375. SAMPLER3DGREENDEPTH: boolean;
  76376. SAMPLER3DBGRMAP: boolean;
  76377. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76378. EXPOSURE: boolean;
  76379. constructor();
  76380. }
  76381. /**
  76382. * This groups together the common properties used for image processing either in direct forward pass
  76383. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76384. * or not.
  76385. */
  76386. export class ImageProcessingConfiguration {
  76387. /**
  76388. * Default tone mapping applied in BabylonJS.
  76389. */
  76390. static readonly TONEMAPPING_STANDARD: number;
  76391. /**
  76392. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76393. * to other engines rendering to increase portability.
  76394. */
  76395. static readonly TONEMAPPING_ACES: number;
  76396. /**
  76397. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76398. */
  76399. colorCurves: Nullable<ColorCurves>;
  76400. private _colorCurvesEnabled;
  76401. /**
  76402. * Gets wether the color curves effect is enabled.
  76403. */
  76404. /**
  76405. * Sets wether the color curves effect is enabled.
  76406. */
  76407. colorCurvesEnabled: boolean;
  76408. private _colorGradingTexture;
  76409. /**
  76410. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76411. */
  76412. /**
  76413. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76414. */
  76415. colorGradingTexture: Nullable<BaseTexture>;
  76416. private _colorGradingEnabled;
  76417. /**
  76418. * Gets wether the color grading effect is enabled.
  76419. */
  76420. /**
  76421. * Sets wether the color grading effect is enabled.
  76422. */
  76423. colorGradingEnabled: boolean;
  76424. private _colorGradingWithGreenDepth;
  76425. /**
  76426. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76427. */
  76428. /**
  76429. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76430. */
  76431. colorGradingWithGreenDepth: boolean;
  76432. private _colorGradingBGR;
  76433. /**
  76434. * Gets wether the color grading texture contains BGR values.
  76435. */
  76436. /**
  76437. * Sets wether the color grading texture contains BGR values.
  76438. */
  76439. colorGradingBGR: boolean;
  76440. /** @hidden */
  76441. _exposure: number;
  76442. /**
  76443. * Gets the Exposure used in the effect.
  76444. */
  76445. /**
  76446. * Sets the Exposure used in the effect.
  76447. */
  76448. exposure: number;
  76449. private _toneMappingEnabled;
  76450. /**
  76451. * Gets wether the tone mapping effect is enabled.
  76452. */
  76453. /**
  76454. * Sets wether the tone mapping effect is enabled.
  76455. */
  76456. toneMappingEnabled: boolean;
  76457. private _toneMappingType;
  76458. /**
  76459. * Gets the type of tone mapping effect.
  76460. */
  76461. /**
  76462. * Sets the type of tone mapping effect used in BabylonJS.
  76463. */
  76464. toneMappingType: number;
  76465. protected _contrast: number;
  76466. /**
  76467. * Gets the contrast used in the effect.
  76468. */
  76469. /**
  76470. * Sets the contrast used in the effect.
  76471. */
  76472. contrast: number;
  76473. /**
  76474. * Vignette stretch size.
  76475. */
  76476. vignetteStretch: number;
  76477. /**
  76478. * Vignette centre X Offset.
  76479. */
  76480. vignetteCentreX: number;
  76481. /**
  76482. * Vignette centre Y Offset.
  76483. */
  76484. vignetteCentreY: number;
  76485. /**
  76486. * Vignette weight or intensity of the vignette effect.
  76487. */
  76488. vignetteWeight: number;
  76489. /**
  76490. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76491. * if vignetteEnabled is set to true.
  76492. */
  76493. vignetteColor: Color4;
  76494. /**
  76495. * Camera field of view used by the Vignette effect.
  76496. */
  76497. vignetteCameraFov: number;
  76498. private _vignetteBlendMode;
  76499. /**
  76500. * Gets the vignette blend mode allowing different kind of effect.
  76501. */
  76502. /**
  76503. * Sets the vignette blend mode allowing different kind of effect.
  76504. */
  76505. vignetteBlendMode: number;
  76506. private _vignetteEnabled;
  76507. /**
  76508. * Gets wether the vignette effect is enabled.
  76509. */
  76510. /**
  76511. * Sets wether the vignette effect is enabled.
  76512. */
  76513. vignetteEnabled: boolean;
  76514. private _applyByPostProcess;
  76515. /**
  76516. * Gets wether the image processing is applied through a post process or not.
  76517. */
  76518. /**
  76519. * Sets wether the image processing is applied through a post process or not.
  76520. */
  76521. applyByPostProcess: boolean;
  76522. private _isEnabled;
  76523. /**
  76524. * Gets wether the image processing is enabled or not.
  76525. */
  76526. /**
  76527. * Sets wether the image processing is enabled or not.
  76528. */
  76529. isEnabled: boolean;
  76530. /**
  76531. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76532. */
  76533. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76534. /**
  76535. * Method called each time the image processing information changes requires to recompile the effect.
  76536. */
  76537. protected _updateParameters(): void;
  76538. /**
  76539. * Gets the current class name.
  76540. * @return "ImageProcessingConfiguration"
  76541. */
  76542. getClassName(): string;
  76543. /**
  76544. * Prepare the list of uniforms associated with the Image Processing effects.
  76545. * @param uniforms The list of uniforms used in the effect
  76546. * @param defines the list of defines currently in use
  76547. */
  76548. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76549. /**
  76550. * Prepare the list of samplers associated with the Image Processing effects.
  76551. * @param samplersList The list of uniforms used in the effect
  76552. * @param defines the list of defines currently in use
  76553. */
  76554. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76555. /**
  76556. * Prepare the list of defines associated to the shader.
  76557. * @param defines the list of defines to complete
  76558. * @param forPostProcess Define if we are currently in post process mode or not
  76559. */
  76560. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76561. /**
  76562. * Returns true if all the image processing information are ready.
  76563. * @returns True if ready, otherwise, false
  76564. */
  76565. isReady(): boolean;
  76566. /**
  76567. * Binds the image processing to the shader.
  76568. * @param effect The effect to bind to
  76569. * @param overrideAspectRatio Override the aspect ratio of the effect
  76570. */
  76571. bind(effect: Effect, overrideAspectRatio?: number): void;
  76572. /**
  76573. * Clones the current image processing instance.
  76574. * @return The cloned image processing
  76575. */
  76576. clone(): ImageProcessingConfiguration;
  76577. /**
  76578. * Serializes the current image processing instance to a json representation.
  76579. * @return a JSON representation
  76580. */
  76581. serialize(): any;
  76582. /**
  76583. * Parses the image processing from a json representation.
  76584. * @param source the JSON source to parse
  76585. * @return The parsed image processing
  76586. */
  76587. static Parse(source: any): ImageProcessingConfiguration;
  76588. private static _VIGNETTEMODE_MULTIPLY;
  76589. private static _VIGNETTEMODE_OPAQUE;
  76590. /**
  76591. * Used to apply the vignette as a mix with the pixel color.
  76592. */
  76593. static readonly VIGNETTEMODE_MULTIPLY: number;
  76594. /**
  76595. * Used to apply the vignette as a replacement of the pixel color.
  76596. */
  76597. static readonly VIGNETTEMODE_OPAQUE: number;
  76598. }
  76599. }
  76600. declare module BABYLON {
  76601. /** @hidden */
  76602. export var postprocessVertexShader: {
  76603. name: string;
  76604. shader: string;
  76605. };
  76606. }
  76607. declare module BABYLON {
  76608. interface ThinEngine {
  76609. /**
  76610. * Creates a new render target texture
  76611. * @param size defines the size of the texture
  76612. * @param options defines the options used to create the texture
  76613. * @returns a new render target texture stored in an InternalTexture
  76614. */
  76615. createRenderTargetTexture(size: number | {
  76616. width: number;
  76617. height: number;
  76618. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76619. /**
  76620. * Creates a depth stencil texture.
  76621. * This is only available in WebGL 2 or with the depth texture extension available.
  76622. * @param size The size of face edge in the texture.
  76623. * @param options The options defining the texture.
  76624. * @returns The texture
  76625. */
  76626. createDepthStencilTexture(size: number | {
  76627. width: number;
  76628. height: number;
  76629. }, options: DepthTextureCreationOptions): InternalTexture;
  76630. /** @hidden */
  76631. _createDepthStencilTexture(size: number | {
  76632. width: number;
  76633. height: number;
  76634. }, options: DepthTextureCreationOptions): InternalTexture;
  76635. }
  76636. }
  76637. declare module BABYLON {
  76638. /** Defines supported spaces */
  76639. export enum Space {
  76640. /** Local (object) space */
  76641. LOCAL = 0,
  76642. /** World space */
  76643. WORLD = 1,
  76644. /** Bone space */
  76645. BONE = 2
  76646. }
  76647. /** Defines the 3 main axes */
  76648. export class Axis {
  76649. /** X axis */
  76650. static X: Vector3;
  76651. /** Y axis */
  76652. static Y: Vector3;
  76653. /** Z axis */
  76654. static Z: Vector3;
  76655. }
  76656. }
  76657. declare module BABYLON {
  76658. /**
  76659. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76660. * This is the base of the follow, arc rotate cameras and Free camera
  76661. * @see http://doc.babylonjs.com/features/cameras
  76662. */
  76663. export class TargetCamera extends Camera {
  76664. private static _RigCamTransformMatrix;
  76665. private static _TargetTransformMatrix;
  76666. private static _TargetFocalPoint;
  76667. /**
  76668. * Define the current direction the camera is moving to
  76669. */
  76670. cameraDirection: Vector3;
  76671. /**
  76672. * Define the current rotation the camera is rotating to
  76673. */
  76674. cameraRotation: Vector2;
  76675. /**
  76676. * When set, the up vector of the camera will be updated by the rotation of the camera
  76677. */
  76678. updateUpVectorFromRotation: boolean;
  76679. private _tmpQuaternion;
  76680. /**
  76681. * Define the current rotation of the camera
  76682. */
  76683. rotation: Vector3;
  76684. /**
  76685. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76686. */
  76687. rotationQuaternion: Quaternion;
  76688. /**
  76689. * Define the current speed of the camera
  76690. */
  76691. speed: number;
  76692. /**
  76693. * Add constraint to the camera to prevent it to move freely in all directions and
  76694. * around all axis.
  76695. */
  76696. noRotationConstraint: boolean;
  76697. /**
  76698. * Define the current target of the camera as an object or a position.
  76699. */
  76700. lockedTarget: any;
  76701. /** @hidden */
  76702. _currentTarget: Vector3;
  76703. /** @hidden */
  76704. _initialFocalDistance: number;
  76705. /** @hidden */
  76706. _viewMatrix: Matrix;
  76707. /** @hidden */
  76708. _camMatrix: Matrix;
  76709. /** @hidden */
  76710. _cameraTransformMatrix: Matrix;
  76711. /** @hidden */
  76712. _cameraRotationMatrix: Matrix;
  76713. /** @hidden */
  76714. _referencePoint: Vector3;
  76715. /** @hidden */
  76716. _transformedReferencePoint: Vector3;
  76717. protected _globalCurrentTarget: Vector3;
  76718. protected _globalCurrentUpVector: Vector3;
  76719. /** @hidden */
  76720. _reset: () => void;
  76721. private _defaultUp;
  76722. /**
  76723. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76724. * This is the base of the follow, arc rotate cameras and Free camera
  76725. * @see http://doc.babylonjs.com/features/cameras
  76726. * @param name Defines the name of the camera in the scene
  76727. * @param position Defines the start position of the camera in the scene
  76728. * @param scene Defines the scene the camera belongs to
  76729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76730. */
  76731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76732. /**
  76733. * Gets the position in front of the camera at a given distance.
  76734. * @param distance The distance from the camera we want the position to be
  76735. * @returns the position
  76736. */
  76737. getFrontPosition(distance: number): Vector3;
  76738. /** @hidden */
  76739. _getLockedTargetPosition(): Nullable<Vector3>;
  76740. private _storedPosition;
  76741. private _storedRotation;
  76742. private _storedRotationQuaternion;
  76743. /**
  76744. * Store current camera state of the camera (fov, position, rotation, etc..)
  76745. * @returns the camera
  76746. */
  76747. storeState(): Camera;
  76748. /**
  76749. * Restored camera state. You must call storeState() first
  76750. * @returns whether it was successful or not
  76751. * @hidden
  76752. */
  76753. _restoreStateValues(): boolean;
  76754. /** @hidden */
  76755. _initCache(): void;
  76756. /** @hidden */
  76757. _updateCache(ignoreParentClass?: boolean): void;
  76758. /** @hidden */
  76759. _isSynchronizedViewMatrix(): boolean;
  76760. /** @hidden */
  76761. _computeLocalCameraSpeed(): number;
  76762. /**
  76763. * Defines the target the camera should look at.
  76764. * @param target Defines the new target as a Vector or a mesh
  76765. */
  76766. setTarget(target: Vector3): void;
  76767. /**
  76768. * Return the current target position of the camera. This value is expressed in local space.
  76769. * @returns the target position
  76770. */
  76771. getTarget(): Vector3;
  76772. /** @hidden */
  76773. _decideIfNeedsToMove(): boolean;
  76774. /** @hidden */
  76775. _updatePosition(): void;
  76776. /** @hidden */
  76777. _checkInputs(): void;
  76778. protected _updateCameraRotationMatrix(): void;
  76779. /**
  76780. * 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)
  76781. * @returns the current camera
  76782. */
  76783. private _rotateUpVectorWithCameraRotationMatrix;
  76784. private _cachedRotationZ;
  76785. private _cachedQuaternionRotationZ;
  76786. /** @hidden */
  76787. _getViewMatrix(): Matrix;
  76788. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76789. /**
  76790. * @hidden
  76791. */
  76792. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76793. /**
  76794. * @hidden
  76795. */
  76796. _updateRigCameras(): void;
  76797. private _getRigCamPositionAndTarget;
  76798. /**
  76799. * Gets the current object class name.
  76800. * @return the class name
  76801. */
  76802. getClassName(): string;
  76803. }
  76804. }
  76805. declare module BABYLON {
  76806. /**
  76807. * Gather the list of keyboard event types as constants.
  76808. */
  76809. export class KeyboardEventTypes {
  76810. /**
  76811. * The keydown event is fired when a key becomes active (pressed).
  76812. */
  76813. static readonly KEYDOWN: number;
  76814. /**
  76815. * The keyup event is fired when a key has been released.
  76816. */
  76817. static readonly KEYUP: number;
  76818. }
  76819. /**
  76820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76821. */
  76822. export class KeyboardInfo {
  76823. /**
  76824. * Defines the type of event (KeyboardEventTypes)
  76825. */
  76826. type: number;
  76827. /**
  76828. * Defines the related dom event
  76829. */
  76830. event: KeyboardEvent;
  76831. /**
  76832. * Instantiates a new keyboard info.
  76833. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76834. * @param type Defines the type of event (KeyboardEventTypes)
  76835. * @param event Defines the related dom event
  76836. */
  76837. constructor(
  76838. /**
  76839. * Defines the type of event (KeyboardEventTypes)
  76840. */
  76841. type: number,
  76842. /**
  76843. * Defines the related dom event
  76844. */
  76845. event: KeyboardEvent);
  76846. }
  76847. /**
  76848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76849. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76850. */
  76851. export class KeyboardInfoPre extends KeyboardInfo {
  76852. /**
  76853. * Defines the type of event (KeyboardEventTypes)
  76854. */
  76855. type: number;
  76856. /**
  76857. * Defines the related dom event
  76858. */
  76859. event: KeyboardEvent;
  76860. /**
  76861. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76862. */
  76863. skipOnPointerObservable: boolean;
  76864. /**
  76865. * Instantiates a new keyboard pre info.
  76866. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76867. * @param type Defines the type of event (KeyboardEventTypes)
  76868. * @param event Defines the related dom event
  76869. */
  76870. constructor(
  76871. /**
  76872. * Defines the type of event (KeyboardEventTypes)
  76873. */
  76874. type: number,
  76875. /**
  76876. * Defines the related dom event
  76877. */
  76878. event: KeyboardEvent);
  76879. }
  76880. }
  76881. declare module BABYLON {
  76882. /**
  76883. * Manage the keyboard inputs to control the movement of a free camera.
  76884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76885. */
  76886. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76887. /**
  76888. * Defines the camera the input is attached to.
  76889. */
  76890. camera: FreeCamera;
  76891. /**
  76892. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76893. */
  76894. keysUp: number[];
  76895. /**
  76896. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76897. */
  76898. keysDown: number[];
  76899. /**
  76900. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76901. */
  76902. keysLeft: number[];
  76903. /**
  76904. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76905. */
  76906. keysRight: number[];
  76907. private _keys;
  76908. private _onCanvasBlurObserver;
  76909. private _onKeyboardObserver;
  76910. private _engine;
  76911. private _scene;
  76912. /**
  76913. * Attach the input controls to a specific dom element to get the input from.
  76914. * @param element Defines the element the controls should be listened from
  76915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76916. */
  76917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76918. /**
  76919. * Detach the current controls from the specified dom element.
  76920. * @param element Defines the element to stop listening the inputs from
  76921. */
  76922. detachControl(element: Nullable<HTMLElement>): void;
  76923. /**
  76924. * Update the current camera state depending on the inputs that have been used this frame.
  76925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76926. */
  76927. checkInputs(): void;
  76928. /**
  76929. * Gets the class name of the current intput.
  76930. * @returns the class name
  76931. */
  76932. getClassName(): string;
  76933. /** @hidden */
  76934. _onLostFocus(): void;
  76935. /**
  76936. * Get the friendly name associated with the input class.
  76937. * @returns the input friendly name
  76938. */
  76939. getSimpleName(): string;
  76940. }
  76941. }
  76942. declare module BABYLON {
  76943. /**
  76944. * Interface describing all the common properties and methods a shadow light needs to implement.
  76945. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76946. * as well as binding the different shadow properties to the effects.
  76947. */
  76948. export interface IShadowLight extends Light {
  76949. /**
  76950. * The light id in the scene (used in scene.findLighById for instance)
  76951. */
  76952. id: string;
  76953. /**
  76954. * The position the shdow will be casted from.
  76955. */
  76956. position: Vector3;
  76957. /**
  76958. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76959. */
  76960. direction: Vector3;
  76961. /**
  76962. * The transformed position. Position of the light in world space taking parenting in account.
  76963. */
  76964. transformedPosition: Vector3;
  76965. /**
  76966. * The transformed direction. Direction of the light in world space taking parenting in account.
  76967. */
  76968. transformedDirection: Vector3;
  76969. /**
  76970. * The friendly name of the light in the scene.
  76971. */
  76972. name: string;
  76973. /**
  76974. * Defines the shadow projection clipping minimum z value.
  76975. */
  76976. shadowMinZ: number;
  76977. /**
  76978. * Defines the shadow projection clipping maximum z value.
  76979. */
  76980. shadowMaxZ: number;
  76981. /**
  76982. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76983. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76984. */
  76985. computeTransformedInformation(): boolean;
  76986. /**
  76987. * Gets the scene the light belongs to.
  76988. * @returns The scene
  76989. */
  76990. getScene(): Scene;
  76991. /**
  76992. * Callback defining a custom Projection Matrix Builder.
  76993. * This can be used to override the default projection matrix computation.
  76994. */
  76995. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76996. /**
  76997. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76998. * @param matrix The materix to updated with the projection information
  76999. * @param viewMatrix The transform matrix of the light
  77000. * @param renderList The list of mesh to render in the map
  77001. * @returns The current light
  77002. */
  77003. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77004. /**
  77005. * Gets the current depth scale used in ESM.
  77006. * @returns The scale
  77007. */
  77008. getDepthScale(): number;
  77009. /**
  77010. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77011. * @returns true if a cube texture needs to be use
  77012. */
  77013. needCube(): boolean;
  77014. /**
  77015. * Detects if the projection matrix requires to be recomputed this frame.
  77016. * @returns true if it requires to be recomputed otherwise, false.
  77017. */
  77018. needProjectionMatrixCompute(): boolean;
  77019. /**
  77020. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77021. */
  77022. forceProjectionMatrixCompute(): void;
  77023. /**
  77024. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77025. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77026. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77027. */
  77028. getShadowDirection(faceIndex?: number): Vector3;
  77029. /**
  77030. * Gets the minZ used for shadow according to both the scene and the light.
  77031. * @param activeCamera The camera we are returning the min for
  77032. * @returns the depth min z
  77033. */
  77034. getDepthMinZ(activeCamera: Camera): number;
  77035. /**
  77036. * Gets the maxZ used for shadow according to both the scene and the light.
  77037. * @param activeCamera The camera we are returning the max for
  77038. * @returns the depth max z
  77039. */
  77040. getDepthMaxZ(activeCamera: Camera): number;
  77041. }
  77042. /**
  77043. * Base implementation IShadowLight
  77044. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77045. */
  77046. export abstract class ShadowLight extends Light implements IShadowLight {
  77047. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77048. protected _position: Vector3;
  77049. protected _setPosition(value: Vector3): void;
  77050. /**
  77051. * Sets the position the shadow will be casted from. Also use as the light position for both
  77052. * point and spot lights.
  77053. */
  77054. /**
  77055. * Sets the position the shadow will be casted from. Also use as the light position for both
  77056. * point and spot lights.
  77057. */
  77058. position: Vector3;
  77059. protected _direction: Vector3;
  77060. protected _setDirection(value: Vector3): void;
  77061. /**
  77062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77063. * Also use as the light direction on spot and directional lights.
  77064. */
  77065. /**
  77066. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77067. * Also use as the light direction on spot and directional lights.
  77068. */
  77069. direction: Vector3;
  77070. private _shadowMinZ;
  77071. /**
  77072. * Gets the shadow projection clipping minimum z value.
  77073. */
  77074. /**
  77075. * Sets the shadow projection clipping minimum z value.
  77076. */
  77077. shadowMinZ: number;
  77078. private _shadowMaxZ;
  77079. /**
  77080. * Sets the shadow projection clipping maximum z value.
  77081. */
  77082. /**
  77083. * Gets the shadow projection clipping maximum z value.
  77084. */
  77085. shadowMaxZ: number;
  77086. /**
  77087. * Callback defining a custom Projection Matrix Builder.
  77088. * This can be used to override the default projection matrix computation.
  77089. */
  77090. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77091. /**
  77092. * The transformed position. Position of the light in world space taking parenting in account.
  77093. */
  77094. transformedPosition: Vector3;
  77095. /**
  77096. * The transformed direction. Direction of the light in world space taking parenting in account.
  77097. */
  77098. transformedDirection: Vector3;
  77099. private _needProjectionMatrixCompute;
  77100. /**
  77101. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77102. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77103. */
  77104. computeTransformedInformation(): boolean;
  77105. /**
  77106. * Return the depth scale used for the shadow map.
  77107. * @returns the depth scale.
  77108. */
  77109. getDepthScale(): number;
  77110. /**
  77111. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77112. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77113. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77114. */
  77115. getShadowDirection(faceIndex?: number): Vector3;
  77116. /**
  77117. * Returns the ShadowLight absolute position in the World.
  77118. * @returns the position vector in world space
  77119. */
  77120. getAbsolutePosition(): Vector3;
  77121. /**
  77122. * Sets the ShadowLight direction toward the passed target.
  77123. * @param target The point to target in local space
  77124. * @returns the updated ShadowLight direction
  77125. */
  77126. setDirectionToTarget(target: Vector3): Vector3;
  77127. /**
  77128. * Returns the light rotation in euler definition.
  77129. * @returns the x y z rotation in local space.
  77130. */
  77131. getRotation(): Vector3;
  77132. /**
  77133. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77134. * @returns true if a cube texture needs to be use
  77135. */
  77136. needCube(): boolean;
  77137. /**
  77138. * Detects if the projection matrix requires to be recomputed this frame.
  77139. * @returns true if it requires to be recomputed otherwise, false.
  77140. */
  77141. needProjectionMatrixCompute(): boolean;
  77142. /**
  77143. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77144. */
  77145. forceProjectionMatrixCompute(): void;
  77146. /** @hidden */
  77147. _initCache(): void;
  77148. /** @hidden */
  77149. _isSynchronized(): boolean;
  77150. /**
  77151. * Computes the world matrix of the node
  77152. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77153. * @returns the world matrix
  77154. */
  77155. computeWorldMatrix(force?: boolean): Matrix;
  77156. /**
  77157. * Gets the minZ used for shadow according to both the scene and the light.
  77158. * @param activeCamera The camera we are returning the min for
  77159. * @returns the depth min z
  77160. */
  77161. getDepthMinZ(activeCamera: Camera): number;
  77162. /**
  77163. * Gets the maxZ used for shadow according to both the scene and the light.
  77164. * @param activeCamera The camera we are returning the max for
  77165. * @returns the depth max z
  77166. */
  77167. getDepthMaxZ(activeCamera: Camera): number;
  77168. /**
  77169. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77170. * @param matrix The materix to updated with the projection information
  77171. * @param viewMatrix The transform matrix of the light
  77172. * @param renderList The list of mesh to render in the map
  77173. * @returns The current light
  77174. */
  77175. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77176. }
  77177. }
  77178. declare module BABYLON {
  77179. /**
  77180. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77181. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77182. */
  77183. export class EffectFallbacks implements IEffectFallbacks {
  77184. private _defines;
  77185. private _currentRank;
  77186. private _maxRank;
  77187. private _mesh;
  77188. /**
  77189. * Removes the fallback from the bound mesh.
  77190. */
  77191. unBindMesh(): void;
  77192. /**
  77193. * Adds a fallback on the specified property.
  77194. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77195. * @param define The name of the define in the shader
  77196. */
  77197. addFallback(rank: number, define: string): void;
  77198. /**
  77199. * Sets the mesh to use CPU skinning when needing to fallback.
  77200. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77201. * @param mesh The mesh to use the fallbacks.
  77202. */
  77203. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77204. /**
  77205. * Checks to see if more fallbacks are still availible.
  77206. */
  77207. readonly hasMoreFallbacks: boolean;
  77208. /**
  77209. * Removes the defines that should be removed when falling back.
  77210. * @param currentDefines defines the current define statements for the shader.
  77211. * @param effect defines the current effect we try to compile
  77212. * @returns The resulting defines with defines of the current rank removed.
  77213. */
  77214. reduce(currentDefines: string, effect: Effect): string;
  77215. }
  77216. }
  77217. declare module BABYLON {
  77218. /**
  77219. * "Static Class" containing the most commonly used helper while dealing with material for
  77220. * rendering purpose.
  77221. *
  77222. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77223. *
  77224. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77225. */
  77226. export class MaterialHelper {
  77227. /**
  77228. * Bind the current view position to an effect.
  77229. * @param effect The effect to be bound
  77230. * @param scene The scene the eyes position is used from
  77231. */
  77232. static BindEyePosition(effect: Effect, scene: Scene): void;
  77233. /**
  77234. * Helps preparing the defines values about the UVs in used in the effect.
  77235. * UVs are shared as much as we can accross channels in the shaders.
  77236. * @param texture The texture we are preparing the UVs for
  77237. * @param defines The defines to update
  77238. * @param key The channel key "diffuse", "specular"... used in the shader
  77239. */
  77240. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77241. /**
  77242. * Binds a texture matrix value to its corrsponding uniform
  77243. * @param texture The texture to bind the matrix for
  77244. * @param uniformBuffer The uniform buffer receivin the data
  77245. * @param key The channel key "diffuse", "specular"... used in the shader
  77246. */
  77247. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77248. /**
  77249. * Gets the current status of the fog (should it be enabled?)
  77250. * @param mesh defines the mesh to evaluate for fog support
  77251. * @param scene defines the hosting scene
  77252. * @returns true if fog must be enabled
  77253. */
  77254. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77255. /**
  77256. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77257. * @param mesh defines the current mesh
  77258. * @param scene defines the current scene
  77259. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77260. * @param pointsCloud defines if point cloud rendering has to be turned on
  77261. * @param fogEnabled defines if fog has to be turned on
  77262. * @param alphaTest defines if alpha testing has to be turned on
  77263. * @param defines defines the current list of defines
  77264. */
  77265. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77266. /**
  77267. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77268. * @param scene defines the current scene
  77269. * @param engine defines the current engine
  77270. * @param defines specifies the list of active defines
  77271. * @param useInstances defines if instances have to be turned on
  77272. * @param useClipPlane defines if clip plane have to be turned on
  77273. */
  77274. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77275. /**
  77276. * Prepares the defines for bones
  77277. * @param mesh The mesh containing the geometry data we will draw
  77278. * @param defines The defines to update
  77279. */
  77280. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77281. /**
  77282. * Prepares the defines for morph targets
  77283. * @param mesh The mesh containing the geometry data we will draw
  77284. * @param defines The defines to update
  77285. */
  77286. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77287. /**
  77288. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77289. * @param mesh The mesh containing the geometry data we will draw
  77290. * @param defines The defines to update
  77291. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77292. * @param useBones Precise whether bones should be used or not (override mesh info)
  77293. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77294. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77295. * @returns false if defines are considered not dirty and have not been checked
  77296. */
  77297. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77298. /**
  77299. * Prepares the defines related to multiview
  77300. * @param scene The scene we are intending to draw
  77301. * @param defines The defines to update
  77302. */
  77303. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77304. /**
  77305. * Prepares the defines related to the light information passed in parameter
  77306. * @param scene The scene we are intending to draw
  77307. * @param mesh The mesh the effect is compiling for
  77308. * @param light The light the effect is compiling for
  77309. * @param lightIndex The index of the light
  77310. * @param defines The defines to update
  77311. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77312. * @param state Defines the current state regarding what is needed (normals, etc...)
  77313. */
  77314. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77315. needNormals: boolean;
  77316. needRebuild: boolean;
  77317. shadowEnabled: boolean;
  77318. specularEnabled: boolean;
  77319. lightmapMode: boolean;
  77320. }): void;
  77321. /**
  77322. * Prepares the defines related to the light information passed in parameter
  77323. * @param scene The scene we are intending to draw
  77324. * @param mesh The mesh the effect is compiling for
  77325. * @param defines The defines to update
  77326. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77327. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77328. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77329. * @returns true if normals will be required for the rest of the effect
  77330. */
  77331. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77332. /**
  77333. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77334. * @param lightIndex defines the light index
  77335. * @param uniformsList The uniform list
  77336. * @param samplersList The sampler list
  77337. * @param projectedLightTexture defines if projected texture must be used
  77338. * @param uniformBuffersList defines an optional list of uniform buffers
  77339. */
  77340. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77341. /**
  77342. * Prepares the uniforms and samplers list to be used in the effect
  77343. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77344. * @param samplersList The sampler list
  77345. * @param defines The defines helping in the list generation
  77346. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77347. */
  77348. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77349. /**
  77350. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77351. * @param defines The defines to update while falling back
  77352. * @param fallbacks The authorized effect fallbacks
  77353. * @param maxSimultaneousLights The maximum number of lights allowed
  77354. * @param rank the current rank of the Effect
  77355. * @returns The newly affected rank
  77356. */
  77357. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77358. private static _TmpMorphInfluencers;
  77359. /**
  77360. * Prepares the list of attributes required for morph targets according to the effect defines.
  77361. * @param attribs The current list of supported attribs
  77362. * @param mesh The mesh to prepare the morph targets attributes for
  77363. * @param influencers The number of influencers
  77364. */
  77365. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77366. /**
  77367. * Prepares the list of attributes required for morph targets according to the effect defines.
  77368. * @param attribs The current list of supported attribs
  77369. * @param mesh The mesh to prepare the morph targets attributes for
  77370. * @param defines The current Defines of the effect
  77371. */
  77372. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77373. /**
  77374. * Prepares the list of attributes required for bones according to the effect defines.
  77375. * @param attribs The current list of supported attribs
  77376. * @param mesh The mesh to prepare the bones attributes for
  77377. * @param defines The current Defines of the effect
  77378. * @param fallbacks The current efffect fallback strategy
  77379. */
  77380. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77381. /**
  77382. * Check and prepare the list of attributes required for instances according to the effect defines.
  77383. * @param attribs The current list of supported attribs
  77384. * @param defines The current MaterialDefines of the effect
  77385. */
  77386. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77387. /**
  77388. * Add the list of attributes required for instances to the attribs array.
  77389. * @param attribs The current list of supported attribs
  77390. */
  77391. static PushAttributesForInstances(attribs: string[]): void;
  77392. /**
  77393. * Binds the light information to the effect.
  77394. * @param light The light containing the generator
  77395. * @param effect The effect we are binding the data to
  77396. * @param lightIndex The light index in the effect used to render
  77397. */
  77398. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77399. /**
  77400. * Binds the lights information from the scene to the effect for the given mesh.
  77401. * @param light Light to bind
  77402. * @param lightIndex Light index
  77403. * @param scene The scene where the light belongs to
  77404. * @param effect The effect we are binding the data to
  77405. * @param useSpecular Defines if specular is supported
  77406. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77407. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77408. */
  77409. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77410. /**
  77411. * Binds the lights information from the scene to the effect for the given mesh.
  77412. * @param scene The scene the lights belongs to
  77413. * @param mesh The mesh we are binding the information to render
  77414. * @param effect The effect we are binding the data to
  77415. * @param defines The generated defines for the effect
  77416. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77417. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77418. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77419. */
  77420. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77421. private static _tempFogColor;
  77422. /**
  77423. * Binds the fog information from the scene to the effect for the given mesh.
  77424. * @param scene The scene the lights belongs to
  77425. * @param mesh The mesh we are binding the information to render
  77426. * @param effect The effect we are binding the data to
  77427. * @param linearSpace Defines if the fog effect is applied in linear space
  77428. */
  77429. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77430. /**
  77431. * Binds the bones information from the mesh to the effect.
  77432. * @param mesh The mesh we are binding the information to render
  77433. * @param effect The effect we are binding the data to
  77434. */
  77435. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77436. /**
  77437. * Binds the morph targets information from the mesh to the effect.
  77438. * @param abstractMesh The mesh we are binding the information to render
  77439. * @param effect The effect we are binding the data to
  77440. */
  77441. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77442. /**
  77443. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77444. * @param defines The generated defines used in the effect
  77445. * @param effect The effect we are binding the data to
  77446. * @param scene The scene we are willing to render with logarithmic scale for
  77447. */
  77448. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77449. /**
  77450. * Binds the clip plane information from the scene to the effect.
  77451. * @param scene The scene the clip plane information are extracted from
  77452. * @param effect The effect we are binding the data to
  77453. */
  77454. static BindClipPlane(effect: Effect, scene: Scene): void;
  77455. }
  77456. }
  77457. declare module BABYLON {
  77458. /** @hidden */
  77459. export var packingFunctions: {
  77460. name: string;
  77461. shader: string;
  77462. };
  77463. }
  77464. declare module BABYLON {
  77465. /** @hidden */
  77466. export var shadowMapPixelShader: {
  77467. name: string;
  77468. shader: string;
  77469. };
  77470. }
  77471. declare module BABYLON {
  77472. /** @hidden */
  77473. export var bonesDeclaration: {
  77474. name: string;
  77475. shader: string;
  77476. };
  77477. }
  77478. declare module BABYLON {
  77479. /** @hidden */
  77480. export var morphTargetsVertexGlobalDeclaration: {
  77481. name: string;
  77482. shader: string;
  77483. };
  77484. }
  77485. declare module BABYLON {
  77486. /** @hidden */
  77487. export var morphTargetsVertexDeclaration: {
  77488. name: string;
  77489. shader: string;
  77490. };
  77491. }
  77492. declare module BABYLON {
  77493. /** @hidden */
  77494. export var instancesDeclaration: {
  77495. name: string;
  77496. shader: string;
  77497. };
  77498. }
  77499. declare module BABYLON {
  77500. /** @hidden */
  77501. export var helperFunctions: {
  77502. name: string;
  77503. shader: string;
  77504. };
  77505. }
  77506. declare module BABYLON {
  77507. /** @hidden */
  77508. export var morphTargetsVertex: {
  77509. name: string;
  77510. shader: string;
  77511. };
  77512. }
  77513. declare module BABYLON {
  77514. /** @hidden */
  77515. export var instancesVertex: {
  77516. name: string;
  77517. shader: string;
  77518. };
  77519. }
  77520. declare module BABYLON {
  77521. /** @hidden */
  77522. export var bonesVertex: {
  77523. name: string;
  77524. shader: string;
  77525. };
  77526. }
  77527. declare module BABYLON {
  77528. /** @hidden */
  77529. export var shadowMapVertexShader: {
  77530. name: string;
  77531. shader: string;
  77532. };
  77533. }
  77534. declare module BABYLON {
  77535. /** @hidden */
  77536. export var depthBoxBlurPixelShader: {
  77537. name: string;
  77538. shader: string;
  77539. };
  77540. }
  77541. declare module BABYLON {
  77542. /**
  77543. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77544. */
  77545. export interface ICustomShaderOptions {
  77546. /**
  77547. * Gets or sets the custom shader name to use
  77548. */
  77549. shaderName: string;
  77550. /**
  77551. * The list of attribute names used in the shader
  77552. */
  77553. attributes?: string[];
  77554. /**
  77555. * The list of unifrom names used in the shader
  77556. */
  77557. uniforms?: string[];
  77558. /**
  77559. * The list of sampler names used in the shader
  77560. */
  77561. samplers?: string[];
  77562. /**
  77563. * The list of defines used in the shader
  77564. */
  77565. defines?: string[];
  77566. }
  77567. /**
  77568. * Interface to implement to create a shadow generator compatible with BJS.
  77569. */
  77570. export interface IShadowGenerator {
  77571. /**
  77572. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77573. * @returns The render target texture if present otherwise, null
  77574. */
  77575. getShadowMap(): Nullable<RenderTargetTexture>;
  77576. /**
  77577. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77578. * @returns The render target texture if the shadow map is present otherwise, null
  77579. */
  77580. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77581. /**
  77582. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77583. * @param subMesh The submesh we want to render in the shadow map
  77584. * @param useInstances Defines wether will draw in the map using instances
  77585. * @returns true if ready otherwise, false
  77586. */
  77587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77588. /**
  77589. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77590. * @param defines Defines of the material we want to update
  77591. * @param lightIndex Index of the light in the enabled light list of the material
  77592. */
  77593. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77594. /**
  77595. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77596. * defined in the generator but impacting the effect).
  77597. * It implies the unifroms available on the materials are the standard BJS ones.
  77598. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77599. * @param effect The effect we are binfing the information for
  77600. */
  77601. bindShadowLight(lightIndex: string, effect: Effect): void;
  77602. /**
  77603. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77604. * (eq to shadow prjection matrix * light transform matrix)
  77605. * @returns The transform matrix used to create the shadow map
  77606. */
  77607. getTransformMatrix(): Matrix;
  77608. /**
  77609. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77610. * Cube and 2D textures for instance.
  77611. */
  77612. recreateShadowMap(): void;
  77613. /**
  77614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77615. * @param onCompiled Callback triggered at the and of the effects compilation
  77616. * @param options Sets of optional options forcing the compilation with different modes
  77617. */
  77618. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77619. useInstances: boolean;
  77620. }>): void;
  77621. /**
  77622. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77623. * @param options Sets of optional options forcing the compilation with different modes
  77624. * @returns A promise that resolves when the compilation completes
  77625. */
  77626. forceCompilationAsync(options?: Partial<{
  77627. useInstances: boolean;
  77628. }>): Promise<void>;
  77629. /**
  77630. * Serializes the shadow generator setup to a json object.
  77631. * @returns The serialized JSON object
  77632. */
  77633. serialize(): any;
  77634. /**
  77635. * Disposes the Shadow map and related Textures and effects.
  77636. */
  77637. dispose(): void;
  77638. }
  77639. /**
  77640. * Default implementation IShadowGenerator.
  77641. * This is the main object responsible of generating shadows in the framework.
  77642. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77643. */
  77644. export class ShadowGenerator implements IShadowGenerator {
  77645. /**
  77646. * Shadow generator mode None: no filtering applied.
  77647. */
  77648. static readonly FILTER_NONE: number;
  77649. /**
  77650. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77651. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77652. */
  77653. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77654. /**
  77655. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77656. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77657. */
  77658. static readonly FILTER_POISSONSAMPLING: number;
  77659. /**
  77660. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77661. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77662. */
  77663. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77664. /**
  77665. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77666. * edge artifacts on steep falloff.
  77667. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77668. */
  77669. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77670. /**
  77671. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77672. * edge artifacts on steep falloff.
  77673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77674. */
  77675. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77676. /**
  77677. * Shadow generator mode PCF: Percentage Closer Filtering
  77678. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77679. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77680. */
  77681. static readonly FILTER_PCF: number;
  77682. /**
  77683. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77684. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77685. * Contact Hardening
  77686. */
  77687. static readonly FILTER_PCSS: number;
  77688. /**
  77689. * Reserved for PCF and PCSS
  77690. * Highest Quality.
  77691. *
  77692. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77693. *
  77694. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77695. */
  77696. static readonly QUALITY_HIGH: number;
  77697. /**
  77698. * Reserved for PCF and PCSS
  77699. * Good tradeoff for quality/perf cross devices
  77700. *
  77701. * Execute PCF on a 3*3 kernel.
  77702. *
  77703. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77704. */
  77705. static readonly QUALITY_MEDIUM: number;
  77706. /**
  77707. * Reserved for PCF and PCSS
  77708. * The lowest quality but the fastest.
  77709. *
  77710. * Execute PCF on a 1*1 kernel.
  77711. *
  77712. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77713. */
  77714. static readonly QUALITY_LOW: number;
  77715. /** Gets or sets the custom shader name to use */
  77716. customShaderOptions: ICustomShaderOptions;
  77717. /**
  77718. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77719. */
  77720. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77721. /**
  77722. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77723. */
  77724. onAfterShadowMapRenderObservable: Observable<Effect>;
  77725. /**
  77726. * Observable triggered before a mesh is rendered in the shadow map.
  77727. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77728. */
  77729. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77730. /**
  77731. * Observable triggered after a mesh is rendered in the shadow map.
  77732. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77733. */
  77734. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77735. private _bias;
  77736. /**
  77737. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77738. */
  77739. /**
  77740. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77741. */
  77742. bias: number;
  77743. private _normalBias;
  77744. /**
  77745. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77746. */
  77747. /**
  77748. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77749. */
  77750. normalBias: number;
  77751. private _blurBoxOffset;
  77752. /**
  77753. * Gets the blur box offset: offset applied during the blur pass.
  77754. * Only useful if useKernelBlur = false
  77755. */
  77756. /**
  77757. * Sets the blur box offset: offset applied during the blur pass.
  77758. * Only useful if useKernelBlur = false
  77759. */
  77760. blurBoxOffset: number;
  77761. private _blurScale;
  77762. /**
  77763. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77764. * 2 means half of the size.
  77765. */
  77766. /**
  77767. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77768. * 2 means half of the size.
  77769. */
  77770. blurScale: number;
  77771. private _blurKernel;
  77772. /**
  77773. * Gets the blur kernel: kernel size of the blur pass.
  77774. * Only useful if useKernelBlur = true
  77775. */
  77776. /**
  77777. * Sets the blur kernel: kernel size of the blur pass.
  77778. * Only useful if useKernelBlur = true
  77779. */
  77780. blurKernel: number;
  77781. private _useKernelBlur;
  77782. /**
  77783. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77784. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77785. */
  77786. /**
  77787. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77788. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77789. */
  77790. useKernelBlur: boolean;
  77791. private _depthScale;
  77792. /**
  77793. * Gets the depth scale used in ESM mode.
  77794. */
  77795. /**
  77796. * Sets the depth scale used in ESM mode.
  77797. * This can override the scale stored on the light.
  77798. */
  77799. depthScale: number;
  77800. private _filter;
  77801. /**
  77802. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77803. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77804. */
  77805. /**
  77806. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77807. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77808. */
  77809. filter: number;
  77810. /**
  77811. * Gets if the current filter is set to Poisson Sampling.
  77812. */
  77813. /**
  77814. * Sets the current filter to Poisson Sampling.
  77815. */
  77816. usePoissonSampling: boolean;
  77817. /**
  77818. * Gets if the current filter is set to ESM.
  77819. */
  77820. /**
  77821. * Sets the current filter is to ESM.
  77822. */
  77823. useExponentialShadowMap: boolean;
  77824. /**
  77825. * Gets if the current filter is set to filtered ESM.
  77826. */
  77827. /**
  77828. * Gets if the current filter is set to filtered ESM.
  77829. */
  77830. useBlurExponentialShadowMap: boolean;
  77831. /**
  77832. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77833. * exponential to prevent steep falloff artifacts).
  77834. */
  77835. /**
  77836. * Sets the current filter to "close ESM" (using the inverse of the
  77837. * exponential to prevent steep falloff artifacts).
  77838. */
  77839. useCloseExponentialShadowMap: boolean;
  77840. /**
  77841. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77842. * exponential to prevent steep falloff artifacts).
  77843. */
  77844. /**
  77845. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77846. * exponential to prevent steep falloff artifacts).
  77847. */
  77848. useBlurCloseExponentialShadowMap: boolean;
  77849. /**
  77850. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77851. */
  77852. /**
  77853. * Sets the current filter to "PCF" (percentage closer filtering).
  77854. */
  77855. usePercentageCloserFiltering: boolean;
  77856. private _filteringQuality;
  77857. /**
  77858. * Gets the PCF or PCSS Quality.
  77859. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77860. */
  77861. /**
  77862. * Sets the PCF or PCSS Quality.
  77863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77864. */
  77865. filteringQuality: number;
  77866. /**
  77867. * Gets if the current filter is set to "PCSS" (contact hardening).
  77868. */
  77869. /**
  77870. * Sets the current filter to "PCSS" (contact hardening).
  77871. */
  77872. useContactHardeningShadow: boolean;
  77873. private _contactHardeningLightSizeUVRatio;
  77874. /**
  77875. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77876. * Using a ratio helps keeping shape stability independently of the map size.
  77877. *
  77878. * It does not account for the light projection as it was having too much
  77879. * instability during the light setup or during light position changes.
  77880. *
  77881. * Only valid if useContactHardeningShadow is true.
  77882. */
  77883. /**
  77884. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77885. * Using a ratio helps keeping shape stability independently of the map size.
  77886. *
  77887. * It does not account for the light projection as it was having too much
  77888. * instability during the light setup or during light position changes.
  77889. *
  77890. * Only valid if useContactHardeningShadow is true.
  77891. */
  77892. contactHardeningLightSizeUVRatio: number;
  77893. private _darkness;
  77894. /** Gets or sets the actual darkness of a shadow */
  77895. darkness: number;
  77896. /**
  77897. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77898. * 0 means strongest and 1 would means no shadow.
  77899. * @returns the darkness.
  77900. */
  77901. getDarkness(): number;
  77902. /**
  77903. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77904. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77905. * @returns the shadow generator allowing fluent coding.
  77906. */
  77907. setDarkness(darkness: number): ShadowGenerator;
  77908. private _transparencyShadow;
  77909. /** Gets or sets the ability to have transparent shadow */
  77910. transparencyShadow: boolean;
  77911. /**
  77912. * Sets the ability to have transparent shadow (boolean).
  77913. * @param transparent True if transparent else False
  77914. * @returns the shadow generator allowing fluent coding
  77915. */
  77916. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77917. private _shadowMap;
  77918. private _shadowMap2;
  77919. /**
  77920. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77921. * @returns The render target texture if present otherwise, null
  77922. */
  77923. getShadowMap(): Nullable<RenderTargetTexture>;
  77924. /**
  77925. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77926. * @returns The render target texture if the shadow map is present otherwise, null
  77927. */
  77928. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77929. /**
  77930. * Gets the class name of that object
  77931. * @returns "ShadowGenerator"
  77932. */
  77933. getClassName(): string;
  77934. /**
  77935. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77936. * @param mesh Mesh to add
  77937. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77938. * @returns the Shadow Generator itself
  77939. */
  77940. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77941. /**
  77942. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77943. * @param mesh Mesh to remove
  77944. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77945. * @returns the Shadow Generator itself
  77946. */
  77947. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77948. /**
  77949. * Controls the extent to which the shadows fade out at the edge of the frustum
  77950. * Used only by directionals and spots
  77951. */
  77952. frustumEdgeFalloff: number;
  77953. private _light;
  77954. /**
  77955. * Returns the associated light object.
  77956. * @returns the light generating the shadow
  77957. */
  77958. getLight(): IShadowLight;
  77959. /**
  77960. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77961. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77962. * It might on the other hand introduce peter panning.
  77963. */
  77964. forceBackFacesOnly: boolean;
  77965. private _scene;
  77966. private _lightDirection;
  77967. private _effect;
  77968. private _viewMatrix;
  77969. private _projectionMatrix;
  77970. private _transformMatrix;
  77971. private _cachedPosition;
  77972. private _cachedDirection;
  77973. private _cachedDefines;
  77974. private _currentRenderID;
  77975. private _boxBlurPostprocess;
  77976. private _kernelBlurXPostprocess;
  77977. private _kernelBlurYPostprocess;
  77978. private _blurPostProcesses;
  77979. private _mapSize;
  77980. private _currentFaceIndex;
  77981. private _currentFaceIndexCache;
  77982. private _textureType;
  77983. private _defaultTextureMatrix;
  77984. private _storedUniqueId;
  77985. /** @hidden */
  77986. static _SceneComponentInitialization: (scene: Scene) => void;
  77987. /**
  77988. * Creates a ShadowGenerator object.
  77989. * A ShadowGenerator is the required tool to use the shadows.
  77990. * Each light casting shadows needs to use its own ShadowGenerator.
  77991. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77992. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77993. * @param light The light object generating the shadows.
  77994. * @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.
  77995. */
  77996. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77997. private _initializeGenerator;
  77998. private _initializeShadowMap;
  77999. private _initializeBlurRTTAndPostProcesses;
  78000. private _renderForShadowMap;
  78001. private _renderSubMeshForShadowMap;
  78002. private _applyFilterValues;
  78003. /**
  78004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78005. * @param onCompiled Callback triggered at the and of the effects compilation
  78006. * @param options Sets of optional options forcing the compilation with different modes
  78007. */
  78008. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78009. useInstances: boolean;
  78010. }>): void;
  78011. /**
  78012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78013. * @param options Sets of optional options forcing the compilation with different modes
  78014. * @returns A promise that resolves when the compilation completes
  78015. */
  78016. forceCompilationAsync(options?: Partial<{
  78017. useInstances: boolean;
  78018. }>): Promise<void>;
  78019. /**
  78020. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78021. * @param subMesh The submesh we want to render in the shadow map
  78022. * @param useInstances Defines wether will draw in the map using instances
  78023. * @returns true if ready otherwise, false
  78024. */
  78025. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78026. /**
  78027. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78028. * @param defines Defines of the material we want to update
  78029. * @param lightIndex Index of the light in the enabled light list of the material
  78030. */
  78031. prepareDefines(defines: any, lightIndex: number): void;
  78032. /**
  78033. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78034. * defined in the generator but impacting the effect).
  78035. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78036. * @param effect The effect we are binfing the information for
  78037. */
  78038. bindShadowLight(lightIndex: string, effect: Effect): void;
  78039. /**
  78040. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78041. * (eq to shadow prjection matrix * light transform matrix)
  78042. * @returns The transform matrix used to create the shadow map
  78043. */
  78044. getTransformMatrix(): Matrix;
  78045. /**
  78046. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78047. * Cube and 2D textures for instance.
  78048. */
  78049. recreateShadowMap(): void;
  78050. private _disposeBlurPostProcesses;
  78051. private _disposeRTTandPostProcesses;
  78052. /**
  78053. * Disposes the ShadowGenerator.
  78054. * Returns nothing.
  78055. */
  78056. dispose(): void;
  78057. /**
  78058. * Serializes the shadow generator setup to a json object.
  78059. * @returns The serialized JSON object
  78060. */
  78061. serialize(): any;
  78062. /**
  78063. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78064. * @param parsedShadowGenerator The JSON object to parse
  78065. * @param scene The scene to create the shadow map for
  78066. * @returns The parsed shadow generator
  78067. */
  78068. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78069. }
  78070. }
  78071. declare module BABYLON {
  78072. /**
  78073. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78074. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78075. * 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.
  78076. */
  78077. export abstract class Light extends Node {
  78078. /**
  78079. * Falloff Default: light is falling off following the material specification:
  78080. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78081. */
  78082. static readonly FALLOFF_DEFAULT: number;
  78083. /**
  78084. * Falloff Physical: light is falling off following the inverse squared distance law.
  78085. */
  78086. static readonly FALLOFF_PHYSICAL: number;
  78087. /**
  78088. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78089. * to enhance interoperability with other engines.
  78090. */
  78091. static readonly FALLOFF_GLTF: number;
  78092. /**
  78093. * Falloff Standard: light is falling off like in the standard material
  78094. * to enhance interoperability with other materials.
  78095. */
  78096. static readonly FALLOFF_STANDARD: number;
  78097. /**
  78098. * If every light affecting the material is in this lightmapMode,
  78099. * material.lightmapTexture adds or multiplies
  78100. * (depends on material.useLightmapAsShadowmap)
  78101. * after every other light calculations.
  78102. */
  78103. static readonly LIGHTMAP_DEFAULT: number;
  78104. /**
  78105. * material.lightmapTexture as only diffuse lighting from this light
  78106. * adds only specular lighting from this light
  78107. * adds dynamic shadows
  78108. */
  78109. static readonly LIGHTMAP_SPECULAR: number;
  78110. /**
  78111. * material.lightmapTexture as only lighting
  78112. * no light calculation from this light
  78113. * only adds dynamic shadows from this light
  78114. */
  78115. static readonly LIGHTMAP_SHADOWSONLY: number;
  78116. /**
  78117. * Each light type uses the default quantity according to its type:
  78118. * point/spot lights use luminous intensity
  78119. * directional lights use illuminance
  78120. */
  78121. static readonly INTENSITYMODE_AUTOMATIC: number;
  78122. /**
  78123. * lumen (lm)
  78124. */
  78125. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78126. /**
  78127. * candela (lm/sr)
  78128. */
  78129. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78130. /**
  78131. * lux (lm/m^2)
  78132. */
  78133. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78134. /**
  78135. * nit (cd/m^2)
  78136. */
  78137. static readonly INTENSITYMODE_LUMINANCE: number;
  78138. /**
  78139. * Light type const id of the point light.
  78140. */
  78141. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78142. /**
  78143. * Light type const id of the directional light.
  78144. */
  78145. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78146. /**
  78147. * Light type const id of the spot light.
  78148. */
  78149. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78150. /**
  78151. * Light type const id of the hemispheric light.
  78152. */
  78153. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78154. /**
  78155. * Diffuse gives the basic color to an object.
  78156. */
  78157. diffuse: Color3;
  78158. /**
  78159. * Specular produces a highlight color on an object.
  78160. * Note: This is note affecting PBR materials.
  78161. */
  78162. specular: Color3;
  78163. /**
  78164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78165. * falling off base on range or angle.
  78166. * This can be set to any values in Light.FALLOFF_x.
  78167. *
  78168. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78169. * other types of materials.
  78170. */
  78171. falloffType: number;
  78172. /**
  78173. * Strength of the light.
  78174. * Note: By default it is define in the framework own unit.
  78175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78176. */
  78177. intensity: number;
  78178. private _range;
  78179. protected _inverseSquaredRange: number;
  78180. /**
  78181. * Defines how far from the source the light is impacting in scene units.
  78182. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78183. */
  78184. /**
  78185. * Defines how far from the source the light is impacting in scene units.
  78186. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78187. */
  78188. range: number;
  78189. /**
  78190. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78191. * of light.
  78192. */
  78193. private _photometricScale;
  78194. private _intensityMode;
  78195. /**
  78196. * Gets the photometric scale used to interpret the intensity.
  78197. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78198. */
  78199. /**
  78200. * Sets the photometric scale used to interpret the intensity.
  78201. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78202. */
  78203. intensityMode: number;
  78204. private _radius;
  78205. /**
  78206. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78207. */
  78208. /**
  78209. * sets the light radius used by PBR Materials to simulate soft area lights.
  78210. */
  78211. radius: number;
  78212. private _renderPriority;
  78213. /**
  78214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78215. * exceeding the number allowed of the materials.
  78216. */
  78217. renderPriority: number;
  78218. private _shadowEnabled;
  78219. /**
  78220. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78221. * the current shadow generator.
  78222. */
  78223. /**
  78224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78225. * the current shadow generator.
  78226. */
  78227. shadowEnabled: boolean;
  78228. private _includedOnlyMeshes;
  78229. /**
  78230. * Gets the only meshes impacted by this light.
  78231. */
  78232. /**
  78233. * Sets the only meshes impacted by this light.
  78234. */
  78235. includedOnlyMeshes: AbstractMesh[];
  78236. private _excludedMeshes;
  78237. /**
  78238. * Gets the meshes not impacted by this light.
  78239. */
  78240. /**
  78241. * Sets the meshes not impacted by this light.
  78242. */
  78243. excludedMeshes: AbstractMesh[];
  78244. private _excludeWithLayerMask;
  78245. /**
  78246. * Gets the layer id use to find what meshes are not impacted by the light.
  78247. * Inactive if 0
  78248. */
  78249. /**
  78250. * Sets the layer id use to find what meshes are not impacted by the light.
  78251. * Inactive if 0
  78252. */
  78253. excludeWithLayerMask: number;
  78254. private _includeOnlyWithLayerMask;
  78255. /**
  78256. * Gets the layer id use to find what meshes are impacted by the light.
  78257. * Inactive if 0
  78258. */
  78259. /**
  78260. * Sets the layer id use to find what meshes are impacted by the light.
  78261. * Inactive if 0
  78262. */
  78263. includeOnlyWithLayerMask: number;
  78264. private _lightmapMode;
  78265. /**
  78266. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78267. */
  78268. /**
  78269. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78270. */
  78271. lightmapMode: number;
  78272. /**
  78273. * Shadow generator associted to the light.
  78274. * @hidden Internal use only.
  78275. */
  78276. _shadowGenerator: Nullable<IShadowGenerator>;
  78277. /**
  78278. * @hidden Internal use only.
  78279. */
  78280. _excludedMeshesIds: string[];
  78281. /**
  78282. * @hidden Internal use only.
  78283. */
  78284. _includedOnlyMeshesIds: string[];
  78285. /**
  78286. * The current light unifom buffer.
  78287. * @hidden Internal use only.
  78288. */
  78289. _uniformBuffer: UniformBuffer;
  78290. /** @hidden */
  78291. _renderId: number;
  78292. /**
  78293. * Creates a Light object in the scene.
  78294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78295. * @param name The firendly name of the light
  78296. * @param scene The scene the light belongs too
  78297. */
  78298. constructor(name: string, scene: Scene);
  78299. protected abstract _buildUniformLayout(): void;
  78300. /**
  78301. * Sets the passed Effect "effect" with the Light information.
  78302. * @param effect The effect to update
  78303. * @param lightIndex The index of the light in the effect to update
  78304. * @returns The light
  78305. */
  78306. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78307. /**
  78308. * Sets the passed Effect "effect" with the Light information.
  78309. * @param effect The effect to update
  78310. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78311. * @returns The light
  78312. */
  78313. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78314. /**
  78315. * Returns the string "Light".
  78316. * @returns the class name
  78317. */
  78318. getClassName(): string;
  78319. /** @hidden */
  78320. readonly _isLight: boolean;
  78321. /**
  78322. * Converts the light information to a readable string for debug purpose.
  78323. * @param fullDetails Supports for multiple levels of logging within scene loading
  78324. * @returns the human readable light info
  78325. */
  78326. toString(fullDetails?: boolean): string;
  78327. /** @hidden */
  78328. protected _syncParentEnabledState(): void;
  78329. /**
  78330. * Set the enabled state of this node.
  78331. * @param value - the new enabled state
  78332. */
  78333. setEnabled(value: boolean): void;
  78334. /**
  78335. * Returns the Light associated shadow generator if any.
  78336. * @return the associated shadow generator.
  78337. */
  78338. getShadowGenerator(): Nullable<IShadowGenerator>;
  78339. /**
  78340. * Returns a Vector3, the absolute light position in the World.
  78341. * @returns the world space position of the light
  78342. */
  78343. getAbsolutePosition(): Vector3;
  78344. /**
  78345. * Specifies if the light will affect the passed mesh.
  78346. * @param mesh The mesh to test against the light
  78347. * @return true the mesh is affected otherwise, false.
  78348. */
  78349. canAffectMesh(mesh: AbstractMesh): boolean;
  78350. /**
  78351. * Sort function to order lights for rendering.
  78352. * @param a First Light object to compare to second.
  78353. * @param b Second Light object to compare first.
  78354. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78355. */
  78356. static CompareLightsPriority(a: Light, b: Light): number;
  78357. /**
  78358. * Releases resources associated with this node.
  78359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78361. */
  78362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78363. /**
  78364. * Returns the light type ID (integer).
  78365. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78366. */
  78367. getTypeID(): number;
  78368. /**
  78369. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78370. * @returns the scaled intensity in intensity mode unit
  78371. */
  78372. getScaledIntensity(): number;
  78373. /**
  78374. * Returns a new Light object, named "name", from the current one.
  78375. * @param name The name of the cloned light
  78376. * @returns the new created light
  78377. */
  78378. clone(name: string): Nullable<Light>;
  78379. /**
  78380. * Serializes the current light into a Serialization object.
  78381. * @returns the serialized object.
  78382. */
  78383. serialize(): any;
  78384. /**
  78385. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78386. * This new light is named "name" and added to the passed scene.
  78387. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78388. * @param name The friendly name of the light
  78389. * @param scene The scene the new light will belong to
  78390. * @returns the constructor function
  78391. */
  78392. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78393. /**
  78394. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78395. * @param parsedLight The JSON representation of the light
  78396. * @param scene The scene to create the parsed light in
  78397. * @returns the created light after parsing
  78398. */
  78399. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78400. private _hookArrayForExcluded;
  78401. private _hookArrayForIncludedOnly;
  78402. private _resyncMeshes;
  78403. /**
  78404. * Forces the meshes to update their light related information in their rendering used effects
  78405. * @hidden Internal Use Only
  78406. */
  78407. _markMeshesAsLightDirty(): void;
  78408. /**
  78409. * Recomputes the cached photometric scale if needed.
  78410. */
  78411. private _computePhotometricScale;
  78412. /**
  78413. * Returns the Photometric Scale according to the light type and intensity mode.
  78414. */
  78415. private _getPhotometricScale;
  78416. /**
  78417. * Reorder the light in the scene according to their defined priority.
  78418. * @hidden Internal Use Only
  78419. */
  78420. _reorderLightsInScene(): void;
  78421. /**
  78422. * Prepares the list of defines specific to the light type.
  78423. * @param defines the list of defines
  78424. * @param lightIndex defines the index of the light for the effect
  78425. */
  78426. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78427. }
  78428. }
  78429. declare module BABYLON {
  78430. /**
  78431. * Interface used to define Action
  78432. */
  78433. export interface IAction {
  78434. /**
  78435. * Trigger for the action
  78436. */
  78437. trigger: number;
  78438. /** Options of the trigger */
  78439. triggerOptions: any;
  78440. /**
  78441. * Gets the trigger parameters
  78442. * @returns the trigger parameters
  78443. */
  78444. getTriggerParameter(): any;
  78445. /**
  78446. * Internal only - executes current action event
  78447. * @hidden
  78448. */
  78449. _executeCurrent(evt?: ActionEvent): void;
  78450. /**
  78451. * Serialize placeholder for child classes
  78452. * @param parent of child
  78453. * @returns the serialized object
  78454. */
  78455. serialize(parent: any): any;
  78456. /**
  78457. * Internal only
  78458. * @hidden
  78459. */
  78460. _prepare(): void;
  78461. /**
  78462. * Internal only - manager for action
  78463. * @hidden
  78464. */
  78465. _actionManager: AbstractActionManager;
  78466. /**
  78467. * Adds action to chain of actions, may be a DoNothingAction
  78468. * @param action defines the next action to execute
  78469. * @returns The action passed in
  78470. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78471. */
  78472. then(action: IAction): IAction;
  78473. }
  78474. /**
  78475. * The action to be carried out following a trigger
  78476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78477. */
  78478. export class Action implements IAction {
  78479. /** the trigger, with or without parameters, for the action */
  78480. triggerOptions: any;
  78481. /**
  78482. * Trigger for the action
  78483. */
  78484. trigger: number;
  78485. /**
  78486. * Internal only - manager for action
  78487. * @hidden
  78488. */
  78489. _actionManager: ActionManager;
  78490. private _nextActiveAction;
  78491. private _child;
  78492. private _condition?;
  78493. private _triggerParameter;
  78494. /**
  78495. * An event triggered prior to action being executed.
  78496. */
  78497. onBeforeExecuteObservable: Observable<Action>;
  78498. /**
  78499. * Creates a new Action
  78500. * @param triggerOptions the trigger, with or without parameters, for the action
  78501. * @param condition an optional determinant of action
  78502. */
  78503. constructor(
  78504. /** the trigger, with or without parameters, for the action */
  78505. triggerOptions: any, condition?: Condition);
  78506. /**
  78507. * Internal only
  78508. * @hidden
  78509. */
  78510. _prepare(): void;
  78511. /**
  78512. * Gets the trigger parameters
  78513. * @returns the trigger parameters
  78514. */
  78515. getTriggerParameter(): any;
  78516. /**
  78517. * Internal only - executes current action event
  78518. * @hidden
  78519. */
  78520. _executeCurrent(evt?: ActionEvent): void;
  78521. /**
  78522. * Execute placeholder for child classes
  78523. * @param evt optional action event
  78524. */
  78525. execute(evt?: ActionEvent): void;
  78526. /**
  78527. * Skips to next active action
  78528. */
  78529. skipToNextActiveAction(): void;
  78530. /**
  78531. * Adds action to chain of actions, may be a DoNothingAction
  78532. * @param action defines the next action to execute
  78533. * @returns The action passed in
  78534. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78535. */
  78536. then(action: Action): Action;
  78537. /**
  78538. * Internal only
  78539. * @hidden
  78540. */
  78541. _getProperty(propertyPath: string): string;
  78542. /**
  78543. * Internal only
  78544. * @hidden
  78545. */
  78546. _getEffectiveTarget(target: any, propertyPath: string): any;
  78547. /**
  78548. * Serialize placeholder for child classes
  78549. * @param parent of child
  78550. * @returns the serialized object
  78551. */
  78552. serialize(parent: any): any;
  78553. /**
  78554. * Internal only called by serialize
  78555. * @hidden
  78556. */
  78557. protected _serialize(serializedAction: any, parent?: any): any;
  78558. /**
  78559. * Internal only
  78560. * @hidden
  78561. */
  78562. static _SerializeValueAsString: (value: any) => string;
  78563. /**
  78564. * Internal only
  78565. * @hidden
  78566. */
  78567. static _GetTargetProperty: (target: Node | Scene) => {
  78568. name: string;
  78569. targetType: string;
  78570. value: string;
  78571. };
  78572. }
  78573. }
  78574. declare module BABYLON {
  78575. /**
  78576. * A Condition applied to an Action
  78577. */
  78578. export class Condition {
  78579. /**
  78580. * Internal only - manager for action
  78581. * @hidden
  78582. */
  78583. _actionManager: ActionManager;
  78584. /**
  78585. * Internal only
  78586. * @hidden
  78587. */
  78588. _evaluationId: number;
  78589. /**
  78590. * Internal only
  78591. * @hidden
  78592. */
  78593. _currentResult: boolean;
  78594. /**
  78595. * Creates a new Condition
  78596. * @param actionManager the manager of the action the condition is applied to
  78597. */
  78598. constructor(actionManager: ActionManager);
  78599. /**
  78600. * Check if the current condition is valid
  78601. * @returns a boolean
  78602. */
  78603. isValid(): boolean;
  78604. /**
  78605. * Internal only
  78606. * @hidden
  78607. */
  78608. _getProperty(propertyPath: string): string;
  78609. /**
  78610. * Internal only
  78611. * @hidden
  78612. */
  78613. _getEffectiveTarget(target: any, propertyPath: string): any;
  78614. /**
  78615. * Serialize placeholder for child classes
  78616. * @returns the serialized object
  78617. */
  78618. serialize(): any;
  78619. /**
  78620. * Internal only
  78621. * @hidden
  78622. */
  78623. protected _serialize(serializedCondition: any): any;
  78624. }
  78625. /**
  78626. * Defines specific conditional operators as extensions of Condition
  78627. */
  78628. export class ValueCondition extends Condition {
  78629. /** path to specify the property of the target the conditional operator uses */
  78630. propertyPath: string;
  78631. /** the value compared by the conditional operator against the current value of the property */
  78632. value: any;
  78633. /** the conditional operator, default ValueCondition.IsEqual */
  78634. operator: number;
  78635. /**
  78636. * Internal only
  78637. * @hidden
  78638. */
  78639. private static _IsEqual;
  78640. /**
  78641. * Internal only
  78642. * @hidden
  78643. */
  78644. private static _IsDifferent;
  78645. /**
  78646. * Internal only
  78647. * @hidden
  78648. */
  78649. private static _IsGreater;
  78650. /**
  78651. * Internal only
  78652. * @hidden
  78653. */
  78654. private static _IsLesser;
  78655. /**
  78656. * returns the number for IsEqual
  78657. */
  78658. static readonly IsEqual: number;
  78659. /**
  78660. * Returns the number for IsDifferent
  78661. */
  78662. static readonly IsDifferent: number;
  78663. /**
  78664. * Returns the number for IsGreater
  78665. */
  78666. static readonly IsGreater: number;
  78667. /**
  78668. * Returns the number for IsLesser
  78669. */
  78670. static readonly IsLesser: number;
  78671. /**
  78672. * Internal only The action manager for the condition
  78673. * @hidden
  78674. */
  78675. _actionManager: ActionManager;
  78676. /**
  78677. * Internal only
  78678. * @hidden
  78679. */
  78680. private _target;
  78681. /**
  78682. * Internal only
  78683. * @hidden
  78684. */
  78685. private _effectiveTarget;
  78686. /**
  78687. * Internal only
  78688. * @hidden
  78689. */
  78690. private _property;
  78691. /**
  78692. * Creates a new ValueCondition
  78693. * @param actionManager manager for the action the condition applies to
  78694. * @param target for the action
  78695. * @param propertyPath path to specify the property of the target the conditional operator uses
  78696. * @param value the value compared by the conditional operator against the current value of the property
  78697. * @param operator the conditional operator, default ValueCondition.IsEqual
  78698. */
  78699. constructor(actionManager: ActionManager, target: any,
  78700. /** path to specify the property of the target the conditional operator uses */
  78701. propertyPath: string,
  78702. /** the value compared by the conditional operator against the current value of the property */
  78703. value: any,
  78704. /** the conditional operator, default ValueCondition.IsEqual */
  78705. operator?: number);
  78706. /**
  78707. * Compares the given value with the property value for the specified conditional operator
  78708. * @returns the result of the comparison
  78709. */
  78710. isValid(): boolean;
  78711. /**
  78712. * Serialize the ValueCondition into a JSON compatible object
  78713. * @returns serialization object
  78714. */
  78715. serialize(): any;
  78716. /**
  78717. * Gets the name of the conditional operator for the ValueCondition
  78718. * @param operator the conditional operator
  78719. * @returns the name
  78720. */
  78721. static GetOperatorName(operator: number): string;
  78722. }
  78723. /**
  78724. * Defines a predicate condition as an extension of Condition
  78725. */
  78726. export class PredicateCondition extends Condition {
  78727. /** defines the predicate function used to validate the condition */
  78728. predicate: () => boolean;
  78729. /**
  78730. * Internal only - manager for action
  78731. * @hidden
  78732. */
  78733. _actionManager: ActionManager;
  78734. /**
  78735. * Creates a new PredicateCondition
  78736. * @param actionManager manager for the action the condition applies to
  78737. * @param predicate defines the predicate function used to validate the condition
  78738. */
  78739. constructor(actionManager: ActionManager,
  78740. /** defines the predicate function used to validate the condition */
  78741. predicate: () => boolean);
  78742. /**
  78743. * @returns the validity of the predicate condition
  78744. */
  78745. isValid(): boolean;
  78746. }
  78747. /**
  78748. * Defines a state condition as an extension of Condition
  78749. */
  78750. export class StateCondition extends Condition {
  78751. /** Value to compare with target state */
  78752. value: string;
  78753. /**
  78754. * Internal only - manager for action
  78755. * @hidden
  78756. */
  78757. _actionManager: ActionManager;
  78758. /**
  78759. * Internal only
  78760. * @hidden
  78761. */
  78762. private _target;
  78763. /**
  78764. * Creates a new StateCondition
  78765. * @param actionManager manager for the action the condition applies to
  78766. * @param target of the condition
  78767. * @param value to compare with target state
  78768. */
  78769. constructor(actionManager: ActionManager, target: any,
  78770. /** Value to compare with target state */
  78771. value: string);
  78772. /**
  78773. * Gets a boolean indicating if the current condition is met
  78774. * @returns the validity of the state
  78775. */
  78776. isValid(): boolean;
  78777. /**
  78778. * Serialize the StateCondition into a JSON compatible object
  78779. * @returns serialization object
  78780. */
  78781. serialize(): any;
  78782. }
  78783. }
  78784. declare module BABYLON {
  78785. /**
  78786. * This defines an action responsible to toggle a boolean once triggered.
  78787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78788. */
  78789. export class SwitchBooleanAction extends Action {
  78790. /**
  78791. * The path to the boolean property in the target object
  78792. */
  78793. propertyPath: string;
  78794. private _target;
  78795. private _effectiveTarget;
  78796. private _property;
  78797. /**
  78798. * Instantiate the action
  78799. * @param triggerOptions defines the trigger options
  78800. * @param target defines the object containing the boolean
  78801. * @param propertyPath defines the path to the boolean property in the target object
  78802. * @param condition defines the trigger related conditions
  78803. */
  78804. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78805. /** @hidden */
  78806. _prepare(): void;
  78807. /**
  78808. * Execute the action toggle the boolean value.
  78809. */
  78810. execute(): void;
  78811. /**
  78812. * Serializes the actions and its related information.
  78813. * @param parent defines the object to serialize in
  78814. * @returns the serialized object
  78815. */
  78816. serialize(parent: any): any;
  78817. }
  78818. /**
  78819. * This defines an action responsible to set a the state field of the target
  78820. * to a desired value once triggered.
  78821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78822. */
  78823. export class SetStateAction extends Action {
  78824. /**
  78825. * The value to store in the state field.
  78826. */
  78827. value: string;
  78828. private _target;
  78829. /**
  78830. * Instantiate the action
  78831. * @param triggerOptions defines the trigger options
  78832. * @param target defines the object containing the state property
  78833. * @param value defines the value to store in the state field
  78834. * @param condition defines the trigger related conditions
  78835. */
  78836. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78837. /**
  78838. * Execute the action and store the value on the target state property.
  78839. */
  78840. execute(): void;
  78841. /**
  78842. * Serializes the actions and its related information.
  78843. * @param parent defines the object to serialize in
  78844. * @returns the serialized object
  78845. */
  78846. serialize(parent: any): any;
  78847. }
  78848. /**
  78849. * This defines an action responsible to set a property of the target
  78850. * to a desired value once triggered.
  78851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78852. */
  78853. export class SetValueAction extends Action {
  78854. /**
  78855. * The path of the property to set in the target.
  78856. */
  78857. propertyPath: string;
  78858. /**
  78859. * The value to set in the property
  78860. */
  78861. value: any;
  78862. private _target;
  78863. private _effectiveTarget;
  78864. private _property;
  78865. /**
  78866. * Instantiate the action
  78867. * @param triggerOptions defines the trigger options
  78868. * @param target defines the object containing the property
  78869. * @param propertyPath defines the path of the property to set in the target
  78870. * @param value defines the value to set in the property
  78871. * @param condition defines the trigger related conditions
  78872. */
  78873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78874. /** @hidden */
  78875. _prepare(): void;
  78876. /**
  78877. * Execute the action and set the targetted property to the desired value.
  78878. */
  78879. execute(): void;
  78880. /**
  78881. * Serializes the actions and its related information.
  78882. * @param parent defines the object to serialize in
  78883. * @returns the serialized object
  78884. */
  78885. serialize(parent: any): any;
  78886. }
  78887. /**
  78888. * This defines an action responsible to increment the target value
  78889. * to a desired value once triggered.
  78890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78891. */
  78892. export class IncrementValueAction extends Action {
  78893. /**
  78894. * The path of the property to increment in the target.
  78895. */
  78896. propertyPath: string;
  78897. /**
  78898. * The value we should increment the property by.
  78899. */
  78900. value: any;
  78901. private _target;
  78902. private _effectiveTarget;
  78903. private _property;
  78904. /**
  78905. * Instantiate the action
  78906. * @param triggerOptions defines the trigger options
  78907. * @param target defines the object containing the property
  78908. * @param propertyPath defines the path of the property to increment in the target
  78909. * @param value defines the value value we should increment the property by
  78910. * @param condition defines the trigger related conditions
  78911. */
  78912. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78913. /** @hidden */
  78914. _prepare(): void;
  78915. /**
  78916. * Execute the action and increment the target of the value amount.
  78917. */
  78918. execute(): void;
  78919. /**
  78920. * Serializes the actions and its related information.
  78921. * @param parent defines the object to serialize in
  78922. * @returns the serialized object
  78923. */
  78924. serialize(parent: any): any;
  78925. }
  78926. /**
  78927. * This defines an action responsible to start an animation once triggered.
  78928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78929. */
  78930. export class PlayAnimationAction extends Action {
  78931. /**
  78932. * Where the animation should start (animation frame)
  78933. */
  78934. from: number;
  78935. /**
  78936. * Where the animation should stop (animation frame)
  78937. */
  78938. to: number;
  78939. /**
  78940. * Define if the animation should loop or stop after the first play.
  78941. */
  78942. loop?: boolean;
  78943. private _target;
  78944. /**
  78945. * Instantiate the action
  78946. * @param triggerOptions defines the trigger options
  78947. * @param target defines the target animation or animation name
  78948. * @param from defines from where the animation should start (animation frame)
  78949. * @param end defines where the animation should stop (animation frame)
  78950. * @param loop defines if the animation should loop or stop after the first play
  78951. * @param condition defines the trigger related conditions
  78952. */
  78953. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78954. /** @hidden */
  78955. _prepare(): void;
  78956. /**
  78957. * Execute the action and play the animation.
  78958. */
  78959. execute(): void;
  78960. /**
  78961. * Serializes the actions and its related information.
  78962. * @param parent defines the object to serialize in
  78963. * @returns the serialized object
  78964. */
  78965. serialize(parent: any): any;
  78966. }
  78967. /**
  78968. * This defines an action responsible to stop an animation once triggered.
  78969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78970. */
  78971. export class StopAnimationAction extends Action {
  78972. private _target;
  78973. /**
  78974. * Instantiate the action
  78975. * @param triggerOptions defines the trigger options
  78976. * @param target defines the target animation or animation name
  78977. * @param condition defines the trigger related conditions
  78978. */
  78979. constructor(triggerOptions: any, target: any, condition?: Condition);
  78980. /** @hidden */
  78981. _prepare(): void;
  78982. /**
  78983. * Execute the action and stop the animation.
  78984. */
  78985. execute(): void;
  78986. /**
  78987. * Serializes the actions and its related information.
  78988. * @param parent defines the object to serialize in
  78989. * @returns the serialized object
  78990. */
  78991. serialize(parent: any): any;
  78992. }
  78993. /**
  78994. * This defines an action responsible that does nothing once triggered.
  78995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78996. */
  78997. export class DoNothingAction extends Action {
  78998. /**
  78999. * Instantiate the action
  79000. * @param triggerOptions defines the trigger options
  79001. * @param condition defines the trigger related conditions
  79002. */
  79003. constructor(triggerOptions?: any, condition?: Condition);
  79004. /**
  79005. * Execute the action and do nothing.
  79006. */
  79007. execute(): void;
  79008. /**
  79009. * Serializes the actions and its related information.
  79010. * @param parent defines the object to serialize in
  79011. * @returns the serialized object
  79012. */
  79013. serialize(parent: any): any;
  79014. }
  79015. /**
  79016. * This defines an action responsible to trigger several actions once triggered.
  79017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79018. */
  79019. export class CombineAction extends Action {
  79020. /**
  79021. * The list of aggregated animations to run.
  79022. */
  79023. children: Action[];
  79024. /**
  79025. * Instantiate the action
  79026. * @param triggerOptions defines the trigger options
  79027. * @param children defines the list of aggregated animations to run
  79028. * @param condition defines the trigger related conditions
  79029. */
  79030. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79031. /** @hidden */
  79032. _prepare(): void;
  79033. /**
  79034. * Execute the action and executes all the aggregated actions.
  79035. */
  79036. execute(evt: ActionEvent): void;
  79037. /**
  79038. * Serializes the actions and its related information.
  79039. * @param parent defines the object to serialize in
  79040. * @returns the serialized object
  79041. */
  79042. serialize(parent: any): any;
  79043. }
  79044. /**
  79045. * This defines an action responsible to run code (external event) once triggered.
  79046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79047. */
  79048. export class ExecuteCodeAction extends Action {
  79049. /**
  79050. * The callback function to run.
  79051. */
  79052. func: (evt: ActionEvent) => void;
  79053. /**
  79054. * Instantiate the action
  79055. * @param triggerOptions defines the trigger options
  79056. * @param func defines the callback function to run
  79057. * @param condition defines the trigger related conditions
  79058. */
  79059. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79060. /**
  79061. * Execute the action and run the attached code.
  79062. */
  79063. execute(evt: ActionEvent): void;
  79064. }
  79065. /**
  79066. * This defines an action responsible to set the parent property of the target once triggered.
  79067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79068. */
  79069. export class SetParentAction extends Action {
  79070. private _parent;
  79071. private _target;
  79072. /**
  79073. * Instantiate the action
  79074. * @param triggerOptions defines the trigger options
  79075. * @param target defines the target containing the parent property
  79076. * @param parent defines from where the animation should start (animation frame)
  79077. * @param condition defines the trigger related conditions
  79078. */
  79079. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79080. /** @hidden */
  79081. _prepare(): void;
  79082. /**
  79083. * Execute the action and set the parent property.
  79084. */
  79085. execute(): void;
  79086. /**
  79087. * Serializes the actions and its related information.
  79088. * @param parent defines the object to serialize in
  79089. * @returns the serialized object
  79090. */
  79091. serialize(parent: any): any;
  79092. }
  79093. }
  79094. declare module BABYLON {
  79095. /**
  79096. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79097. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79099. */
  79100. export class ActionManager extends AbstractActionManager {
  79101. /**
  79102. * Nothing
  79103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79104. */
  79105. static readonly NothingTrigger: number;
  79106. /**
  79107. * On pick
  79108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79109. */
  79110. static readonly OnPickTrigger: number;
  79111. /**
  79112. * On left pick
  79113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79114. */
  79115. static readonly OnLeftPickTrigger: number;
  79116. /**
  79117. * On right pick
  79118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79119. */
  79120. static readonly OnRightPickTrigger: number;
  79121. /**
  79122. * On center pick
  79123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79124. */
  79125. static readonly OnCenterPickTrigger: number;
  79126. /**
  79127. * On pick down
  79128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79129. */
  79130. static readonly OnPickDownTrigger: number;
  79131. /**
  79132. * On double pick
  79133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79134. */
  79135. static readonly OnDoublePickTrigger: number;
  79136. /**
  79137. * On pick up
  79138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79139. */
  79140. static readonly OnPickUpTrigger: number;
  79141. /**
  79142. * On pick out.
  79143. * This trigger will only be raised if you also declared a OnPickDown
  79144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79145. */
  79146. static readonly OnPickOutTrigger: number;
  79147. /**
  79148. * On long press
  79149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79150. */
  79151. static readonly OnLongPressTrigger: number;
  79152. /**
  79153. * On pointer over
  79154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79155. */
  79156. static readonly OnPointerOverTrigger: number;
  79157. /**
  79158. * On pointer out
  79159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79160. */
  79161. static readonly OnPointerOutTrigger: number;
  79162. /**
  79163. * On every frame
  79164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79165. */
  79166. static readonly OnEveryFrameTrigger: number;
  79167. /**
  79168. * On intersection enter
  79169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79170. */
  79171. static readonly OnIntersectionEnterTrigger: number;
  79172. /**
  79173. * On intersection exit
  79174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79175. */
  79176. static readonly OnIntersectionExitTrigger: number;
  79177. /**
  79178. * On key down
  79179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79180. */
  79181. static readonly OnKeyDownTrigger: number;
  79182. /**
  79183. * On key up
  79184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79185. */
  79186. static readonly OnKeyUpTrigger: number;
  79187. private _scene;
  79188. /**
  79189. * Creates a new action manager
  79190. * @param scene defines the hosting scene
  79191. */
  79192. constructor(scene: Scene);
  79193. /**
  79194. * Releases all associated resources
  79195. */
  79196. dispose(): void;
  79197. /**
  79198. * Gets hosting scene
  79199. * @returns the hosting scene
  79200. */
  79201. getScene(): Scene;
  79202. /**
  79203. * Does this action manager handles actions of any of the given triggers
  79204. * @param triggers defines the triggers to be tested
  79205. * @return a boolean indicating whether one (or more) of the triggers is handled
  79206. */
  79207. hasSpecificTriggers(triggers: number[]): boolean;
  79208. /**
  79209. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79210. * speed.
  79211. * @param triggerA defines the trigger to be tested
  79212. * @param triggerB defines the trigger to be tested
  79213. * @return a boolean indicating whether one (or more) of the triggers is handled
  79214. */
  79215. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79216. /**
  79217. * Does this action manager handles actions of a given trigger
  79218. * @param trigger defines the trigger to be tested
  79219. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79220. * @return whether the trigger is handled
  79221. */
  79222. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79223. /**
  79224. * Does this action manager has pointer triggers
  79225. */
  79226. readonly hasPointerTriggers: boolean;
  79227. /**
  79228. * Does this action manager has pick triggers
  79229. */
  79230. readonly hasPickTriggers: boolean;
  79231. /**
  79232. * Registers an action to this action manager
  79233. * @param action defines the action to be registered
  79234. * @return the action amended (prepared) after registration
  79235. */
  79236. registerAction(action: IAction): Nullable<IAction>;
  79237. /**
  79238. * Unregisters an action to this action manager
  79239. * @param action defines the action to be unregistered
  79240. * @return a boolean indicating whether the action has been unregistered
  79241. */
  79242. unregisterAction(action: IAction): Boolean;
  79243. /**
  79244. * Process a specific trigger
  79245. * @param trigger defines the trigger to process
  79246. * @param evt defines the event details to be processed
  79247. */
  79248. processTrigger(trigger: number, evt?: IActionEvent): void;
  79249. /** @hidden */
  79250. _getEffectiveTarget(target: any, propertyPath: string): any;
  79251. /** @hidden */
  79252. _getProperty(propertyPath: string): string;
  79253. /**
  79254. * Serialize this manager to a JSON object
  79255. * @param name defines the property name to store this manager
  79256. * @returns a JSON representation of this manager
  79257. */
  79258. serialize(name: string): any;
  79259. /**
  79260. * Creates a new ActionManager from a JSON data
  79261. * @param parsedActions defines the JSON data to read from
  79262. * @param object defines the hosting mesh
  79263. * @param scene defines the hosting scene
  79264. */
  79265. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79266. /**
  79267. * Get a trigger name by index
  79268. * @param trigger defines the trigger index
  79269. * @returns a trigger name
  79270. */
  79271. static GetTriggerName(trigger: number): string;
  79272. }
  79273. }
  79274. declare module BABYLON {
  79275. /**
  79276. * Class representing a ray with position and direction
  79277. */
  79278. export class Ray {
  79279. /** origin point */
  79280. origin: Vector3;
  79281. /** direction */
  79282. direction: Vector3;
  79283. /** length of the ray */
  79284. length: number;
  79285. private static readonly TmpVector3;
  79286. private _tmpRay;
  79287. /**
  79288. * Creates a new ray
  79289. * @param origin origin point
  79290. * @param direction direction
  79291. * @param length length of the ray
  79292. */
  79293. constructor(
  79294. /** origin point */
  79295. origin: Vector3,
  79296. /** direction */
  79297. direction: Vector3,
  79298. /** length of the ray */
  79299. length?: number);
  79300. /**
  79301. * Checks if the ray intersects a box
  79302. * @param minimum bound of the box
  79303. * @param maximum bound of the box
  79304. * @param intersectionTreshold extra extend to be added to the box in all direction
  79305. * @returns if the box was hit
  79306. */
  79307. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79308. /**
  79309. * Checks if the ray intersects a box
  79310. * @param box the bounding box to check
  79311. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79312. * @returns if the box was hit
  79313. */
  79314. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79315. /**
  79316. * If the ray hits a sphere
  79317. * @param sphere the bounding sphere to check
  79318. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79319. * @returns true if it hits the sphere
  79320. */
  79321. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79322. /**
  79323. * If the ray hits a triange
  79324. * @param vertex0 triangle vertex
  79325. * @param vertex1 triangle vertex
  79326. * @param vertex2 triangle vertex
  79327. * @returns intersection information if hit
  79328. */
  79329. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79330. /**
  79331. * Checks if ray intersects a plane
  79332. * @param plane the plane to check
  79333. * @returns the distance away it was hit
  79334. */
  79335. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79336. /**
  79337. * Calculate the intercept of a ray on a given axis
  79338. * @param axis to check 'x' | 'y' | 'z'
  79339. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79340. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79341. */
  79342. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79343. /**
  79344. * Checks if ray intersects a mesh
  79345. * @param mesh the mesh to check
  79346. * @param fastCheck if only the bounding box should checked
  79347. * @returns picking info of the intersecton
  79348. */
  79349. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79350. /**
  79351. * Checks if ray intersects a mesh
  79352. * @param meshes the meshes to check
  79353. * @param fastCheck if only the bounding box should checked
  79354. * @param results array to store result in
  79355. * @returns Array of picking infos
  79356. */
  79357. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79358. private _comparePickingInfo;
  79359. private static smallnum;
  79360. private static rayl;
  79361. /**
  79362. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79363. * @param sega the first point of the segment to test the intersection against
  79364. * @param segb the second point of the segment to test the intersection against
  79365. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79366. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79367. */
  79368. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79369. /**
  79370. * Update the ray from viewport position
  79371. * @param x position
  79372. * @param y y position
  79373. * @param viewportWidth viewport width
  79374. * @param viewportHeight viewport height
  79375. * @param world world matrix
  79376. * @param view view matrix
  79377. * @param projection projection matrix
  79378. * @returns this ray updated
  79379. */
  79380. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79381. /**
  79382. * Creates a ray with origin and direction of 0,0,0
  79383. * @returns the new ray
  79384. */
  79385. static Zero(): Ray;
  79386. /**
  79387. * Creates a new ray from screen space and viewport
  79388. * @param x position
  79389. * @param y y position
  79390. * @param viewportWidth viewport width
  79391. * @param viewportHeight viewport height
  79392. * @param world world matrix
  79393. * @param view view matrix
  79394. * @param projection projection matrix
  79395. * @returns new ray
  79396. */
  79397. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79398. /**
  79399. * 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
  79400. * transformed to the given world matrix.
  79401. * @param origin The origin point
  79402. * @param end The end point
  79403. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79404. * @returns the new ray
  79405. */
  79406. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79407. /**
  79408. * Transforms a ray by a matrix
  79409. * @param ray ray to transform
  79410. * @param matrix matrix to apply
  79411. * @returns the resulting new ray
  79412. */
  79413. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79414. /**
  79415. * Transforms a ray by a matrix
  79416. * @param ray ray to transform
  79417. * @param matrix matrix to apply
  79418. * @param result ray to store result in
  79419. */
  79420. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79421. /**
  79422. * Unproject a ray from screen space to object space
  79423. * @param sourceX defines the screen space x coordinate to use
  79424. * @param sourceY defines the screen space y coordinate to use
  79425. * @param viewportWidth defines the current width of the viewport
  79426. * @param viewportHeight defines the current height of the viewport
  79427. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79428. * @param view defines the view matrix to use
  79429. * @param projection defines the projection matrix to use
  79430. */
  79431. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79432. }
  79433. /**
  79434. * Type used to define predicate used to select faces when a mesh intersection is detected
  79435. */
  79436. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79437. interface Scene {
  79438. /** @hidden */
  79439. _tempPickingRay: Nullable<Ray>;
  79440. /** @hidden */
  79441. _cachedRayForTransform: Ray;
  79442. /** @hidden */
  79443. _pickWithRayInverseMatrix: Matrix;
  79444. /** @hidden */
  79445. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79446. /** @hidden */
  79447. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /**
  79452. * Groups all the scene component constants in one place to ease maintenance.
  79453. * @hidden
  79454. */
  79455. export class SceneComponentConstants {
  79456. static readonly NAME_EFFECTLAYER: string;
  79457. static readonly NAME_LAYER: string;
  79458. static readonly NAME_LENSFLARESYSTEM: string;
  79459. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79460. static readonly NAME_PARTICLESYSTEM: string;
  79461. static readonly NAME_GAMEPAD: string;
  79462. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79463. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79464. static readonly NAME_DEPTHRENDERER: string;
  79465. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79466. static readonly NAME_SPRITE: string;
  79467. static readonly NAME_OUTLINERENDERER: string;
  79468. static readonly NAME_PROCEDURALTEXTURE: string;
  79469. static readonly NAME_SHADOWGENERATOR: string;
  79470. static readonly NAME_OCTREE: string;
  79471. static readonly NAME_PHYSICSENGINE: string;
  79472. static readonly NAME_AUDIO: string;
  79473. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79474. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79475. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79476. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79477. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79478. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79479. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79480. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79481. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79482. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79483. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79484. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79485. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79486. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79487. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79488. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79489. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79490. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79491. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79492. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79493. static readonly STEP_AFTERRENDER_AUDIO: number;
  79494. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79495. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79496. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79497. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79498. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79499. static readonly STEP_POINTERMOVE_SPRITE: number;
  79500. static readonly STEP_POINTERDOWN_SPRITE: number;
  79501. static readonly STEP_POINTERUP_SPRITE: number;
  79502. }
  79503. /**
  79504. * This represents a scene component.
  79505. *
  79506. * This is used to decouple the dependency the scene is having on the different workloads like
  79507. * layers, post processes...
  79508. */
  79509. export interface ISceneComponent {
  79510. /**
  79511. * The name of the component. Each component must have a unique name.
  79512. */
  79513. name: string;
  79514. /**
  79515. * The scene the component belongs to.
  79516. */
  79517. scene: Scene;
  79518. /**
  79519. * Register the component to one instance of a scene.
  79520. */
  79521. register(): void;
  79522. /**
  79523. * Rebuilds the elements related to this component in case of
  79524. * context lost for instance.
  79525. */
  79526. rebuild(): void;
  79527. /**
  79528. * Disposes the component and the associated ressources.
  79529. */
  79530. dispose(): void;
  79531. }
  79532. /**
  79533. * This represents a SERIALIZABLE scene component.
  79534. *
  79535. * This extends Scene Component to add Serialization methods on top.
  79536. */
  79537. export interface ISceneSerializableComponent extends ISceneComponent {
  79538. /**
  79539. * Adds all the elements from the container to the scene
  79540. * @param container the container holding the elements
  79541. */
  79542. addFromContainer(container: AbstractScene): void;
  79543. /**
  79544. * Removes all the elements in the container from the scene
  79545. * @param container contains the elements to remove
  79546. * @param dispose if the removed element should be disposed (default: false)
  79547. */
  79548. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79549. /**
  79550. * Serializes the component data to the specified json object
  79551. * @param serializationObject The object to serialize to
  79552. */
  79553. serialize(serializationObject: any): void;
  79554. }
  79555. /**
  79556. * Strong typing of a Mesh related stage step action
  79557. */
  79558. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79559. /**
  79560. * Strong typing of a Evaluate Sub Mesh related stage step action
  79561. */
  79562. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79563. /**
  79564. * Strong typing of a Active Mesh related stage step action
  79565. */
  79566. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79567. /**
  79568. * Strong typing of a Camera related stage step action
  79569. */
  79570. export type CameraStageAction = (camera: Camera) => void;
  79571. /**
  79572. * Strong typing of a Camera Frame buffer related stage step action
  79573. */
  79574. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79575. /**
  79576. * Strong typing of a Render Target related stage step action
  79577. */
  79578. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79579. /**
  79580. * Strong typing of a RenderingGroup related stage step action
  79581. */
  79582. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79583. /**
  79584. * Strong typing of a Mesh Render related stage step action
  79585. */
  79586. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79587. /**
  79588. * Strong typing of a simple stage step action
  79589. */
  79590. export type SimpleStageAction = () => void;
  79591. /**
  79592. * Strong typing of a render target action.
  79593. */
  79594. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79595. /**
  79596. * Strong typing of a pointer move action.
  79597. */
  79598. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79599. /**
  79600. * Strong typing of a pointer up/down action.
  79601. */
  79602. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79603. /**
  79604. * Representation of a stage in the scene (Basically a list of ordered steps)
  79605. * @hidden
  79606. */
  79607. export class Stage<T extends Function> extends Array<{
  79608. index: number;
  79609. component: ISceneComponent;
  79610. action: T;
  79611. }> {
  79612. /**
  79613. * Hide ctor from the rest of the world.
  79614. * @param items The items to add.
  79615. */
  79616. private constructor();
  79617. /**
  79618. * Creates a new Stage.
  79619. * @returns A new instance of a Stage
  79620. */
  79621. static Create<T extends Function>(): Stage<T>;
  79622. /**
  79623. * Registers a step in an ordered way in the targeted stage.
  79624. * @param index Defines the position to register the step in
  79625. * @param component Defines the component attached to the step
  79626. * @param action Defines the action to launch during the step
  79627. */
  79628. registerStep(index: number, component: ISceneComponent, action: T): void;
  79629. /**
  79630. * Clears all the steps from the stage.
  79631. */
  79632. clear(): void;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. interface Scene {
  79637. /** @hidden */
  79638. _pointerOverSprite: Nullable<Sprite>;
  79639. /** @hidden */
  79640. _pickedDownSprite: Nullable<Sprite>;
  79641. /** @hidden */
  79642. _tempSpritePickingRay: Nullable<Ray>;
  79643. /**
  79644. * All of the sprite managers added to this scene
  79645. * @see http://doc.babylonjs.com/babylon101/sprites
  79646. */
  79647. spriteManagers: Array<ISpriteManager>;
  79648. /**
  79649. * An event triggered when sprites rendering is about to start
  79650. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79651. */
  79652. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79653. /**
  79654. * An event triggered when sprites rendering is done
  79655. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79656. */
  79657. onAfterSpritesRenderingObservable: Observable<Scene>;
  79658. /** @hidden */
  79659. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79660. /** Launch a ray to try to pick a sprite in the scene
  79661. * @param x position on screen
  79662. * @param y position on screen
  79663. * @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
  79664. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79665. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79666. * @returns a PickingInfo
  79667. */
  79668. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79669. /** Use the given ray to pick a sprite in the scene
  79670. * @param ray The ray (in world space) to use to pick meshes
  79671. * @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
  79672. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79673. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79674. * @returns a PickingInfo
  79675. */
  79676. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79677. /** @hidden */
  79678. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79679. /** Launch a ray to try to pick sprites in the scene
  79680. * @param x position on screen
  79681. * @param y position on screen
  79682. * @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
  79683. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79684. * @returns a PickingInfo array
  79685. */
  79686. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79687. /** Use the given ray to pick sprites in the scene
  79688. * @param ray The ray (in world space) to use to pick meshes
  79689. * @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
  79690. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79691. * @returns a PickingInfo array
  79692. */
  79693. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79694. /**
  79695. * Force the sprite under the pointer
  79696. * @param sprite defines the sprite to use
  79697. */
  79698. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79699. /**
  79700. * Gets the sprite under the pointer
  79701. * @returns a Sprite or null if no sprite is under the pointer
  79702. */
  79703. getPointerOverSprite(): Nullable<Sprite>;
  79704. }
  79705. /**
  79706. * Defines the sprite scene component responsible to manage sprites
  79707. * in a given scene.
  79708. */
  79709. export class SpriteSceneComponent implements ISceneComponent {
  79710. /**
  79711. * The component name helpfull to identify the component in the list of scene components.
  79712. */
  79713. readonly name: string;
  79714. /**
  79715. * The scene the component belongs to.
  79716. */
  79717. scene: Scene;
  79718. /** @hidden */
  79719. private _spritePredicate;
  79720. /**
  79721. * Creates a new instance of the component for the given scene
  79722. * @param scene Defines the scene to register the component in
  79723. */
  79724. constructor(scene: Scene);
  79725. /**
  79726. * Registers the component in a given scene
  79727. */
  79728. register(): void;
  79729. /**
  79730. * Rebuilds the elements related to this component in case of
  79731. * context lost for instance.
  79732. */
  79733. rebuild(): void;
  79734. /**
  79735. * Disposes the component and the associated ressources.
  79736. */
  79737. dispose(): void;
  79738. private _pickSpriteButKeepRay;
  79739. private _pointerMove;
  79740. private _pointerDown;
  79741. private _pointerUp;
  79742. }
  79743. }
  79744. declare module BABYLON {
  79745. /** @hidden */
  79746. export var fogFragmentDeclaration: {
  79747. name: string;
  79748. shader: string;
  79749. };
  79750. }
  79751. declare module BABYLON {
  79752. /** @hidden */
  79753. export var fogFragment: {
  79754. name: string;
  79755. shader: string;
  79756. };
  79757. }
  79758. declare module BABYLON {
  79759. /** @hidden */
  79760. export var spritesPixelShader: {
  79761. name: string;
  79762. shader: string;
  79763. };
  79764. }
  79765. declare module BABYLON {
  79766. /** @hidden */
  79767. export var fogVertexDeclaration: {
  79768. name: string;
  79769. shader: string;
  79770. };
  79771. }
  79772. declare module BABYLON {
  79773. /** @hidden */
  79774. export var spritesVertexShader: {
  79775. name: string;
  79776. shader: string;
  79777. };
  79778. }
  79779. declare module BABYLON {
  79780. /**
  79781. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79782. */
  79783. export interface ISpriteManager extends IDisposable {
  79784. /**
  79785. * Restricts the camera to viewing objects with the same layerMask.
  79786. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79787. */
  79788. layerMask: number;
  79789. /**
  79790. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79791. */
  79792. isPickable: boolean;
  79793. /**
  79794. * Specifies the rendering group id for this mesh (0 by default)
  79795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79796. */
  79797. renderingGroupId: number;
  79798. /**
  79799. * Defines the list of sprites managed by the manager.
  79800. */
  79801. sprites: Array<Sprite>;
  79802. /**
  79803. * Tests the intersection of a sprite with a specific ray.
  79804. * @param ray The ray we are sending to test the collision
  79805. * @param camera The camera space we are sending rays in
  79806. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79807. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79808. * @returns picking info or null.
  79809. */
  79810. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79811. /**
  79812. * Intersects the sprites with a ray
  79813. * @param ray defines the ray to intersect with
  79814. * @param camera defines the current active camera
  79815. * @param predicate defines a predicate used to select candidate sprites
  79816. * @returns null if no hit or a PickingInfo array
  79817. */
  79818. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79819. /**
  79820. * Renders the list of sprites on screen.
  79821. */
  79822. render(): void;
  79823. }
  79824. /**
  79825. * Class used to manage multiple sprites on the same spritesheet
  79826. * @see http://doc.babylonjs.com/babylon101/sprites
  79827. */
  79828. export class SpriteManager implements ISpriteManager {
  79829. /** defines the manager's name */
  79830. name: string;
  79831. /** Gets the list of sprites */
  79832. sprites: Sprite[];
  79833. /** Gets or sets the rendering group id (0 by default) */
  79834. renderingGroupId: number;
  79835. /** Gets or sets camera layer mask */
  79836. layerMask: number;
  79837. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79838. fogEnabled: boolean;
  79839. /** Gets or sets a boolean indicating if the sprites are pickable */
  79840. isPickable: boolean;
  79841. /** Defines the default width of a cell in the spritesheet */
  79842. cellWidth: number;
  79843. /** Defines the default height of a cell in the spritesheet */
  79844. cellHeight: number;
  79845. /** Associative array from JSON sprite data file */
  79846. private _cellData;
  79847. /** Array of sprite names from JSON sprite data file */
  79848. private _spriteMap;
  79849. /** True when packed cell data from JSON file is ready*/
  79850. private _packedAndReady;
  79851. /**
  79852. * An event triggered when the manager is disposed.
  79853. */
  79854. onDisposeObservable: Observable<SpriteManager>;
  79855. private _onDisposeObserver;
  79856. /**
  79857. * Callback called when the manager is disposed
  79858. */
  79859. onDispose: () => void;
  79860. private _capacity;
  79861. private _fromPacked;
  79862. private _spriteTexture;
  79863. private _epsilon;
  79864. private _scene;
  79865. private _vertexData;
  79866. private _buffer;
  79867. private _vertexBuffers;
  79868. private _indexBuffer;
  79869. private _effectBase;
  79870. private _effectFog;
  79871. /**
  79872. * Gets or sets the spritesheet texture
  79873. */
  79874. texture: Texture;
  79875. /**
  79876. * Creates a new sprite manager
  79877. * @param name defines the manager's name
  79878. * @param imgUrl defines the sprite sheet url
  79879. * @param capacity defines the maximum allowed number of sprites
  79880. * @param cellSize defines the size of a sprite cell
  79881. * @param scene defines the hosting scene
  79882. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79883. * @param samplingMode defines the smapling mode to use with spritesheet
  79884. * @param fromPacked set to false; do not alter
  79885. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79886. */
  79887. constructor(
  79888. /** defines the manager's name */
  79889. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79890. private _makePacked;
  79891. private _appendSpriteVertex;
  79892. /**
  79893. * Intersects the sprites with a ray
  79894. * @param ray defines the ray to intersect with
  79895. * @param camera defines the current active camera
  79896. * @param predicate defines a predicate used to select candidate sprites
  79897. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79898. * @returns null if no hit or a PickingInfo
  79899. */
  79900. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79901. /**
  79902. * Intersects the sprites with a ray
  79903. * @param ray defines the ray to intersect with
  79904. * @param camera defines the current active camera
  79905. * @param predicate defines a predicate used to select candidate sprites
  79906. * @returns null if no hit or a PickingInfo array
  79907. */
  79908. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79909. /**
  79910. * Render all child sprites
  79911. */
  79912. render(): void;
  79913. /**
  79914. * Release associated resources
  79915. */
  79916. dispose(): void;
  79917. }
  79918. }
  79919. declare module BABYLON {
  79920. /**
  79921. * Class used to represent a sprite
  79922. * @see http://doc.babylonjs.com/babylon101/sprites
  79923. */
  79924. export class Sprite {
  79925. /** defines the name */
  79926. name: string;
  79927. /** Gets or sets the current world position */
  79928. position: Vector3;
  79929. /** Gets or sets the main color */
  79930. color: Color4;
  79931. /** Gets or sets the width */
  79932. width: number;
  79933. /** Gets or sets the height */
  79934. height: number;
  79935. /** Gets or sets rotation angle */
  79936. angle: number;
  79937. /** Gets or sets the cell index in the sprite sheet */
  79938. cellIndex: number;
  79939. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79940. cellRef: string;
  79941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79942. invertU: number;
  79943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79944. invertV: number;
  79945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79946. disposeWhenFinishedAnimating: boolean;
  79947. /** Gets the list of attached animations */
  79948. animations: Animation[];
  79949. /** Gets or sets a boolean indicating if the sprite can be picked */
  79950. isPickable: boolean;
  79951. /**
  79952. * Gets or sets the associated action manager
  79953. */
  79954. actionManager: Nullable<ActionManager>;
  79955. private _animationStarted;
  79956. private _loopAnimation;
  79957. private _fromIndex;
  79958. private _toIndex;
  79959. private _delay;
  79960. private _direction;
  79961. private _manager;
  79962. private _time;
  79963. private _onAnimationEnd;
  79964. /**
  79965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79966. */
  79967. isVisible: boolean;
  79968. /**
  79969. * Gets or sets the sprite size
  79970. */
  79971. size: number;
  79972. /**
  79973. * Creates a new Sprite
  79974. * @param name defines the name
  79975. * @param manager defines the manager
  79976. */
  79977. constructor(
  79978. /** defines the name */
  79979. name: string, manager: ISpriteManager);
  79980. /**
  79981. * Starts an animation
  79982. * @param from defines the initial key
  79983. * @param to defines the end key
  79984. * @param loop defines if the animation must loop
  79985. * @param delay defines the start delay (in ms)
  79986. * @param onAnimationEnd defines a callback to call when animation ends
  79987. */
  79988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79989. /** Stops current animation (if any) */
  79990. stopAnimation(): void;
  79991. /** @hidden */
  79992. _animate(deltaTime: number): void;
  79993. /** Release associated resources */
  79994. dispose(): void;
  79995. }
  79996. }
  79997. declare module BABYLON {
  79998. /**
  79999. * Information about the result of picking within a scene
  80000. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80001. */
  80002. export class PickingInfo {
  80003. /** @hidden */
  80004. _pickingUnavailable: boolean;
  80005. /**
  80006. * If the pick collided with an object
  80007. */
  80008. hit: boolean;
  80009. /**
  80010. * Distance away where the pick collided
  80011. */
  80012. distance: number;
  80013. /**
  80014. * The location of pick collision
  80015. */
  80016. pickedPoint: Nullable<Vector3>;
  80017. /**
  80018. * The mesh corresponding the the pick collision
  80019. */
  80020. pickedMesh: Nullable<AbstractMesh>;
  80021. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80022. bu: number;
  80023. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80024. bv: number;
  80025. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80026. faceId: number;
  80027. /** Id of the the submesh that was picked */
  80028. subMeshId: number;
  80029. /** If a sprite was picked, this will be the sprite the pick collided with */
  80030. pickedSprite: Nullable<Sprite>;
  80031. /**
  80032. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80033. */
  80034. originMesh: Nullable<AbstractMesh>;
  80035. /**
  80036. * The ray that was used to perform the picking.
  80037. */
  80038. ray: Nullable<Ray>;
  80039. /**
  80040. * Gets the normal correspodning to the face the pick collided with
  80041. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80042. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80043. * @returns The normal correspodning to the face the pick collided with
  80044. */
  80045. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80046. /**
  80047. * Gets the texture coordinates of where the pick occured
  80048. * @returns the vector containing the coordnates of the texture
  80049. */
  80050. getTextureCoordinates(): Nullable<Vector2>;
  80051. }
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * Gather the list of pointer event types as constants.
  80056. */
  80057. export class PointerEventTypes {
  80058. /**
  80059. * 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.
  80060. */
  80061. static readonly POINTERDOWN: number;
  80062. /**
  80063. * The pointerup event is fired when a pointer is no longer active.
  80064. */
  80065. static readonly POINTERUP: number;
  80066. /**
  80067. * The pointermove event is fired when a pointer changes coordinates.
  80068. */
  80069. static readonly POINTERMOVE: number;
  80070. /**
  80071. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80072. */
  80073. static readonly POINTERWHEEL: number;
  80074. /**
  80075. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80076. */
  80077. static readonly POINTERPICK: number;
  80078. /**
  80079. * The pointertap event is fired when a the object has been touched and released without drag.
  80080. */
  80081. static readonly POINTERTAP: number;
  80082. /**
  80083. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80084. */
  80085. static readonly POINTERDOUBLETAP: number;
  80086. }
  80087. /**
  80088. * Base class of pointer info types.
  80089. */
  80090. export class PointerInfoBase {
  80091. /**
  80092. * Defines the type of event (PointerEventTypes)
  80093. */
  80094. type: number;
  80095. /**
  80096. * Defines the related dom event
  80097. */
  80098. event: PointerEvent | MouseWheelEvent;
  80099. /**
  80100. * Instantiates the base class of pointers info.
  80101. * @param type Defines the type of event (PointerEventTypes)
  80102. * @param event Defines the related dom event
  80103. */
  80104. constructor(
  80105. /**
  80106. * Defines the type of event (PointerEventTypes)
  80107. */
  80108. type: number,
  80109. /**
  80110. * Defines the related dom event
  80111. */
  80112. event: PointerEvent | MouseWheelEvent);
  80113. }
  80114. /**
  80115. * This class is used to store pointer related info for the onPrePointerObservable event.
  80116. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80117. */
  80118. export class PointerInfoPre extends PointerInfoBase {
  80119. /**
  80120. * Ray from a pointer if availible (eg. 6dof controller)
  80121. */
  80122. ray: Nullable<Ray>;
  80123. /**
  80124. * Defines the local position of the pointer on the canvas.
  80125. */
  80126. localPosition: Vector2;
  80127. /**
  80128. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80129. */
  80130. skipOnPointerObservable: boolean;
  80131. /**
  80132. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80133. * @param type Defines the type of event (PointerEventTypes)
  80134. * @param event Defines the related dom event
  80135. * @param localX Defines the local x coordinates of the pointer when the event occured
  80136. * @param localY Defines the local y coordinates of the pointer when the event occured
  80137. */
  80138. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80139. }
  80140. /**
  80141. * This type contains all the data related to a pointer event in Babylon.js.
  80142. * 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.
  80143. */
  80144. export class PointerInfo extends PointerInfoBase {
  80145. /**
  80146. * Defines the picking info associated to the info (if any)\
  80147. */
  80148. pickInfo: Nullable<PickingInfo>;
  80149. /**
  80150. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80151. * @param type Defines the type of event (PointerEventTypes)
  80152. * @param event Defines the related dom event
  80153. * @param pickInfo Defines the picking info associated to the info (if any)\
  80154. */
  80155. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80156. /**
  80157. * Defines the picking info associated to the info (if any)\
  80158. */
  80159. pickInfo: Nullable<PickingInfo>);
  80160. }
  80161. /**
  80162. * Data relating to a touch event on the screen.
  80163. */
  80164. export interface PointerTouch {
  80165. /**
  80166. * X coordinate of touch.
  80167. */
  80168. x: number;
  80169. /**
  80170. * Y coordinate of touch.
  80171. */
  80172. y: number;
  80173. /**
  80174. * Id of touch. Unique for each finger.
  80175. */
  80176. pointerId: number;
  80177. /**
  80178. * Event type passed from DOM.
  80179. */
  80180. type: any;
  80181. }
  80182. }
  80183. declare module BABYLON {
  80184. /**
  80185. * Manage the mouse inputs to control the movement of a free camera.
  80186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80187. */
  80188. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80189. /**
  80190. * Define if touch is enabled in the mouse input
  80191. */
  80192. touchEnabled: boolean;
  80193. /**
  80194. * Defines the camera the input is attached to.
  80195. */
  80196. camera: FreeCamera;
  80197. /**
  80198. * Defines the buttons associated with the input to handle camera move.
  80199. */
  80200. buttons: number[];
  80201. /**
  80202. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80203. */
  80204. angularSensibility: number;
  80205. private _pointerInput;
  80206. private _onMouseMove;
  80207. private _observer;
  80208. private previousPosition;
  80209. /**
  80210. * Observable for when a pointer move event occurs containing the move offset
  80211. */
  80212. onPointerMovedObservable: Observable<{
  80213. offsetX: number;
  80214. offsetY: number;
  80215. }>;
  80216. /**
  80217. * @hidden
  80218. * If the camera should be rotated automatically based on pointer movement
  80219. */
  80220. _allowCameraRotation: boolean;
  80221. /**
  80222. * Manage the mouse inputs to control the movement of a free camera.
  80223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80224. * @param touchEnabled Defines if touch is enabled or not
  80225. */
  80226. constructor(
  80227. /**
  80228. * Define if touch is enabled in the mouse input
  80229. */
  80230. touchEnabled?: boolean);
  80231. /**
  80232. * Attach the input controls to a specific dom element to get the input from.
  80233. * @param element Defines the element the controls should be listened from
  80234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80235. */
  80236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80237. /**
  80238. * Called on JS contextmenu event.
  80239. * Override this method to provide functionality.
  80240. */
  80241. protected onContextMenu(evt: PointerEvent): void;
  80242. /**
  80243. * Detach the current controls from the specified dom element.
  80244. * @param element Defines the element to stop listening the inputs from
  80245. */
  80246. detachControl(element: Nullable<HTMLElement>): void;
  80247. /**
  80248. * Gets the class name of the current intput.
  80249. * @returns the class name
  80250. */
  80251. getClassName(): string;
  80252. /**
  80253. * Get the friendly name associated with the input class.
  80254. * @returns the input friendly name
  80255. */
  80256. getSimpleName(): string;
  80257. }
  80258. }
  80259. declare module BABYLON {
  80260. /**
  80261. * Manage the touch inputs to control the movement of a free camera.
  80262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80263. */
  80264. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80265. /**
  80266. * Defines the camera the input is attached to.
  80267. */
  80268. camera: FreeCamera;
  80269. /**
  80270. * Defines the touch sensibility for rotation.
  80271. * The higher the faster.
  80272. */
  80273. touchAngularSensibility: number;
  80274. /**
  80275. * Defines the touch sensibility for move.
  80276. * The higher the faster.
  80277. */
  80278. touchMoveSensibility: number;
  80279. private _offsetX;
  80280. private _offsetY;
  80281. private _pointerPressed;
  80282. private _pointerInput;
  80283. private _observer;
  80284. private _onLostFocus;
  80285. /**
  80286. * Attach the input controls to a specific dom element to get the input from.
  80287. * @param element Defines the element the controls should be listened from
  80288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80289. */
  80290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80291. /**
  80292. * Detach the current controls from the specified dom element.
  80293. * @param element Defines the element to stop listening the inputs from
  80294. */
  80295. detachControl(element: Nullable<HTMLElement>): void;
  80296. /**
  80297. * Update the current camera state depending on the inputs that have been used this frame.
  80298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80299. */
  80300. checkInputs(): void;
  80301. /**
  80302. * Gets the class name of the current intput.
  80303. * @returns the class name
  80304. */
  80305. getClassName(): string;
  80306. /**
  80307. * Get the friendly name associated with the input class.
  80308. * @returns the input friendly name
  80309. */
  80310. getSimpleName(): string;
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /**
  80315. * Default Inputs manager for the FreeCamera.
  80316. * It groups all the default supported inputs for ease of use.
  80317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80318. */
  80319. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80320. /**
  80321. * @hidden
  80322. */
  80323. _mouseInput: Nullable<FreeCameraMouseInput>;
  80324. /**
  80325. * Instantiates a new FreeCameraInputsManager.
  80326. * @param camera Defines the camera the inputs belong to
  80327. */
  80328. constructor(camera: FreeCamera);
  80329. /**
  80330. * Add keyboard input support to the input manager.
  80331. * @returns the current input manager
  80332. */
  80333. addKeyboard(): FreeCameraInputsManager;
  80334. /**
  80335. * Add mouse input support to the input manager.
  80336. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80337. * @returns the current input manager
  80338. */
  80339. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80340. /**
  80341. * Removes the mouse input support from the manager
  80342. * @returns the current input manager
  80343. */
  80344. removeMouse(): FreeCameraInputsManager;
  80345. /**
  80346. * Add touch input support to the input manager.
  80347. * @returns the current input manager
  80348. */
  80349. addTouch(): FreeCameraInputsManager;
  80350. /**
  80351. * Remove all attached input methods from a camera
  80352. */
  80353. clear(): void;
  80354. }
  80355. }
  80356. declare module BABYLON {
  80357. /**
  80358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80359. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80360. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80361. */
  80362. export class FreeCamera extends TargetCamera {
  80363. /**
  80364. * Define the collision ellipsoid of the camera.
  80365. * This is helpful to simulate a camera body like the player body around the camera
  80366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80367. */
  80368. ellipsoid: Vector3;
  80369. /**
  80370. * Define an offset for the position of the ellipsoid around the camera.
  80371. * This can be helpful to determine the center of the body near the gravity center of the body
  80372. * instead of its head.
  80373. */
  80374. ellipsoidOffset: Vector3;
  80375. /**
  80376. * Enable or disable collisions of the camera with the rest of the scene objects.
  80377. */
  80378. checkCollisions: boolean;
  80379. /**
  80380. * Enable or disable gravity on the camera.
  80381. */
  80382. applyGravity: boolean;
  80383. /**
  80384. * Define the input manager associated to the camera.
  80385. */
  80386. inputs: FreeCameraInputsManager;
  80387. /**
  80388. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80389. * Higher values reduce sensitivity.
  80390. */
  80391. /**
  80392. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80393. * Higher values reduce sensitivity.
  80394. */
  80395. angularSensibility: number;
  80396. /**
  80397. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80398. */
  80399. keysUp: number[];
  80400. /**
  80401. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80402. */
  80403. keysDown: number[];
  80404. /**
  80405. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80406. */
  80407. keysLeft: number[];
  80408. /**
  80409. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80410. */
  80411. keysRight: number[];
  80412. /**
  80413. * Event raised when the camera collide with a mesh in the scene.
  80414. */
  80415. onCollide: (collidedMesh: AbstractMesh) => void;
  80416. private _collider;
  80417. private _needMoveForGravity;
  80418. private _oldPosition;
  80419. private _diffPosition;
  80420. private _newPosition;
  80421. /** @hidden */
  80422. _localDirection: Vector3;
  80423. /** @hidden */
  80424. _transformedDirection: Vector3;
  80425. /**
  80426. * Instantiates a Free Camera.
  80427. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80428. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80430. * @param name Define the name of the camera in the scene
  80431. * @param position Define the start position of the camera in the scene
  80432. * @param scene Define the scene the camera belongs to
  80433. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80434. */
  80435. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80436. /**
  80437. * Attached controls to the current camera.
  80438. * @param element Defines the element the controls should be listened from
  80439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80440. */
  80441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80442. /**
  80443. * Detach the current controls from the camera.
  80444. * The camera will stop reacting to inputs.
  80445. * @param element Defines the element to stop listening the inputs from
  80446. */
  80447. detachControl(element: HTMLElement): void;
  80448. private _collisionMask;
  80449. /**
  80450. * Define a collision mask to limit the list of object the camera can collide with
  80451. */
  80452. collisionMask: number;
  80453. /** @hidden */
  80454. _collideWithWorld(displacement: Vector3): void;
  80455. private _onCollisionPositionChange;
  80456. /** @hidden */
  80457. _checkInputs(): void;
  80458. /** @hidden */
  80459. _decideIfNeedsToMove(): boolean;
  80460. /** @hidden */
  80461. _updatePosition(): void;
  80462. /**
  80463. * Destroy the camera and release the current resources hold by it.
  80464. */
  80465. dispose(): void;
  80466. /**
  80467. * Gets the current object class name.
  80468. * @return the class name
  80469. */
  80470. getClassName(): string;
  80471. }
  80472. }
  80473. declare module BABYLON {
  80474. /**
  80475. * Represents a gamepad control stick position
  80476. */
  80477. export class StickValues {
  80478. /**
  80479. * The x component of the control stick
  80480. */
  80481. x: number;
  80482. /**
  80483. * The y component of the control stick
  80484. */
  80485. y: number;
  80486. /**
  80487. * Initializes the gamepad x and y control stick values
  80488. * @param x The x component of the gamepad control stick value
  80489. * @param y The y component of the gamepad control stick value
  80490. */
  80491. constructor(
  80492. /**
  80493. * The x component of the control stick
  80494. */
  80495. x: number,
  80496. /**
  80497. * The y component of the control stick
  80498. */
  80499. y: number);
  80500. }
  80501. /**
  80502. * An interface which manages callbacks for gamepad button changes
  80503. */
  80504. export interface GamepadButtonChanges {
  80505. /**
  80506. * Called when a gamepad has been changed
  80507. */
  80508. changed: boolean;
  80509. /**
  80510. * Called when a gamepad press event has been triggered
  80511. */
  80512. pressChanged: boolean;
  80513. /**
  80514. * Called when a touch event has been triggered
  80515. */
  80516. touchChanged: boolean;
  80517. /**
  80518. * Called when a value has changed
  80519. */
  80520. valueChanged: boolean;
  80521. }
  80522. /**
  80523. * Represents a gamepad
  80524. */
  80525. export class Gamepad {
  80526. /**
  80527. * The id of the gamepad
  80528. */
  80529. id: string;
  80530. /**
  80531. * The index of the gamepad
  80532. */
  80533. index: number;
  80534. /**
  80535. * The browser gamepad
  80536. */
  80537. browserGamepad: any;
  80538. /**
  80539. * Specifies what type of gamepad this represents
  80540. */
  80541. type: number;
  80542. private _leftStick;
  80543. private _rightStick;
  80544. /** @hidden */
  80545. _isConnected: boolean;
  80546. private _leftStickAxisX;
  80547. private _leftStickAxisY;
  80548. private _rightStickAxisX;
  80549. private _rightStickAxisY;
  80550. /**
  80551. * Triggered when the left control stick has been changed
  80552. */
  80553. private _onleftstickchanged;
  80554. /**
  80555. * Triggered when the right control stick has been changed
  80556. */
  80557. private _onrightstickchanged;
  80558. /**
  80559. * Represents a gamepad controller
  80560. */
  80561. static GAMEPAD: number;
  80562. /**
  80563. * Represents a generic controller
  80564. */
  80565. static GENERIC: number;
  80566. /**
  80567. * Represents an XBox controller
  80568. */
  80569. static XBOX: number;
  80570. /**
  80571. * Represents a pose-enabled controller
  80572. */
  80573. static POSE_ENABLED: number;
  80574. /**
  80575. * Represents an Dual Shock controller
  80576. */
  80577. static DUALSHOCK: number;
  80578. /**
  80579. * Specifies whether the left control stick should be Y-inverted
  80580. */
  80581. protected _invertLeftStickY: boolean;
  80582. /**
  80583. * Specifies if the gamepad has been connected
  80584. */
  80585. readonly isConnected: boolean;
  80586. /**
  80587. * Initializes the gamepad
  80588. * @param id The id of the gamepad
  80589. * @param index The index of the gamepad
  80590. * @param browserGamepad The browser gamepad
  80591. * @param leftStickX The x component of the left joystick
  80592. * @param leftStickY The y component of the left joystick
  80593. * @param rightStickX The x component of the right joystick
  80594. * @param rightStickY The y component of the right joystick
  80595. */
  80596. constructor(
  80597. /**
  80598. * The id of the gamepad
  80599. */
  80600. id: string,
  80601. /**
  80602. * The index of the gamepad
  80603. */
  80604. index: number,
  80605. /**
  80606. * The browser gamepad
  80607. */
  80608. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80609. /**
  80610. * Callback triggered when the left joystick has changed
  80611. * @param callback
  80612. */
  80613. onleftstickchanged(callback: (values: StickValues) => void): void;
  80614. /**
  80615. * Callback triggered when the right joystick has changed
  80616. * @param callback
  80617. */
  80618. onrightstickchanged(callback: (values: StickValues) => void): void;
  80619. /**
  80620. * Gets the left joystick
  80621. */
  80622. /**
  80623. * Sets the left joystick values
  80624. */
  80625. leftStick: StickValues;
  80626. /**
  80627. * Gets the right joystick
  80628. */
  80629. /**
  80630. * Sets the right joystick value
  80631. */
  80632. rightStick: StickValues;
  80633. /**
  80634. * Updates the gamepad joystick positions
  80635. */
  80636. update(): void;
  80637. /**
  80638. * Disposes the gamepad
  80639. */
  80640. dispose(): void;
  80641. }
  80642. /**
  80643. * Represents a generic gamepad
  80644. */
  80645. export class GenericPad extends Gamepad {
  80646. private _buttons;
  80647. private _onbuttondown;
  80648. private _onbuttonup;
  80649. /**
  80650. * Observable triggered when a button has been pressed
  80651. */
  80652. onButtonDownObservable: Observable<number>;
  80653. /**
  80654. * Observable triggered when a button has been released
  80655. */
  80656. onButtonUpObservable: Observable<number>;
  80657. /**
  80658. * Callback triggered when a button has been pressed
  80659. * @param callback Called when a button has been pressed
  80660. */
  80661. onbuttondown(callback: (buttonPressed: number) => void): void;
  80662. /**
  80663. * Callback triggered when a button has been released
  80664. * @param callback Called when a button has been released
  80665. */
  80666. onbuttonup(callback: (buttonReleased: number) => void): void;
  80667. /**
  80668. * Initializes the generic gamepad
  80669. * @param id The id of the generic gamepad
  80670. * @param index The index of the generic gamepad
  80671. * @param browserGamepad The browser gamepad
  80672. */
  80673. constructor(id: string, index: number, browserGamepad: any);
  80674. private _setButtonValue;
  80675. /**
  80676. * Updates the generic gamepad
  80677. */
  80678. update(): void;
  80679. /**
  80680. * Disposes the generic gamepad
  80681. */
  80682. dispose(): void;
  80683. }
  80684. }
  80685. declare module BABYLON {
  80686. interface Engine {
  80687. /**
  80688. * Creates a raw texture
  80689. * @param data defines the data to store in the texture
  80690. * @param width defines the width of the texture
  80691. * @param height defines the height of the texture
  80692. * @param format defines the format of the data
  80693. * @param generateMipMaps defines if the engine should generate the mip levels
  80694. * @param invertY defines if data must be stored with Y axis inverted
  80695. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80696. * @param compression defines the compression used (null by default)
  80697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80698. * @returns the raw texture inside an InternalTexture
  80699. */
  80700. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80701. /**
  80702. * Update a raw texture
  80703. * @param texture defines the texture to update
  80704. * @param data defines the data to store in the texture
  80705. * @param format defines the format of the data
  80706. * @param invertY defines if data must be stored with Y axis inverted
  80707. */
  80708. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80709. /**
  80710. * Update a raw texture
  80711. * @param texture defines the texture to update
  80712. * @param data defines the data to store in the texture
  80713. * @param format defines the format of the data
  80714. * @param invertY defines if data must be stored with Y axis inverted
  80715. * @param compression defines the compression used (null by default)
  80716. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80717. */
  80718. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80719. /**
  80720. * Creates a new raw cube texture
  80721. * @param data defines the array of data to use to create each face
  80722. * @param size defines the size of the textures
  80723. * @param format defines the format of the data
  80724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80725. * @param generateMipMaps defines if the engine should generate the mip levels
  80726. * @param invertY defines if data must be stored with Y axis inverted
  80727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80728. * @param compression defines the compression used (null by default)
  80729. * @returns the cube texture as an InternalTexture
  80730. */
  80731. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80732. /**
  80733. * Update a raw cube texture
  80734. * @param texture defines the texture to udpdate
  80735. * @param data defines the data to store
  80736. * @param format defines the data format
  80737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80738. * @param invertY defines if data must be stored with Y axis inverted
  80739. */
  80740. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80741. /**
  80742. * Update a raw cube texture
  80743. * @param texture defines the texture to udpdate
  80744. * @param data defines the data to store
  80745. * @param format defines the data format
  80746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80747. * @param invertY defines if data must be stored with Y axis inverted
  80748. * @param compression defines the compression used (null by default)
  80749. */
  80750. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80751. /**
  80752. * Update a raw cube texture
  80753. * @param texture defines the texture to udpdate
  80754. * @param data defines the data to store
  80755. * @param format defines the data format
  80756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80757. * @param invertY defines if data must be stored with Y axis inverted
  80758. * @param compression defines the compression used (null by default)
  80759. * @param level defines which level of the texture to update
  80760. */
  80761. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80762. /**
  80763. * Creates a new raw cube texture from a specified url
  80764. * @param url defines the url where the data is located
  80765. * @param scene defines the current scene
  80766. * @param size defines the size of the textures
  80767. * @param format defines the format of the data
  80768. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80769. * @param noMipmap defines if the engine should avoid generating the mip levels
  80770. * @param callback defines a callback used to extract texture data from loaded data
  80771. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80772. * @param onLoad defines a callback called when texture is loaded
  80773. * @param onError defines a callback called if there is an error
  80774. * @returns the cube texture as an InternalTexture
  80775. */
  80776. 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;
  80777. /**
  80778. * Creates a new raw cube texture from a specified url
  80779. * @param url defines the url where the data is located
  80780. * @param scene defines the current scene
  80781. * @param size defines the size of the textures
  80782. * @param format defines the format of the data
  80783. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80784. * @param noMipmap defines if the engine should avoid generating the mip levels
  80785. * @param callback defines a callback used to extract texture data from loaded data
  80786. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80787. * @param onLoad defines a callback called when texture is loaded
  80788. * @param onError defines a callback called if there is an error
  80789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80790. * @param invertY defines if data must be stored with Y axis inverted
  80791. * @returns the cube texture as an InternalTexture
  80792. */
  80793. 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;
  80794. /**
  80795. * Creates a new raw 3D texture
  80796. * @param data defines the data used to create the texture
  80797. * @param width defines the width of the texture
  80798. * @param height defines the height of the texture
  80799. * @param depth defines the depth of the texture
  80800. * @param format defines the format of the texture
  80801. * @param generateMipMaps defines if the engine must generate mip levels
  80802. * @param invertY defines if data must be stored with Y axis inverted
  80803. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80804. * @param compression defines the compressed used (can be null)
  80805. * @param textureType defines the compressed used (can be null)
  80806. * @returns a new raw 3D texture (stored in an InternalTexture)
  80807. */
  80808. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80809. /**
  80810. * Update a raw 3D texture
  80811. * @param texture defines the texture to update
  80812. * @param data defines the data to store
  80813. * @param format defines the data format
  80814. * @param invertY defines if data must be stored with Y axis inverted
  80815. */
  80816. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80817. /**
  80818. * Update a raw 3D texture
  80819. * @param texture defines the texture to update
  80820. * @param data defines the data to store
  80821. * @param format defines the data format
  80822. * @param invertY defines if data must be stored with Y axis inverted
  80823. * @param compression defines the used compression (can be null)
  80824. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80825. */
  80826. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80827. /**
  80828. * Creates a new raw 2D array texture
  80829. * @param data defines the data used to create the texture
  80830. * @param width defines the width of the texture
  80831. * @param height defines the height of the texture
  80832. * @param depth defines the number of layers of the texture
  80833. * @param format defines the format of the texture
  80834. * @param generateMipMaps defines if the engine must generate mip levels
  80835. * @param invertY defines if data must be stored with Y axis inverted
  80836. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80837. * @param compression defines the compressed used (can be null)
  80838. * @param textureType defines the compressed used (can be null)
  80839. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80840. */
  80841. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80842. /**
  80843. * Update a raw 2D array texture
  80844. * @param texture defines the texture to update
  80845. * @param data defines the data to store
  80846. * @param format defines the data format
  80847. * @param invertY defines if data must be stored with Y axis inverted
  80848. */
  80849. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80850. /**
  80851. * Update a raw 2D array texture
  80852. * @param texture defines the texture to update
  80853. * @param data defines the data to store
  80854. * @param format defines the data format
  80855. * @param invertY defines if data must be stored with Y axis inverted
  80856. * @param compression defines the used compression (can be null)
  80857. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80858. */
  80859. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80860. }
  80861. }
  80862. declare module BABYLON {
  80863. /**
  80864. * Raw texture can help creating a texture directly from an array of data.
  80865. * This can be super useful if you either get the data from an uncompressed source or
  80866. * if you wish to create your texture pixel by pixel.
  80867. */
  80868. export class RawTexture extends Texture {
  80869. /**
  80870. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80871. */
  80872. format: number;
  80873. private _engine;
  80874. /**
  80875. * Instantiates a new RawTexture.
  80876. * Raw texture can help creating a texture directly from an array of data.
  80877. * This can be super useful if you either get the data from an uncompressed source or
  80878. * if you wish to create your texture pixel by pixel.
  80879. * @param data define the array of data to use to create the texture
  80880. * @param width define the width of the texture
  80881. * @param height define the height of the texture
  80882. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80883. * @param scene define the scene the texture belongs to
  80884. * @param generateMipMaps define whether mip maps should be generated or not
  80885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80888. */
  80889. constructor(data: ArrayBufferView, width: number, height: number,
  80890. /**
  80891. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80892. */
  80893. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80894. /**
  80895. * Updates the texture underlying data.
  80896. * @param data Define the new data of the texture
  80897. */
  80898. update(data: ArrayBufferView): void;
  80899. /**
  80900. * Creates a luminance texture from some data.
  80901. * @param data Define the texture data
  80902. * @param width Define the width of the texture
  80903. * @param height Define the height of the texture
  80904. * @param scene Define the scene the texture belongs to
  80905. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80906. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80907. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80908. * @returns the luminance texture
  80909. */
  80910. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80911. /**
  80912. * Creates a luminance alpha texture from some data.
  80913. * @param data Define the texture data
  80914. * @param width Define the width of the texture
  80915. * @param height Define the height of the texture
  80916. * @param scene Define the scene the texture belongs to
  80917. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80918. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80919. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80920. * @returns the luminance alpha texture
  80921. */
  80922. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80923. /**
  80924. * Creates an alpha texture from some data.
  80925. * @param data Define the texture data
  80926. * @param width Define the width of the texture
  80927. * @param height Define the height of the texture
  80928. * @param scene Define the scene the texture belongs to
  80929. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80930. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80931. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80932. * @returns the alpha texture
  80933. */
  80934. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80935. /**
  80936. * Creates a RGB texture from some data.
  80937. * @param data Define the texture data
  80938. * @param width Define the width of the texture
  80939. * @param height Define the height of the texture
  80940. * @param scene Define the scene the texture belongs to
  80941. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80942. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80943. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80944. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80945. * @returns the RGB alpha texture
  80946. */
  80947. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80948. /**
  80949. * Creates a RGBA texture from some data.
  80950. * @param data Define the texture data
  80951. * @param width Define the width of the texture
  80952. * @param height Define the height of the texture
  80953. * @param scene Define the scene the texture belongs to
  80954. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80955. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80956. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80957. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80958. * @returns the RGBA texture
  80959. */
  80960. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80961. /**
  80962. * Creates a R texture from some data.
  80963. * @param data Define the texture data
  80964. * @param width Define the width of the texture
  80965. * @param height Define the height of the texture
  80966. * @param scene Define the scene the texture belongs to
  80967. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80968. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80969. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80970. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80971. * @returns the R texture
  80972. */
  80973. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80974. }
  80975. }
  80976. declare module BABYLON {
  80977. /**
  80978. * Interface for the size containing width and height
  80979. */
  80980. export interface ISize {
  80981. /**
  80982. * Width
  80983. */
  80984. width: number;
  80985. /**
  80986. * Heighht
  80987. */
  80988. height: number;
  80989. }
  80990. /**
  80991. * Size containing widht and height
  80992. */
  80993. export class Size implements ISize {
  80994. /**
  80995. * Width
  80996. */
  80997. width: number;
  80998. /**
  80999. * Height
  81000. */
  81001. height: number;
  81002. /**
  81003. * Creates a Size object from the given width and height (floats).
  81004. * @param width width of the new size
  81005. * @param height height of the new size
  81006. */
  81007. constructor(width: number, height: number);
  81008. /**
  81009. * Returns a string with the Size width and height
  81010. * @returns a string with the Size width and height
  81011. */
  81012. toString(): string;
  81013. /**
  81014. * "Size"
  81015. * @returns the string "Size"
  81016. */
  81017. getClassName(): string;
  81018. /**
  81019. * Returns the Size hash code.
  81020. * @returns a hash code for a unique width and height
  81021. */
  81022. getHashCode(): number;
  81023. /**
  81024. * Updates the current size from the given one.
  81025. * @param src the given size
  81026. */
  81027. copyFrom(src: Size): void;
  81028. /**
  81029. * Updates in place the current Size from the given floats.
  81030. * @param width width of the new size
  81031. * @param height height of the new size
  81032. * @returns the updated Size.
  81033. */
  81034. copyFromFloats(width: number, height: number): Size;
  81035. /**
  81036. * Updates in place the current Size from the given floats.
  81037. * @param width width to set
  81038. * @param height height to set
  81039. * @returns the updated Size.
  81040. */
  81041. set(width: number, height: number): Size;
  81042. /**
  81043. * Multiplies the width and height by numbers
  81044. * @param w factor to multiple the width by
  81045. * @param h factor to multiple the height by
  81046. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81047. */
  81048. multiplyByFloats(w: number, h: number): Size;
  81049. /**
  81050. * Clones the size
  81051. * @returns a new Size copied from the given one.
  81052. */
  81053. clone(): Size;
  81054. /**
  81055. * True if the current Size and the given one width and height are strictly equal.
  81056. * @param other the other size to compare against
  81057. * @returns True if the current Size and the given one width and height are strictly equal.
  81058. */
  81059. equals(other: Size): boolean;
  81060. /**
  81061. * The surface of the Size : width * height (float).
  81062. */
  81063. readonly surface: number;
  81064. /**
  81065. * Create a new size of zero
  81066. * @returns a new Size set to (0.0, 0.0)
  81067. */
  81068. static Zero(): Size;
  81069. /**
  81070. * Sums the width and height of two sizes
  81071. * @param otherSize size to add to this size
  81072. * @returns a new Size set as the addition result of the current Size and the given one.
  81073. */
  81074. add(otherSize: Size): Size;
  81075. /**
  81076. * Subtracts the width and height of two
  81077. * @param otherSize size to subtract to this size
  81078. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81079. */
  81080. subtract(otherSize: Size): Size;
  81081. /**
  81082. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81083. * @param start starting size to lerp between
  81084. * @param end end size to lerp between
  81085. * @param amount amount to lerp between the start and end values
  81086. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81087. */
  81088. static Lerp(start: Size, end: Size, amount: number): Size;
  81089. }
  81090. }
  81091. declare module BABYLON {
  81092. /**
  81093. * Defines a runtime animation
  81094. */
  81095. export class RuntimeAnimation {
  81096. private _events;
  81097. /**
  81098. * The current frame of the runtime animation
  81099. */
  81100. private _currentFrame;
  81101. /**
  81102. * The animation used by the runtime animation
  81103. */
  81104. private _animation;
  81105. /**
  81106. * The target of the runtime animation
  81107. */
  81108. private _target;
  81109. /**
  81110. * The initiating animatable
  81111. */
  81112. private _host;
  81113. /**
  81114. * The original value of the runtime animation
  81115. */
  81116. private _originalValue;
  81117. /**
  81118. * The original blend value of the runtime animation
  81119. */
  81120. private _originalBlendValue;
  81121. /**
  81122. * The offsets cache of the runtime animation
  81123. */
  81124. private _offsetsCache;
  81125. /**
  81126. * The high limits cache of the runtime animation
  81127. */
  81128. private _highLimitsCache;
  81129. /**
  81130. * Specifies if the runtime animation has been stopped
  81131. */
  81132. private _stopped;
  81133. /**
  81134. * The blending factor of the runtime animation
  81135. */
  81136. private _blendingFactor;
  81137. /**
  81138. * The BabylonJS scene
  81139. */
  81140. private _scene;
  81141. /**
  81142. * The current value of the runtime animation
  81143. */
  81144. private _currentValue;
  81145. /** @hidden */
  81146. _animationState: _IAnimationState;
  81147. /**
  81148. * The active target of the runtime animation
  81149. */
  81150. private _activeTargets;
  81151. private _currentActiveTarget;
  81152. private _directTarget;
  81153. /**
  81154. * The target path of the runtime animation
  81155. */
  81156. private _targetPath;
  81157. /**
  81158. * The weight of the runtime animation
  81159. */
  81160. private _weight;
  81161. /**
  81162. * The ratio offset of the runtime animation
  81163. */
  81164. private _ratioOffset;
  81165. /**
  81166. * The previous delay of the runtime animation
  81167. */
  81168. private _previousDelay;
  81169. /**
  81170. * The previous ratio of the runtime animation
  81171. */
  81172. private _previousRatio;
  81173. private _enableBlending;
  81174. private _keys;
  81175. private _minFrame;
  81176. private _maxFrame;
  81177. private _minValue;
  81178. private _maxValue;
  81179. private _targetIsArray;
  81180. /**
  81181. * Gets the current frame of the runtime animation
  81182. */
  81183. readonly currentFrame: number;
  81184. /**
  81185. * Gets the weight of the runtime animation
  81186. */
  81187. readonly weight: number;
  81188. /**
  81189. * Gets the current value of the runtime animation
  81190. */
  81191. readonly currentValue: any;
  81192. /**
  81193. * Gets the target path of the runtime animation
  81194. */
  81195. readonly targetPath: string;
  81196. /**
  81197. * Gets the actual target of the runtime animation
  81198. */
  81199. readonly target: any;
  81200. /** @hidden */
  81201. _onLoop: () => void;
  81202. /**
  81203. * Create a new RuntimeAnimation object
  81204. * @param target defines the target of the animation
  81205. * @param animation defines the source animation object
  81206. * @param scene defines the hosting scene
  81207. * @param host defines the initiating Animatable
  81208. */
  81209. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81210. private _preparePath;
  81211. /**
  81212. * Gets the animation from the runtime animation
  81213. */
  81214. readonly animation: Animation;
  81215. /**
  81216. * Resets the runtime animation to the beginning
  81217. * @param restoreOriginal defines whether to restore the target property to the original value
  81218. */
  81219. reset(restoreOriginal?: boolean): void;
  81220. /**
  81221. * Specifies if the runtime animation is stopped
  81222. * @returns Boolean specifying if the runtime animation is stopped
  81223. */
  81224. isStopped(): boolean;
  81225. /**
  81226. * Disposes of the runtime animation
  81227. */
  81228. dispose(): void;
  81229. /**
  81230. * Apply the interpolated value to the target
  81231. * @param currentValue defines the value computed by the animation
  81232. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81233. */
  81234. setValue(currentValue: any, weight: number): void;
  81235. private _getOriginalValues;
  81236. private _setValue;
  81237. /**
  81238. * Gets the loop pmode of the runtime animation
  81239. * @returns Loop Mode
  81240. */
  81241. private _getCorrectLoopMode;
  81242. /**
  81243. * Move the current animation to a given frame
  81244. * @param frame defines the frame to move to
  81245. */
  81246. goToFrame(frame: number): void;
  81247. /**
  81248. * @hidden Internal use only
  81249. */
  81250. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81251. /**
  81252. * Execute the current animation
  81253. * @param delay defines the delay to add to the current frame
  81254. * @param from defines the lower bound of the animation range
  81255. * @param to defines the upper bound of the animation range
  81256. * @param loop defines if the current animation must loop
  81257. * @param speedRatio defines the current speed ratio
  81258. * @param weight defines the weight of the animation (default is -1 so no weight)
  81259. * @param onLoop optional callback called when animation loops
  81260. * @returns a boolean indicating if the animation is running
  81261. */
  81262. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81263. }
  81264. }
  81265. declare module BABYLON {
  81266. /**
  81267. * Class used to store an actual running animation
  81268. */
  81269. export class Animatable {
  81270. /** defines the target object */
  81271. target: any;
  81272. /** defines the starting frame number (default is 0) */
  81273. fromFrame: number;
  81274. /** defines the ending frame number (default is 100) */
  81275. toFrame: number;
  81276. /** defines if the animation must loop (default is false) */
  81277. loopAnimation: boolean;
  81278. /** defines a callback to call when animation ends if it is not looping */
  81279. onAnimationEnd?: (() => void) | null | undefined;
  81280. /** defines a callback to call when animation loops */
  81281. onAnimationLoop?: (() => void) | null | undefined;
  81282. private _localDelayOffset;
  81283. private _pausedDelay;
  81284. private _runtimeAnimations;
  81285. private _paused;
  81286. private _scene;
  81287. private _speedRatio;
  81288. private _weight;
  81289. private _syncRoot;
  81290. /**
  81291. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81292. * This will only apply for non looping animation (default is true)
  81293. */
  81294. disposeOnEnd: boolean;
  81295. /**
  81296. * Gets a boolean indicating if the animation has started
  81297. */
  81298. animationStarted: boolean;
  81299. /**
  81300. * Observer raised when the animation ends
  81301. */
  81302. onAnimationEndObservable: Observable<Animatable>;
  81303. /**
  81304. * Observer raised when the animation loops
  81305. */
  81306. onAnimationLoopObservable: Observable<Animatable>;
  81307. /**
  81308. * Gets the root Animatable used to synchronize and normalize animations
  81309. */
  81310. readonly syncRoot: Nullable<Animatable>;
  81311. /**
  81312. * Gets the current frame of the first RuntimeAnimation
  81313. * Used to synchronize Animatables
  81314. */
  81315. readonly masterFrame: number;
  81316. /**
  81317. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81318. */
  81319. weight: number;
  81320. /**
  81321. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81322. */
  81323. speedRatio: number;
  81324. /**
  81325. * Creates a new Animatable
  81326. * @param scene defines the hosting scene
  81327. * @param target defines the target object
  81328. * @param fromFrame defines the starting frame number (default is 0)
  81329. * @param toFrame defines the ending frame number (default is 100)
  81330. * @param loopAnimation defines if the animation must loop (default is false)
  81331. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81332. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81333. * @param animations defines a group of animation to add to the new Animatable
  81334. * @param onAnimationLoop defines a callback to call when animation loops
  81335. */
  81336. constructor(scene: Scene,
  81337. /** defines the target object */
  81338. target: any,
  81339. /** defines the starting frame number (default is 0) */
  81340. fromFrame?: number,
  81341. /** defines the ending frame number (default is 100) */
  81342. toFrame?: number,
  81343. /** defines if the animation must loop (default is false) */
  81344. loopAnimation?: boolean, speedRatio?: number,
  81345. /** defines a callback to call when animation ends if it is not looping */
  81346. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81347. /** defines a callback to call when animation loops */
  81348. onAnimationLoop?: (() => void) | null | undefined);
  81349. /**
  81350. * Synchronize and normalize current Animatable with a source Animatable
  81351. * This is useful when using animation weights and when animations are not of the same length
  81352. * @param root defines the root Animatable to synchronize with
  81353. * @returns the current Animatable
  81354. */
  81355. syncWith(root: Animatable): Animatable;
  81356. /**
  81357. * Gets the list of runtime animations
  81358. * @returns an array of RuntimeAnimation
  81359. */
  81360. getAnimations(): RuntimeAnimation[];
  81361. /**
  81362. * Adds more animations to the current animatable
  81363. * @param target defines the target of the animations
  81364. * @param animations defines the new animations to add
  81365. */
  81366. appendAnimations(target: any, animations: Animation[]): void;
  81367. /**
  81368. * Gets the source animation for a specific property
  81369. * @param property defines the propertyu to look for
  81370. * @returns null or the source animation for the given property
  81371. */
  81372. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81373. /**
  81374. * Gets the runtime animation for a specific property
  81375. * @param property defines the propertyu to look for
  81376. * @returns null or the runtime animation for the given property
  81377. */
  81378. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81379. /**
  81380. * Resets the animatable to its original state
  81381. */
  81382. reset(): void;
  81383. /**
  81384. * Allows the animatable to blend with current running animations
  81385. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81386. * @param blendingSpeed defines the blending speed to use
  81387. */
  81388. enableBlending(blendingSpeed: number): void;
  81389. /**
  81390. * Disable animation blending
  81391. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81392. */
  81393. disableBlending(): void;
  81394. /**
  81395. * Jump directly to a given frame
  81396. * @param frame defines the frame to jump to
  81397. */
  81398. goToFrame(frame: number): void;
  81399. /**
  81400. * Pause the animation
  81401. */
  81402. pause(): void;
  81403. /**
  81404. * Restart the animation
  81405. */
  81406. restart(): void;
  81407. private _raiseOnAnimationEnd;
  81408. /**
  81409. * Stop and delete the current animation
  81410. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81411. * @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)
  81412. */
  81413. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81414. /**
  81415. * Wait asynchronously for the animation to end
  81416. * @returns a promise which will be fullfilled when the animation ends
  81417. */
  81418. waitAsync(): Promise<Animatable>;
  81419. /** @hidden */
  81420. _animate(delay: number): boolean;
  81421. }
  81422. interface Scene {
  81423. /** @hidden */
  81424. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81425. /** @hidden */
  81426. _processLateAnimationBindingsForMatrices(holder: {
  81427. totalWeight: number;
  81428. animations: RuntimeAnimation[];
  81429. originalValue: Matrix;
  81430. }): any;
  81431. /** @hidden */
  81432. _processLateAnimationBindingsForQuaternions(holder: {
  81433. totalWeight: number;
  81434. animations: RuntimeAnimation[];
  81435. originalValue: Quaternion;
  81436. }, refQuaternion: Quaternion): Quaternion;
  81437. /** @hidden */
  81438. _processLateAnimationBindings(): void;
  81439. /**
  81440. * Will start the animation sequence of a given target
  81441. * @param target defines the target
  81442. * @param from defines from which frame should animation start
  81443. * @param to defines until which frame should animation run.
  81444. * @param weight defines the weight to apply to the animation (1.0 by default)
  81445. * @param loop defines if the animation loops
  81446. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81447. * @param onAnimationEnd defines the function to be executed when the animation ends
  81448. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81449. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81450. * @param onAnimationLoop defines the callback to call when an animation loops
  81451. * @returns the animatable object created for this animation
  81452. */
  81453. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81454. /**
  81455. * Will start the animation sequence of a given target
  81456. * @param target defines the target
  81457. * @param from defines from which frame should animation start
  81458. * @param to defines until which frame should animation run.
  81459. * @param loop defines if the animation loops
  81460. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81461. * @param onAnimationEnd defines the function to be executed when the animation ends
  81462. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81463. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81464. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81465. * @param onAnimationLoop defines the callback to call when an animation loops
  81466. * @returns the animatable object created for this animation
  81467. */
  81468. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81469. /**
  81470. * Will start the animation sequence of a given target and its hierarchy
  81471. * @param target defines the target
  81472. * @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.
  81473. * @param from defines from which frame should animation start
  81474. * @param to defines until which frame should animation run.
  81475. * @param loop defines if the animation loops
  81476. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81477. * @param onAnimationEnd defines the function to be executed when the animation ends
  81478. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81479. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81480. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81481. * @param onAnimationLoop defines the callback to call when an animation loops
  81482. * @returns the list of created animatables
  81483. */
  81484. 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[];
  81485. /**
  81486. * Begin a new animation on a given node
  81487. * @param target defines the target where the animation will take place
  81488. * @param animations defines the list of animations to start
  81489. * @param from defines the initial value
  81490. * @param to defines the final value
  81491. * @param loop defines if you want animation to loop (off by default)
  81492. * @param speedRatio defines the speed ratio to apply to all animations
  81493. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81494. * @param onAnimationLoop defines the callback to call when an animation loops
  81495. * @returns the list of created animatables
  81496. */
  81497. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81498. /**
  81499. * Begin a new animation on a given node and its hierarchy
  81500. * @param target defines the root node where the animation will take place
  81501. * @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.
  81502. * @param animations defines the list of animations to start
  81503. * @param from defines the initial value
  81504. * @param to defines the final value
  81505. * @param loop defines if you want animation to loop (off by default)
  81506. * @param speedRatio defines the speed ratio to apply to all animations
  81507. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81508. * @param onAnimationLoop defines the callback to call when an animation loops
  81509. * @returns the list of animatables created for all nodes
  81510. */
  81511. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81512. /**
  81513. * Gets the animatable associated with a specific target
  81514. * @param target defines the target of the animatable
  81515. * @returns the required animatable if found
  81516. */
  81517. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81518. /**
  81519. * Gets all animatables associated with a given target
  81520. * @param target defines the target to look animatables for
  81521. * @returns an array of Animatables
  81522. */
  81523. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81524. /**
  81525. * Stops and removes all animations that have been applied to the scene
  81526. */
  81527. stopAllAnimations(): void;
  81528. /**
  81529. * Gets the current delta time used by animation engine
  81530. */
  81531. deltaTime: number;
  81532. }
  81533. interface Bone {
  81534. /**
  81535. * Copy an animation range from another bone
  81536. * @param source defines the source bone
  81537. * @param rangeName defines the range name to copy
  81538. * @param frameOffset defines the frame offset
  81539. * @param rescaleAsRequired defines if rescaling must be applied if required
  81540. * @param skelDimensionsRatio defines the scaling ratio
  81541. * @returns true if operation was successful
  81542. */
  81543. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81544. }
  81545. }
  81546. declare module BABYLON {
  81547. /**
  81548. * Class used to override all child animations of a given target
  81549. */
  81550. export class AnimationPropertiesOverride {
  81551. /**
  81552. * Gets or sets a value indicating if animation blending must be used
  81553. */
  81554. enableBlending: boolean;
  81555. /**
  81556. * Gets or sets the blending speed to use when enableBlending is true
  81557. */
  81558. blendingSpeed: number;
  81559. /**
  81560. * Gets or sets the default loop mode to use
  81561. */
  81562. loopMode: number;
  81563. }
  81564. }
  81565. declare module BABYLON {
  81566. /**
  81567. * Class used to handle skinning animations
  81568. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81569. */
  81570. export class Skeleton implements IAnimatable {
  81571. /** defines the skeleton name */
  81572. name: string;
  81573. /** defines the skeleton Id */
  81574. id: string;
  81575. /**
  81576. * Defines the list of child bones
  81577. */
  81578. bones: Bone[];
  81579. /**
  81580. * Defines an estimate of the dimension of the skeleton at rest
  81581. */
  81582. dimensionsAtRest: Vector3;
  81583. /**
  81584. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81585. */
  81586. needInitialSkinMatrix: boolean;
  81587. /**
  81588. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81589. */
  81590. overrideMesh: Nullable<AbstractMesh>;
  81591. /**
  81592. * Gets the list of animations attached to this skeleton
  81593. */
  81594. animations: Array<Animation>;
  81595. private _scene;
  81596. private _isDirty;
  81597. private _transformMatrices;
  81598. private _transformMatrixTexture;
  81599. private _meshesWithPoseMatrix;
  81600. private _animatables;
  81601. private _identity;
  81602. private _synchronizedWithMesh;
  81603. private _ranges;
  81604. private _lastAbsoluteTransformsUpdateId;
  81605. private _canUseTextureForBones;
  81606. private _uniqueId;
  81607. /** @hidden */
  81608. _numBonesWithLinkedTransformNode: number;
  81609. /** @hidden */
  81610. _hasWaitingData: Nullable<boolean>;
  81611. /**
  81612. * Specifies if the skeleton should be serialized
  81613. */
  81614. doNotSerialize: boolean;
  81615. private _useTextureToStoreBoneMatrices;
  81616. /**
  81617. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81618. * Please note that this option is not available if the hardware does not support it
  81619. */
  81620. useTextureToStoreBoneMatrices: boolean;
  81621. private _animationPropertiesOverride;
  81622. /**
  81623. * Gets or sets the animation properties override
  81624. */
  81625. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81626. /**
  81627. * List of inspectable custom properties (used by the Inspector)
  81628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81629. */
  81630. inspectableCustomProperties: IInspectable[];
  81631. /**
  81632. * An observable triggered before computing the skeleton's matrices
  81633. */
  81634. onBeforeComputeObservable: Observable<Skeleton>;
  81635. /**
  81636. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81637. */
  81638. readonly isUsingTextureForMatrices: boolean;
  81639. /**
  81640. * Gets the unique ID of this skeleton
  81641. */
  81642. readonly uniqueId: number;
  81643. /**
  81644. * Creates a new skeleton
  81645. * @param name defines the skeleton name
  81646. * @param id defines the skeleton Id
  81647. * @param scene defines the hosting scene
  81648. */
  81649. constructor(
  81650. /** defines the skeleton name */
  81651. name: string,
  81652. /** defines the skeleton Id */
  81653. id: string, scene: Scene);
  81654. /**
  81655. * Gets the current object class name.
  81656. * @return the class name
  81657. */
  81658. getClassName(): string;
  81659. /**
  81660. * Returns an array containing the root bones
  81661. * @returns an array containing the root bones
  81662. */
  81663. getChildren(): Array<Bone>;
  81664. /**
  81665. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81666. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81667. * @returns a Float32Array containing matrices data
  81668. */
  81669. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81670. /**
  81671. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81673. * @returns a raw texture containing the data
  81674. */
  81675. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81676. /**
  81677. * Gets the current hosting scene
  81678. * @returns a scene object
  81679. */
  81680. getScene(): Scene;
  81681. /**
  81682. * Gets a string representing the current skeleton data
  81683. * @param fullDetails defines a boolean indicating if we want a verbose version
  81684. * @returns a string representing the current skeleton data
  81685. */
  81686. toString(fullDetails?: boolean): string;
  81687. /**
  81688. * Get bone's index searching by name
  81689. * @param name defines bone's name to search for
  81690. * @return the indice of the bone. Returns -1 if not found
  81691. */
  81692. getBoneIndexByName(name: string): number;
  81693. /**
  81694. * Creater a new animation range
  81695. * @param name defines the name of the range
  81696. * @param from defines the start key
  81697. * @param to defines the end key
  81698. */
  81699. createAnimationRange(name: string, from: number, to: number): void;
  81700. /**
  81701. * Delete a specific animation range
  81702. * @param name defines the name of the range
  81703. * @param deleteFrames defines if frames must be removed as well
  81704. */
  81705. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81706. /**
  81707. * Gets a specific animation range
  81708. * @param name defines the name of the range to look for
  81709. * @returns the requested animation range or null if not found
  81710. */
  81711. getAnimationRange(name: string): Nullable<AnimationRange>;
  81712. /**
  81713. * Gets the list of all animation ranges defined on this skeleton
  81714. * @returns an array
  81715. */
  81716. getAnimationRanges(): Nullable<AnimationRange>[];
  81717. /**
  81718. * Copy animation range from a source skeleton.
  81719. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81720. * @param source defines the source skeleton
  81721. * @param name defines the name of the range to copy
  81722. * @param rescaleAsRequired defines if rescaling must be applied if required
  81723. * @returns true if operation was successful
  81724. */
  81725. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81726. /**
  81727. * Forces the skeleton to go to rest pose
  81728. */
  81729. returnToRest(): void;
  81730. private _getHighestAnimationFrame;
  81731. /**
  81732. * Begin a specific animation range
  81733. * @param name defines the name of the range to start
  81734. * @param loop defines if looping must be turned on (false by default)
  81735. * @param speedRatio defines the speed ratio to apply (1 by default)
  81736. * @param onAnimationEnd defines a callback which will be called when animation will end
  81737. * @returns a new animatable
  81738. */
  81739. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81740. /** @hidden */
  81741. _markAsDirty(): void;
  81742. /** @hidden */
  81743. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81744. /** @hidden */
  81745. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81746. private _computeTransformMatrices;
  81747. /**
  81748. * Build all resources required to render a skeleton
  81749. */
  81750. prepare(): void;
  81751. /**
  81752. * Gets the list of animatables currently running for this skeleton
  81753. * @returns an array of animatables
  81754. */
  81755. getAnimatables(): IAnimatable[];
  81756. /**
  81757. * Clone the current skeleton
  81758. * @param name defines the name of the new skeleton
  81759. * @param id defines the id of the new skeleton
  81760. * @returns the new skeleton
  81761. */
  81762. clone(name: string, id?: string): Skeleton;
  81763. /**
  81764. * Enable animation blending for this skeleton
  81765. * @param blendingSpeed defines the blending speed to apply
  81766. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81767. */
  81768. enableBlending(blendingSpeed?: number): void;
  81769. /**
  81770. * Releases all resources associated with the current skeleton
  81771. */
  81772. dispose(): void;
  81773. /**
  81774. * Serialize the skeleton in a JSON object
  81775. * @returns a JSON object
  81776. */
  81777. serialize(): any;
  81778. /**
  81779. * Creates a new skeleton from serialized data
  81780. * @param parsedSkeleton defines the serialized data
  81781. * @param scene defines the hosting scene
  81782. * @returns a new skeleton
  81783. */
  81784. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81785. /**
  81786. * Compute all node absolute transforms
  81787. * @param forceUpdate defines if computation must be done even if cache is up to date
  81788. */
  81789. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81790. /**
  81791. * Gets the root pose matrix
  81792. * @returns a matrix
  81793. */
  81794. getPoseMatrix(): Nullable<Matrix>;
  81795. /**
  81796. * Sorts bones per internal index
  81797. */
  81798. sortBones(): void;
  81799. private _sortBones;
  81800. }
  81801. }
  81802. declare module BABYLON {
  81803. /**
  81804. * Class used to store bone information
  81805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81806. */
  81807. export class Bone extends Node {
  81808. /**
  81809. * defines the bone name
  81810. */
  81811. name: string;
  81812. private static _tmpVecs;
  81813. private static _tmpQuat;
  81814. private static _tmpMats;
  81815. /**
  81816. * Gets the list of child bones
  81817. */
  81818. children: Bone[];
  81819. /** Gets the animations associated with this bone */
  81820. animations: Animation[];
  81821. /**
  81822. * Gets or sets bone length
  81823. */
  81824. length: number;
  81825. /**
  81826. * @hidden Internal only
  81827. * Set this value to map this bone to a different index in the transform matrices
  81828. * Set this value to -1 to exclude the bone from the transform matrices
  81829. */
  81830. _index: Nullable<number>;
  81831. private _skeleton;
  81832. private _localMatrix;
  81833. private _restPose;
  81834. private _baseMatrix;
  81835. private _absoluteTransform;
  81836. private _invertedAbsoluteTransform;
  81837. private _parent;
  81838. private _scalingDeterminant;
  81839. private _worldTransform;
  81840. private _localScaling;
  81841. private _localRotation;
  81842. private _localPosition;
  81843. private _needToDecompose;
  81844. private _needToCompose;
  81845. /** @hidden */
  81846. _linkedTransformNode: Nullable<TransformNode>;
  81847. /** @hidden */
  81848. _waitingTransformNodeId: Nullable<string>;
  81849. /** @hidden */
  81850. /** @hidden */
  81851. _matrix: Matrix;
  81852. /**
  81853. * Create a new bone
  81854. * @param name defines the bone name
  81855. * @param skeleton defines the parent skeleton
  81856. * @param parentBone defines the parent (can be null if the bone is the root)
  81857. * @param localMatrix defines the local matrix
  81858. * @param restPose defines the rest pose matrix
  81859. * @param baseMatrix defines the base matrix
  81860. * @param index defines index of the bone in the hiearchy
  81861. */
  81862. constructor(
  81863. /**
  81864. * defines the bone name
  81865. */
  81866. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81867. /**
  81868. * Gets the current object class name.
  81869. * @return the class name
  81870. */
  81871. getClassName(): string;
  81872. /**
  81873. * Gets the parent skeleton
  81874. * @returns a skeleton
  81875. */
  81876. getSkeleton(): Skeleton;
  81877. /**
  81878. * Gets parent bone
  81879. * @returns a bone or null if the bone is the root of the bone hierarchy
  81880. */
  81881. getParent(): Nullable<Bone>;
  81882. /**
  81883. * Returns an array containing the root bones
  81884. * @returns an array containing the root bones
  81885. */
  81886. getChildren(): Array<Bone>;
  81887. /**
  81888. * Gets the node index in matrix array generated for rendering
  81889. * @returns the node index
  81890. */
  81891. getIndex(): number;
  81892. /**
  81893. * Sets the parent bone
  81894. * @param parent defines the parent (can be null if the bone is the root)
  81895. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81896. */
  81897. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81898. /**
  81899. * Gets the local matrix
  81900. * @returns a matrix
  81901. */
  81902. getLocalMatrix(): Matrix;
  81903. /**
  81904. * Gets the base matrix (initial matrix which remains unchanged)
  81905. * @returns a matrix
  81906. */
  81907. getBaseMatrix(): Matrix;
  81908. /**
  81909. * Gets the rest pose matrix
  81910. * @returns a matrix
  81911. */
  81912. getRestPose(): Matrix;
  81913. /**
  81914. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81915. */
  81916. getWorldMatrix(): Matrix;
  81917. /**
  81918. * Sets the local matrix to rest pose matrix
  81919. */
  81920. returnToRest(): void;
  81921. /**
  81922. * Gets the inverse of the absolute transform matrix.
  81923. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81924. * @returns a matrix
  81925. */
  81926. getInvertedAbsoluteTransform(): Matrix;
  81927. /**
  81928. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81929. * @returns a matrix
  81930. */
  81931. getAbsoluteTransform(): Matrix;
  81932. /**
  81933. * Links with the given transform node.
  81934. * The local matrix of this bone is copied from the transform node every frame.
  81935. * @param transformNode defines the transform node to link to
  81936. */
  81937. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81938. /**
  81939. * Gets the node used to drive the bone's transformation
  81940. * @returns a transform node or null
  81941. */
  81942. getTransformNode(): Nullable<TransformNode>;
  81943. /** Gets or sets current position (in local space) */
  81944. position: Vector3;
  81945. /** Gets or sets current rotation (in local space) */
  81946. rotation: Vector3;
  81947. /** Gets or sets current rotation quaternion (in local space) */
  81948. rotationQuaternion: Quaternion;
  81949. /** Gets or sets current scaling (in local space) */
  81950. scaling: Vector3;
  81951. /**
  81952. * Gets the animation properties override
  81953. */
  81954. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81955. private _decompose;
  81956. private _compose;
  81957. /**
  81958. * Update the base and local matrices
  81959. * @param matrix defines the new base or local matrix
  81960. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81961. * @param updateLocalMatrix defines if the local matrix should be updated
  81962. */
  81963. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81964. /** @hidden */
  81965. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81966. /**
  81967. * Flag the bone as dirty (Forcing it to update everything)
  81968. */
  81969. markAsDirty(): void;
  81970. /** @hidden */
  81971. _markAsDirtyAndCompose(): void;
  81972. private _markAsDirtyAndDecompose;
  81973. /**
  81974. * Translate the bone in local or world space
  81975. * @param vec The amount to translate the bone
  81976. * @param space The space that the translation is in
  81977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81978. */
  81979. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81980. /**
  81981. * Set the postion of the bone in local or world space
  81982. * @param position The position to set the bone
  81983. * @param space The space that the position is in
  81984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81985. */
  81986. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81987. /**
  81988. * Set the absolute position of the bone (world space)
  81989. * @param position The position to set the bone
  81990. * @param mesh The mesh that this bone is attached to
  81991. */
  81992. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81993. /**
  81994. * Scale the bone on the x, y and z axes (in local space)
  81995. * @param x The amount to scale the bone on the x axis
  81996. * @param y The amount to scale the bone on the y axis
  81997. * @param z The amount to scale the bone on the z axis
  81998. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81999. */
  82000. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82001. /**
  82002. * Set the bone scaling in local space
  82003. * @param scale defines the scaling vector
  82004. */
  82005. setScale(scale: Vector3): void;
  82006. /**
  82007. * Gets the current scaling in local space
  82008. * @returns the current scaling vector
  82009. */
  82010. getScale(): Vector3;
  82011. /**
  82012. * Gets the current scaling in local space and stores it in a target vector
  82013. * @param result defines the target vector
  82014. */
  82015. getScaleToRef(result: Vector3): void;
  82016. /**
  82017. * Set the yaw, pitch, and roll of the bone in local or world space
  82018. * @param yaw The rotation of the bone on the y axis
  82019. * @param pitch The rotation of the bone on the x axis
  82020. * @param roll The rotation of the bone on the z axis
  82021. * @param space The space that the axes of rotation are in
  82022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82023. */
  82024. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82025. /**
  82026. * Add a rotation to the bone on an axis in local or world space
  82027. * @param axis The axis to rotate the bone on
  82028. * @param amount The amount to rotate the bone
  82029. * @param space The space that the axis is in
  82030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82031. */
  82032. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82033. /**
  82034. * Set the rotation of the bone to a particular axis angle in local or world space
  82035. * @param axis The axis to rotate the bone on
  82036. * @param angle The angle that the bone should be rotated to
  82037. * @param space The space that the axis is in
  82038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82039. */
  82040. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82041. /**
  82042. * Set the euler rotation of the bone in local of world space
  82043. * @param rotation The euler rotation that the bone should be set to
  82044. * @param space The space that the rotation is in
  82045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82046. */
  82047. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82048. /**
  82049. * Set the quaternion rotation of the bone in local of world space
  82050. * @param quat The quaternion rotation that the bone should be set to
  82051. * @param space The space that the rotation is in
  82052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82053. */
  82054. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82055. /**
  82056. * Set the rotation matrix of the bone in local of world space
  82057. * @param rotMat The rotation matrix that the bone should be set to
  82058. * @param space The space that the rotation is in
  82059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82060. */
  82061. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82062. private _rotateWithMatrix;
  82063. private _getNegativeRotationToRef;
  82064. /**
  82065. * Get the position of the bone in local or world space
  82066. * @param space The space that the returned position is in
  82067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82068. * @returns The position of the bone
  82069. */
  82070. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82071. /**
  82072. * Copy the position of the bone to a vector3 in local or world space
  82073. * @param space The space that the returned position is in
  82074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82075. * @param result The vector3 to copy the position to
  82076. */
  82077. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82078. /**
  82079. * Get the absolute position of the bone (world space)
  82080. * @param mesh The mesh that this bone is attached to
  82081. * @returns The absolute position of the bone
  82082. */
  82083. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82084. /**
  82085. * Copy the absolute position of the bone (world space) to the result param
  82086. * @param mesh The mesh that this bone is attached to
  82087. * @param result The vector3 to copy the absolute position to
  82088. */
  82089. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82090. /**
  82091. * Compute the absolute transforms of this bone and its children
  82092. */
  82093. computeAbsoluteTransforms(): void;
  82094. /**
  82095. * Get the world direction from an axis that is in the local space of the bone
  82096. * @param localAxis The local direction that is used to compute the world direction
  82097. * @param mesh The mesh that this bone is attached to
  82098. * @returns The world direction
  82099. */
  82100. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82101. /**
  82102. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82103. * @param localAxis The local direction that is used to compute the world direction
  82104. * @param mesh The mesh that this bone is attached to
  82105. * @param result The vector3 that the world direction will be copied to
  82106. */
  82107. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82108. /**
  82109. * Get the euler rotation of the bone in local or world space
  82110. * @param space The space that the rotation should be in
  82111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82112. * @returns The euler rotation
  82113. */
  82114. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82115. /**
  82116. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82117. * @param space The space that the rotation should be in
  82118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82119. * @param result The vector3 that the rotation should be copied to
  82120. */
  82121. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82122. /**
  82123. * Get the quaternion rotation of the bone in either local or world space
  82124. * @param space The space that the rotation should be in
  82125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82126. * @returns The quaternion rotation
  82127. */
  82128. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82129. /**
  82130. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82131. * @param space The space that the rotation should be in
  82132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82133. * @param result The quaternion that the rotation should be copied to
  82134. */
  82135. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82136. /**
  82137. * Get the rotation matrix of the bone in local or world space
  82138. * @param space The space that the rotation should be in
  82139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82140. * @returns The rotation matrix
  82141. */
  82142. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82143. /**
  82144. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82145. * @param space The space that the rotation should be in
  82146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82147. * @param result The quaternion that the rotation should be copied to
  82148. */
  82149. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82150. /**
  82151. * Get the world position of a point that is in the local space of the bone
  82152. * @param position The local position
  82153. * @param mesh The mesh that this bone is attached to
  82154. * @returns The world position
  82155. */
  82156. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82157. /**
  82158. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82159. * @param position The local position
  82160. * @param mesh The mesh that this bone is attached to
  82161. * @param result The vector3 that the world position should be copied to
  82162. */
  82163. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82164. /**
  82165. * Get the local position of a point that is in world space
  82166. * @param position The world position
  82167. * @param mesh The mesh that this bone is attached to
  82168. * @returns The local position
  82169. */
  82170. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82171. /**
  82172. * Get the local position of a point that is in world space and copy it to the result param
  82173. * @param position The world position
  82174. * @param mesh The mesh that this bone is attached to
  82175. * @param result The vector3 that the local position should be copied to
  82176. */
  82177. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82178. }
  82179. }
  82180. declare module BABYLON {
  82181. /**
  82182. * 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.
  82183. * @see https://doc.babylonjs.com/how_to/transformnode
  82184. */
  82185. export class TransformNode extends Node {
  82186. /**
  82187. * Object will not rotate to face the camera
  82188. */
  82189. static BILLBOARDMODE_NONE: number;
  82190. /**
  82191. * Object will rotate to face the camera but only on the x axis
  82192. */
  82193. static BILLBOARDMODE_X: number;
  82194. /**
  82195. * Object will rotate to face the camera but only on the y axis
  82196. */
  82197. static BILLBOARDMODE_Y: number;
  82198. /**
  82199. * Object will rotate to face the camera but only on the z axis
  82200. */
  82201. static BILLBOARDMODE_Z: number;
  82202. /**
  82203. * Object will rotate to face the camera
  82204. */
  82205. static BILLBOARDMODE_ALL: number;
  82206. /**
  82207. * Object will rotate to face the camera's position instead of orientation
  82208. */
  82209. static BILLBOARDMODE_USE_POSITION: number;
  82210. private _forward;
  82211. private _forwardInverted;
  82212. private _up;
  82213. private _right;
  82214. private _rightInverted;
  82215. private _position;
  82216. private _rotation;
  82217. private _rotationQuaternion;
  82218. protected _scaling: Vector3;
  82219. protected _isDirty: boolean;
  82220. private _transformToBoneReferal;
  82221. private _isAbsoluteSynced;
  82222. private _billboardMode;
  82223. /**
  82224. * Gets or sets the billboard mode. Default is 0.
  82225. *
  82226. * | Value | Type | Description |
  82227. * | --- | --- | --- |
  82228. * | 0 | BILLBOARDMODE_NONE | |
  82229. * | 1 | BILLBOARDMODE_X | |
  82230. * | 2 | BILLBOARDMODE_Y | |
  82231. * | 4 | BILLBOARDMODE_Z | |
  82232. * | 7 | BILLBOARDMODE_ALL | |
  82233. *
  82234. */
  82235. billboardMode: number;
  82236. private _preserveParentRotationForBillboard;
  82237. /**
  82238. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82239. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82240. */
  82241. preserveParentRotationForBillboard: boolean;
  82242. /**
  82243. * 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
  82244. */
  82245. scalingDeterminant: number;
  82246. private _infiniteDistance;
  82247. /**
  82248. * Gets or sets the distance of the object to max, often used by skybox
  82249. */
  82250. infiniteDistance: boolean;
  82251. /**
  82252. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82253. * By default the system will update normals to compensate
  82254. */
  82255. ignoreNonUniformScaling: boolean;
  82256. /**
  82257. * 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
  82258. */
  82259. reIntegrateRotationIntoRotationQuaternion: boolean;
  82260. /** @hidden */
  82261. _poseMatrix: Nullable<Matrix>;
  82262. /** @hidden */
  82263. _localMatrix: Matrix;
  82264. private _usePivotMatrix;
  82265. private _absolutePosition;
  82266. private _absoluteScaling;
  82267. private _absoluteRotationQuaternion;
  82268. private _pivotMatrix;
  82269. private _pivotMatrixInverse;
  82270. protected _postMultiplyPivotMatrix: boolean;
  82271. protected _isWorldMatrixFrozen: boolean;
  82272. /** @hidden */
  82273. _indexInSceneTransformNodesArray: number;
  82274. /**
  82275. * An event triggered after the world matrix is updated
  82276. */
  82277. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82278. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82279. /**
  82280. * Gets a string identifying the name of the class
  82281. * @returns "TransformNode" string
  82282. */
  82283. getClassName(): string;
  82284. /**
  82285. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82286. */
  82287. position: Vector3;
  82288. /**
  82289. * 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)).
  82290. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82291. */
  82292. rotation: Vector3;
  82293. /**
  82294. * 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)).
  82295. */
  82296. scaling: Vector3;
  82297. /**
  82298. * 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).
  82299. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82300. */
  82301. rotationQuaternion: Nullable<Quaternion>;
  82302. /**
  82303. * The forward direction of that transform in world space.
  82304. */
  82305. readonly forward: Vector3;
  82306. /**
  82307. * The up direction of that transform in world space.
  82308. */
  82309. readonly up: Vector3;
  82310. /**
  82311. * The right direction of that transform in world space.
  82312. */
  82313. readonly right: Vector3;
  82314. /**
  82315. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82316. * @param matrix the matrix to copy the pose from
  82317. * @returns this TransformNode.
  82318. */
  82319. updatePoseMatrix(matrix: Matrix): TransformNode;
  82320. /**
  82321. * Returns the mesh Pose matrix.
  82322. * @returns the pose matrix
  82323. */
  82324. getPoseMatrix(): Matrix;
  82325. /** @hidden */
  82326. _isSynchronized(): boolean;
  82327. /** @hidden */
  82328. _initCache(): void;
  82329. /**
  82330. * Flag the transform node as dirty (Forcing it to update everything)
  82331. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82332. * @returns this transform node
  82333. */
  82334. markAsDirty(property: string): TransformNode;
  82335. /**
  82336. * Returns the current mesh absolute position.
  82337. * Returns a Vector3.
  82338. */
  82339. readonly absolutePosition: Vector3;
  82340. /**
  82341. * Returns the current mesh absolute scaling.
  82342. * Returns a Vector3.
  82343. */
  82344. readonly absoluteScaling: Vector3;
  82345. /**
  82346. * Returns the current mesh absolute rotation.
  82347. * Returns a Quaternion.
  82348. */
  82349. readonly absoluteRotationQuaternion: Quaternion;
  82350. /**
  82351. * Sets a new matrix to apply before all other transformation
  82352. * @param matrix defines the transform matrix
  82353. * @returns the current TransformNode
  82354. */
  82355. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82356. /**
  82357. * Sets a new pivot matrix to the current node
  82358. * @param matrix defines the new pivot matrix to use
  82359. * @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
  82360. * @returns the current TransformNode
  82361. */
  82362. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82363. /**
  82364. * Returns the mesh pivot matrix.
  82365. * Default : Identity.
  82366. * @returns the matrix
  82367. */
  82368. getPivotMatrix(): Matrix;
  82369. /**
  82370. * Instantiate (when possible) or clone that node with its hierarchy
  82371. * @param newParent defines the new parent to use for the instance (or clone)
  82372. * @param options defines options to configure how copy is done
  82373. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82374. * @returns an instance (or a clone) of the current node with its hiearchy
  82375. */
  82376. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82377. doNotInstantiate: boolean;
  82378. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82379. /**
  82380. * Prevents the World matrix to be computed any longer
  82381. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82382. * @returns the TransformNode.
  82383. */
  82384. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82385. /**
  82386. * Allows back the World matrix computation.
  82387. * @returns the TransformNode.
  82388. */
  82389. unfreezeWorldMatrix(): this;
  82390. /**
  82391. * True if the World matrix has been frozen.
  82392. */
  82393. readonly isWorldMatrixFrozen: boolean;
  82394. /**
  82395. * Retuns the mesh absolute position in the World.
  82396. * @returns a Vector3.
  82397. */
  82398. getAbsolutePosition(): Vector3;
  82399. /**
  82400. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82401. * @param absolutePosition the absolute position to set
  82402. * @returns the TransformNode.
  82403. */
  82404. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82405. /**
  82406. * Sets the mesh position in its local space.
  82407. * @param vector3 the position to set in localspace
  82408. * @returns the TransformNode.
  82409. */
  82410. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82411. /**
  82412. * Returns the mesh position in the local space from the current World matrix values.
  82413. * @returns a new Vector3.
  82414. */
  82415. getPositionExpressedInLocalSpace(): Vector3;
  82416. /**
  82417. * Translates the mesh along the passed Vector3 in its local space.
  82418. * @param vector3 the distance to translate in localspace
  82419. * @returns the TransformNode.
  82420. */
  82421. locallyTranslate(vector3: Vector3): TransformNode;
  82422. private static _lookAtVectorCache;
  82423. /**
  82424. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82425. * @param targetPoint the position (must be in same space as current mesh) to look at
  82426. * @param yawCor optional yaw (y-axis) correction in radians
  82427. * @param pitchCor optional pitch (x-axis) correction in radians
  82428. * @param rollCor optional roll (z-axis) correction in radians
  82429. * @param space the choosen space of the target
  82430. * @returns the TransformNode.
  82431. */
  82432. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82433. /**
  82434. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82435. * This Vector3 is expressed in the World space.
  82436. * @param localAxis axis to rotate
  82437. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82438. */
  82439. getDirection(localAxis: Vector3): Vector3;
  82440. /**
  82441. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82442. * localAxis is expressed in the mesh local space.
  82443. * result is computed in the Wordl space from the mesh World matrix.
  82444. * @param localAxis axis to rotate
  82445. * @param result the resulting transformnode
  82446. * @returns this TransformNode.
  82447. */
  82448. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82449. /**
  82450. * Sets this transform node rotation to the given local axis.
  82451. * @param localAxis the axis in local space
  82452. * @param yawCor optional yaw (y-axis) correction in radians
  82453. * @param pitchCor optional pitch (x-axis) correction in radians
  82454. * @param rollCor optional roll (z-axis) correction in radians
  82455. * @returns this TransformNode
  82456. */
  82457. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82458. /**
  82459. * Sets a new pivot point to the current node
  82460. * @param point defines the new pivot point to use
  82461. * @param space defines if the point is in world or local space (local by default)
  82462. * @returns the current TransformNode
  82463. */
  82464. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82465. /**
  82466. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82467. * @returns the pivot point
  82468. */
  82469. getPivotPoint(): Vector3;
  82470. /**
  82471. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82472. * @param result the vector3 to store the result
  82473. * @returns this TransformNode.
  82474. */
  82475. getPivotPointToRef(result: Vector3): TransformNode;
  82476. /**
  82477. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82478. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82479. */
  82480. getAbsolutePivotPoint(): Vector3;
  82481. /**
  82482. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82483. * @param result vector3 to store the result
  82484. * @returns this TransformNode.
  82485. */
  82486. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82487. /**
  82488. * Defines the passed node as the parent of the current node.
  82489. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82490. * @see https://doc.babylonjs.com/how_to/parenting
  82491. * @param node the node ot set as the parent
  82492. * @returns this TransformNode.
  82493. */
  82494. setParent(node: Nullable<Node>): TransformNode;
  82495. private _nonUniformScaling;
  82496. /**
  82497. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82498. */
  82499. readonly nonUniformScaling: boolean;
  82500. /** @hidden */
  82501. _updateNonUniformScalingState(value: boolean): boolean;
  82502. /**
  82503. * Attach the current TransformNode to another TransformNode associated with a bone
  82504. * @param bone Bone affecting the TransformNode
  82505. * @param affectedTransformNode TransformNode associated with the bone
  82506. * @returns this object
  82507. */
  82508. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82509. /**
  82510. * Detach the transform node if its associated with a bone
  82511. * @returns this object
  82512. */
  82513. detachFromBone(): TransformNode;
  82514. private static _rotationAxisCache;
  82515. /**
  82516. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82517. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82518. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82519. * The passed axis is also normalized.
  82520. * @param axis the axis to rotate around
  82521. * @param amount the amount to rotate in radians
  82522. * @param space Space to rotate in (Default: local)
  82523. * @returns the TransformNode.
  82524. */
  82525. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82526. /**
  82527. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82528. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82529. * The passed axis is also normalized. .
  82530. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82531. * @param point the point to rotate around
  82532. * @param axis the axis to rotate around
  82533. * @param amount the amount to rotate in radians
  82534. * @returns the TransformNode
  82535. */
  82536. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82537. /**
  82538. * Translates the mesh along the axis vector for the passed distance in the given space.
  82539. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82540. * @param axis the axis to translate in
  82541. * @param distance the distance to translate
  82542. * @param space Space to rotate in (Default: local)
  82543. * @returns the TransformNode.
  82544. */
  82545. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82546. /**
  82547. * Adds a rotation step to the mesh current rotation.
  82548. * x, y, z are Euler angles expressed in radians.
  82549. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82550. * This means this rotation is made in the mesh local space only.
  82551. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82552. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82553. * ```javascript
  82554. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82555. * ```
  82556. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82557. * 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.
  82558. * @param x Rotation to add
  82559. * @param y Rotation to add
  82560. * @param z Rotation to add
  82561. * @returns the TransformNode.
  82562. */
  82563. addRotation(x: number, y: number, z: number): TransformNode;
  82564. /**
  82565. * @hidden
  82566. */
  82567. protected _getEffectiveParent(): Nullable<Node>;
  82568. /**
  82569. * Computes the world matrix of the node
  82570. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82571. * @returns the world matrix
  82572. */
  82573. computeWorldMatrix(force?: boolean): Matrix;
  82574. protected _afterComputeWorldMatrix(): void;
  82575. /**
  82576. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82577. * @param func callback function to add
  82578. *
  82579. * @returns the TransformNode.
  82580. */
  82581. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82582. /**
  82583. * Removes a registered callback function.
  82584. * @param func callback function to remove
  82585. * @returns the TransformNode.
  82586. */
  82587. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82588. /**
  82589. * Gets the position of the current mesh in camera space
  82590. * @param camera defines the camera to use
  82591. * @returns a position
  82592. */
  82593. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82594. /**
  82595. * Returns the distance from the mesh to the active camera
  82596. * @param camera defines the camera to use
  82597. * @returns the distance
  82598. */
  82599. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82600. /**
  82601. * Clone the current transform node
  82602. * @param name Name of the new clone
  82603. * @param newParent New parent for the clone
  82604. * @param doNotCloneChildren Do not clone children hierarchy
  82605. * @returns the new transform node
  82606. */
  82607. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82608. /**
  82609. * Serializes the objects information.
  82610. * @param currentSerializationObject defines the object to serialize in
  82611. * @returns the serialized object
  82612. */
  82613. serialize(currentSerializationObject?: any): any;
  82614. /**
  82615. * Returns a new TransformNode object parsed from the source provided.
  82616. * @param parsedTransformNode is the source.
  82617. * @param scene the scne the object belongs to
  82618. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82619. * @returns a new TransformNode object parsed from the source provided.
  82620. */
  82621. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82622. /**
  82623. * Get all child-transformNodes of this node
  82624. * @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
  82625. * @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
  82626. * @returns an array of TransformNode
  82627. */
  82628. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82629. /**
  82630. * Releases resources associated with this transform node.
  82631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82633. */
  82634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82635. /**
  82636. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82637. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82638. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82639. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82640. * @returns the current mesh
  82641. */
  82642. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82643. private _syncAbsoluteScalingAndRotation;
  82644. }
  82645. }
  82646. declare module BABYLON {
  82647. /**
  82648. * Defines the types of pose enabled controllers that are supported
  82649. */
  82650. export enum PoseEnabledControllerType {
  82651. /**
  82652. * HTC Vive
  82653. */
  82654. VIVE = 0,
  82655. /**
  82656. * Oculus Rift
  82657. */
  82658. OCULUS = 1,
  82659. /**
  82660. * Windows mixed reality
  82661. */
  82662. WINDOWS = 2,
  82663. /**
  82664. * Samsung gear VR
  82665. */
  82666. GEAR_VR = 3,
  82667. /**
  82668. * Google Daydream
  82669. */
  82670. DAYDREAM = 4,
  82671. /**
  82672. * Generic
  82673. */
  82674. GENERIC = 5
  82675. }
  82676. /**
  82677. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82678. */
  82679. export interface MutableGamepadButton {
  82680. /**
  82681. * Value of the button/trigger
  82682. */
  82683. value: number;
  82684. /**
  82685. * If the button/trigger is currently touched
  82686. */
  82687. touched: boolean;
  82688. /**
  82689. * If the button/trigger is currently pressed
  82690. */
  82691. pressed: boolean;
  82692. }
  82693. /**
  82694. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82695. * @hidden
  82696. */
  82697. export interface ExtendedGamepadButton extends GamepadButton {
  82698. /**
  82699. * If the button/trigger is currently pressed
  82700. */
  82701. readonly pressed: boolean;
  82702. /**
  82703. * If the button/trigger is currently touched
  82704. */
  82705. readonly touched: boolean;
  82706. /**
  82707. * Value of the button/trigger
  82708. */
  82709. readonly value: number;
  82710. }
  82711. /** @hidden */
  82712. export interface _GamePadFactory {
  82713. /**
  82714. * Returns wether or not the current gamepad can be created for this type of controller.
  82715. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82716. * @returns true if it can be created, otherwise false
  82717. */
  82718. canCreate(gamepadInfo: any): boolean;
  82719. /**
  82720. * Creates a new instance of the Gamepad.
  82721. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82722. * @returns the new gamepad instance
  82723. */
  82724. create(gamepadInfo: any): Gamepad;
  82725. }
  82726. /**
  82727. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82728. */
  82729. export class PoseEnabledControllerHelper {
  82730. /** @hidden */
  82731. static _ControllerFactories: _GamePadFactory[];
  82732. /** @hidden */
  82733. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82734. /**
  82735. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82736. * @param vrGamepad the gamepad to initialized
  82737. * @returns a vr controller of the type the gamepad identified as
  82738. */
  82739. static InitiateController(vrGamepad: any): Gamepad;
  82740. }
  82741. /**
  82742. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82743. */
  82744. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82745. /**
  82746. * If the controller is used in a webXR session
  82747. */
  82748. isXR: boolean;
  82749. private _deviceRoomPosition;
  82750. private _deviceRoomRotationQuaternion;
  82751. /**
  82752. * The device position in babylon space
  82753. */
  82754. devicePosition: Vector3;
  82755. /**
  82756. * The device rotation in babylon space
  82757. */
  82758. deviceRotationQuaternion: Quaternion;
  82759. /**
  82760. * The scale factor of the device in babylon space
  82761. */
  82762. deviceScaleFactor: number;
  82763. /**
  82764. * (Likely devicePosition should be used instead) The device position in its room space
  82765. */
  82766. position: Vector3;
  82767. /**
  82768. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82769. */
  82770. rotationQuaternion: Quaternion;
  82771. /**
  82772. * The type of controller (Eg. Windows mixed reality)
  82773. */
  82774. controllerType: PoseEnabledControllerType;
  82775. protected _calculatedPosition: Vector3;
  82776. private _calculatedRotation;
  82777. /**
  82778. * The raw pose from the device
  82779. */
  82780. rawPose: DevicePose;
  82781. private _trackPosition;
  82782. private _maxRotationDistFromHeadset;
  82783. private _draggedRoomRotation;
  82784. /**
  82785. * @hidden
  82786. */
  82787. _disableTrackPosition(fixedPosition: Vector3): void;
  82788. /**
  82789. * Internal, the mesh attached to the controller
  82790. * @hidden
  82791. */
  82792. _mesh: Nullable<AbstractMesh>;
  82793. private _poseControlledCamera;
  82794. private _leftHandSystemQuaternion;
  82795. /**
  82796. * Internal, matrix used to convert room space to babylon space
  82797. * @hidden
  82798. */
  82799. _deviceToWorld: Matrix;
  82800. /**
  82801. * Node to be used when casting a ray from the controller
  82802. * @hidden
  82803. */
  82804. _pointingPoseNode: Nullable<TransformNode>;
  82805. /**
  82806. * Name of the child mesh that can be used to cast a ray from the controller
  82807. */
  82808. static readonly POINTING_POSE: string;
  82809. /**
  82810. * Creates a new PoseEnabledController from a gamepad
  82811. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82812. */
  82813. constructor(browserGamepad: any);
  82814. private _workingMatrix;
  82815. /**
  82816. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82817. */
  82818. update(): void;
  82819. /**
  82820. * Updates only the pose device and mesh without doing any button event checking
  82821. */
  82822. protected _updatePoseAndMesh(): void;
  82823. /**
  82824. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82825. * @param poseData raw pose fromthe device
  82826. */
  82827. updateFromDevice(poseData: DevicePose): void;
  82828. /**
  82829. * @hidden
  82830. */
  82831. _meshAttachedObservable: Observable<AbstractMesh>;
  82832. /**
  82833. * Attaches a mesh to the controller
  82834. * @param mesh the mesh to be attached
  82835. */
  82836. attachToMesh(mesh: AbstractMesh): void;
  82837. /**
  82838. * Attaches the controllers mesh to a camera
  82839. * @param camera the camera the mesh should be attached to
  82840. */
  82841. attachToPoseControlledCamera(camera: TargetCamera): void;
  82842. /**
  82843. * Disposes of the controller
  82844. */
  82845. dispose(): void;
  82846. /**
  82847. * The mesh that is attached to the controller
  82848. */
  82849. readonly mesh: Nullable<AbstractMesh>;
  82850. /**
  82851. * Gets the ray of the controller in the direction the controller is pointing
  82852. * @param length the length the resulting ray should be
  82853. * @returns a ray in the direction the controller is pointing
  82854. */
  82855. getForwardRay(length?: number): Ray;
  82856. }
  82857. }
  82858. declare module BABYLON {
  82859. /**
  82860. * Defines the WebVRController object that represents controllers tracked in 3D space
  82861. */
  82862. export abstract class WebVRController extends PoseEnabledController {
  82863. /**
  82864. * Internal, the default controller model for the controller
  82865. */
  82866. protected _defaultModel: Nullable<AbstractMesh>;
  82867. /**
  82868. * Fired when the trigger state has changed
  82869. */
  82870. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82871. /**
  82872. * Fired when the main button state has changed
  82873. */
  82874. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82875. /**
  82876. * Fired when the secondary button state has changed
  82877. */
  82878. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82879. /**
  82880. * Fired when the pad state has changed
  82881. */
  82882. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82883. /**
  82884. * Fired when controllers stick values have changed
  82885. */
  82886. onPadValuesChangedObservable: Observable<StickValues>;
  82887. /**
  82888. * Array of button availible on the controller
  82889. */
  82890. protected _buttons: Array<MutableGamepadButton>;
  82891. private _onButtonStateChange;
  82892. /**
  82893. * Fired when a controller button's state has changed
  82894. * @param callback the callback containing the button that was modified
  82895. */
  82896. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82897. /**
  82898. * X and Y axis corresponding to the controllers joystick
  82899. */
  82900. pad: StickValues;
  82901. /**
  82902. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82903. */
  82904. hand: string;
  82905. /**
  82906. * The default controller model for the controller
  82907. */
  82908. readonly defaultModel: Nullable<AbstractMesh>;
  82909. /**
  82910. * Creates a new WebVRController from a gamepad
  82911. * @param vrGamepad the gamepad that the WebVRController should be created from
  82912. */
  82913. constructor(vrGamepad: any);
  82914. /**
  82915. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82916. */
  82917. update(): void;
  82918. /**
  82919. * Function to be called when a button is modified
  82920. */
  82921. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82922. /**
  82923. * Loads a mesh and attaches it to the controller
  82924. * @param scene the scene the mesh should be added to
  82925. * @param meshLoaded callback for when the mesh has been loaded
  82926. */
  82927. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82928. private _setButtonValue;
  82929. private _changes;
  82930. private _checkChanges;
  82931. /**
  82932. * Disposes of th webVRCOntroller
  82933. */
  82934. dispose(): void;
  82935. }
  82936. }
  82937. declare module BABYLON {
  82938. /**
  82939. * The HemisphericLight simulates the ambient environment light,
  82940. * so the passed direction is the light reflection direction, not the incoming direction.
  82941. */
  82942. export class HemisphericLight extends Light {
  82943. /**
  82944. * The groundColor is the light in the opposite direction to the one specified during creation.
  82945. * 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.
  82946. */
  82947. groundColor: Color3;
  82948. /**
  82949. * The light reflection direction, not the incoming direction.
  82950. */
  82951. direction: Vector3;
  82952. /**
  82953. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82954. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82955. * The HemisphericLight can't cast shadows.
  82956. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82957. * @param name The friendly name of the light
  82958. * @param direction The direction of the light reflection
  82959. * @param scene The scene the light belongs to
  82960. */
  82961. constructor(name: string, direction: Vector3, scene: Scene);
  82962. protected _buildUniformLayout(): void;
  82963. /**
  82964. * Returns the string "HemisphericLight".
  82965. * @return The class name
  82966. */
  82967. getClassName(): string;
  82968. /**
  82969. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82970. * Returns the updated direction.
  82971. * @param target The target the direction should point to
  82972. * @return The computed direction
  82973. */
  82974. setDirectionToTarget(target: Vector3): Vector3;
  82975. /**
  82976. * Returns the shadow generator associated to the light.
  82977. * @returns Always null for hemispheric lights because it does not support shadows.
  82978. */
  82979. getShadowGenerator(): Nullable<IShadowGenerator>;
  82980. /**
  82981. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82982. * @param effect The effect to update
  82983. * @param lightIndex The index of the light in the effect to update
  82984. * @returns The hemispheric light
  82985. */
  82986. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82987. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82988. /**
  82989. * Computes the world matrix of the node
  82990. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82991. * @param useWasUpdatedFlag defines a reserved property
  82992. * @returns the world matrix
  82993. */
  82994. computeWorldMatrix(): Matrix;
  82995. /**
  82996. * Returns the integer 3.
  82997. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82998. */
  82999. getTypeID(): number;
  83000. /**
  83001. * Prepares the list of defines specific to the light type.
  83002. * @param defines the list of defines
  83003. * @param lightIndex defines the index of the light for the effect
  83004. */
  83005. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83006. }
  83007. }
  83008. declare module BABYLON {
  83009. /** @hidden */
  83010. export var vrMultiviewToSingleviewPixelShader: {
  83011. name: string;
  83012. shader: string;
  83013. };
  83014. }
  83015. declare module BABYLON {
  83016. /**
  83017. * Renders to multiple views with a single draw call
  83018. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83019. */
  83020. export class MultiviewRenderTarget extends RenderTargetTexture {
  83021. /**
  83022. * Creates a multiview render target
  83023. * @param scene scene used with the render target
  83024. * @param size the size of the render target (used for each view)
  83025. */
  83026. constructor(scene: Scene, size?: number | {
  83027. width: number;
  83028. height: number;
  83029. } | {
  83030. ratio: number;
  83031. });
  83032. /**
  83033. * @hidden
  83034. * @param faceIndex the face index, if its a cube texture
  83035. */
  83036. _bindFrameBuffer(faceIndex?: number): void;
  83037. /**
  83038. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83039. * @returns the view count
  83040. */
  83041. getViewCount(): number;
  83042. }
  83043. }
  83044. declare module BABYLON {
  83045. /**
  83046. * Represents a camera frustum
  83047. */
  83048. export class Frustum {
  83049. /**
  83050. * Gets the planes representing the frustum
  83051. * @param transform matrix to be applied to the returned planes
  83052. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83053. */
  83054. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83055. /**
  83056. * Gets the near frustum plane transformed by the transform matrix
  83057. * @param transform transformation matrix to be applied to the resulting frustum plane
  83058. * @param frustumPlane the resuling frustum plane
  83059. */
  83060. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83061. /**
  83062. * Gets the far frustum plane transformed by the transform matrix
  83063. * @param transform transformation matrix to be applied to the resulting frustum plane
  83064. * @param frustumPlane the resuling frustum plane
  83065. */
  83066. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83067. /**
  83068. * Gets the left frustum plane transformed by the transform matrix
  83069. * @param transform transformation matrix to be applied to the resulting frustum plane
  83070. * @param frustumPlane the resuling frustum plane
  83071. */
  83072. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83073. /**
  83074. * Gets the right frustum plane transformed by the transform matrix
  83075. * @param transform transformation matrix to be applied to the resulting frustum plane
  83076. * @param frustumPlane the resuling frustum plane
  83077. */
  83078. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83079. /**
  83080. * Gets the top frustum plane transformed by the transform matrix
  83081. * @param transform transformation matrix to be applied to the resulting frustum plane
  83082. * @param frustumPlane the resuling frustum plane
  83083. */
  83084. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83085. /**
  83086. * Gets the bottom frustum plane transformed by the transform matrix
  83087. * @param transform transformation matrix to be applied to the resulting frustum plane
  83088. * @param frustumPlane the resuling frustum plane
  83089. */
  83090. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83091. /**
  83092. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83093. * @param transform transformation matrix to be applied to the resulting frustum planes
  83094. * @param frustumPlanes the resuling frustum planes
  83095. */
  83096. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83097. }
  83098. }
  83099. declare module BABYLON {
  83100. interface Engine {
  83101. /**
  83102. * Creates a new multiview render target
  83103. * @param width defines the width of the texture
  83104. * @param height defines the height of the texture
  83105. * @returns the created multiview texture
  83106. */
  83107. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83108. /**
  83109. * Binds a multiview framebuffer to be drawn to
  83110. * @param multiviewTexture texture to bind
  83111. */
  83112. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83113. }
  83114. interface Camera {
  83115. /**
  83116. * @hidden
  83117. * 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)
  83118. */
  83119. _useMultiviewToSingleView: boolean;
  83120. /**
  83121. * @hidden
  83122. * 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)
  83123. */
  83124. _multiviewTexture: Nullable<RenderTargetTexture>;
  83125. /**
  83126. * @hidden
  83127. * ensures the multiview texture of the camera exists and has the specified width/height
  83128. * @param width height to set on the multiview texture
  83129. * @param height width to set on the multiview texture
  83130. */
  83131. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83132. }
  83133. interface Scene {
  83134. /** @hidden */
  83135. _transformMatrixR: Matrix;
  83136. /** @hidden */
  83137. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83138. /** @hidden */
  83139. _createMultiviewUbo(): void;
  83140. /** @hidden */
  83141. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83142. /** @hidden */
  83143. _renderMultiviewToSingleView(camera: Camera): void;
  83144. }
  83145. }
  83146. declare module BABYLON {
  83147. /**
  83148. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83149. * This will not be used for webXR as it supports displaying texture arrays directly
  83150. */
  83151. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83152. /**
  83153. * Initializes a VRMultiviewToSingleview
  83154. * @param name name of the post process
  83155. * @param camera camera to be applied to
  83156. * @param scaleFactor scaling factor to the size of the output texture
  83157. */
  83158. constructor(name: string, camera: Camera, scaleFactor: number);
  83159. }
  83160. }
  83161. declare module BABYLON {
  83162. /**
  83163. * Interface used to define additional presentation attributes
  83164. */
  83165. export interface IVRPresentationAttributes {
  83166. /**
  83167. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83168. */
  83169. highRefreshRate: boolean;
  83170. /**
  83171. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83172. */
  83173. foveationLevel: number;
  83174. }
  83175. interface Engine {
  83176. /** @hidden */
  83177. _vrDisplay: any;
  83178. /** @hidden */
  83179. _vrSupported: boolean;
  83180. /** @hidden */
  83181. _oldSize: Size;
  83182. /** @hidden */
  83183. _oldHardwareScaleFactor: number;
  83184. /** @hidden */
  83185. _vrExclusivePointerMode: boolean;
  83186. /** @hidden */
  83187. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83188. /** @hidden */
  83189. _onVRDisplayPointerRestricted: () => void;
  83190. /** @hidden */
  83191. _onVRDisplayPointerUnrestricted: () => void;
  83192. /** @hidden */
  83193. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83194. /** @hidden */
  83195. _onVrDisplayDisconnect: Nullable<() => void>;
  83196. /** @hidden */
  83197. _onVrDisplayPresentChange: Nullable<() => void>;
  83198. /**
  83199. * Observable signaled when VR display mode changes
  83200. */
  83201. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83202. /**
  83203. * Observable signaled when VR request present is complete
  83204. */
  83205. onVRRequestPresentComplete: Observable<boolean>;
  83206. /**
  83207. * Observable signaled when VR request present starts
  83208. */
  83209. onVRRequestPresentStart: Observable<Engine>;
  83210. /**
  83211. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83212. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83213. */
  83214. isInVRExclusivePointerMode: boolean;
  83215. /**
  83216. * Gets a boolean indicating if a webVR device was detected
  83217. * @returns true if a webVR device was detected
  83218. */
  83219. isVRDevicePresent(): boolean;
  83220. /**
  83221. * Gets the current webVR device
  83222. * @returns the current webVR device (or null)
  83223. */
  83224. getVRDevice(): any;
  83225. /**
  83226. * Initializes a webVR display and starts listening to display change events
  83227. * The onVRDisplayChangedObservable will be notified upon these changes
  83228. * @returns A promise containing a VRDisplay and if vr is supported
  83229. */
  83230. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83231. /** @hidden */
  83232. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83233. /**
  83234. * Gets or sets the presentation attributes used to configure VR rendering
  83235. */
  83236. vrPresentationAttributes?: IVRPresentationAttributes;
  83237. /**
  83238. * Call this function to switch to webVR mode
  83239. * Will do nothing if webVR is not supported or if there is no webVR device
  83240. * @param options the webvr options provided to the camera. mainly used for multiview
  83241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83242. */
  83243. enableVR(options: WebVROptions): void;
  83244. /** @hidden */
  83245. _onVRFullScreenTriggered(): void;
  83246. }
  83247. }
  83248. declare module BABYLON {
  83249. /**
  83250. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83251. * IMPORTANT!! The data is right-hand data.
  83252. * @export
  83253. * @interface DevicePose
  83254. */
  83255. export interface DevicePose {
  83256. /**
  83257. * The position of the device, values in array are [x,y,z].
  83258. */
  83259. readonly position: Nullable<Float32Array>;
  83260. /**
  83261. * The linearVelocity of the device, values in array are [x,y,z].
  83262. */
  83263. readonly linearVelocity: Nullable<Float32Array>;
  83264. /**
  83265. * The linearAcceleration of the device, values in array are [x,y,z].
  83266. */
  83267. readonly linearAcceleration: Nullable<Float32Array>;
  83268. /**
  83269. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83270. */
  83271. readonly orientation: Nullable<Float32Array>;
  83272. /**
  83273. * The angularVelocity of the device, values in array are [x,y,z].
  83274. */
  83275. readonly angularVelocity: Nullable<Float32Array>;
  83276. /**
  83277. * The angularAcceleration of the device, values in array are [x,y,z].
  83278. */
  83279. readonly angularAcceleration: Nullable<Float32Array>;
  83280. }
  83281. /**
  83282. * Interface representing a pose controlled object in Babylon.
  83283. * A pose controlled object has both regular pose values as well as pose values
  83284. * from an external device such as a VR head mounted display
  83285. */
  83286. export interface PoseControlled {
  83287. /**
  83288. * The position of the object in babylon space.
  83289. */
  83290. position: Vector3;
  83291. /**
  83292. * The rotation quaternion of the object in babylon space.
  83293. */
  83294. rotationQuaternion: Quaternion;
  83295. /**
  83296. * The position of the device in babylon space.
  83297. */
  83298. devicePosition?: Vector3;
  83299. /**
  83300. * The rotation quaternion of the device in babylon space.
  83301. */
  83302. deviceRotationQuaternion: Quaternion;
  83303. /**
  83304. * The raw pose coming from the device.
  83305. */
  83306. rawPose: Nullable<DevicePose>;
  83307. /**
  83308. * The scale of the device to be used when translating from device space to babylon space.
  83309. */
  83310. deviceScaleFactor: number;
  83311. /**
  83312. * Updates the poseControlled values based on the input device pose.
  83313. * @param poseData the pose data to update the object with
  83314. */
  83315. updateFromDevice(poseData: DevicePose): void;
  83316. }
  83317. /**
  83318. * Set of options to customize the webVRCamera
  83319. */
  83320. export interface WebVROptions {
  83321. /**
  83322. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83323. */
  83324. trackPosition?: boolean;
  83325. /**
  83326. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83327. */
  83328. positionScale?: number;
  83329. /**
  83330. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83331. */
  83332. displayName?: string;
  83333. /**
  83334. * Should the native controller meshes be initialized. (default: true)
  83335. */
  83336. controllerMeshes?: boolean;
  83337. /**
  83338. * Creating a default HemiLight only on controllers. (default: true)
  83339. */
  83340. defaultLightingOnControllers?: boolean;
  83341. /**
  83342. * If you don't want to use the default VR button of the helper. (default: false)
  83343. */
  83344. useCustomVRButton?: boolean;
  83345. /**
  83346. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83347. */
  83348. customVRButton?: HTMLButtonElement;
  83349. /**
  83350. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83351. */
  83352. rayLength?: number;
  83353. /**
  83354. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83355. */
  83356. defaultHeight?: number;
  83357. /**
  83358. * If multiview should be used if availible (default: false)
  83359. */
  83360. useMultiview?: boolean;
  83361. }
  83362. /**
  83363. * This represents a WebVR camera.
  83364. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83365. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83366. */
  83367. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83368. private webVROptions;
  83369. /**
  83370. * @hidden
  83371. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83372. */
  83373. _vrDevice: any;
  83374. /**
  83375. * The rawPose of the vrDevice.
  83376. */
  83377. rawPose: Nullable<DevicePose>;
  83378. private _onVREnabled;
  83379. private _specsVersion;
  83380. private _attached;
  83381. private _frameData;
  83382. protected _descendants: Array<Node>;
  83383. private _deviceRoomPosition;
  83384. /** @hidden */
  83385. _deviceRoomRotationQuaternion: Quaternion;
  83386. private _standingMatrix;
  83387. /**
  83388. * Represents device position in babylon space.
  83389. */
  83390. devicePosition: Vector3;
  83391. /**
  83392. * Represents device rotation in babylon space.
  83393. */
  83394. deviceRotationQuaternion: Quaternion;
  83395. /**
  83396. * The scale of the device to be used when translating from device space to babylon space.
  83397. */
  83398. deviceScaleFactor: number;
  83399. private _deviceToWorld;
  83400. private _worldToDevice;
  83401. /**
  83402. * References to the webVR controllers for the vrDevice.
  83403. */
  83404. controllers: Array<WebVRController>;
  83405. /**
  83406. * Emits an event when a controller is attached.
  83407. */
  83408. onControllersAttachedObservable: Observable<WebVRController[]>;
  83409. /**
  83410. * Emits an event when a controller's mesh has been loaded;
  83411. */
  83412. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83413. /**
  83414. * Emits an event when the HMD's pose has been updated.
  83415. */
  83416. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83417. private _poseSet;
  83418. /**
  83419. * If the rig cameras be used as parent instead of this camera.
  83420. */
  83421. rigParenting: boolean;
  83422. private _lightOnControllers;
  83423. private _defaultHeight?;
  83424. /**
  83425. * Instantiates a WebVRFreeCamera.
  83426. * @param name The name of the WebVRFreeCamera
  83427. * @param position The starting anchor position for the camera
  83428. * @param scene The scene the camera belongs to
  83429. * @param webVROptions a set of customizable options for the webVRCamera
  83430. */
  83431. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83432. /**
  83433. * Gets the device distance from the ground in meters.
  83434. * @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.
  83435. */
  83436. deviceDistanceToRoomGround(): number;
  83437. /**
  83438. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83439. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83440. */
  83441. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83442. /**
  83443. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83444. * @returns A promise with a boolean set to if the standing matrix is supported.
  83445. */
  83446. useStandingMatrixAsync(): Promise<boolean>;
  83447. /**
  83448. * Disposes the camera
  83449. */
  83450. dispose(): void;
  83451. /**
  83452. * Gets a vrController by name.
  83453. * @param name The name of the controller to retreive
  83454. * @returns the controller matching the name specified or null if not found
  83455. */
  83456. getControllerByName(name: string): Nullable<WebVRController>;
  83457. private _leftController;
  83458. /**
  83459. * The controller corresponding to the users left hand.
  83460. */
  83461. readonly leftController: Nullable<WebVRController>;
  83462. private _rightController;
  83463. /**
  83464. * The controller corresponding to the users right hand.
  83465. */
  83466. readonly rightController: Nullable<WebVRController>;
  83467. /**
  83468. * Casts a ray forward from the vrCamera's gaze.
  83469. * @param length Length of the ray (default: 100)
  83470. * @returns the ray corresponding to the gaze
  83471. */
  83472. getForwardRay(length?: number): Ray;
  83473. /**
  83474. * @hidden
  83475. * Updates the camera based on device's frame data
  83476. */
  83477. _checkInputs(): void;
  83478. /**
  83479. * Updates the poseControlled values based on the input device pose.
  83480. * @param poseData Pose coming from the device
  83481. */
  83482. updateFromDevice(poseData: DevicePose): void;
  83483. private _htmlElementAttached;
  83484. private _detachIfAttached;
  83485. /**
  83486. * WebVR's attach control will start broadcasting frames to the device.
  83487. * Note that in certain browsers (chrome for example) this function must be called
  83488. * within a user-interaction callback. Example:
  83489. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83490. *
  83491. * @param element html element to attach the vrDevice to
  83492. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83493. */
  83494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83495. /**
  83496. * Detaches the camera from the html element and disables VR
  83497. *
  83498. * @param element html element to detach from
  83499. */
  83500. detachControl(element: HTMLElement): void;
  83501. /**
  83502. * @returns the name of this class
  83503. */
  83504. getClassName(): string;
  83505. /**
  83506. * Calls resetPose on the vrDisplay
  83507. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83508. */
  83509. resetToCurrentRotation(): void;
  83510. /**
  83511. * @hidden
  83512. * Updates the rig cameras (left and right eye)
  83513. */
  83514. _updateRigCameras(): void;
  83515. private _workingVector;
  83516. private _oneVector;
  83517. private _workingMatrix;
  83518. private updateCacheCalled;
  83519. private _correctPositionIfNotTrackPosition;
  83520. /**
  83521. * @hidden
  83522. * Updates the cached values of the camera
  83523. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83524. */
  83525. _updateCache(ignoreParentClass?: boolean): void;
  83526. /**
  83527. * @hidden
  83528. * Get current device position in babylon world
  83529. */
  83530. _computeDevicePosition(): void;
  83531. /**
  83532. * Updates the current device position and rotation in the babylon world
  83533. */
  83534. update(): void;
  83535. /**
  83536. * @hidden
  83537. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83538. * @returns an identity matrix
  83539. */
  83540. _getViewMatrix(): Matrix;
  83541. private _tmpMatrix;
  83542. /**
  83543. * This function is called by the two RIG cameras.
  83544. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83545. * @hidden
  83546. */
  83547. _getWebVRViewMatrix(): Matrix;
  83548. /** @hidden */
  83549. _getWebVRProjectionMatrix(): Matrix;
  83550. private _onGamepadConnectedObserver;
  83551. private _onGamepadDisconnectedObserver;
  83552. private _updateCacheWhenTrackingDisabledObserver;
  83553. /**
  83554. * Initializes the controllers and their meshes
  83555. */
  83556. initControllers(): void;
  83557. }
  83558. }
  83559. declare module BABYLON {
  83560. /**
  83561. * Size options for a post process
  83562. */
  83563. export type PostProcessOptions = {
  83564. width: number;
  83565. height: number;
  83566. };
  83567. /**
  83568. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83569. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83570. */
  83571. export class PostProcess {
  83572. /** Name of the PostProcess. */
  83573. name: string;
  83574. /**
  83575. * Gets or sets the unique id of the post process
  83576. */
  83577. uniqueId: number;
  83578. /**
  83579. * Width of the texture to apply the post process on
  83580. */
  83581. width: number;
  83582. /**
  83583. * Height of the texture to apply the post process on
  83584. */
  83585. height: number;
  83586. /**
  83587. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83588. * @hidden
  83589. */
  83590. _outputTexture: Nullable<InternalTexture>;
  83591. /**
  83592. * Sampling mode used by the shader
  83593. * See https://doc.babylonjs.com/classes/3.1/texture
  83594. */
  83595. renderTargetSamplingMode: number;
  83596. /**
  83597. * Clear color to use when screen clearing
  83598. */
  83599. clearColor: Color4;
  83600. /**
  83601. * If the buffer needs to be cleared before applying the post process. (default: true)
  83602. * Should be set to false if shader will overwrite all previous pixels.
  83603. */
  83604. autoClear: boolean;
  83605. /**
  83606. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83607. */
  83608. alphaMode: number;
  83609. /**
  83610. * Sets the setAlphaBlendConstants of the babylon engine
  83611. */
  83612. alphaConstants: Color4;
  83613. /**
  83614. * Animations to be used for the post processing
  83615. */
  83616. animations: Animation[];
  83617. /**
  83618. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83619. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83620. */
  83621. enablePixelPerfectMode: boolean;
  83622. /**
  83623. * Force the postprocess to be applied without taking in account viewport
  83624. */
  83625. forceFullscreenViewport: boolean;
  83626. /**
  83627. * List of inspectable custom properties (used by the Inspector)
  83628. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83629. */
  83630. inspectableCustomProperties: IInspectable[];
  83631. /**
  83632. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83633. *
  83634. * | Value | Type | Description |
  83635. * | ----- | ----------------------------------- | ----------- |
  83636. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83637. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83638. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83639. *
  83640. */
  83641. scaleMode: number;
  83642. /**
  83643. * Force textures to be a power of two (default: false)
  83644. */
  83645. alwaysForcePOT: boolean;
  83646. private _samples;
  83647. /**
  83648. * Number of sample textures (default: 1)
  83649. */
  83650. samples: number;
  83651. /**
  83652. * Modify the scale of the post process to be the same as the viewport (default: false)
  83653. */
  83654. adaptScaleToCurrentViewport: boolean;
  83655. private _camera;
  83656. private _scene;
  83657. private _engine;
  83658. private _options;
  83659. private _reusable;
  83660. private _textureType;
  83661. /**
  83662. * Smart array of input and output textures for the post process.
  83663. * @hidden
  83664. */
  83665. _textures: SmartArray<InternalTexture>;
  83666. /**
  83667. * The index in _textures that corresponds to the output texture.
  83668. * @hidden
  83669. */
  83670. _currentRenderTextureInd: number;
  83671. private _effect;
  83672. private _samplers;
  83673. private _fragmentUrl;
  83674. private _vertexUrl;
  83675. private _parameters;
  83676. private _scaleRatio;
  83677. protected _indexParameters: any;
  83678. private _shareOutputWithPostProcess;
  83679. private _texelSize;
  83680. private _forcedOutputTexture;
  83681. /**
  83682. * Returns the fragment url or shader name used in the post process.
  83683. * @returns the fragment url or name in the shader store.
  83684. */
  83685. getEffectName(): string;
  83686. /**
  83687. * An event triggered when the postprocess is activated.
  83688. */
  83689. onActivateObservable: Observable<Camera>;
  83690. private _onActivateObserver;
  83691. /**
  83692. * A function that is added to the onActivateObservable
  83693. */
  83694. onActivate: Nullable<(camera: Camera) => void>;
  83695. /**
  83696. * An event triggered when the postprocess changes its size.
  83697. */
  83698. onSizeChangedObservable: Observable<PostProcess>;
  83699. private _onSizeChangedObserver;
  83700. /**
  83701. * A function that is added to the onSizeChangedObservable
  83702. */
  83703. onSizeChanged: (postProcess: PostProcess) => void;
  83704. /**
  83705. * An event triggered when the postprocess applies its effect.
  83706. */
  83707. onApplyObservable: Observable<Effect>;
  83708. private _onApplyObserver;
  83709. /**
  83710. * A function that is added to the onApplyObservable
  83711. */
  83712. onApply: (effect: Effect) => void;
  83713. /**
  83714. * An event triggered before rendering the postprocess
  83715. */
  83716. onBeforeRenderObservable: Observable<Effect>;
  83717. private _onBeforeRenderObserver;
  83718. /**
  83719. * A function that is added to the onBeforeRenderObservable
  83720. */
  83721. onBeforeRender: (effect: Effect) => void;
  83722. /**
  83723. * An event triggered after rendering the postprocess
  83724. */
  83725. onAfterRenderObservable: Observable<Effect>;
  83726. private _onAfterRenderObserver;
  83727. /**
  83728. * A function that is added to the onAfterRenderObservable
  83729. */
  83730. onAfterRender: (efect: Effect) => void;
  83731. /**
  83732. * 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
  83733. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83734. */
  83735. inputTexture: InternalTexture;
  83736. /**
  83737. * Gets the camera which post process is applied to.
  83738. * @returns The camera the post process is applied to.
  83739. */
  83740. getCamera(): Camera;
  83741. /**
  83742. * Gets the texel size of the postprocess.
  83743. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83744. */
  83745. readonly texelSize: Vector2;
  83746. /**
  83747. * Creates a new instance PostProcess
  83748. * @param name The name of the PostProcess.
  83749. * @param fragmentUrl The url of the fragment shader to be used.
  83750. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83751. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83752. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83753. * @param camera The camera to apply the render pass to.
  83754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83755. * @param engine The engine which the post process will be applied. (default: current engine)
  83756. * @param reusable If the post process can be reused on the same frame. (default: false)
  83757. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83758. * @param textureType Type of textures used when performing the post process. (default: 0)
  83759. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83760. * @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
  83761. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83762. */
  83763. constructor(
  83764. /** Name of the PostProcess. */
  83765. 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);
  83766. /**
  83767. * Gets a string idenfifying the name of the class
  83768. * @returns "PostProcess" string
  83769. */
  83770. getClassName(): string;
  83771. /**
  83772. * Gets the engine which this post process belongs to.
  83773. * @returns The engine the post process was enabled with.
  83774. */
  83775. getEngine(): Engine;
  83776. /**
  83777. * The effect that is created when initializing the post process.
  83778. * @returns The created effect corresponding the the postprocess.
  83779. */
  83780. getEffect(): Effect;
  83781. /**
  83782. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83783. * @param postProcess The post process to share the output with.
  83784. * @returns This post process.
  83785. */
  83786. shareOutputWith(postProcess: PostProcess): PostProcess;
  83787. /**
  83788. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83789. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83790. */
  83791. useOwnOutput(): void;
  83792. /**
  83793. * Updates the effect with the current post process compile time values and recompiles the shader.
  83794. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83795. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83796. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83797. * @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
  83798. * @param onCompiled Called when the shader has been compiled.
  83799. * @param onError Called if there is an error when compiling a shader.
  83800. */
  83801. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83802. /**
  83803. * The post process is reusable if it can be used multiple times within one frame.
  83804. * @returns If the post process is reusable
  83805. */
  83806. isReusable(): boolean;
  83807. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83808. markTextureDirty(): void;
  83809. /**
  83810. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83811. * 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.
  83812. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83813. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83814. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83815. * @returns The target texture that was bound to be written to.
  83816. */
  83817. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83818. /**
  83819. * If the post process is supported.
  83820. */
  83821. readonly isSupported: boolean;
  83822. /**
  83823. * The aspect ratio of the output texture.
  83824. */
  83825. readonly aspectRatio: number;
  83826. /**
  83827. * Get a value indicating if the post-process is ready to be used
  83828. * @returns true if the post-process is ready (shader is compiled)
  83829. */
  83830. isReady(): boolean;
  83831. /**
  83832. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83833. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83834. */
  83835. apply(): Nullable<Effect>;
  83836. private _disposeTextures;
  83837. /**
  83838. * Disposes the post process.
  83839. * @param camera The camera to dispose the post process on.
  83840. */
  83841. dispose(camera?: Camera): void;
  83842. }
  83843. }
  83844. declare module BABYLON {
  83845. /** @hidden */
  83846. export var kernelBlurVaryingDeclaration: {
  83847. name: string;
  83848. shader: string;
  83849. };
  83850. }
  83851. declare module BABYLON {
  83852. /** @hidden */
  83853. export var kernelBlurFragment: {
  83854. name: string;
  83855. shader: string;
  83856. };
  83857. }
  83858. declare module BABYLON {
  83859. /** @hidden */
  83860. export var kernelBlurFragment2: {
  83861. name: string;
  83862. shader: string;
  83863. };
  83864. }
  83865. declare module BABYLON {
  83866. /** @hidden */
  83867. export var kernelBlurPixelShader: {
  83868. name: string;
  83869. shader: string;
  83870. };
  83871. }
  83872. declare module BABYLON {
  83873. /** @hidden */
  83874. export var kernelBlurVertex: {
  83875. name: string;
  83876. shader: string;
  83877. };
  83878. }
  83879. declare module BABYLON {
  83880. /** @hidden */
  83881. export var kernelBlurVertexShader: {
  83882. name: string;
  83883. shader: string;
  83884. };
  83885. }
  83886. declare module BABYLON {
  83887. /**
  83888. * The Blur Post Process which blurs an image based on a kernel and direction.
  83889. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83890. */
  83891. export class BlurPostProcess extends PostProcess {
  83892. /** The direction in which to blur the image. */
  83893. direction: Vector2;
  83894. private blockCompilation;
  83895. protected _kernel: number;
  83896. protected _idealKernel: number;
  83897. protected _packedFloat: boolean;
  83898. private _staticDefines;
  83899. /**
  83900. * Sets the length in pixels of the blur sample region
  83901. */
  83902. /**
  83903. * Gets the length in pixels of the blur sample region
  83904. */
  83905. kernel: number;
  83906. /**
  83907. * Sets wether or not the blur needs to unpack/repack floats
  83908. */
  83909. /**
  83910. * Gets wether or not the blur is unpacking/repacking floats
  83911. */
  83912. packedFloat: boolean;
  83913. /**
  83914. * Creates a new instance BlurPostProcess
  83915. * @param name The name of the effect.
  83916. * @param direction The direction in which to blur the image.
  83917. * @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.
  83918. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83919. * @param camera The camera to apply the render pass to.
  83920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83921. * @param engine The engine which the post process will be applied. (default: current engine)
  83922. * @param reusable If the post process can be reused on the same frame. (default: false)
  83923. * @param textureType Type of textures used when performing the post process. (default: 0)
  83924. * @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)
  83925. */
  83926. constructor(name: string,
  83927. /** The direction in which to blur the image. */
  83928. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83929. /**
  83930. * Updates the effect with the current post process compile time values and recompiles the shader.
  83931. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83932. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83933. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83934. * @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
  83935. * @param onCompiled Called when the shader has been compiled.
  83936. * @param onError Called if there is an error when compiling a shader.
  83937. */
  83938. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83939. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83940. /**
  83941. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83942. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83943. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83944. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83945. * The gaps between physical kernels are compensated for in the weighting of the samples
  83946. * @param idealKernel Ideal blur kernel.
  83947. * @return Nearest best kernel.
  83948. */
  83949. protected _nearestBestKernel(idealKernel: number): number;
  83950. /**
  83951. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83952. * @param x The point on the Gaussian distribution to sample.
  83953. * @return the value of the Gaussian function at x.
  83954. */
  83955. protected _gaussianWeight(x: number): number;
  83956. /**
  83957. * Generates a string that can be used as a floating point number in GLSL.
  83958. * @param x Value to print.
  83959. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83960. * @return GLSL float string.
  83961. */
  83962. protected _glslFloat(x: number, decimalFigures?: number): string;
  83963. }
  83964. }
  83965. declare module BABYLON {
  83966. /**
  83967. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83968. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83969. * You can then easily use it as a reflectionTexture on a flat surface.
  83970. * In case the surface is not a plane, please consider relying on reflection probes.
  83971. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83972. */
  83973. export class MirrorTexture extends RenderTargetTexture {
  83974. private scene;
  83975. /**
  83976. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83977. * 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.
  83978. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83979. */
  83980. mirrorPlane: Plane;
  83981. /**
  83982. * Define the blur ratio used to blur the reflection if needed.
  83983. */
  83984. blurRatio: number;
  83985. /**
  83986. * Define the adaptive blur kernel used to blur the reflection if needed.
  83987. * This will autocompute the closest best match for the `blurKernel`
  83988. */
  83989. adaptiveBlurKernel: number;
  83990. /**
  83991. * Define the blur kernel used to blur the reflection if needed.
  83992. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83993. */
  83994. blurKernel: number;
  83995. /**
  83996. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83997. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83998. */
  83999. blurKernelX: number;
  84000. /**
  84001. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84002. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84003. */
  84004. blurKernelY: number;
  84005. private _autoComputeBlurKernel;
  84006. protected _onRatioRescale(): void;
  84007. private _updateGammaSpace;
  84008. private _imageProcessingConfigChangeObserver;
  84009. private _transformMatrix;
  84010. private _mirrorMatrix;
  84011. private _savedViewMatrix;
  84012. private _blurX;
  84013. private _blurY;
  84014. private _adaptiveBlurKernel;
  84015. private _blurKernelX;
  84016. private _blurKernelY;
  84017. private _blurRatio;
  84018. /**
  84019. * Instantiates a Mirror Texture.
  84020. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84021. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84022. * You can then easily use it as a reflectionTexture on a flat surface.
  84023. * In case the surface is not a plane, please consider relying on reflection probes.
  84024. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84025. * @param name
  84026. * @param size
  84027. * @param scene
  84028. * @param generateMipMaps
  84029. * @param type
  84030. * @param samplingMode
  84031. * @param generateDepthBuffer
  84032. */
  84033. constructor(name: string, size: number | {
  84034. width: number;
  84035. height: number;
  84036. } | {
  84037. ratio: number;
  84038. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84039. private _preparePostProcesses;
  84040. /**
  84041. * Clone the mirror texture.
  84042. * @returns the cloned texture
  84043. */
  84044. clone(): MirrorTexture;
  84045. /**
  84046. * Serialize the texture to a JSON representation you could use in Parse later on
  84047. * @returns the serialized JSON representation
  84048. */
  84049. serialize(): any;
  84050. /**
  84051. * Dispose the texture and release its associated resources.
  84052. */
  84053. dispose(): void;
  84054. }
  84055. }
  84056. declare module BABYLON {
  84057. /**
  84058. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84059. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84060. */
  84061. export class Texture extends BaseTexture {
  84062. /**
  84063. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84064. */
  84065. static SerializeBuffers: boolean;
  84066. /** @hidden */
  84067. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84068. /** @hidden */
  84069. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84070. /** @hidden */
  84071. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84072. /** nearest is mag = nearest and min = nearest and mip = linear */
  84073. static readonly NEAREST_SAMPLINGMODE: number;
  84074. /** nearest is mag = nearest and min = nearest and mip = linear */
  84075. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84077. static readonly BILINEAR_SAMPLINGMODE: number;
  84078. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84079. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84080. /** Trilinear is mag = linear and min = linear and mip = linear */
  84081. static readonly TRILINEAR_SAMPLINGMODE: number;
  84082. /** Trilinear is mag = linear and min = linear and mip = linear */
  84083. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84084. /** mag = nearest and min = nearest and mip = nearest */
  84085. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84086. /** mag = nearest and min = linear and mip = nearest */
  84087. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84088. /** mag = nearest and min = linear and mip = linear */
  84089. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84090. /** mag = nearest and min = linear and mip = none */
  84091. static readonly NEAREST_LINEAR: number;
  84092. /** mag = nearest and min = nearest and mip = none */
  84093. static readonly NEAREST_NEAREST: number;
  84094. /** mag = linear and min = nearest and mip = nearest */
  84095. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84096. /** mag = linear and min = nearest and mip = linear */
  84097. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84098. /** mag = linear and min = linear and mip = none */
  84099. static readonly LINEAR_LINEAR: number;
  84100. /** mag = linear and min = nearest and mip = none */
  84101. static readonly LINEAR_NEAREST: number;
  84102. /** Explicit coordinates mode */
  84103. static readonly EXPLICIT_MODE: number;
  84104. /** Spherical coordinates mode */
  84105. static readonly SPHERICAL_MODE: number;
  84106. /** Planar coordinates mode */
  84107. static readonly PLANAR_MODE: number;
  84108. /** Cubic coordinates mode */
  84109. static readonly CUBIC_MODE: number;
  84110. /** Projection coordinates mode */
  84111. static readonly PROJECTION_MODE: number;
  84112. /** Inverse Cubic coordinates mode */
  84113. static readonly SKYBOX_MODE: number;
  84114. /** Inverse Cubic coordinates mode */
  84115. static readonly INVCUBIC_MODE: number;
  84116. /** Equirectangular coordinates mode */
  84117. static readonly EQUIRECTANGULAR_MODE: number;
  84118. /** Equirectangular Fixed coordinates mode */
  84119. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84120. /** Equirectangular Fixed Mirrored coordinates mode */
  84121. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84122. /** Texture is not repeating outside of 0..1 UVs */
  84123. static readonly CLAMP_ADDRESSMODE: number;
  84124. /** Texture is repeating outside of 0..1 UVs */
  84125. static readonly WRAP_ADDRESSMODE: number;
  84126. /** Texture is repeating and mirrored */
  84127. static readonly MIRROR_ADDRESSMODE: number;
  84128. /**
  84129. * 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
  84130. */
  84131. static UseSerializedUrlIfAny: boolean;
  84132. /**
  84133. * Define the url of the texture.
  84134. */
  84135. url: Nullable<string>;
  84136. /**
  84137. * Define an offset on the texture to offset the u coordinates of the UVs
  84138. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84139. */
  84140. uOffset: number;
  84141. /**
  84142. * Define an offset on the texture to offset the v coordinates of the UVs
  84143. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84144. */
  84145. vOffset: number;
  84146. /**
  84147. * Define an offset on the texture to scale the u coordinates of the UVs
  84148. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84149. */
  84150. uScale: number;
  84151. /**
  84152. * Define an offset on the texture to scale the v coordinates of the UVs
  84153. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84154. */
  84155. vScale: number;
  84156. /**
  84157. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84158. * @see http://doc.babylonjs.com/how_to/more_materials
  84159. */
  84160. uAng: number;
  84161. /**
  84162. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84163. * @see http://doc.babylonjs.com/how_to/more_materials
  84164. */
  84165. vAng: number;
  84166. /**
  84167. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84168. * @see http://doc.babylonjs.com/how_to/more_materials
  84169. */
  84170. wAng: number;
  84171. /**
  84172. * Defines the center of rotation (U)
  84173. */
  84174. uRotationCenter: number;
  84175. /**
  84176. * Defines the center of rotation (V)
  84177. */
  84178. vRotationCenter: number;
  84179. /**
  84180. * Defines the center of rotation (W)
  84181. */
  84182. wRotationCenter: number;
  84183. /**
  84184. * Are mip maps generated for this texture or not.
  84185. */
  84186. readonly noMipmap: boolean;
  84187. /**
  84188. * List of inspectable custom properties (used by the Inspector)
  84189. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84190. */
  84191. inspectableCustomProperties: Nullable<IInspectable[]>;
  84192. private _noMipmap;
  84193. /** @hidden */
  84194. _invertY: boolean;
  84195. private _rowGenerationMatrix;
  84196. private _cachedTextureMatrix;
  84197. private _projectionModeMatrix;
  84198. private _t0;
  84199. private _t1;
  84200. private _t2;
  84201. private _cachedUOffset;
  84202. private _cachedVOffset;
  84203. private _cachedUScale;
  84204. private _cachedVScale;
  84205. private _cachedUAng;
  84206. private _cachedVAng;
  84207. private _cachedWAng;
  84208. private _cachedProjectionMatrixId;
  84209. private _cachedCoordinatesMode;
  84210. /** @hidden */
  84211. protected _initialSamplingMode: number;
  84212. /** @hidden */
  84213. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84214. private _deleteBuffer;
  84215. protected _format: Nullable<number>;
  84216. private _delayedOnLoad;
  84217. private _delayedOnError;
  84218. private _mimeType?;
  84219. /**
  84220. * Observable triggered once the texture has been loaded.
  84221. */
  84222. onLoadObservable: Observable<Texture>;
  84223. protected _isBlocking: boolean;
  84224. /**
  84225. * Is the texture preventing material to render while loading.
  84226. * If false, a default texture will be used instead of the loading one during the preparation step.
  84227. */
  84228. isBlocking: boolean;
  84229. /**
  84230. * Get the current sampling mode associated with the texture.
  84231. */
  84232. readonly samplingMode: number;
  84233. /**
  84234. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84235. */
  84236. readonly invertY: boolean;
  84237. /**
  84238. * Instantiates a new texture.
  84239. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84240. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84241. * @param url defines the url of the picture to load as a texture
  84242. * @param scene defines the scene or engine the texture will belong to
  84243. * @param noMipmap defines if the texture will require mip maps or not
  84244. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84245. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84246. * @param onLoad defines a callback triggered when the texture has been loaded
  84247. * @param onError defines a callback triggered when an error occurred during the loading session
  84248. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84249. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84250. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84251. * @param mimeType defines an optional mime type information
  84252. */
  84253. 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);
  84254. /**
  84255. * Update the url (and optional buffer) of this texture if url was null during construction.
  84256. * @param url the url of the texture
  84257. * @param buffer the buffer of the texture (defaults to null)
  84258. * @param onLoad callback called when the texture is loaded (defaults to null)
  84259. */
  84260. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84261. /**
  84262. * Finish the loading sequence of a texture flagged as delayed load.
  84263. * @hidden
  84264. */
  84265. delayLoad(): void;
  84266. private _prepareRowForTextureGeneration;
  84267. /**
  84268. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84269. * @returns the transform matrix of the texture.
  84270. */
  84271. getTextureMatrix(): Matrix;
  84272. /**
  84273. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84274. * @returns The reflection texture transform
  84275. */
  84276. getReflectionTextureMatrix(): Matrix;
  84277. /**
  84278. * Clones the texture.
  84279. * @returns the cloned texture
  84280. */
  84281. clone(): Texture;
  84282. /**
  84283. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84284. * @returns The JSON representation of the texture
  84285. */
  84286. serialize(): any;
  84287. /**
  84288. * Get the current class name of the texture useful for serialization or dynamic coding.
  84289. * @returns "Texture"
  84290. */
  84291. getClassName(): string;
  84292. /**
  84293. * Dispose the texture and release its associated resources.
  84294. */
  84295. dispose(): void;
  84296. /**
  84297. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84298. * @param parsedTexture Define the JSON representation of the texture
  84299. * @param scene Define the scene the parsed texture should be instantiated in
  84300. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84301. * @returns The parsed texture if successful
  84302. */
  84303. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84304. /**
  84305. * Creates a texture from its base 64 representation.
  84306. * @param data Define the base64 payload without the data: prefix
  84307. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84308. * @param scene Define the scene the texture should belong to
  84309. * @param noMipmap Forces the texture to not create mip map information if true
  84310. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84311. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84312. * @param onLoad define a callback triggered when the texture has been loaded
  84313. * @param onError define a callback triggered when an error occurred during the loading session
  84314. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84315. * @returns the created texture
  84316. */
  84317. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84318. /**
  84319. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84320. * @param data Define the base64 payload without the data: prefix
  84321. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84322. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84323. * @param scene Define the scene the texture should belong to
  84324. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84325. * @param noMipmap Forces the texture to not create mip map information if true
  84326. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84327. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84328. * @param onLoad define a callback triggered when the texture has been loaded
  84329. * @param onError define a callback triggered when an error occurred during the loading session
  84330. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84331. * @returns the created texture
  84332. */
  84333. 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;
  84334. }
  84335. }
  84336. declare module BABYLON {
  84337. /**
  84338. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84339. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84340. */
  84341. export class PostProcessManager {
  84342. private _scene;
  84343. private _indexBuffer;
  84344. private _vertexBuffers;
  84345. /**
  84346. * Creates a new instance PostProcess
  84347. * @param scene The scene that the post process is associated with.
  84348. */
  84349. constructor(scene: Scene);
  84350. private _prepareBuffers;
  84351. private _buildIndexBuffer;
  84352. /**
  84353. * Rebuilds the vertex buffers of the manager.
  84354. * @hidden
  84355. */
  84356. _rebuild(): void;
  84357. /**
  84358. * Prepares a frame to be run through a post process.
  84359. * @param sourceTexture The input texture to the post procesess. (default: null)
  84360. * @param postProcesses An array of post processes to be run. (default: null)
  84361. * @returns True if the post processes were able to be run.
  84362. * @hidden
  84363. */
  84364. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84365. /**
  84366. * Manually render a set of post processes to a texture.
  84367. * @param postProcesses An array of post processes to be run.
  84368. * @param targetTexture The target texture to render to.
  84369. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84370. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84371. * @param lodLevel defines which lod of the texture to render to
  84372. */
  84373. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84374. /**
  84375. * Finalize the result of the output of the postprocesses.
  84376. * @param doNotPresent If true the result will not be displayed to the screen.
  84377. * @param targetTexture The target texture to render to.
  84378. * @param faceIndex The index of the face to bind the target texture to.
  84379. * @param postProcesses The array of post processes to render.
  84380. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84381. * @hidden
  84382. */
  84383. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84384. /**
  84385. * Disposes of the post process manager.
  84386. */
  84387. dispose(): void;
  84388. }
  84389. }
  84390. declare module BABYLON {
  84391. /** Interface used by value gradients (color, factor, ...) */
  84392. export interface IValueGradient {
  84393. /**
  84394. * Gets or sets the gradient value (between 0 and 1)
  84395. */
  84396. gradient: number;
  84397. }
  84398. /** Class used to store color4 gradient */
  84399. export class ColorGradient implements IValueGradient {
  84400. /**
  84401. * Gets or sets the gradient value (between 0 and 1)
  84402. */
  84403. gradient: number;
  84404. /**
  84405. * Gets or sets first associated color
  84406. */
  84407. color1: Color4;
  84408. /**
  84409. * Gets or sets second associated color
  84410. */
  84411. color2?: Color4;
  84412. /**
  84413. * Will get a color picked randomly between color1 and color2.
  84414. * If color2 is undefined then color1 will be used
  84415. * @param result defines the target Color4 to store the result in
  84416. */
  84417. getColorToRef(result: Color4): void;
  84418. }
  84419. /** Class used to store color 3 gradient */
  84420. export class Color3Gradient implements IValueGradient {
  84421. /**
  84422. * Gets or sets the gradient value (between 0 and 1)
  84423. */
  84424. gradient: number;
  84425. /**
  84426. * Gets or sets the associated color
  84427. */
  84428. color: Color3;
  84429. }
  84430. /** Class used to store factor gradient */
  84431. export class FactorGradient implements IValueGradient {
  84432. /**
  84433. * Gets or sets the gradient value (between 0 and 1)
  84434. */
  84435. gradient: number;
  84436. /**
  84437. * Gets or sets first associated factor
  84438. */
  84439. factor1: number;
  84440. /**
  84441. * Gets or sets second associated factor
  84442. */
  84443. factor2?: number;
  84444. /**
  84445. * Will get a number picked randomly between factor1 and factor2.
  84446. * If factor2 is undefined then factor1 will be used
  84447. * @returns the picked number
  84448. */
  84449. getFactor(): number;
  84450. }
  84451. /**
  84452. * Helper used to simplify some generic gradient tasks
  84453. */
  84454. export class GradientHelper {
  84455. /**
  84456. * Gets the current gradient from an array of IValueGradient
  84457. * @param ratio defines the current ratio to get
  84458. * @param gradients defines the array of IValueGradient
  84459. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84460. */
  84461. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84462. }
  84463. }
  84464. declare module BABYLON {
  84465. interface ThinEngine {
  84466. /**
  84467. * Creates a dynamic texture
  84468. * @param width defines the width of the texture
  84469. * @param height defines the height of the texture
  84470. * @param generateMipMaps defines if the engine should generate the mip levels
  84471. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84472. * @returns the dynamic texture inside an InternalTexture
  84473. */
  84474. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84475. /**
  84476. * Update the content of a dynamic texture
  84477. * @param texture defines the texture to update
  84478. * @param canvas defines the canvas containing the source
  84479. * @param invertY defines if data must be stored with Y axis inverted
  84480. * @param premulAlpha defines if alpha is stored as premultiplied
  84481. * @param format defines the format of the data
  84482. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84483. */
  84484. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84485. }
  84486. }
  84487. declare module BABYLON {
  84488. /**
  84489. * Helper class used to generate a canvas to manipulate images
  84490. */
  84491. export class CanvasGenerator {
  84492. /**
  84493. * Create a new canvas (or offscreen canvas depending on the context)
  84494. * @param width defines the expected width
  84495. * @param height defines the expected height
  84496. * @return a new canvas or offscreen canvas
  84497. */
  84498. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84499. }
  84500. }
  84501. declare module BABYLON {
  84502. /**
  84503. * A class extending Texture allowing drawing on a texture
  84504. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84505. */
  84506. export class DynamicTexture extends Texture {
  84507. private _generateMipMaps;
  84508. private _canvas;
  84509. private _context;
  84510. private _engine;
  84511. /**
  84512. * Creates a DynamicTexture
  84513. * @param name defines the name of the texture
  84514. * @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
  84515. * @param scene defines the scene where you want the texture
  84516. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84517. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84518. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84519. */
  84520. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84521. /**
  84522. * Get the current class name of the texture useful for serialization or dynamic coding.
  84523. * @returns "DynamicTexture"
  84524. */
  84525. getClassName(): string;
  84526. /**
  84527. * Gets the current state of canRescale
  84528. */
  84529. readonly canRescale: boolean;
  84530. private _recreate;
  84531. /**
  84532. * Scales the texture
  84533. * @param ratio the scale factor to apply to both width and height
  84534. */
  84535. scale(ratio: number): void;
  84536. /**
  84537. * Resizes the texture
  84538. * @param width the new width
  84539. * @param height the new height
  84540. */
  84541. scaleTo(width: number, height: number): void;
  84542. /**
  84543. * Gets the context of the canvas used by the texture
  84544. * @returns the canvas context of the dynamic texture
  84545. */
  84546. getContext(): CanvasRenderingContext2D;
  84547. /**
  84548. * Clears the texture
  84549. */
  84550. clear(): void;
  84551. /**
  84552. * Updates the texture
  84553. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84554. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84555. */
  84556. update(invertY?: boolean, premulAlpha?: boolean): void;
  84557. /**
  84558. * Draws text onto the texture
  84559. * @param text defines the text to be drawn
  84560. * @param x defines the placement of the text from the left
  84561. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84562. * @param font defines the font to be used with font-style, font-size, font-name
  84563. * @param color defines the color used for the text
  84564. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84566. * @param update defines whether texture is immediately update (default is true)
  84567. */
  84568. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84569. /**
  84570. * Clones the texture
  84571. * @returns the clone of the texture.
  84572. */
  84573. clone(): DynamicTexture;
  84574. /**
  84575. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84576. * @returns a serialized dynamic texture object
  84577. */
  84578. serialize(): any;
  84579. /** @hidden */
  84580. _rebuild(): void;
  84581. }
  84582. }
  84583. declare module BABYLON {
  84584. interface AbstractScene {
  84585. /**
  84586. * The list of procedural textures added to the scene
  84587. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84588. */
  84589. proceduralTextures: Array<ProceduralTexture>;
  84590. }
  84591. /**
  84592. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84593. * in a given scene.
  84594. */
  84595. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84596. /**
  84597. * The component name helpfull to identify the component in the list of scene components.
  84598. */
  84599. readonly name: string;
  84600. /**
  84601. * The scene the component belongs to.
  84602. */
  84603. scene: Scene;
  84604. /**
  84605. * Creates a new instance of the component for the given scene
  84606. * @param scene Defines the scene to register the component in
  84607. */
  84608. constructor(scene: Scene);
  84609. /**
  84610. * Registers the component in a given scene
  84611. */
  84612. register(): void;
  84613. /**
  84614. * Rebuilds the elements related to this component in case of
  84615. * context lost for instance.
  84616. */
  84617. rebuild(): void;
  84618. /**
  84619. * Disposes the component and the associated ressources.
  84620. */
  84621. dispose(): void;
  84622. private _beforeClear;
  84623. }
  84624. }
  84625. declare module BABYLON {
  84626. interface ThinEngine {
  84627. /**
  84628. * Creates a new render target cube texture
  84629. * @param size defines the size of the texture
  84630. * @param options defines the options used to create the texture
  84631. * @returns a new render target cube texture stored in an InternalTexture
  84632. */
  84633. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84634. }
  84635. }
  84636. declare module BABYLON {
  84637. /** @hidden */
  84638. export var proceduralVertexShader: {
  84639. name: string;
  84640. shader: string;
  84641. };
  84642. }
  84643. declare module BABYLON {
  84644. /**
  84645. * 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.
  84646. * This is the base class of any Procedural texture and contains most of the shareable code.
  84647. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84648. */
  84649. export class ProceduralTexture extends Texture {
  84650. isCube: boolean;
  84651. /**
  84652. * Define if the texture is enabled or not (disabled texture will not render)
  84653. */
  84654. isEnabled: boolean;
  84655. /**
  84656. * Define if the texture must be cleared before rendering (default is true)
  84657. */
  84658. autoClear: boolean;
  84659. /**
  84660. * Callback called when the texture is generated
  84661. */
  84662. onGenerated: () => void;
  84663. /**
  84664. * Event raised when the texture is generated
  84665. */
  84666. onGeneratedObservable: Observable<ProceduralTexture>;
  84667. /** @hidden */
  84668. _generateMipMaps: boolean;
  84669. /** @hidden **/
  84670. _effect: Effect;
  84671. /** @hidden */
  84672. _textures: {
  84673. [key: string]: Texture;
  84674. };
  84675. private _size;
  84676. private _currentRefreshId;
  84677. private _refreshRate;
  84678. private _vertexBuffers;
  84679. private _indexBuffer;
  84680. private _uniforms;
  84681. private _samplers;
  84682. private _fragment;
  84683. private _floats;
  84684. private _ints;
  84685. private _floatsArrays;
  84686. private _colors3;
  84687. private _colors4;
  84688. private _vectors2;
  84689. private _vectors3;
  84690. private _matrices;
  84691. private _fallbackTexture;
  84692. private _fallbackTextureUsed;
  84693. private _engine;
  84694. private _cachedDefines;
  84695. private _contentUpdateId;
  84696. private _contentData;
  84697. /**
  84698. * Instantiates a new procedural texture.
  84699. * 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.
  84700. * This is the base class of any Procedural texture and contains most of the shareable code.
  84701. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84702. * @param name Define the name of the texture
  84703. * @param size Define the size of the texture to create
  84704. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84705. * @param scene Define the scene the texture belongs to
  84706. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84707. * @param generateMipMaps Define if the texture should creates mip maps or not
  84708. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84709. */
  84710. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84711. /**
  84712. * The effect that is created when initializing the post process.
  84713. * @returns The created effect corresponding the the postprocess.
  84714. */
  84715. getEffect(): Effect;
  84716. /**
  84717. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84718. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84719. */
  84720. getContent(): Nullable<ArrayBufferView>;
  84721. private _createIndexBuffer;
  84722. /** @hidden */
  84723. _rebuild(): void;
  84724. /**
  84725. * Resets the texture in order to recreate its associated resources.
  84726. * This can be called in case of context loss
  84727. */
  84728. reset(): void;
  84729. protected _getDefines(): string;
  84730. /**
  84731. * Is the texture ready to be used ? (rendered at least once)
  84732. * @returns true if ready, otherwise, false.
  84733. */
  84734. isReady(): boolean;
  84735. /**
  84736. * Resets the refresh counter of the texture and start bak from scratch.
  84737. * Could be useful to regenerate the texture if it is setup to render only once.
  84738. */
  84739. resetRefreshCounter(): void;
  84740. /**
  84741. * Set the fragment shader to use in order to render the texture.
  84742. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84743. */
  84744. setFragment(fragment: any): void;
  84745. /**
  84746. * Define the refresh rate of the texture or the rendering frequency.
  84747. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84748. */
  84749. refreshRate: number;
  84750. /** @hidden */
  84751. _shouldRender(): boolean;
  84752. /**
  84753. * Get the size the texture is rendering at.
  84754. * @returns the size (texture is always squared)
  84755. */
  84756. getRenderSize(): number;
  84757. /**
  84758. * Resize the texture to new value.
  84759. * @param size Define the new size the texture should have
  84760. * @param generateMipMaps Define whether the new texture should create mip maps
  84761. */
  84762. resize(size: number, generateMipMaps: boolean): void;
  84763. private _checkUniform;
  84764. /**
  84765. * Set a texture in the shader program used to render.
  84766. * @param name Define the name of the uniform samplers as defined in the shader
  84767. * @param texture Define the texture to bind to this sampler
  84768. * @return the texture itself allowing "fluent" like uniform updates
  84769. */
  84770. setTexture(name: string, texture: Texture): ProceduralTexture;
  84771. /**
  84772. * Set a float in the shader.
  84773. * @param name Define the name of the uniform as defined in the shader
  84774. * @param value Define the value to give to the uniform
  84775. * @return the texture itself allowing "fluent" like uniform updates
  84776. */
  84777. setFloat(name: string, value: number): ProceduralTexture;
  84778. /**
  84779. * Set a int in the shader.
  84780. * @param name Define the name of the uniform as defined in the shader
  84781. * @param value Define the value to give to the uniform
  84782. * @return the texture itself allowing "fluent" like uniform updates
  84783. */
  84784. setInt(name: string, value: number): ProceduralTexture;
  84785. /**
  84786. * Set an array of floats in the shader.
  84787. * @param name Define the name of the uniform as defined in the shader
  84788. * @param value Define the value to give to the uniform
  84789. * @return the texture itself allowing "fluent" like uniform updates
  84790. */
  84791. setFloats(name: string, value: number[]): ProceduralTexture;
  84792. /**
  84793. * Set a vec3 in the shader from a Color3.
  84794. * @param name Define the name of the uniform as defined in the shader
  84795. * @param value Define the value to give to the uniform
  84796. * @return the texture itself allowing "fluent" like uniform updates
  84797. */
  84798. setColor3(name: string, value: Color3): ProceduralTexture;
  84799. /**
  84800. * Set a vec4 in the shader from a Color4.
  84801. * @param name Define the name of the uniform as defined in the shader
  84802. * @param value Define the value to give to the uniform
  84803. * @return the texture itself allowing "fluent" like uniform updates
  84804. */
  84805. setColor4(name: string, value: Color4): ProceduralTexture;
  84806. /**
  84807. * Set a vec2 in the shader from a Vector2.
  84808. * @param name Define the name of the uniform as defined in the shader
  84809. * @param value Define the value to give to the uniform
  84810. * @return the texture itself allowing "fluent" like uniform updates
  84811. */
  84812. setVector2(name: string, value: Vector2): ProceduralTexture;
  84813. /**
  84814. * Set a vec3 in the shader from a Vector3.
  84815. * @param name Define the name of the uniform as defined in the shader
  84816. * @param value Define the value to give to the uniform
  84817. * @return the texture itself allowing "fluent" like uniform updates
  84818. */
  84819. setVector3(name: string, value: Vector3): ProceduralTexture;
  84820. /**
  84821. * Set a mat4 in the shader from a MAtrix.
  84822. * @param name Define the name of the uniform as defined in the shader
  84823. * @param value Define the value to give to the uniform
  84824. * @return the texture itself allowing "fluent" like uniform updates
  84825. */
  84826. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84827. /**
  84828. * Render the texture to its associated render target.
  84829. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84830. */
  84831. render(useCameraPostProcess?: boolean): void;
  84832. /**
  84833. * Clone the texture.
  84834. * @returns the cloned texture
  84835. */
  84836. clone(): ProceduralTexture;
  84837. /**
  84838. * Dispose the texture and release its asoociated resources.
  84839. */
  84840. dispose(): void;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * This represents the base class for particle system in Babylon.
  84846. * 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.
  84847. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84848. * @example https://doc.babylonjs.com/babylon101/particles
  84849. */
  84850. export class BaseParticleSystem {
  84851. /**
  84852. * Source color is added to the destination color without alpha affecting the result
  84853. */
  84854. static BLENDMODE_ONEONE: number;
  84855. /**
  84856. * Blend current color and particle color using particle’s alpha
  84857. */
  84858. static BLENDMODE_STANDARD: number;
  84859. /**
  84860. * Add current color and particle color multiplied by particle’s alpha
  84861. */
  84862. static BLENDMODE_ADD: number;
  84863. /**
  84864. * Multiply current color with particle color
  84865. */
  84866. static BLENDMODE_MULTIPLY: number;
  84867. /**
  84868. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84869. */
  84870. static BLENDMODE_MULTIPLYADD: number;
  84871. /**
  84872. * List of animations used by the particle system.
  84873. */
  84874. animations: Animation[];
  84875. /**
  84876. * The id of the Particle system.
  84877. */
  84878. id: string;
  84879. /**
  84880. * The friendly name of the Particle system.
  84881. */
  84882. name: string;
  84883. /**
  84884. * The rendering group used by the Particle system to chose when to render.
  84885. */
  84886. renderingGroupId: number;
  84887. /**
  84888. * The emitter represents the Mesh or position we are attaching the particle system to.
  84889. */
  84890. emitter: Nullable<AbstractMesh | Vector3>;
  84891. /**
  84892. * The maximum number of particles to emit per frame
  84893. */
  84894. emitRate: number;
  84895. /**
  84896. * If you want to launch only a few particles at once, that can be done, as well.
  84897. */
  84898. manualEmitCount: number;
  84899. /**
  84900. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84901. */
  84902. updateSpeed: number;
  84903. /**
  84904. * The amount of time the particle system is running (depends of the overall update speed).
  84905. */
  84906. targetStopDuration: number;
  84907. /**
  84908. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84909. */
  84910. disposeOnStop: boolean;
  84911. /**
  84912. * Minimum power of emitting particles.
  84913. */
  84914. minEmitPower: number;
  84915. /**
  84916. * Maximum power of emitting particles.
  84917. */
  84918. maxEmitPower: number;
  84919. /**
  84920. * Minimum life time of emitting particles.
  84921. */
  84922. minLifeTime: number;
  84923. /**
  84924. * Maximum life time of emitting particles.
  84925. */
  84926. maxLifeTime: number;
  84927. /**
  84928. * Minimum Size of emitting particles.
  84929. */
  84930. minSize: number;
  84931. /**
  84932. * Maximum Size of emitting particles.
  84933. */
  84934. maxSize: number;
  84935. /**
  84936. * Minimum scale of emitting particles on X axis.
  84937. */
  84938. minScaleX: number;
  84939. /**
  84940. * Maximum scale of emitting particles on X axis.
  84941. */
  84942. maxScaleX: number;
  84943. /**
  84944. * Minimum scale of emitting particles on Y axis.
  84945. */
  84946. minScaleY: number;
  84947. /**
  84948. * Maximum scale of emitting particles on Y axis.
  84949. */
  84950. maxScaleY: number;
  84951. /**
  84952. * Gets or sets the minimal initial rotation in radians.
  84953. */
  84954. minInitialRotation: number;
  84955. /**
  84956. * Gets or sets the maximal initial rotation in radians.
  84957. */
  84958. maxInitialRotation: number;
  84959. /**
  84960. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84961. */
  84962. minAngularSpeed: number;
  84963. /**
  84964. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84965. */
  84966. maxAngularSpeed: number;
  84967. /**
  84968. * The texture used to render each particle. (this can be a spritesheet)
  84969. */
  84970. particleTexture: Nullable<Texture>;
  84971. /**
  84972. * The layer mask we are rendering the particles through.
  84973. */
  84974. layerMask: number;
  84975. /**
  84976. * This can help using your own shader to render the particle system.
  84977. * The according effect will be created
  84978. */
  84979. customShader: any;
  84980. /**
  84981. * By default particle system starts as soon as they are created. This prevents the
  84982. * automatic start to happen and let you decide when to start emitting particles.
  84983. */
  84984. preventAutoStart: boolean;
  84985. private _noiseTexture;
  84986. /**
  84987. * Gets or sets a texture used to add random noise to particle positions
  84988. */
  84989. noiseTexture: Nullable<ProceduralTexture>;
  84990. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84991. noiseStrength: Vector3;
  84992. /**
  84993. * Callback triggered when the particle animation is ending.
  84994. */
  84995. onAnimationEnd: Nullable<() => void>;
  84996. /**
  84997. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84998. */
  84999. blendMode: number;
  85000. /**
  85001. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85002. * to override the particles.
  85003. */
  85004. forceDepthWrite: boolean;
  85005. /** 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 */
  85006. preWarmCycles: number;
  85007. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85008. preWarmStepOffset: number;
  85009. /**
  85010. * 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)
  85011. */
  85012. spriteCellChangeSpeed: number;
  85013. /**
  85014. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85015. */
  85016. startSpriteCellID: number;
  85017. /**
  85018. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85019. */
  85020. endSpriteCellID: number;
  85021. /**
  85022. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85023. */
  85024. spriteCellWidth: number;
  85025. /**
  85026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85027. */
  85028. spriteCellHeight: number;
  85029. /**
  85030. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85031. */
  85032. spriteRandomStartCell: boolean;
  85033. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85034. translationPivot: Vector2;
  85035. /** @hidden */
  85036. protected _isAnimationSheetEnabled: boolean;
  85037. /**
  85038. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85039. */
  85040. beginAnimationOnStart: boolean;
  85041. /**
  85042. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85043. */
  85044. beginAnimationFrom: number;
  85045. /**
  85046. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85047. */
  85048. beginAnimationTo: number;
  85049. /**
  85050. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85051. */
  85052. beginAnimationLoop: boolean;
  85053. /**
  85054. * Gets or sets a world offset applied to all particles
  85055. */
  85056. worldOffset: Vector3;
  85057. /**
  85058. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85059. */
  85060. isAnimationSheetEnabled: boolean;
  85061. /**
  85062. * Get hosting scene
  85063. * @returns the scene
  85064. */
  85065. getScene(): Scene;
  85066. /**
  85067. * You can use gravity if you want to give an orientation to your particles.
  85068. */
  85069. gravity: Vector3;
  85070. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85071. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85072. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85073. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85074. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85075. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85076. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85077. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85078. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85079. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85080. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85081. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85082. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85083. /**
  85084. * Defines the delay in milliseconds before starting the system (0 by default)
  85085. */
  85086. startDelay: number;
  85087. /**
  85088. * Gets the current list of drag gradients.
  85089. * You must use addDragGradient and removeDragGradient to udpate this list
  85090. * @returns the list of drag gradients
  85091. */
  85092. getDragGradients(): Nullable<Array<FactorGradient>>;
  85093. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85094. limitVelocityDamping: number;
  85095. /**
  85096. * Gets the current list of limit velocity gradients.
  85097. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85098. * @returns the list of limit velocity gradients
  85099. */
  85100. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85101. /**
  85102. * Gets the current list of color gradients.
  85103. * You must use addColorGradient and removeColorGradient to udpate this list
  85104. * @returns the list of color gradients
  85105. */
  85106. getColorGradients(): Nullable<Array<ColorGradient>>;
  85107. /**
  85108. * Gets the current list of size gradients.
  85109. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85110. * @returns the list of size gradients
  85111. */
  85112. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85113. /**
  85114. * Gets the current list of color remap gradients.
  85115. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85116. * @returns the list of color remap gradients
  85117. */
  85118. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85119. /**
  85120. * Gets the current list of alpha remap gradients.
  85121. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85122. * @returns the list of alpha remap gradients
  85123. */
  85124. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85125. /**
  85126. * Gets the current list of life time gradients.
  85127. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85128. * @returns the list of life time gradients
  85129. */
  85130. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85131. /**
  85132. * Gets the current list of angular speed gradients.
  85133. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85134. * @returns the list of angular speed gradients
  85135. */
  85136. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85137. /**
  85138. * Gets the current list of velocity gradients.
  85139. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85140. * @returns the list of velocity gradients
  85141. */
  85142. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85143. /**
  85144. * Gets the current list of start size gradients.
  85145. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85146. * @returns the list of start size gradients
  85147. */
  85148. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85149. /**
  85150. * Gets the current list of emit rate gradients.
  85151. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85152. * @returns the list of emit rate gradients
  85153. */
  85154. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85155. /**
  85156. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85157. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85158. */
  85159. direction1: Vector3;
  85160. /**
  85161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85162. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85163. */
  85164. direction2: Vector3;
  85165. /**
  85166. * 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.
  85167. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85168. */
  85169. minEmitBox: Vector3;
  85170. /**
  85171. * 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.
  85172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85173. */
  85174. maxEmitBox: Vector3;
  85175. /**
  85176. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85177. */
  85178. color1: Color4;
  85179. /**
  85180. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85181. */
  85182. color2: Color4;
  85183. /**
  85184. * Color the particle will have at the end of its lifetime
  85185. */
  85186. colorDead: Color4;
  85187. /**
  85188. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85189. */
  85190. textureMask: Color4;
  85191. /**
  85192. * The particle emitter type defines the emitter used by the particle system.
  85193. * It can be for example box, sphere, or cone...
  85194. */
  85195. particleEmitterType: IParticleEmitterType;
  85196. /** @hidden */
  85197. _isSubEmitter: boolean;
  85198. /**
  85199. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85200. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85201. */
  85202. billboardMode: number;
  85203. protected _isBillboardBased: boolean;
  85204. /**
  85205. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85206. */
  85207. isBillboardBased: boolean;
  85208. /**
  85209. * The scene the particle system belongs to.
  85210. */
  85211. protected _scene: Scene;
  85212. /**
  85213. * Local cache of defines for image processing.
  85214. */
  85215. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85216. /**
  85217. * Default configuration related to image processing available in the standard Material.
  85218. */
  85219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85220. /**
  85221. * Gets the image processing configuration used either in this material.
  85222. */
  85223. /**
  85224. * Sets the Default image processing configuration used either in the this material.
  85225. *
  85226. * If sets to null, the scene one is in use.
  85227. */
  85228. imageProcessingConfiguration: ImageProcessingConfiguration;
  85229. /**
  85230. * Attaches a new image processing configuration to the Standard Material.
  85231. * @param configuration
  85232. */
  85233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85234. /** @hidden */
  85235. protected _reset(): void;
  85236. /** @hidden */
  85237. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85238. /**
  85239. * Instantiates a particle system.
  85240. * 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.
  85241. * @param name The name of the particle system
  85242. */
  85243. constructor(name: string);
  85244. /**
  85245. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85246. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85247. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85248. * @returns the emitter
  85249. */
  85250. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85251. /**
  85252. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85253. * @param radius The radius of the hemisphere to emit from
  85254. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85255. * @returns the emitter
  85256. */
  85257. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85258. /**
  85259. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85260. * @param radius The radius of the sphere to emit from
  85261. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85262. * @returns the emitter
  85263. */
  85264. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85265. /**
  85266. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85267. * @param radius The radius of the sphere to emit from
  85268. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85269. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85270. * @returns the emitter
  85271. */
  85272. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85273. /**
  85274. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85275. * @param radius The radius of the emission cylinder
  85276. * @param height The height of the emission cylinder
  85277. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85278. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85279. * @returns the emitter
  85280. */
  85281. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85282. /**
  85283. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85284. * @param radius The radius of the cylinder to emit from
  85285. * @param height The height of the emission cylinder
  85286. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85289. * @returns the emitter
  85290. */
  85291. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85292. /**
  85293. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85294. * @param radius The radius of the cone to emit from
  85295. * @param angle The base angle of the cone
  85296. * @returns the emitter
  85297. */
  85298. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85299. /**
  85300. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85301. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85302. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85303. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85304. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85305. * @returns the emitter
  85306. */
  85307. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85308. }
  85309. }
  85310. declare module BABYLON {
  85311. /**
  85312. * Type of sub emitter
  85313. */
  85314. export enum SubEmitterType {
  85315. /**
  85316. * Attached to the particle over it's lifetime
  85317. */
  85318. ATTACHED = 0,
  85319. /**
  85320. * Created when the particle dies
  85321. */
  85322. END = 1
  85323. }
  85324. /**
  85325. * Sub emitter class used to emit particles from an existing particle
  85326. */
  85327. export class SubEmitter {
  85328. /**
  85329. * the particle system to be used by the sub emitter
  85330. */
  85331. particleSystem: ParticleSystem;
  85332. /**
  85333. * Type of the submitter (Default: END)
  85334. */
  85335. type: SubEmitterType;
  85336. /**
  85337. * 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)
  85338. * Note: This only is supported when using an emitter of type Mesh
  85339. */
  85340. inheritDirection: boolean;
  85341. /**
  85342. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85343. */
  85344. inheritedVelocityAmount: number;
  85345. /**
  85346. * Creates a sub emitter
  85347. * @param particleSystem the particle system to be used by the sub emitter
  85348. */
  85349. constructor(
  85350. /**
  85351. * the particle system to be used by the sub emitter
  85352. */
  85353. particleSystem: ParticleSystem);
  85354. /**
  85355. * Clones the sub emitter
  85356. * @returns the cloned sub emitter
  85357. */
  85358. clone(): SubEmitter;
  85359. /**
  85360. * Serialize current object to a JSON object
  85361. * @returns the serialized object
  85362. */
  85363. serialize(): any;
  85364. /** @hidden */
  85365. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85366. /**
  85367. * Creates a new SubEmitter from a serialized JSON version
  85368. * @param serializationObject defines the JSON object to read from
  85369. * @param scene defines the hosting scene
  85370. * @param rootUrl defines the rootUrl for data loading
  85371. * @returns a new SubEmitter
  85372. */
  85373. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85374. /** Release associated resources */
  85375. dispose(): void;
  85376. }
  85377. }
  85378. declare module BABYLON {
  85379. /** @hidden */
  85380. export var clipPlaneFragmentDeclaration: {
  85381. name: string;
  85382. shader: string;
  85383. };
  85384. }
  85385. declare module BABYLON {
  85386. /** @hidden */
  85387. export var imageProcessingDeclaration: {
  85388. name: string;
  85389. shader: string;
  85390. };
  85391. }
  85392. declare module BABYLON {
  85393. /** @hidden */
  85394. export var imageProcessingFunctions: {
  85395. name: string;
  85396. shader: string;
  85397. };
  85398. }
  85399. declare module BABYLON {
  85400. /** @hidden */
  85401. export var clipPlaneFragment: {
  85402. name: string;
  85403. shader: string;
  85404. };
  85405. }
  85406. declare module BABYLON {
  85407. /** @hidden */
  85408. export var particlesPixelShader: {
  85409. name: string;
  85410. shader: string;
  85411. };
  85412. }
  85413. declare module BABYLON {
  85414. /** @hidden */
  85415. export var clipPlaneVertexDeclaration: {
  85416. name: string;
  85417. shader: string;
  85418. };
  85419. }
  85420. declare module BABYLON {
  85421. /** @hidden */
  85422. export var clipPlaneVertex: {
  85423. name: string;
  85424. shader: string;
  85425. };
  85426. }
  85427. declare module BABYLON {
  85428. /** @hidden */
  85429. export var particlesVertexShader: {
  85430. name: string;
  85431. shader: string;
  85432. };
  85433. }
  85434. declare module BABYLON {
  85435. /**
  85436. * This represents a particle system in Babylon.
  85437. * 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.
  85438. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85439. * @example https://doc.babylonjs.com/babylon101/particles
  85440. */
  85441. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85442. /**
  85443. * Billboard mode will only apply to Y axis
  85444. */
  85445. static readonly BILLBOARDMODE_Y: number;
  85446. /**
  85447. * Billboard mode will apply to all axes
  85448. */
  85449. static readonly BILLBOARDMODE_ALL: number;
  85450. /**
  85451. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85452. */
  85453. static readonly BILLBOARDMODE_STRETCHED: number;
  85454. /**
  85455. * This function can be defined to provide custom update for active particles.
  85456. * This function will be called instead of regular update (age, position, color, etc.).
  85457. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85458. */
  85459. updateFunction: (particles: Particle[]) => void;
  85460. private _emitterWorldMatrix;
  85461. /**
  85462. * This function can be defined to specify initial direction for every new particle.
  85463. * It by default use the emitterType defined function
  85464. */
  85465. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85466. /**
  85467. * This function can be defined to specify initial position for every new particle.
  85468. * It by default use the emitterType defined function
  85469. */
  85470. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85471. /**
  85472. * @hidden
  85473. */
  85474. _inheritedVelocityOffset: Vector3;
  85475. /**
  85476. * An event triggered when the system is disposed
  85477. */
  85478. onDisposeObservable: Observable<ParticleSystem>;
  85479. private _onDisposeObserver;
  85480. /**
  85481. * Sets a callback that will be triggered when the system is disposed
  85482. */
  85483. onDispose: () => void;
  85484. private _particles;
  85485. private _epsilon;
  85486. private _capacity;
  85487. private _stockParticles;
  85488. private _newPartsExcess;
  85489. private _vertexData;
  85490. private _vertexBuffer;
  85491. private _vertexBuffers;
  85492. private _spriteBuffer;
  85493. private _indexBuffer;
  85494. private _effect;
  85495. private _customEffect;
  85496. private _cachedDefines;
  85497. private _scaledColorStep;
  85498. private _colorDiff;
  85499. private _scaledDirection;
  85500. private _scaledGravity;
  85501. private _currentRenderId;
  85502. private _alive;
  85503. private _useInstancing;
  85504. private _started;
  85505. private _stopped;
  85506. private _actualFrame;
  85507. private _scaledUpdateSpeed;
  85508. private _vertexBufferSize;
  85509. /** @hidden */
  85510. _currentEmitRateGradient: Nullable<FactorGradient>;
  85511. /** @hidden */
  85512. _currentEmitRate1: number;
  85513. /** @hidden */
  85514. _currentEmitRate2: number;
  85515. /** @hidden */
  85516. _currentStartSizeGradient: Nullable<FactorGradient>;
  85517. /** @hidden */
  85518. _currentStartSize1: number;
  85519. /** @hidden */
  85520. _currentStartSize2: number;
  85521. private readonly _rawTextureWidth;
  85522. private _rampGradientsTexture;
  85523. private _useRampGradients;
  85524. /** Gets or sets a boolean indicating that ramp gradients must be used
  85525. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85526. */
  85527. useRampGradients: boolean;
  85528. /**
  85529. * 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.
  85530. * 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: [])
  85531. */
  85532. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85533. private _subEmitters;
  85534. /**
  85535. * @hidden
  85536. * If the particle systems emitter should be disposed when the particle system is disposed
  85537. */
  85538. _disposeEmitterOnDispose: boolean;
  85539. /**
  85540. * The current active Sub-systems, this property is used by the root particle system only.
  85541. */
  85542. activeSubSystems: Array<ParticleSystem>;
  85543. private _rootParticleSystem;
  85544. /**
  85545. * Gets the current list of active particles
  85546. */
  85547. readonly particles: Particle[];
  85548. /**
  85549. * Returns the string "ParticleSystem"
  85550. * @returns a string containing the class name
  85551. */
  85552. getClassName(): string;
  85553. /**
  85554. * Instantiates a particle system.
  85555. * 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.
  85556. * @param name The name of the particle system
  85557. * @param capacity The max number of particles alive at the same time
  85558. * @param scene The scene the particle system belongs to
  85559. * @param customEffect a custom effect used to change the way particles are rendered by default
  85560. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85561. * @param epsilon Offset used to render the particles
  85562. */
  85563. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85564. private _addFactorGradient;
  85565. private _removeFactorGradient;
  85566. /**
  85567. * Adds a new life time gradient
  85568. * @param gradient defines the gradient to use (between 0 and 1)
  85569. * @param factor defines the life time factor to affect to the specified gradient
  85570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85571. * @returns the current particle system
  85572. */
  85573. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85574. /**
  85575. * Remove a specific life time gradient
  85576. * @param gradient defines the gradient to remove
  85577. * @returns the current particle system
  85578. */
  85579. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85580. /**
  85581. * Adds a new size gradient
  85582. * @param gradient defines the gradient to use (between 0 and 1)
  85583. * @param factor defines the size factor to affect to the specified gradient
  85584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85585. * @returns the current particle system
  85586. */
  85587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85588. /**
  85589. * Remove a specific size gradient
  85590. * @param gradient defines the gradient to remove
  85591. * @returns the current particle system
  85592. */
  85593. removeSizeGradient(gradient: number): IParticleSystem;
  85594. /**
  85595. * Adds a new color remap gradient
  85596. * @param gradient defines the gradient to use (between 0 and 1)
  85597. * @param min defines the color remap minimal range
  85598. * @param max defines the color remap maximal range
  85599. * @returns the current particle system
  85600. */
  85601. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85602. /**
  85603. * Remove a specific color remap gradient
  85604. * @param gradient defines the gradient to remove
  85605. * @returns the current particle system
  85606. */
  85607. removeColorRemapGradient(gradient: number): IParticleSystem;
  85608. /**
  85609. * Adds a new alpha remap gradient
  85610. * @param gradient defines the gradient to use (between 0 and 1)
  85611. * @param min defines the alpha remap minimal range
  85612. * @param max defines the alpha remap maximal range
  85613. * @returns the current particle system
  85614. */
  85615. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85616. /**
  85617. * Remove a specific alpha remap gradient
  85618. * @param gradient defines the gradient to remove
  85619. * @returns the current particle system
  85620. */
  85621. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85622. /**
  85623. * Adds a new angular speed gradient
  85624. * @param gradient defines the gradient to use (between 0 and 1)
  85625. * @param factor defines the angular speed to affect to the specified gradient
  85626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85627. * @returns the current particle system
  85628. */
  85629. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85630. /**
  85631. * Remove a specific angular speed gradient
  85632. * @param gradient defines the gradient to remove
  85633. * @returns the current particle system
  85634. */
  85635. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85636. /**
  85637. * Adds a new velocity gradient
  85638. * @param gradient defines the gradient to use (between 0 and 1)
  85639. * @param factor defines the velocity to affect to the specified gradient
  85640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85641. * @returns the current particle system
  85642. */
  85643. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85644. /**
  85645. * Remove a specific velocity gradient
  85646. * @param gradient defines the gradient to remove
  85647. * @returns the current particle system
  85648. */
  85649. removeVelocityGradient(gradient: number): IParticleSystem;
  85650. /**
  85651. * Adds a new limit velocity gradient
  85652. * @param gradient defines the gradient to use (between 0 and 1)
  85653. * @param factor defines the limit velocity value to affect to the specified gradient
  85654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85655. * @returns the current particle system
  85656. */
  85657. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85658. /**
  85659. * Remove a specific limit velocity gradient
  85660. * @param gradient defines the gradient to remove
  85661. * @returns the current particle system
  85662. */
  85663. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85664. /**
  85665. * Adds a new drag gradient
  85666. * @param gradient defines the gradient to use (between 0 and 1)
  85667. * @param factor defines the drag value to affect to the specified gradient
  85668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85669. * @returns the current particle system
  85670. */
  85671. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85672. /**
  85673. * Remove a specific drag gradient
  85674. * @param gradient defines the gradient to remove
  85675. * @returns the current particle system
  85676. */
  85677. removeDragGradient(gradient: number): IParticleSystem;
  85678. /**
  85679. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85680. * @param gradient defines the gradient to use (between 0 and 1)
  85681. * @param factor defines the emit rate value to affect to the specified gradient
  85682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85683. * @returns the current particle system
  85684. */
  85685. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85686. /**
  85687. * Remove a specific emit rate gradient
  85688. * @param gradient defines the gradient to remove
  85689. * @returns the current particle system
  85690. */
  85691. removeEmitRateGradient(gradient: number): IParticleSystem;
  85692. /**
  85693. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85694. * @param gradient defines the gradient to use (between 0 and 1)
  85695. * @param factor defines the start size value to affect to the specified gradient
  85696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85697. * @returns the current particle system
  85698. */
  85699. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85700. /**
  85701. * Remove a specific start size gradient
  85702. * @param gradient defines the gradient to remove
  85703. * @returns the current particle system
  85704. */
  85705. removeStartSizeGradient(gradient: number): IParticleSystem;
  85706. private _createRampGradientTexture;
  85707. /**
  85708. * Gets the current list of ramp gradients.
  85709. * You must use addRampGradient and removeRampGradient to udpate this list
  85710. * @returns the list of ramp gradients
  85711. */
  85712. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85713. /**
  85714. * Adds a new ramp gradient used to remap particle colors
  85715. * @param gradient defines the gradient to use (between 0 and 1)
  85716. * @param color defines the color to affect to the specified gradient
  85717. * @returns the current particle system
  85718. */
  85719. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85720. /**
  85721. * Remove a specific ramp gradient
  85722. * @param gradient defines the gradient to remove
  85723. * @returns the current particle system
  85724. */
  85725. removeRampGradient(gradient: number): ParticleSystem;
  85726. /**
  85727. * Adds a new color gradient
  85728. * @param gradient defines the gradient to use (between 0 and 1)
  85729. * @param color1 defines the color to affect to the specified gradient
  85730. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85731. * @returns this particle system
  85732. */
  85733. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85734. /**
  85735. * Remove a specific color gradient
  85736. * @param gradient defines the gradient to remove
  85737. * @returns this particle system
  85738. */
  85739. removeColorGradient(gradient: number): IParticleSystem;
  85740. private _fetchR;
  85741. protected _reset(): void;
  85742. private _resetEffect;
  85743. private _createVertexBuffers;
  85744. private _createIndexBuffer;
  85745. /**
  85746. * Gets the maximum number of particles active at the same time.
  85747. * @returns The max number of active particles.
  85748. */
  85749. getCapacity(): number;
  85750. /**
  85751. * Gets whether there are still active particles in the system.
  85752. * @returns True if it is alive, otherwise false.
  85753. */
  85754. isAlive(): boolean;
  85755. /**
  85756. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85757. * @returns True if it has been started, otherwise false.
  85758. */
  85759. isStarted(): boolean;
  85760. private _prepareSubEmitterInternalArray;
  85761. /**
  85762. * Starts the particle system and begins to emit
  85763. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85764. */
  85765. start(delay?: number): void;
  85766. /**
  85767. * Stops the particle system.
  85768. * @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.
  85769. */
  85770. stop(stopSubEmitters?: boolean): void;
  85771. /**
  85772. * Remove all active particles
  85773. */
  85774. reset(): void;
  85775. /**
  85776. * @hidden (for internal use only)
  85777. */
  85778. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85779. /**
  85780. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85781. * Its lifetime will start back at 0.
  85782. */
  85783. recycleParticle: (particle: Particle) => void;
  85784. private _stopSubEmitters;
  85785. private _createParticle;
  85786. private _removeFromRoot;
  85787. private _emitFromParticle;
  85788. private _update;
  85789. /** @hidden */
  85790. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85791. /** @hidden */
  85792. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85793. /** @hidden */
  85794. private _getEffect;
  85795. /**
  85796. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85797. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85798. */
  85799. animate(preWarmOnly?: boolean): void;
  85800. private _appendParticleVertices;
  85801. /**
  85802. * Rebuilds the particle system.
  85803. */
  85804. rebuild(): void;
  85805. /**
  85806. * Is this system ready to be used/rendered
  85807. * @return true if the system is ready
  85808. */
  85809. isReady(): boolean;
  85810. private _render;
  85811. /**
  85812. * Renders the particle system in its current state.
  85813. * @returns the current number of particles
  85814. */
  85815. render(): number;
  85816. /**
  85817. * Disposes the particle system and free the associated resources
  85818. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85819. */
  85820. dispose(disposeTexture?: boolean): void;
  85821. /**
  85822. * Clones the particle system.
  85823. * @param name The name of the cloned object
  85824. * @param newEmitter The new emitter to use
  85825. * @returns the cloned particle system
  85826. */
  85827. clone(name: string, newEmitter: any): ParticleSystem;
  85828. /**
  85829. * Serializes the particle system to a JSON object.
  85830. * @returns the JSON object
  85831. */
  85832. serialize(): any;
  85833. /** @hidden */
  85834. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85835. /** @hidden */
  85836. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85837. /**
  85838. * Parses a JSON object to create a particle system.
  85839. * @param parsedParticleSystem The JSON object to parse
  85840. * @param scene The scene to create the particle system in
  85841. * @param rootUrl The root url to use to load external dependencies like texture
  85842. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85843. * @returns the Parsed particle system
  85844. */
  85845. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85846. }
  85847. }
  85848. declare module BABYLON {
  85849. /**
  85850. * A particle represents one of the element emitted by a particle system.
  85851. * This is mainly define by its coordinates, direction, velocity and age.
  85852. */
  85853. export class Particle {
  85854. /**
  85855. * The particle system the particle belongs to.
  85856. */
  85857. particleSystem: ParticleSystem;
  85858. private static _Count;
  85859. /**
  85860. * Unique ID of the particle
  85861. */
  85862. id: number;
  85863. /**
  85864. * The world position of the particle in the scene.
  85865. */
  85866. position: Vector3;
  85867. /**
  85868. * The world direction of the particle in the scene.
  85869. */
  85870. direction: Vector3;
  85871. /**
  85872. * The color of the particle.
  85873. */
  85874. color: Color4;
  85875. /**
  85876. * The color change of the particle per step.
  85877. */
  85878. colorStep: Color4;
  85879. /**
  85880. * Defines how long will the life of the particle be.
  85881. */
  85882. lifeTime: number;
  85883. /**
  85884. * The current age of the particle.
  85885. */
  85886. age: number;
  85887. /**
  85888. * The current size of the particle.
  85889. */
  85890. size: number;
  85891. /**
  85892. * The current scale of the particle.
  85893. */
  85894. scale: Vector2;
  85895. /**
  85896. * The current angle of the particle.
  85897. */
  85898. angle: number;
  85899. /**
  85900. * Defines how fast is the angle changing.
  85901. */
  85902. angularSpeed: number;
  85903. /**
  85904. * Defines the cell index used by the particle to be rendered from a sprite.
  85905. */
  85906. cellIndex: number;
  85907. /**
  85908. * The information required to support color remapping
  85909. */
  85910. remapData: Vector4;
  85911. /** @hidden */
  85912. _randomCellOffset?: number;
  85913. /** @hidden */
  85914. _initialDirection: Nullable<Vector3>;
  85915. /** @hidden */
  85916. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85917. /** @hidden */
  85918. _initialStartSpriteCellID: number;
  85919. /** @hidden */
  85920. _initialEndSpriteCellID: number;
  85921. /** @hidden */
  85922. _currentColorGradient: Nullable<ColorGradient>;
  85923. /** @hidden */
  85924. _currentColor1: Color4;
  85925. /** @hidden */
  85926. _currentColor2: Color4;
  85927. /** @hidden */
  85928. _currentSizeGradient: Nullable<FactorGradient>;
  85929. /** @hidden */
  85930. _currentSize1: number;
  85931. /** @hidden */
  85932. _currentSize2: number;
  85933. /** @hidden */
  85934. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85935. /** @hidden */
  85936. _currentAngularSpeed1: number;
  85937. /** @hidden */
  85938. _currentAngularSpeed2: number;
  85939. /** @hidden */
  85940. _currentVelocityGradient: Nullable<FactorGradient>;
  85941. /** @hidden */
  85942. _currentVelocity1: number;
  85943. /** @hidden */
  85944. _currentVelocity2: number;
  85945. /** @hidden */
  85946. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85947. /** @hidden */
  85948. _currentLimitVelocity1: number;
  85949. /** @hidden */
  85950. _currentLimitVelocity2: number;
  85951. /** @hidden */
  85952. _currentDragGradient: Nullable<FactorGradient>;
  85953. /** @hidden */
  85954. _currentDrag1: number;
  85955. /** @hidden */
  85956. _currentDrag2: number;
  85957. /** @hidden */
  85958. _randomNoiseCoordinates1: Vector3;
  85959. /** @hidden */
  85960. _randomNoiseCoordinates2: Vector3;
  85961. /**
  85962. * Creates a new instance Particle
  85963. * @param particleSystem the particle system the particle belongs to
  85964. */
  85965. constructor(
  85966. /**
  85967. * The particle system the particle belongs to.
  85968. */
  85969. particleSystem: ParticleSystem);
  85970. private updateCellInfoFromSystem;
  85971. /**
  85972. * Defines how the sprite cell index is updated for the particle
  85973. */
  85974. updateCellIndex(): void;
  85975. /** @hidden */
  85976. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85977. /** @hidden */
  85978. _inheritParticleInfoToSubEmitters(): void;
  85979. /** @hidden */
  85980. _reset(): void;
  85981. /**
  85982. * Copy the properties of particle to another one.
  85983. * @param other the particle to copy the information to.
  85984. */
  85985. copyTo(other: Particle): void;
  85986. }
  85987. }
  85988. declare module BABYLON {
  85989. /**
  85990. * Particle emitter represents a volume emitting particles.
  85991. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85992. */
  85993. export interface IParticleEmitterType {
  85994. /**
  85995. * Called by the particle System when the direction is computed for the created particle.
  85996. * @param worldMatrix is the world matrix of the particle system
  85997. * @param directionToUpdate is the direction vector to update with the result
  85998. * @param particle is the particle we are computed the direction for
  85999. */
  86000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86001. /**
  86002. * Called by the particle System when the position is computed for the created particle.
  86003. * @param worldMatrix is the world matrix of the particle system
  86004. * @param positionToUpdate is the position vector to update with the result
  86005. * @param particle is the particle we are computed the position for
  86006. */
  86007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86008. /**
  86009. * Clones the current emitter and returns a copy of it
  86010. * @returns the new emitter
  86011. */
  86012. clone(): IParticleEmitterType;
  86013. /**
  86014. * Called by the GPUParticleSystem to setup the update shader
  86015. * @param effect defines the update shader
  86016. */
  86017. applyToShader(effect: Effect): void;
  86018. /**
  86019. * Returns a string to use to update the GPU particles update shader
  86020. * @returns the effect defines string
  86021. */
  86022. getEffectDefines(): string;
  86023. /**
  86024. * Returns a string representing the class name
  86025. * @returns a string containing the class name
  86026. */
  86027. getClassName(): string;
  86028. /**
  86029. * Serializes the particle system to a JSON object.
  86030. * @returns the JSON object
  86031. */
  86032. serialize(): any;
  86033. /**
  86034. * Parse properties from a JSON object
  86035. * @param serializationObject defines the JSON object
  86036. */
  86037. parse(serializationObject: any): void;
  86038. }
  86039. }
  86040. declare module BABYLON {
  86041. /**
  86042. * Particle emitter emitting particles from the inside of a box.
  86043. * It emits the particles randomly between 2 given directions.
  86044. */
  86045. export class BoxParticleEmitter implements IParticleEmitterType {
  86046. /**
  86047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86048. */
  86049. direction1: Vector3;
  86050. /**
  86051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86052. */
  86053. direction2: Vector3;
  86054. /**
  86055. * 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.
  86056. */
  86057. minEmitBox: Vector3;
  86058. /**
  86059. * 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.
  86060. */
  86061. maxEmitBox: Vector3;
  86062. /**
  86063. * Creates a new instance BoxParticleEmitter
  86064. */
  86065. constructor();
  86066. /**
  86067. * Called by the particle System when the direction is computed for the created particle.
  86068. * @param worldMatrix is the world matrix of the particle system
  86069. * @param directionToUpdate is the direction vector to update with the result
  86070. * @param particle is the particle we are computed the direction for
  86071. */
  86072. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86073. /**
  86074. * Called by the particle System when the position is computed for the created particle.
  86075. * @param worldMatrix is the world matrix of the particle system
  86076. * @param positionToUpdate is the position vector to update with the result
  86077. * @param particle is the particle we are computed the position for
  86078. */
  86079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86080. /**
  86081. * Clones the current emitter and returns a copy of it
  86082. * @returns the new emitter
  86083. */
  86084. clone(): BoxParticleEmitter;
  86085. /**
  86086. * Called by the GPUParticleSystem to setup the update shader
  86087. * @param effect defines the update shader
  86088. */
  86089. applyToShader(effect: Effect): void;
  86090. /**
  86091. * Returns a string to use to update the GPU particles update shader
  86092. * @returns a string containng the defines string
  86093. */
  86094. getEffectDefines(): string;
  86095. /**
  86096. * Returns the string "BoxParticleEmitter"
  86097. * @returns a string containing the class name
  86098. */
  86099. getClassName(): string;
  86100. /**
  86101. * Serializes the particle system to a JSON object.
  86102. * @returns the JSON object
  86103. */
  86104. serialize(): any;
  86105. /**
  86106. * Parse properties from a JSON object
  86107. * @param serializationObject defines the JSON object
  86108. */
  86109. parse(serializationObject: any): void;
  86110. }
  86111. }
  86112. declare module BABYLON {
  86113. /**
  86114. * Particle emitter emitting particles from the inside of a cone.
  86115. * It emits the particles alongside the cone volume from the base to the particle.
  86116. * The emission direction might be randomized.
  86117. */
  86118. export class ConeParticleEmitter implements IParticleEmitterType {
  86119. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86120. directionRandomizer: number;
  86121. private _radius;
  86122. private _angle;
  86123. private _height;
  86124. /**
  86125. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86126. */
  86127. radiusRange: number;
  86128. /**
  86129. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86130. */
  86131. heightRange: number;
  86132. /**
  86133. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86134. */
  86135. emitFromSpawnPointOnly: boolean;
  86136. /**
  86137. * Gets or sets the radius of the emission cone
  86138. */
  86139. radius: number;
  86140. /**
  86141. * Gets or sets the angle of the emission cone
  86142. */
  86143. angle: number;
  86144. private _buildHeight;
  86145. /**
  86146. * Creates a new instance ConeParticleEmitter
  86147. * @param radius the radius of the emission cone (1 by default)
  86148. * @param angle the cone base angle (PI by default)
  86149. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86150. */
  86151. constructor(radius?: number, angle?: number,
  86152. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86153. directionRandomizer?: number);
  86154. /**
  86155. * Called by the particle System when the direction is computed for the created particle.
  86156. * @param worldMatrix is the world matrix of the particle system
  86157. * @param directionToUpdate is the direction vector to update with the result
  86158. * @param particle is the particle we are computed the direction for
  86159. */
  86160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86161. /**
  86162. * Called by the particle System when the position is computed for the created particle.
  86163. * @param worldMatrix is the world matrix of the particle system
  86164. * @param positionToUpdate is the position vector to update with the result
  86165. * @param particle is the particle we are computed the position for
  86166. */
  86167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86168. /**
  86169. * Clones the current emitter and returns a copy of it
  86170. * @returns the new emitter
  86171. */
  86172. clone(): ConeParticleEmitter;
  86173. /**
  86174. * Called by the GPUParticleSystem to setup the update shader
  86175. * @param effect defines the update shader
  86176. */
  86177. applyToShader(effect: Effect): void;
  86178. /**
  86179. * Returns a string to use to update the GPU particles update shader
  86180. * @returns a string containng the defines string
  86181. */
  86182. getEffectDefines(): string;
  86183. /**
  86184. * Returns the string "ConeParticleEmitter"
  86185. * @returns a string containing the class name
  86186. */
  86187. getClassName(): string;
  86188. /**
  86189. * Serializes the particle system to a JSON object.
  86190. * @returns the JSON object
  86191. */
  86192. serialize(): any;
  86193. /**
  86194. * Parse properties from a JSON object
  86195. * @param serializationObject defines the JSON object
  86196. */
  86197. parse(serializationObject: any): void;
  86198. }
  86199. }
  86200. declare module BABYLON {
  86201. /**
  86202. * Particle emitter emitting particles from the inside of a cylinder.
  86203. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86204. */
  86205. export class CylinderParticleEmitter implements IParticleEmitterType {
  86206. /**
  86207. * The radius of the emission cylinder.
  86208. */
  86209. radius: number;
  86210. /**
  86211. * The height of the emission cylinder.
  86212. */
  86213. height: number;
  86214. /**
  86215. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86216. */
  86217. radiusRange: number;
  86218. /**
  86219. * How much to randomize the particle direction [0-1].
  86220. */
  86221. directionRandomizer: number;
  86222. /**
  86223. * Creates a new instance CylinderParticleEmitter
  86224. * @param radius the radius of the emission cylinder (1 by default)
  86225. * @param height the height of the emission cylinder (1 by default)
  86226. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86227. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86228. */
  86229. constructor(
  86230. /**
  86231. * The radius of the emission cylinder.
  86232. */
  86233. radius?: number,
  86234. /**
  86235. * The height of the emission cylinder.
  86236. */
  86237. height?: number,
  86238. /**
  86239. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86240. */
  86241. radiusRange?: number,
  86242. /**
  86243. * How much to randomize the particle direction [0-1].
  86244. */
  86245. directionRandomizer?: number);
  86246. /**
  86247. * Called by the particle System when the direction is computed for the created particle.
  86248. * @param worldMatrix is the world matrix of the particle system
  86249. * @param directionToUpdate is the direction vector to update with the result
  86250. * @param particle is the particle we are computed the direction for
  86251. */
  86252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86253. /**
  86254. * Called by the particle System when the position is computed for the created particle.
  86255. * @param worldMatrix is the world matrix of the particle system
  86256. * @param positionToUpdate is the position vector to update with the result
  86257. * @param particle is the particle we are computed the position for
  86258. */
  86259. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86260. /**
  86261. * Clones the current emitter and returns a copy of it
  86262. * @returns the new emitter
  86263. */
  86264. clone(): CylinderParticleEmitter;
  86265. /**
  86266. * Called by the GPUParticleSystem to setup the update shader
  86267. * @param effect defines the update shader
  86268. */
  86269. applyToShader(effect: Effect): void;
  86270. /**
  86271. * Returns a string to use to update the GPU particles update shader
  86272. * @returns a string containng the defines string
  86273. */
  86274. getEffectDefines(): string;
  86275. /**
  86276. * Returns the string "CylinderParticleEmitter"
  86277. * @returns a string containing the class name
  86278. */
  86279. getClassName(): string;
  86280. /**
  86281. * Serializes the particle system to a JSON object.
  86282. * @returns the JSON object
  86283. */
  86284. serialize(): any;
  86285. /**
  86286. * Parse properties from a JSON object
  86287. * @param serializationObject defines the JSON object
  86288. */
  86289. parse(serializationObject: any): void;
  86290. }
  86291. /**
  86292. * Particle emitter emitting particles from the inside of a cylinder.
  86293. * It emits the particles randomly between two vectors.
  86294. */
  86295. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86296. /**
  86297. * The min limit of the emission direction.
  86298. */
  86299. direction1: Vector3;
  86300. /**
  86301. * The max limit of the emission direction.
  86302. */
  86303. direction2: Vector3;
  86304. /**
  86305. * Creates a new instance CylinderDirectedParticleEmitter
  86306. * @param radius the radius of the emission cylinder (1 by default)
  86307. * @param height the height of the emission cylinder (1 by default)
  86308. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86309. * @param direction1 the min limit of the emission direction (up vector by default)
  86310. * @param direction2 the max limit of the emission direction (up vector by default)
  86311. */
  86312. constructor(radius?: number, height?: number, radiusRange?: number,
  86313. /**
  86314. * The min limit of the emission direction.
  86315. */
  86316. direction1?: Vector3,
  86317. /**
  86318. * The max limit of the emission direction.
  86319. */
  86320. direction2?: Vector3);
  86321. /**
  86322. * Called by the particle System when the direction is computed for the created particle.
  86323. * @param worldMatrix is the world matrix of the particle system
  86324. * @param directionToUpdate is the direction vector to update with the result
  86325. * @param particle is the particle we are computed the direction for
  86326. */
  86327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86328. /**
  86329. * Clones the current emitter and returns a copy of it
  86330. * @returns the new emitter
  86331. */
  86332. clone(): CylinderDirectedParticleEmitter;
  86333. /**
  86334. * Called by the GPUParticleSystem to setup the update shader
  86335. * @param effect defines the update shader
  86336. */
  86337. applyToShader(effect: Effect): void;
  86338. /**
  86339. * Returns a string to use to update the GPU particles update shader
  86340. * @returns a string containng the defines string
  86341. */
  86342. getEffectDefines(): string;
  86343. /**
  86344. * Returns the string "CylinderDirectedParticleEmitter"
  86345. * @returns a string containing the class name
  86346. */
  86347. getClassName(): string;
  86348. /**
  86349. * Serializes the particle system to a JSON object.
  86350. * @returns the JSON object
  86351. */
  86352. serialize(): any;
  86353. /**
  86354. * Parse properties from a JSON object
  86355. * @param serializationObject defines the JSON object
  86356. */
  86357. parse(serializationObject: any): void;
  86358. }
  86359. }
  86360. declare module BABYLON {
  86361. /**
  86362. * Particle emitter emitting particles from the inside of a hemisphere.
  86363. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86364. */
  86365. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86366. /**
  86367. * The radius of the emission hemisphere.
  86368. */
  86369. radius: number;
  86370. /**
  86371. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86372. */
  86373. radiusRange: number;
  86374. /**
  86375. * How much to randomize the particle direction [0-1].
  86376. */
  86377. directionRandomizer: number;
  86378. /**
  86379. * Creates a new instance HemisphericParticleEmitter
  86380. * @param radius the radius of the emission hemisphere (1 by default)
  86381. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86382. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86383. */
  86384. constructor(
  86385. /**
  86386. * The radius of the emission hemisphere.
  86387. */
  86388. radius?: number,
  86389. /**
  86390. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86391. */
  86392. radiusRange?: number,
  86393. /**
  86394. * How much to randomize the particle direction [0-1].
  86395. */
  86396. directionRandomizer?: number);
  86397. /**
  86398. * Called by the particle System when the direction is computed for the created particle.
  86399. * @param worldMatrix is the world matrix of the particle system
  86400. * @param directionToUpdate is the direction vector to update with the result
  86401. * @param particle is the particle we are computed the direction for
  86402. */
  86403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86404. /**
  86405. * Called by the particle System when the position is computed for the created particle.
  86406. * @param worldMatrix is the world matrix of the particle system
  86407. * @param positionToUpdate is the position vector to update with the result
  86408. * @param particle is the particle we are computed the position for
  86409. */
  86410. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86411. /**
  86412. * Clones the current emitter and returns a copy of it
  86413. * @returns the new emitter
  86414. */
  86415. clone(): HemisphericParticleEmitter;
  86416. /**
  86417. * Called by the GPUParticleSystem to setup the update shader
  86418. * @param effect defines the update shader
  86419. */
  86420. applyToShader(effect: Effect): void;
  86421. /**
  86422. * Returns a string to use to update the GPU particles update shader
  86423. * @returns a string containng the defines string
  86424. */
  86425. getEffectDefines(): string;
  86426. /**
  86427. * Returns the string "HemisphericParticleEmitter"
  86428. * @returns a string containing the class name
  86429. */
  86430. getClassName(): string;
  86431. /**
  86432. * Serializes the particle system to a JSON object.
  86433. * @returns the JSON object
  86434. */
  86435. serialize(): any;
  86436. /**
  86437. * Parse properties from a JSON object
  86438. * @param serializationObject defines the JSON object
  86439. */
  86440. parse(serializationObject: any): void;
  86441. }
  86442. }
  86443. declare module BABYLON {
  86444. /**
  86445. * Particle emitter emitting particles from a point.
  86446. * It emits the particles randomly between 2 given directions.
  86447. */
  86448. export class PointParticleEmitter implements IParticleEmitterType {
  86449. /**
  86450. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86451. */
  86452. direction1: Vector3;
  86453. /**
  86454. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86455. */
  86456. direction2: Vector3;
  86457. /**
  86458. * Creates a new instance PointParticleEmitter
  86459. */
  86460. constructor();
  86461. /**
  86462. * Called by the particle System when the direction is computed for the created particle.
  86463. * @param worldMatrix is the world matrix of the particle system
  86464. * @param directionToUpdate is the direction vector to update with the result
  86465. * @param particle is the particle we are computed the direction for
  86466. */
  86467. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86468. /**
  86469. * Called by the particle System when the position is computed for the created particle.
  86470. * @param worldMatrix is the world matrix of the particle system
  86471. * @param positionToUpdate is the position vector to update with the result
  86472. * @param particle is the particle we are computed the position for
  86473. */
  86474. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86475. /**
  86476. * Clones the current emitter and returns a copy of it
  86477. * @returns the new emitter
  86478. */
  86479. clone(): PointParticleEmitter;
  86480. /**
  86481. * Called by the GPUParticleSystem to setup the update shader
  86482. * @param effect defines the update shader
  86483. */
  86484. applyToShader(effect: Effect): void;
  86485. /**
  86486. * Returns a string to use to update the GPU particles update shader
  86487. * @returns a string containng the defines string
  86488. */
  86489. getEffectDefines(): string;
  86490. /**
  86491. * Returns the string "PointParticleEmitter"
  86492. * @returns a string containing the class name
  86493. */
  86494. getClassName(): string;
  86495. /**
  86496. * Serializes the particle system to a JSON object.
  86497. * @returns the JSON object
  86498. */
  86499. serialize(): any;
  86500. /**
  86501. * Parse properties from a JSON object
  86502. * @param serializationObject defines the JSON object
  86503. */
  86504. parse(serializationObject: any): void;
  86505. }
  86506. }
  86507. declare module BABYLON {
  86508. /**
  86509. * Particle emitter emitting particles from the inside of a sphere.
  86510. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86511. */
  86512. export class SphereParticleEmitter implements IParticleEmitterType {
  86513. /**
  86514. * The radius of the emission sphere.
  86515. */
  86516. radius: number;
  86517. /**
  86518. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86519. */
  86520. radiusRange: number;
  86521. /**
  86522. * How much to randomize the particle direction [0-1].
  86523. */
  86524. directionRandomizer: number;
  86525. /**
  86526. * Creates a new instance SphereParticleEmitter
  86527. * @param radius the radius of the emission sphere (1 by default)
  86528. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86529. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86530. */
  86531. constructor(
  86532. /**
  86533. * The radius of the emission sphere.
  86534. */
  86535. radius?: number,
  86536. /**
  86537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86538. */
  86539. radiusRange?: number,
  86540. /**
  86541. * How much to randomize the particle direction [0-1].
  86542. */
  86543. directionRandomizer?: number);
  86544. /**
  86545. * Called by the particle System when the direction is computed for the created particle.
  86546. * @param worldMatrix is the world matrix of the particle system
  86547. * @param directionToUpdate is the direction vector to update with the result
  86548. * @param particle is the particle we are computed the direction for
  86549. */
  86550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86551. /**
  86552. * Called by the particle System when the position is computed for the created particle.
  86553. * @param worldMatrix is the world matrix of the particle system
  86554. * @param positionToUpdate is the position vector to update with the result
  86555. * @param particle is the particle we are computed the position for
  86556. */
  86557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86558. /**
  86559. * Clones the current emitter and returns a copy of it
  86560. * @returns the new emitter
  86561. */
  86562. clone(): SphereParticleEmitter;
  86563. /**
  86564. * Called by the GPUParticleSystem to setup the update shader
  86565. * @param effect defines the update shader
  86566. */
  86567. applyToShader(effect: Effect): void;
  86568. /**
  86569. * Returns a string to use to update the GPU particles update shader
  86570. * @returns a string containng the defines string
  86571. */
  86572. getEffectDefines(): string;
  86573. /**
  86574. * Returns the string "SphereParticleEmitter"
  86575. * @returns a string containing the class name
  86576. */
  86577. getClassName(): string;
  86578. /**
  86579. * Serializes the particle system to a JSON object.
  86580. * @returns the JSON object
  86581. */
  86582. serialize(): any;
  86583. /**
  86584. * Parse properties from a JSON object
  86585. * @param serializationObject defines the JSON object
  86586. */
  86587. parse(serializationObject: any): void;
  86588. }
  86589. /**
  86590. * Particle emitter emitting particles from the inside of a sphere.
  86591. * It emits the particles randomly between two vectors.
  86592. */
  86593. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86594. /**
  86595. * The min limit of the emission direction.
  86596. */
  86597. direction1: Vector3;
  86598. /**
  86599. * The max limit of the emission direction.
  86600. */
  86601. direction2: Vector3;
  86602. /**
  86603. * Creates a new instance SphereDirectedParticleEmitter
  86604. * @param radius the radius of the emission sphere (1 by default)
  86605. * @param direction1 the min limit of the emission direction (up vector by default)
  86606. * @param direction2 the max limit of the emission direction (up vector by default)
  86607. */
  86608. constructor(radius?: number,
  86609. /**
  86610. * The min limit of the emission direction.
  86611. */
  86612. direction1?: Vector3,
  86613. /**
  86614. * The max limit of the emission direction.
  86615. */
  86616. direction2?: Vector3);
  86617. /**
  86618. * Called by the particle System when the direction is computed for the created particle.
  86619. * @param worldMatrix is the world matrix of the particle system
  86620. * @param directionToUpdate is the direction vector to update with the result
  86621. * @param particle is the particle we are computed the direction for
  86622. */
  86623. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86624. /**
  86625. * Clones the current emitter and returns a copy of it
  86626. * @returns the new emitter
  86627. */
  86628. clone(): SphereDirectedParticleEmitter;
  86629. /**
  86630. * Called by the GPUParticleSystem to setup the update shader
  86631. * @param effect defines the update shader
  86632. */
  86633. applyToShader(effect: Effect): void;
  86634. /**
  86635. * Returns a string to use to update the GPU particles update shader
  86636. * @returns a string containng the defines string
  86637. */
  86638. getEffectDefines(): string;
  86639. /**
  86640. * Returns the string "SphereDirectedParticleEmitter"
  86641. * @returns a string containing the class name
  86642. */
  86643. getClassName(): string;
  86644. /**
  86645. * Serializes the particle system to a JSON object.
  86646. * @returns the JSON object
  86647. */
  86648. serialize(): any;
  86649. /**
  86650. * Parse properties from a JSON object
  86651. * @param serializationObject defines the JSON object
  86652. */
  86653. parse(serializationObject: any): void;
  86654. }
  86655. }
  86656. declare module BABYLON {
  86657. /**
  86658. * Interface representing a particle system in Babylon.js.
  86659. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86660. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86661. */
  86662. export interface IParticleSystem {
  86663. /**
  86664. * List of animations used by the particle system.
  86665. */
  86666. animations: Animation[];
  86667. /**
  86668. * The id of the Particle system.
  86669. */
  86670. id: string;
  86671. /**
  86672. * The name of the Particle system.
  86673. */
  86674. name: string;
  86675. /**
  86676. * The emitter represents the Mesh or position we are attaching the particle system to.
  86677. */
  86678. emitter: Nullable<AbstractMesh | Vector3>;
  86679. /**
  86680. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86681. */
  86682. isBillboardBased: boolean;
  86683. /**
  86684. * The rendering group used by the Particle system to chose when to render.
  86685. */
  86686. renderingGroupId: number;
  86687. /**
  86688. * The layer mask we are rendering the particles through.
  86689. */
  86690. layerMask: number;
  86691. /**
  86692. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86693. */
  86694. updateSpeed: number;
  86695. /**
  86696. * The amount of time the particle system is running (depends of the overall update speed).
  86697. */
  86698. targetStopDuration: number;
  86699. /**
  86700. * The texture used to render each particle. (this can be a spritesheet)
  86701. */
  86702. particleTexture: Nullable<Texture>;
  86703. /**
  86704. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86705. */
  86706. blendMode: number;
  86707. /**
  86708. * Minimum life time of emitting particles.
  86709. */
  86710. minLifeTime: number;
  86711. /**
  86712. * Maximum life time of emitting particles.
  86713. */
  86714. maxLifeTime: number;
  86715. /**
  86716. * Minimum Size of emitting particles.
  86717. */
  86718. minSize: number;
  86719. /**
  86720. * Maximum Size of emitting particles.
  86721. */
  86722. maxSize: number;
  86723. /**
  86724. * Minimum scale of emitting particles on X axis.
  86725. */
  86726. minScaleX: number;
  86727. /**
  86728. * Maximum scale of emitting particles on X axis.
  86729. */
  86730. maxScaleX: number;
  86731. /**
  86732. * Minimum scale of emitting particles on Y axis.
  86733. */
  86734. minScaleY: number;
  86735. /**
  86736. * Maximum scale of emitting particles on Y axis.
  86737. */
  86738. maxScaleY: number;
  86739. /**
  86740. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86741. */
  86742. color1: Color4;
  86743. /**
  86744. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86745. */
  86746. color2: Color4;
  86747. /**
  86748. * Color the particle will have at the end of its lifetime.
  86749. */
  86750. colorDead: Color4;
  86751. /**
  86752. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86753. */
  86754. emitRate: number;
  86755. /**
  86756. * You can use gravity if you want to give an orientation to your particles.
  86757. */
  86758. gravity: Vector3;
  86759. /**
  86760. * Minimum power of emitting particles.
  86761. */
  86762. minEmitPower: number;
  86763. /**
  86764. * Maximum power of emitting particles.
  86765. */
  86766. maxEmitPower: number;
  86767. /**
  86768. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86769. */
  86770. minAngularSpeed: number;
  86771. /**
  86772. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86773. */
  86774. maxAngularSpeed: number;
  86775. /**
  86776. * Gets or sets the minimal initial rotation in radians.
  86777. */
  86778. minInitialRotation: number;
  86779. /**
  86780. * Gets or sets the maximal initial rotation in radians.
  86781. */
  86782. maxInitialRotation: number;
  86783. /**
  86784. * The particle emitter type defines the emitter used by the particle system.
  86785. * It can be for example box, sphere, or cone...
  86786. */
  86787. particleEmitterType: Nullable<IParticleEmitterType>;
  86788. /**
  86789. * Defines the delay in milliseconds before starting the system (0 by default)
  86790. */
  86791. startDelay: number;
  86792. /**
  86793. * 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
  86794. */
  86795. preWarmCycles: number;
  86796. /**
  86797. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86798. */
  86799. preWarmStepOffset: number;
  86800. /**
  86801. * 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)
  86802. */
  86803. spriteCellChangeSpeed: number;
  86804. /**
  86805. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86806. */
  86807. startSpriteCellID: number;
  86808. /**
  86809. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86810. */
  86811. endSpriteCellID: number;
  86812. /**
  86813. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86814. */
  86815. spriteCellWidth: number;
  86816. /**
  86817. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86818. */
  86819. spriteCellHeight: number;
  86820. /**
  86821. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86822. */
  86823. spriteRandomStartCell: boolean;
  86824. /**
  86825. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86826. */
  86827. isAnimationSheetEnabled: boolean;
  86828. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86829. translationPivot: Vector2;
  86830. /**
  86831. * Gets or sets a texture used to add random noise to particle positions
  86832. */
  86833. noiseTexture: Nullable<BaseTexture>;
  86834. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86835. noiseStrength: Vector3;
  86836. /**
  86837. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86838. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86839. */
  86840. billboardMode: number;
  86841. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86842. limitVelocityDamping: number;
  86843. /**
  86844. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86845. */
  86846. beginAnimationOnStart: boolean;
  86847. /**
  86848. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86849. */
  86850. beginAnimationFrom: number;
  86851. /**
  86852. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86853. */
  86854. beginAnimationTo: number;
  86855. /**
  86856. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86857. */
  86858. beginAnimationLoop: boolean;
  86859. /**
  86860. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86861. */
  86862. disposeOnStop: boolean;
  86863. /**
  86864. * Gets the maximum number of particles active at the same time.
  86865. * @returns The max number of active particles.
  86866. */
  86867. getCapacity(): number;
  86868. /**
  86869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86870. * @returns True if it has been started, otherwise false.
  86871. */
  86872. isStarted(): boolean;
  86873. /**
  86874. * Animates the particle system for this frame.
  86875. */
  86876. animate(): void;
  86877. /**
  86878. * Renders the particle system in its current state.
  86879. * @returns the current number of particles
  86880. */
  86881. render(): number;
  86882. /**
  86883. * Dispose the particle system and frees its associated resources.
  86884. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86885. */
  86886. dispose(disposeTexture?: boolean): void;
  86887. /**
  86888. * Clones the particle system.
  86889. * @param name The name of the cloned object
  86890. * @param newEmitter The new emitter to use
  86891. * @returns the cloned particle system
  86892. */
  86893. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86894. /**
  86895. * Serializes the particle system to a JSON object.
  86896. * @returns the JSON object
  86897. */
  86898. serialize(): any;
  86899. /**
  86900. * Rebuild the particle system
  86901. */
  86902. rebuild(): void;
  86903. /**
  86904. * Starts the particle system and begins to emit
  86905. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86906. */
  86907. start(delay?: number): void;
  86908. /**
  86909. * Stops the particle system.
  86910. */
  86911. stop(): void;
  86912. /**
  86913. * Remove all active particles
  86914. */
  86915. reset(): void;
  86916. /**
  86917. * Is this system ready to be used/rendered
  86918. * @return true if the system is ready
  86919. */
  86920. isReady(): boolean;
  86921. /**
  86922. * Adds a new color gradient
  86923. * @param gradient defines the gradient to use (between 0 and 1)
  86924. * @param color1 defines the color to affect to the specified gradient
  86925. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86926. * @returns the current particle system
  86927. */
  86928. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86929. /**
  86930. * Remove a specific color gradient
  86931. * @param gradient defines the gradient to remove
  86932. * @returns the current particle system
  86933. */
  86934. removeColorGradient(gradient: number): IParticleSystem;
  86935. /**
  86936. * Adds a new size gradient
  86937. * @param gradient defines the gradient to use (between 0 and 1)
  86938. * @param factor defines the size factor to affect to the specified gradient
  86939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86940. * @returns the current particle system
  86941. */
  86942. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86943. /**
  86944. * Remove a specific size gradient
  86945. * @param gradient defines the gradient to remove
  86946. * @returns the current particle system
  86947. */
  86948. removeSizeGradient(gradient: number): IParticleSystem;
  86949. /**
  86950. * Gets the current list of color gradients.
  86951. * You must use addColorGradient and removeColorGradient to udpate this list
  86952. * @returns the list of color gradients
  86953. */
  86954. getColorGradients(): Nullable<Array<ColorGradient>>;
  86955. /**
  86956. * Gets the current list of size gradients.
  86957. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86958. * @returns the list of size gradients
  86959. */
  86960. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86961. /**
  86962. * Gets the current list of angular speed gradients.
  86963. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86964. * @returns the list of angular speed gradients
  86965. */
  86966. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86967. /**
  86968. * Adds a new angular speed gradient
  86969. * @param gradient defines the gradient to use (between 0 and 1)
  86970. * @param factor defines the angular speed to affect to the specified gradient
  86971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86972. * @returns the current particle system
  86973. */
  86974. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86975. /**
  86976. * Remove a specific angular speed gradient
  86977. * @param gradient defines the gradient to remove
  86978. * @returns the current particle system
  86979. */
  86980. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86981. /**
  86982. * Gets the current list of velocity gradients.
  86983. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86984. * @returns the list of velocity gradients
  86985. */
  86986. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86987. /**
  86988. * Adds a new velocity gradient
  86989. * @param gradient defines the gradient to use (between 0 and 1)
  86990. * @param factor defines the velocity to affect to the specified gradient
  86991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86992. * @returns the current particle system
  86993. */
  86994. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86995. /**
  86996. * Remove a specific velocity gradient
  86997. * @param gradient defines the gradient to remove
  86998. * @returns the current particle system
  86999. */
  87000. removeVelocityGradient(gradient: number): IParticleSystem;
  87001. /**
  87002. * Gets the current list of limit velocity gradients.
  87003. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87004. * @returns the list of limit velocity gradients
  87005. */
  87006. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87007. /**
  87008. * Adds a new limit velocity gradient
  87009. * @param gradient defines the gradient to use (between 0 and 1)
  87010. * @param factor defines the limit velocity to affect to the specified gradient
  87011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87012. * @returns the current particle system
  87013. */
  87014. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87015. /**
  87016. * Remove a specific limit velocity gradient
  87017. * @param gradient defines the gradient to remove
  87018. * @returns the current particle system
  87019. */
  87020. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87021. /**
  87022. * Adds a new drag gradient
  87023. * @param gradient defines the gradient to use (between 0 and 1)
  87024. * @param factor defines the drag to affect to the specified gradient
  87025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87026. * @returns the current particle system
  87027. */
  87028. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87029. /**
  87030. * Remove a specific drag gradient
  87031. * @param gradient defines the gradient to remove
  87032. * @returns the current particle system
  87033. */
  87034. removeDragGradient(gradient: number): IParticleSystem;
  87035. /**
  87036. * Gets the current list of drag gradients.
  87037. * You must use addDragGradient and removeDragGradient to udpate this list
  87038. * @returns the list of drag gradients
  87039. */
  87040. getDragGradients(): Nullable<Array<FactorGradient>>;
  87041. /**
  87042. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87043. * @param gradient defines the gradient to use (between 0 and 1)
  87044. * @param factor defines the emit rate to affect to the specified gradient
  87045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87046. * @returns the current particle system
  87047. */
  87048. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87049. /**
  87050. * Remove a specific emit rate gradient
  87051. * @param gradient defines the gradient to remove
  87052. * @returns the current particle system
  87053. */
  87054. removeEmitRateGradient(gradient: number): IParticleSystem;
  87055. /**
  87056. * Gets the current list of emit rate gradients.
  87057. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87058. * @returns the list of emit rate gradients
  87059. */
  87060. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87061. /**
  87062. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87063. * @param gradient defines the gradient to use (between 0 and 1)
  87064. * @param factor defines the start size to affect to the specified gradient
  87065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87066. * @returns the current particle system
  87067. */
  87068. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87069. /**
  87070. * Remove a specific start size gradient
  87071. * @param gradient defines the gradient to remove
  87072. * @returns the current particle system
  87073. */
  87074. removeStartSizeGradient(gradient: number): IParticleSystem;
  87075. /**
  87076. * Gets the current list of start size gradients.
  87077. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87078. * @returns the list of start size gradients
  87079. */
  87080. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87081. /**
  87082. * Adds a new life time gradient
  87083. * @param gradient defines the gradient to use (between 0 and 1)
  87084. * @param factor defines the life time factor to affect to the specified gradient
  87085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87086. * @returns the current particle system
  87087. */
  87088. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87089. /**
  87090. * Remove a specific life time gradient
  87091. * @param gradient defines the gradient to remove
  87092. * @returns the current particle system
  87093. */
  87094. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87095. /**
  87096. * Gets the current list of life time gradients.
  87097. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87098. * @returns the list of life time gradients
  87099. */
  87100. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87101. /**
  87102. * Gets the current list of color gradients.
  87103. * You must use addColorGradient and removeColorGradient to udpate this list
  87104. * @returns the list of color gradients
  87105. */
  87106. getColorGradients(): Nullable<Array<ColorGradient>>;
  87107. /**
  87108. * Adds a new ramp gradient used to remap particle colors
  87109. * @param gradient defines the gradient to use (between 0 and 1)
  87110. * @param color defines the color to affect to the specified gradient
  87111. * @returns the current particle system
  87112. */
  87113. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87114. /**
  87115. * Gets the current list of ramp gradients.
  87116. * You must use addRampGradient and removeRampGradient to udpate this list
  87117. * @returns the list of ramp gradients
  87118. */
  87119. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87120. /** Gets or sets a boolean indicating that ramp gradients must be used
  87121. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87122. */
  87123. useRampGradients: boolean;
  87124. /**
  87125. * Adds a new color remap gradient
  87126. * @param gradient defines the gradient to use (between 0 and 1)
  87127. * @param min defines the color remap minimal range
  87128. * @param max defines the color remap maximal range
  87129. * @returns the current particle system
  87130. */
  87131. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87132. /**
  87133. * Gets the current list of color remap gradients.
  87134. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87135. * @returns the list of color remap gradients
  87136. */
  87137. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87138. /**
  87139. * Adds a new alpha remap gradient
  87140. * @param gradient defines the gradient to use (between 0 and 1)
  87141. * @param min defines the alpha remap minimal range
  87142. * @param max defines the alpha remap maximal range
  87143. * @returns the current particle system
  87144. */
  87145. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87146. /**
  87147. * Gets the current list of alpha remap gradients.
  87148. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87149. * @returns the list of alpha remap gradients
  87150. */
  87151. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87152. /**
  87153. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87154. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87155. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87156. * @returns the emitter
  87157. */
  87158. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87159. /**
  87160. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87161. * @param radius The radius of the hemisphere to emit from
  87162. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87163. * @returns the emitter
  87164. */
  87165. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87166. /**
  87167. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87168. * @param radius The radius of the sphere to emit from
  87169. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87170. * @returns the emitter
  87171. */
  87172. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87173. /**
  87174. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87175. * @param radius The radius of the sphere to emit from
  87176. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87177. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87178. * @returns the emitter
  87179. */
  87180. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87181. /**
  87182. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87183. * @param radius The radius of the emission cylinder
  87184. * @param height The height of the emission cylinder
  87185. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87186. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87187. * @returns the emitter
  87188. */
  87189. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87190. /**
  87191. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87192. * @param radius The radius of the cylinder to emit from
  87193. * @param height The height of the emission cylinder
  87194. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87195. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87196. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87197. * @returns the emitter
  87198. */
  87199. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87200. /**
  87201. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87202. * @param radius The radius of the cone to emit from
  87203. * @param angle The base angle of the cone
  87204. * @returns the emitter
  87205. */
  87206. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87207. /**
  87208. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87211. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87212. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87213. * @returns the emitter
  87214. */
  87215. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87216. /**
  87217. * Get hosting scene
  87218. * @returns the scene
  87219. */
  87220. getScene(): Scene;
  87221. }
  87222. }
  87223. declare module BABYLON {
  87224. /**
  87225. * Creates an instance based on a source mesh.
  87226. */
  87227. export class InstancedMesh extends AbstractMesh {
  87228. private _sourceMesh;
  87229. private _currentLOD;
  87230. /** @hidden */
  87231. _indexInSourceMeshInstanceArray: number;
  87232. constructor(name: string, source: Mesh);
  87233. /**
  87234. * Returns the string "InstancedMesh".
  87235. */
  87236. getClassName(): string;
  87237. /** Gets the list of lights affecting that mesh */
  87238. readonly lightSources: Light[];
  87239. _resyncLightSources(): void;
  87240. _resyncLighSource(light: Light): void;
  87241. _removeLightSource(light: Light, dispose: boolean): void;
  87242. /**
  87243. * If the source mesh receives shadows
  87244. */
  87245. readonly receiveShadows: boolean;
  87246. /**
  87247. * The material of the source mesh
  87248. */
  87249. readonly material: Nullable<Material>;
  87250. /**
  87251. * Visibility of the source mesh
  87252. */
  87253. readonly visibility: number;
  87254. /**
  87255. * Skeleton of the source mesh
  87256. */
  87257. readonly skeleton: Nullable<Skeleton>;
  87258. /**
  87259. * Rendering ground id of the source mesh
  87260. */
  87261. renderingGroupId: number;
  87262. /**
  87263. * Returns the total number of vertices (integer).
  87264. */
  87265. getTotalVertices(): number;
  87266. /**
  87267. * Returns a positive integer : the total number of indices in this mesh geometry.
  87268. * @returns the numner of indices or zero if the mesh has no geometry.
  87269. */
  87270. getTotalIndices(): number;
  87271. /**
  87272. * The source mesh of the instance
  87273. */
  87274. readonly sourceMesh: Mesh;
  87275. /**
  87276. * Is this node ready to be used/rendered
  87277. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87278. * @return {boolean} is it ready
  87279. */
  87280. isReady(completeCheck?: boolean): boolean;
  87281. /**
  87282. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87283. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87284. * @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.
  87285. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87286. */
  87287. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87288. /**
  87289. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87290. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87291. * The `data` are either a numeric array either a Float32Array.
  87292. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87293. * 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).
  87294. * Note that a new underlying VertexBuffer object is created each call.
  87295. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87296. *
  87297. * Possible `kind` values :
  87298. * - VertexBuffer.PositionKind
  87299. * - VertexBuffer.UVKind
  87300. * - VertexBuffer.UV2Kind
  87301. * - VertexBuffer.UV3Kind
  87302. * - VertexBuffer.UV4Kind
  87303. * - VertexBuffer.UV5Kind
  87304. * - VertexBuffer.UV6Kind
  87305. * - VertexBuffer.ColorKind
  87306. * - VertexBuffer.MatricesIndicesKind
  87307. * - VertexBuffer.MatricesIndicesExtraKind
  87308. * - VertexBuffer.MatricesWeightsKind
  87309. * - VertexBuffer.MatricesWeightsExtraKind
  87310. *
  87311. * Returns the Mesh.
  87312. */
  87313. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87314. /**
  87315. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87316. * If the mesh has no geometry, it is simply returned as it is.
  87317. * The `data` are either a numeric array either a Float32Array.
  87318. * No new underlying VertexBuffer object is created.
  87319. * 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.
  87320. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87321. *
  87322. * Possible `kind` values :
  87323. * - VertexBuffer.PositionKind
  87324. * - VertexBuffer.UVKind
  87325. * - VertexBuffer.UV2Kind
  87326. * - VertexBuffer.UV3Kind
  87327. * - VertexBuffer.UV4Kind
  87328. * - VertexBuffer.UV5Kind
  87329. * - VertexBuffer.UV6Kind
  87330. * - VertexBuffer.ColorKind
  87331. * - VertexBuffer.MatricesIndicesKind
  87332. * - VertexBuffer.MatricesIndicesExtraKind
  87333. * - VertexBuffer.MatricesWeightsKind
  87334. * - VertexBuffer.MatricesWeightsExtraKind
  87335. *
  87336. * Returns the Mesh.
  87337. */
  87338. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87339. /**
  87340. * Sets the mesh indices.
  87341. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87342. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87343. * This method creates a new index buffer each call.
  87344. * Returns the Mesh.
  87345. */
  87346. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87347. /**
  87348. * Boolean : True if the mesh owns the requested kind of data.
  87349. */
  87350. isVerticesDataPresent(kind: string): boolean;
  87351. /**
  87352. * Returns an array of indices (IndicesArray).
  87353. */
  87354. getIndices(): Nullable<IndicesArray>;
  87355. readonly _positions: Nullable<Vector3[]>;
  87356. /**
  87357. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87358. * This means the mesh underlying bounding box and sphere are recomputed.
  87359. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87360. * @returns the current mesh
  87361. */
  87362. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87363. /** @hidden */
  87364. _preActivate(): InstancedMesh;
  87365. /** @hidden */
  87366. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87367. /** @hidden */
  87368. _postActivate(): void;
  87369. getWorldMatrix(): Matrix;
  87370. readonly isAnInstance: boolean;
  87371. /**
  87372. * Returns the current associated LOD AbstractMesh.
  87373. */
  87374. getLOD(camera: Camera): AbstractMesh;
  87375. /** @hidden */
  87376. _syncSubMeshes(): InstancedMesh;
  87377. /** @hidden */
  87378. _generatePointsArray(): boolean;
  87379. /**
  87380. * Creates a new InstancedMesh from the current mesh.
  87381. * - name (string) : the cloned mesh name
  87382. * - newParent (optional Node) : the optional Node to parent the clone to.
  87383. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87384. *
  87385. * Returns the clone.
  87386. */
  87387. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87388. /**
  87389. * Disposes the InstancedMesh.
  87390. * Returns nothing.
  87391. */
  87392. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87393. }
  87394. interface Mesh {
  87395. /**
  87396. * Register a custom buffer that will be instanced
  87397. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87398. * @param kind defines the buffer kind
  87399. * @param stride defines the stride in floats
  87400. */
  87401. registerInstancedBuffer(kind: string, stride: number): void;
  87402. /** @hidden */
  87403. _userInstancedBuffersStorage: {
  87404. data: {
  87405. [key: string]: Float32Array;
  87406. };
  87407. sizes: {
  87408. [key: string]: number;
  87409. };
  87410. vertexBuffers: {
  87411. [key: string]: Nullable<VertexBuffer>;
  87412. };
  87413. strides: {
  87414. [key: string]: number;
  87415. };
  87416. };
  87417. }
  87418. interface AbstractMesh {
  87419. /**
  87420. * Object used to store instanced buffers defined by user
  87421. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87422. */
  87423. instancedBuffers: {
  87424. [key: string]: any;
  87425. };
  87426. }
  87427. }
  87428. declare module BABYLON {
  87429. /**
  87430. * Defines the options associated with the creation of a shader material.
  87431. */
  87432. export interface IShaderMaterialOptions {
  87433. /**
  87434. * Does the material work in alpha blend mode
  87435. */
  87436. needAlphaBlending: boolean;
  87437. /**
  87438. * Does the material work in alpha test mode
  87439. */
  87440. needAlphaTesting: boolean;
  87441. /**
  87442. * The list of attribute names used in the shader
  87443. */
  87444. attributes: string[];
  87445. /**
  87446. * The list of unifrom names used in the shader
  87447. */
  87448. uniforms: string[];
  87449. /**
  87450. * The list of UBO names used in the shader
  87451. */
  87452. uniformBuffers: string[];
  87453. /**
  87454. * The list of sampler names used in the shader
  87455. */
  87456. samplers: string[];
  87457. /**
  87458. * The list of defines used in the shader
  87459. */
  87460. defines: string[];
  87461. }
  87462. /**
  87463. * 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.
  87464. *
  87465. * This returned material effects how the mesh will look based on the code in the shaders.
  87466. *
  87467. * @see http://doc.babylonjs.com/how_to/shader_material
  87468. */
  87469. export class ShaderMaterial extends Material {
  87470. private _shaderPath;
  87471. private _options;
  87472. private _textures;
  87473. private _textureArrays;
  87474. private _floats;
  87475. private _ints;
  87476. private _floatsArrays;
  87477. private _colors3;
  87478. private _colors3Arrays;
  87479. private _colors4;
  87480. private _colors4Arrays;
  87481. private _vectors2;
  87482. private _vectors3;
  87483. private _vectors4;
  87484. private _matrices;
  87485. private _matrixArrays;
  87486. private _matrices3x3;
  87487. private _matrices2x2;
  87488. private _vectors2Arrays;
  87489. private _vectors3Arrays;
  87490. private _vectors4Arrays;
  87491. private _cachedWorldViewMatrix;
  87492. private _cachedWorldViewProjectionMatrix;
  87493. private _renderId;
  87494. private _multiview;
  87495. /**
  87496. * Instantiate a new shader material.
  87497. * 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.
  87498. * This returned material effects how the mesh will look based on the code in the shaders.
  87499. * @see http://doc.babylonjs.com/how_to/shader_material
  87500. * @param name Define the name of the material in the scene
  87501. * @param scene Define the scene the material belongs to
  87502. * @param shaderPath Defines the route to the shader code in one of three ways:
  87503. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87504. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87505. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87506. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87507. * @param options Define the options used to create the shader
  87508. */
  87509. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87510. /**
  87511. * Gets the shader path used to define the shader code
  87512. * It can be modified to trigger a new compilation
  87513. */
  87514. /**
  87515. * Sets the shader path used to define the shader code
  87516. * It can be modified to trigger a new compilation
  87517. */
  87518. shaderPath: any;
  87519. /**
  87520. * Gets the options used to compile the shader.
  87521. * They can be modified to trigger a new compilation
  87522. */
  87523. readonly options: IShaderMaterialOptions;
  87524. /**
  87525. * Gets the current class name of the material e.g. "ShaderMaterial"
  87526. * Mainly use in serialization.
  87527. * @returns the class name
  87528. */
  87529. getClassName(): string;
  87530. /**
  87531. * Specifies if the material will require alpha blending
  87532. * @returns a boolean specifying if alpha blending is needed
  87533. */
  87534. needAlphaBlending(): boolean;
  87535. /**
  87536. * Specifies if this material should be rendered in alpha test mode
  87537. * @returns a boolean specifying if an alpha test is needed.
  87538. */
  87539. needAlphaTesting(): boolean;
  87540. private _checkUniform;
  87541. /**
  87542. * Set a texture in the shader.
  87543. * @param name Define the name of the uniform samplers as defined in the shader
  87544. * @param texture Define the texture to bind to this sampler
  87545. * @return the material itself allowing "fluent" like uniform updates
  87546. */
  87547. setTexture(name: string, texture: Texture): ShaderMaterial;
  87548. /**
  87549. * Set a texture array in the shader.
  87550. * @param name Define the name of the uniform sampler array as defined in the shader
  87551. * @param textures Define the list of textures to bind to this sampler
  87552. * @return the material itself allowing "fluent" like uniform updates
  87553. */
  87554. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87555. /**
  87556. * Set a float in the shader.
  87557. * @param name Define the name of the uniform as defined in the shader
  87558. * @param value Define the value to give to the uniform
  87559. * @return the material itself allowing "fluent" like uniform updates
  87560. */
  87561. setFloat(name: string, value: number): ShaderMaterial;
  87562. /**
  87563. * Set a int in the shader.
  87564. * @param name Define the name of the uniform as defined in the shader
  87565. * @param value Define the value to give to the uniform
  87566. * @return the material itself allowing "fluent" like uniform updates
  87567. */
  87568. setInt(name: string, value: number): ShaderMaterial;
  87569. /**
  87570. * Set an array of floats in the shader.
  87571. * @param name Define the name of the uniform as defined in the shader
  87572. * @param value Define the value to give to the uniform
  87573. * @return the material itself allowing "fluent" like uniform updates
  87574. */
  87575. setFloats(name: string, value: number[]): ShaderMaterial;
  87576. /**
  87577. * Set a vec3 in the shader from a Color3.
  87578. * @param name Define the name of the uniform as defined in the shader
  87579. * @param value Define the value to give to the uniform
  87580. * @return the material itself allowing "fluent" like uniform updates
  87581. */
  87582. setColor3(name: string, value: Color3): ShaderMaterial;
  87583. /**
  87584. * Set a vec3 array in the shader from a Color3 array.
  87585. * @param name Define the name of the uniform as defined in the shader
  87586. * @param value Define the value to give to the uniform
  87587. * @return the material itself allowing "fluent" like uniform updates
  87588. */
  87589. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87590. /**
  87591. * Set a vec4 in the shader from a Color4.
  87592. * @param name Define the name of the uniform as defined in the shader
  87593. * @param value Define the value to give to the uniform
  87594. * @return the material itself allowing "fluent" like uniform updates
  87595. */
  87596. setColor4(name: string, value: Color4): ShaderMaterial;
  87597. /**
  87598. * Set a vec4 array in the shader from a Color4 array.
  87599. * @param name Define the name of the uniform as defined in the shader
  87600. * @param value Define the value to give to the uniform
  87601. * @return the material itself allowing "fluent" like uniform updates
  87602. */
  87603. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87604. /**
  87605. * Set a vec2 in the shader from a Vector2.
  87606. * @param name Define the name of the uniform as defined in the shader
  87607. * @param value Define the value to give to the uniform
  87608. * @return the material itself allowing "fluent" like uniform updates
  87609. */
  87610. setVector2(name: string, value: Vector2): ShaderMaterial;
  87611. /**
  87612. * Set a vec3 in the shader from a Vector3.
  87613. * @param name Define the name of the uniform as defined in the shader
  87614. * @param value Define the value to give to the uniform
  87615. * @return the material itself allowing "fluent" like uniform updates
  87616. */
  87617. setVector3(name: string, value: Vector3): ShaderMaterial;
  87618. /**
  87619. * Set a vec4 in the shader from a Vector4.
  87620. * @param name Define the name of the uniform as defined in the shader
  87621. * @param value Define the value to give to the uniform
  87622. * @return the material itself allowing "fluent" like uniform updates
  87623. */
  87624. setVector4(name: string, value: Vector4): ShaderMaterial;
  87625. /**
  87626. * Set a mat4 in the shader from a Matrix.
  87627. * @param name Define the name of the uniform as defined in the shader
  87628. * @param value Define the value to give to the uniform
  87629. * @return the material itself allowing "fluent" like uniform updates
  87630. */
  87631. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87632. /**
  87633. * Set a float32Array in the shader from a matrix array.
  87634. * @param name Define the name of the uniform as defined in the shader
  87635. * @param value Define the value to give to the uniform
  87636. * @return the material itself allowing "fluent" like uniform updates
  87637. */
  87638. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87639. /**
  87640. * Set a mat3 in the shader from a Float32Array.
  87641. * @param name Define the name of the uniform as defined in the shader
  87642. * @param value Define the value to give to the uniform
  87643. * @return the material itself allowing "fluent" like uniform updates
  87644. */
  87645. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87646. /**
  87647. * Set a mat2 in the shader from a Float32Array.
  87648. * @param name Define the name of the uniform as defined in the shader
  87649. * @param value Define the value to give to the uniform
  87650. * @return the material itself allowing "fluent" like uniform updates
  87651. */
  87652. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87653. /**
  87654. * Set a vec2 array in the shader from a number array.
  87655. * @param name Define the name of the uniform as defined in the shader
  87656. * @param value Define the value to give to the uniform
  87657. * @return the material itself allowing "fluent" like uniform updates
  87658. */
  87659. setArray2(name: string, value: number[]): ShaderMaterial;
  87660. /**
  87661. * Set a vec3 array in the shader from a number array.
  87662. * @param name Define the name of the uniform as defined in the shader
  87663. * @param value Define the value to give to the uniform
  87664. * @return the material itself allowing "fluent" like uniform updates
  87665. */
  87666. setArray3(name: string, value: number[]): ShaderMaterial;
  87667. /**
  87668. * Set a vec4 array in the shader from a number array.
  87669. * @param name Define the name of the uniform as defined in the shader
  87670. * @param value Define the value to give to the uniform
  87671. * @return the material itself allowing "fluent" like uniform updates
  87672. */
  87673. setArray4(name: string, value: number[]): ShaderMaterial;
  87674. private _checkCache;
  87675. /**
  87676. * Specifies that the submesh is ready to be used
  87677. * @param mesh defines the mesh to check
  87678. * @param subMesh defines which submesh to check
  87679. * @param useInstances specifies that instances should be used
  87680. * @returns a boolean indicating that the submesh is ready or not
  87681. */
  87682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87683. /**
  87684. * Checks if the material is ready to render the requested mesh
  87685. * @param mesh Define the mesh to render
  87686. * @param useInstances Define whether or not the material is used with instances
  87687. * @returns true if ready, otherwise false
  87688. */
  87689. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87690. /**
  87691. * Binds the world matrix to the material
  87692. * @param world defines the world transformation matrix
  87693. */
  87694. bindOnlyWorldMatrix(world: Matrix): void;
  87695. /**
  87696. * Binds the material to the mesh
  87697. * @param world defines the world transformation matrix
  87698. * @param mesh defines the mesh to bind the material to
  87699. */
  87700. bind(world: Matrix, mesh?: Mesh): void;
  87701. /**
  87702. * Gets the active textures from the material
  87703. * @returns an array of textures
  87704. */
  87705. getActiveTextures(): BaseTexture[];
  87706. /**
  87707. * Specifies if the material uses a texture
  87708. * @param texture defines the texture to check against the material
  87709. * @returns a boolean specifying if the material uses the texture
  87710. */
  87711. hasTexture(texture: BaseTexture): boolean;
  87712. /**
  87713. * Makes a duplicate of the material, and gives it a new name
  87714. * @param name defines the new name for the duplicated material
  87715. * @returns the cloned material
  87716. */
  87717. clone(name: string): ShaderMaterial;
  87718. /**
  87719. * Disposes the material
  87720. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87721. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87722. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87723. */
  87724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87725. /**
  87726. * Serializes this material in a JSON representation
  87727. * @returns the serialized material object
  87728. */
  87729. serialize(): any;
  87730. /**
  87731. * Creates a shader material from parsed shader material data
  87732. * @param source defines the JSON represnetation of the material
  87733. * @param scene defines the hosting scene
  87734. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87735. * @returns a new material
  87736. */
  87737. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87738. }
  87739. }
  87740. declare module BABYLON {
  87741. /** @hidden */
  87742. export var colorPixelShader: {
  87743. name: string;
  87744. shader: string;
  87745. };
  87746. }
  87747. declare module BABYLON {
  87748. /** @hidden */
  87749. export var colorVertexShader: {
  87750. name: string;
  87751. shader: string;
  87752. };
  87753. }
  87754. declare module BABYLON {
  87755. /**
  87756. * Line mesh
  87757. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87758. */
  87759. export class LinesMesh extends Mesh {
  87760. /**
  87761. * If vertex color should be applied to the mesh
  87762. */
  87763. readonly useVertexColor?: boolean | undefined;
  87764. /**
  87765. * If vertex alpha should be applied to the mesh
  87766. */
  87767. readonly useVertexAlpha?: boolean | undefined;
  87768. /**
  87769. * Color of the line (Default: White)
  87770. */
  87771. color: Color3;
  87772. /**
  87773. * Alpha of the line (Default: 1)
  87774. */
  87775. alpha: number;
  87776. /**
  87777. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87778. * This margin is expressed in world space coordinates, so its value may vary.
  87779. * Default value is 0.1
  87780. */
  87781. intersectionThreshold: number;
  87782. private _colorShader;
  87783. private color4;
  87784. /**
  87785. * Creates a new LinesMesh
  87786. * @param name defines the name
  87787. * @param scene defines the hosting scene
  87788. * @param parent defines the parent mesh if any
  87789. * @param source defines the optional source LinesMesh used to clone data from
  87790. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87791. * When false, achieved by calling a clone(), also passing False.
  87792. * This will make creation of children, recursive.
  87793. * @param useVertexColor defines if this LinesMesh supports vertex color
  87794. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87795. */
  87796. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87797. /**
  87798. * If vertex color should be applied to the mesh
  87799. */
  87800. useVertexColor?: boolean | undefined,
  87801. /**
  87802. * If vertex alpha should be applied to the mesh
  87803. */
  87804. useVertexAlpha?: boolean | undefined);
  87805. private _addClipPlaneDefine;
  87806. private _removeClipPlaneDefine;
  87807. isReady(): boolean;
  87808. /**
  87809. * Returns the string "LineMesh"
  87810. */
  87811. getClassName(): string;
  87812. /**
  87813. * @hidden
  87814. */
  87815. /**
  87816. * @hidden
  87817. */
  87818. material: Material;
  87819. /**
  87820. * @hidden
  87821. */
  87822. readonly checkCollisions: boolean;
  87823. /** @hidden */
  87824. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87825. /** @hidden */
  87826. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87827. /**
  87828. * Disposes of the line mesh
  87829. * @param doNotRecurse If children should be disposed
  87830. */
  87831. dispose(doNotRecurse?: boolean): void;
  87832. /**
  87833. * Returns a new LineMesh object cloned from the current one.
  87834. */
  87835. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87836. /**
  87837. * Creates a new InstancedLinesMesh object from the mesh model.
  87838. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87839. * @param name defines the name of the new instance
  87840. * @returns a new InstancedLinesMesh
  87841. */
  87842. createInstance(name: string): InstancedLinesMesh;
  87843. }
  87844. /**
  87845. * Creates an instance based on a source LinesMesh
  87846. */
  87847. export class InstancedLinesMesh extends InstancedMesh {
  87848. /**
  87849. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87850. * This margin is expressed in world space coordinates, so its value may vary.
  87851. * Initilized with the intersectionThreshold value of the source LinesMesh
  87852. */
  87853. intersectionThreshold: number;
  87854. constructor(name: string, source: LinesMesh);
  87855. /**
  87856. * Returns the string "InstancedLinesMesh".
  87857. */
  87858. getClassName(): string;
  87859. }
  87860. }
  87861. declare module BABYLON {
  87862. /** @hidden */
  87863. export var linePixelShader: {
  87864. name: string;
  87865. shader: string;
  87866. };
  87867. }
  87868. declare module BABYLON {
  87869. /** @hidden */
  87870. export var lineVertexShader: {
  87871. name: string;
  87872. shader: string;
  87873. };
  87874. }
  87875. declare module BABYLON {
  87876. interface AbstractMesh {
  87877. /**
  87878. * Gets the edgesRenderer associated with the mesh
  87879. */
  87880. edgesRenderer: Nullable<EdgesRenderer>;
  87881. }
  87882. interface LinesMesh {
  87883. /**
  87884. * Enables the edge rendering mode on the mesh.
  87885. * This mode makes the mesh edges visible
  87886. * @param epsilon defines the maximal distance between two angles to detect a face
  87887. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87888. * @returns the currentAbstractMesh
  87889. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87890. */
  87891. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87892. }
  87893. interface InstancedLinesMesh {
  87894. /**
  87895. * Enables the edge rendering mode on the mesh.
  87896. * This mode makes the mesh edges visible
  87897. * @param epsilon defines the maximal distance between two angles to detect a face
  87898. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87899. * @returns the current InstancedLinesMesh
  87900. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87901. */
  87902. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87903. }
  87904. /**
  87905. * Defines the minimum contract an Edges renderer should follow.
  87906. */
  87907. export interface IEdgesRenderer extends IDisposable {
  87908. /**
  87909. * Gets or sets a boolean indicating if the edgesRenderer is active
  87910. */
  87911. isEnabled: boolean;
  87912. /**
  87913. * Renders the edges of the attached mesh,
  87914. */
  87915. render(): void;
  87916. /**
  87917. * Checks wether or not the edges renderer is ready to render.
  87918. * @return true if ready, otherwise false.
  87919. */
  87920. isReady(): boolean;
  87921. }
  87922. /**
  87923. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87924. */
  87925. export class EdgesRenderer implements IEdgesRenderer {
  87926. /**
  87927. * Define the size of the edges with an orthographic camera
  87928. */
  87929. edgesWidthScalerForOrthographic: number;
  87930. /**
  87931. * Define the size of the edges with a perspective camera
  87932. */
  87933. edgesWidthScalerForPerspective: number;
  87934. protected _source: AbstractMesh;
  87935. protected _linesPositions: number[];
  87936. protected _linesNormals: number[];
  87937. protected _linesIndices: number[];
  87938. protected _epsilon: number;
  87939. protected _indicesCount: number;
  87940. protected _lineShader: ShaderMaterial;
  87941. protected _ib: DataBuffer;
  87942. protected _buffers: {
  87943. [key: string]: Nullable<VertexBuffer>;
  87944. };
  87945. protected _checkVerticesInsteadOfIndices: boolean;
  87946. private _meshRebuildObserver;
  87947. private _meshDisposeObserver;
  87948. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87949. isEnabled: boolean;
  87950. /**
  87951. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87952. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87953. * @param source Mesh used to create edges
  87954. * @param epsilon sum of angles in adjacency to check for edge
  87955. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87956. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87957. */
  87958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87959. protected _prepareRessources(): void;
  87960. /** @hidden */
  87961. _rebuild(): void;
  87962. /**
  87963. * Releases the required resources for the edges renderer
  87964. */
  87965. dispose(): void;
  87966. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87967. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87968. /**
  87969. * Checks if the pair of p0 and p1 is en edge
  87970. * @param faceIndex
  87971. * @param edge
  87972. * @param faceNormals
  87973. * @param p0
  87974. * @param p1
  87975. * @private
  87976. */
  87977. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87978. /**
  87979. * push line into the position, normal and index buffer
  87980. * @protected
  87981. */
  87982. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87983. /**
  87984. * Generates lines edges from adjacencjes
  87985. * @private
  87986. */
  87987. _generateEdgesLines(): void;
  87988. /**
  87989. * Checks wether or not the edges renderer is ready to render.
  87990. * @return true if ready, otherwise false.
  87991. */
  87992. isReady(): boolean;
  87993. /**
  87994. * Renders the edges of the attached mesh,
  87995. */
  87996. render(): void;
  87997. }
  87998. /**
  87999. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88000. */
  88001. export class LineEdgesRenderer extends EdgesRenderer {
  88002. /**
  88003. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88004. * @param source LineMesh used to generate edges
  88005. * @param epsilon not important (specified angle for edge detection)
  88006. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88007. */
  88008. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88009. /**
  88010. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88011. */
  88012. _generateEdgesLines(): void;
  88013. }
  88014. }
  88015. declare module BABYLON {
  88016. /**
  88017. * This represents the object necessary to create a rendering group.
  88018. * This is exclusively used and created by the rendering manager.
  88019. * To modify the behavior, you use the available helpers in your scene or meshes.
  88020. * @hidden
  88021. */
  88022. export class RenderingGroup {
  88023. index: number;
  88024. private static _zeroVector;
  88025. private _scene;
  88026. private _opaqueSubMeshes;
  88027. private _transparentSubMeshes;
  88028. private _alphaTestSubMeshes;
  88029. private _depthOnlySubMeshes;
  88030. private _particleSystems;
  88031. private _spriteManagers;
  88032. private _opaqueSortCompareFn;
  88033. private _alphaTestSortCompareFn;
  88034. private _transparentSortCompareFn;
  88035. private _renderOpaque;
  88036. private _renderAlphaTest;
  88037. private _renderTransparent;
  88038. /** @hidden */
  88039. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88040. onBeforeTransparentRendering: () => void;
  88041. /**
  88042. * Set the opaque sort comparison function.
  88043. * If null the sub meshes will be render in the order they were created
  88044. */
  88045. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88046. /**
  88047. * Set the alpha test sort comparison function.
  88048. * If null the sub meshes will be render in the order they were created
  88049. */
  88050. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88051. /**
  88052. * Set the transparent sort comparison function.
  88053. * If null the sub meshes will be render in the order they were created
  88054. */
  88055. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88056. /**
  88057. * Creates a new rendering group.
  88058. * @param index The rendering group index
  88059. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88060. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88061. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88062. */
  88063. 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>);
  88064. /**
  88065. * Render all the sub meshes contained in the group.
  88066. * @param customRenderFunction Used to override the default render behaviour of the group.
  88067. * @returns true if rendered some submeshes.
  88068. */
  88069. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88070. /**
  88071. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88072. * @param subMeshes The submeshes to render
  88073. */
  88074. private renderOpaqueSorted;
  88075. /**
  88076. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88077. * @param subMeshes The submeshes to render
  88078. */
  88079. private renderAlphaTestSorted;
  88080. /**
  88081. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88082. * @param subMeshes The submeshes to render
  88083. */
  88084. private renderTransparentSorted;
  88085. /**
  88086. * Renders the submeshes in a specified order.
  88087. * @param subMeshes The submeshes to sort before render
  88088. * @param sortCompareFn The comparison function use to sort
  88089. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88090. * @param transparent Specifies to activate blending if true
  88091. */
  88092. private static renderSorted;
  88093. /**
  88094. * Renders the submeshes in the order they were dispatched (no sort applied).
  88095. * @param subMeshes The submeshes to render
  88096. */
  88097. private static renderUnsorted;
  88098. /**
  88099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88100. * are rendered back to front if in the same alpha index.
  88101. *
  88102. * @param a The first submesh
  88103. * @param b The second submesh
  88104. * @returns The result of the comparison
  88105. */
  88106. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88107. /**
  88108. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88109. * are rendered back to front.
  88110. *
  88111. * @param a The first submesh
  88112. * @param b The second submesh
  88113. * @returns The result of the comparison
  88114. */
  88115. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88116. /**
  88117. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88118. * are rendered front to back (prevent overdraw).
  88119. *
  88120. * @param a The first submesh
  88121. * @param b The second submesh
  88122. * @returns The result of the comparison
  88123. */
  88124. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88125. /**
  88126. * Resets the different lists of submeshes to prepare a new frame.
  88127. */
  88128. prepare(): void;
  88129. dispose(): void;
  88130. /**
  88131. * Inserts the submesh in its correct queue depending on its material.
  88132. * @param subMesh The submesh to dispatch
  88133. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88134. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88135. */
  88136. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88137. dispatchSprites(spriteManager: ISpriteManager): void;
  88138. dispatchParticles(particleSystem: IParticleSystem): void;
  88139. private _renderParticles;
  88140. private _renderSprites;
  88141. }
  88142. }
  88143. declare module BABYLON {
  88144. /**
  88145. * Interface describing the different options available in the rendering manager
  88146. * regarding Auto Clear between groups.
  88147. */
  88148. export interface IRenderingManagerAutoClearSetup {
  88149. /**
  88150. * Defines whether or not autoclear is enable.
  88151. */
  88152. autoClear: boolean;
  88153. /**
  88154. * Defines whether or not to autoclear the depth buffer.
  88155. */
  88156. depth: boolean;
  88157. /**
  88158. * Defines whether or not to autoclear the stencil buffer.
  88159. */
  88160. stencil: boolean;
  88161. }
  88162. /**
  88163. * This class is used by the onRenderingGroupObservable
  88164. */
  88165. export class RenderingGroupInfo {
  88166. /**
  88167. * The Scene that being rendered
  88168. */
  88169. scene: Scene;
  88170. /**
  88171. * The camera currently used for the rendering pass
  88172. */
  88173. camera: Nullable<Camera>;
  88174. /**
  88175. * The ID of the renderingGroup being processed
  88176. */
  88177. renderingGroupId: number;
  88178. }
  88179. /**
  88180. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88181. * It is enable to manage the different groups as well as the different necessary sort functions.
  88182. * This should not be used directly aside of the few static configurations
  88183. */
  88184. export class RenderingManager {
  88185. /**
  88186. * The max id used for rendering groups (not included)
  88187. */
  88188. static MAX_RENDERINGGROUPS: number;
  88189. /**
  88190. * The min id used for rendering groups (included)
  88191. */
  88192. static MIN_RENDERINGGROUPS: number;
  88193. /**
  88194. * Used to globally prevent autoclearing scenes.
  88195. */
  88196. static AUTOCLEAR: boolean;
  88197. /**
  88198. * @hidden
  88199. */
  88200. _useSceneAutoClearSetup: boolean;
  88201. private _scene;
  88202. private _renderingGroups;
  88203. private _depthStencilBufferAlreadyCleaned;
  88204. private _autoClearDepthStencil;
  88205. private _customOpaqueSortCompareFn;
  88206. private _customAlphaTestSortCompareFn;
  88207. private _customTransparentSortCompareFn;
  88208. private _renderingGroupInfo;
  88209. /**
  88210. * Instantiates a new rendering group for a particular scene
  88211. * @param scene Defines the scene the groups belongs to
  88212. */
  88213. constructor(scene: Scene);
  88214. private _clearDepthStencilBuffer;
  88215. /**
  88216. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88217. * @hidden
  88218. */
  88219. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88220. /**
  88221. * Resets the different information of the group to prepare a new frame
  88222. * @hidden
  88223. */
  88224. reset(): void;
  88225. /**
  88226. * Dispose and release the group and its associated resources.
  88227. * @hidden
  88228. */
  88229. dispose(): void;
  88230. /**
  88231. * Clear the info related to rendering groups preventing retention points during dispose.
  88232. */
  88233. freeRenderingGroups(): void;
  88234. private _prepareRenderingGroup;
  88235. /**
  88236. * Add a sprite manager to the rendering manager in order to render it this frame.
  88237. * @param spriteManager Define the sprite manager to render
  88238. */
  88239. dispatchSprites(spriteManager: ISpriteManager): void;
  88240. /**
  88241. * Add a particle system to the rendering manager in order to render it this frame.
  88242. * @param particleSystem Define the particle system to render
  88243. */
  88244. dispatchParticles(particleSystem: IParticleSystem): void;
  88245. /**
  88246. * Add a submesh to the manager in order to render it this frame
  88247. * @param subMesh The submesh to dispatch
  88248. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88249. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88250. */
  88251. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88252. /**
  88253. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88254. * This allowed control for front to back rendering or reversly depending of the special needs.
  88255. *
  88256. * @param renderingGroupId The rendering group id corresponding to its index
  88257. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88258. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88259. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88260. */
  88261. 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;
  88262. /**
  88263. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88264. *
  88265. * @param renderingGroupId The rendering group id corresponding to its index
  88266. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88267. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88268. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88269. */
  88270. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88271. /**
  88272. * Gets the current auto clear configuration for one rendering group of the rendering
  88273. * manager.
  88274. * @param index the rendering group index to get the information for
  88275. * @returns The auto clear setup for the requested rendering group
  88276. */
  88277. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88278. }
  88279. }
  88280. declare module BABYLON {
  88281. /**
  88282. * This Helps creating a texture that will be created from a camera in your scene.
  88283. * It is basically a dynamic texture that could be used to create special effects for instance.
  88284. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88285. */
  88286. export class RenderTargetTexture extends Texture {
  88287. isCube: boolean;
  88288. /**
  88289. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88290. */
  88291. static readonly REFRESHRATE_RENDER_ONCE: number;
  88292. /**
  88293. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88294. */
  88295. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88296. /**
  88297. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88298. * the central point of your effect and can save a lot of performances.
  88299. */
  88300. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88301. /**
  88302. * Use this predicate to dynamically define the list of mesh you want to render.
  88303. * If set, the renderList property will be overwritten.
  88304. */
  88305. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88306. private _renderList;
  88307. /**
  88308. * Use this list to define the list of mesh you want to render.
  88309. */
  88310. renderList: Nullable<Array<AbstractMesh>>;
  88311. private _hookArray;
  88312. /**
  88313. * Define if particles should be rendered in your texture.
  88314. */
  88315. renderParticles: boolean;
  88316. /**
  88317. * Define if sprites should be rendered in your texture.
  88318. */
  88319. renderSprites: boolean;
  88320. /**
  88321. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88322. */
  88323. coordinatesMode: number;
  88324. /**
  88325. * Define the camera used to render the texture.
  88326. */
  88327. activeCamera: Nullable<Camera>;
  88328. /**
  88329. * Override the render function of the texture with your own one.
  88330. */
  88331. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88332. /**
  88333. * Define if camera post processes should be use while rendering the texture.
  88334. */
  88335. useCameraPostProcesses: boolean;
  88336. /**
  88337. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88338. */
  88339. ignoreCameraViewport: boolean;
  88340. private _postProcessManager;
  88341. private _postProcesses;
  88342. private _resizeObserver;
  88343. /**
  88344. * An event triggered when the texture is unbind.
  88345. */
  88346. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88347. /**
  88348. * An event triggered when the texture is unbind.
  88349. */
  88350. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88351. private _onAfterUnbindObserver;
  88352. /**
  88353. * Set a after unbind callback in the texture.
  88354. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88355. */
  88356. onAfterUnbind: () => void;
  88357. /**
  88358. * An event triggered before rendering the texture
  88359. */
  88360. onBeforeRenderObservable: Observable<number>;
  88361. private _onBeforeRenderObserver;
  88362. /**
  88363. * Set a before render callback in the texture.
  88364. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88365. */
  88366. onBeforeRender: (faceIndex: number) => void;
  88367. /**
  88368. * An event triggered after rendering the texture
  88369. */
  88370. onAfterRenderObservable: Observable<number>;
  88371. private _onAfterRenderObserver;
  88372. /**
  88373. * Set a after render callback in the texture.
  88374. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88375. */
  88376. onAfterRender: (faceIndex: number) => void;
  88377. /**
  88378. * An event triggered after the texture clear
  88379. */
  88380. onClearObservable: Observable<Engine>;
  88381. private _onClearObserver;
  88382. /**
  88383. * Set a clear callback in the texture.
  88384. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88385. */
  88386. onClear: (Engine: Engine) => void;
  88387. /**
  88388. * An event triggered when the texture is resized.
  88389. */
  88390. onResizeObservable: Observable<RenderTargetTexture>;
  88391. /**
  88392. * Define the clear color of the Render Target if it should be different from the scene.
  88393. */
  88394. clearColor: Color4;
  88395. protected _size: number | {
  88396. width: number;
  88397. height: number;
  88398. };
  88399. protected _initialSizeParameter: number | {
  88400. width: number;
  88401. height: number;
  88402. } | {
  88403. ratio: number;
  88404. };
  88405. protected _sizeRatio: Nullable<number>;
  88406. /** @hidden */
  88407. _generateMipMaps: boolean;
  88408. protected _renderingManager: RenderingManager;
  88409. /** @hidden */
  88410. _waitingRenderList: string[];
  88411. protected _doNotChangeAspectRatio: boolean;
  88412. protected _currentRefreshId: number;
  88413. protected _refreshRate: number;
  88414. protected _textureMatrix: Matrix;
  88415. protected _samples: number;
  88416. protected _renderTargetOptions: RenderTargetCreationOptions;
  88417. /**
  88418. * Gets render target creation options that were used.
  88419. */
  88420. readonly renderTargetOptions: RenderTargetCreationOptions;
  88421. protected _engine: Engine;
  88422. protected _onRatioRescale(): void;
  88423. /**
  88424. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88425. * It must define where the camera used to render the texture is set
  88426. */
  88427. boundingBoxPosition: Vector3;
  88428. private _boundingBoxSize;
  88429. /**
  88430. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88431. * When defined, the cubemap will switch to local mode
  88432. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88433. * @example https://www.babylonjs-playground.com/#RNASML
  88434. */
  88435. boundingBoxSize: Vector3;
  88436. /**
  88437. * In case the RTT has been created with a depth texture, get the associated
  88438. * depth texture.
  88439. * Otherwise, return null.
  88440. */
  88441. depthStencilTexture: Nullable<InternalTexture>;
  88442. /**
  88443. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88444. * or used a shadow, depth texture...
  88445. * @param name The friendly name of the texture
  88446. * @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)
  88447. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88448. * @param generateMipMaps True if mip maps need to be generated after render.
  88449. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88450. * @param type The type of the buffer in the RTT (int, half float, float...)
  88451. * @param isCube True if a cube texture needs to be created
  88452. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88453. * @param generateDepthBuffer True to generate a depth buffer
  88454. * @param generateStencilBuffer True to generate a stencil buffer
  88455. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88456. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88457. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88458. */
  88459. constructor(name: string, size: number | {
  88460. width: number;
  88461. height: number;
  88462. } | {
  88463. ratio: number;
  88464. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88465. /**
  88466. * Creates a depth stencil texture.
  88467. * This is only available in WebGL 2 or with the depth texture extension available.
  88468. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88469. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88470. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88471. */
  88472. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88473. private _processSizeParameter;
  88474. /**
  88475. * Define the number of samples to use in case of MSAA.
  88476. * It defaults to one meaning no MSAA has been enabled.
  88477. */
  88478. samples: number;
  88479. /**
  88480. * Resets the refresh counter of the texture and start bak from scratch.
  88481. * Could be useful to regenerate the texture if it is setup to render only once.
  88482. */
  88483. resetRefreshCounter(): void;
  88484. /**
  88485. * Define the refresh rate of the texture or the rendering frequency.
  88486. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88487. */
  88488. refreshRate: number;
  88489. /**
  88490. * Adds a post process to the render target rendering passes.
  88491. * @param postProcess define the post process to add
  88492. */
  88493. addPostProcess(postProcess: PostProcess): void;
  88494. /**
  88495. * Clear all the post processes attached to the render target
  88496. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88497. */
  88498. clearPostProcesses(dispose?: boolean): void;
  88499. /**
  88500. * Remove one of the post process from the list of attached post processes to the texture
  88501. * @param postProcess define the post process to remove from the list
  88502. */
  88503. removePostProcess(postProcess: PostProcess): void;
  88504. /** @hidden */
  88505. _shouldRender(): boolean;
  88506. /**
  88507. * Gets the actual render size of the texture.
  88508. * @returns the width of the render size
  88509. */
  88510. getRenderSize(): number;
  88511. /**
  88512. * Gets the actual render width of the texture.
  88513. * @returns the width of the render size
  88514. */
  88515. getRenderWidth(): number;
  88516. /**
  88517. * Gets the actual render height of the texture.
  88518. * @returns the height of the render size
  88519. */
  88520. getRenderHeight(): number;
  88521. /**
  88522. * Get if the texture can be rescaled or not.
  88523. */
  88524. readonly canRescale: boolean;
  88525. /**
  88526. * Resize the texture using a ratio.
  88527. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88528. */
  88529. scale(ratio: number): void;
  88530. /**
  88531. * Get the texture reflection matrix used to rotate/transform the reflection.
  88532. * @returns the reflection matrix
  88533. */
  88534. getReflectionTextureMatrix(): Matrix;
  88535. /**
  88536. * Resize the texture to a new desired size.
  88537. * Be carrefull as it will recreate all the data in the new texture.
  88538. * @param size Define the new size. It can be:
  88539. * - a number for squared texture,
  88540. * - an object containing { width: number, height: number }
  88541. * - or an object containing a ratio { ratio: number }
  88542. */
  88543. resize(size: number | {
  88544. width: number;
  88545. height: number;
  88546. } | {
  88547. ratio: number;
  88548. }): void;
  88549. /**
  88550. * Renders all the objects from the render list into the texture.
  88551. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88552. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88553. */
  88554. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88555. private _bestReflectionRenderTargetDimension;
  88556. /**
  88557. * @hidden
  88558. * @param faceIndex face index to bind to if this is a cubetexture
  88559. */
  88560. _bindFrameBuffer(faceIndex?: number): void;
  88561. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88562. private renderToTarget;
  88563. /**
  88564. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88565. * This allowed control for front to back rendering or reversly depending of the special needs.
  88566. *
  88567. * @param renderingGroupId The rendering group id corresponding to its index
  88568. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88569. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88570. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88571. */
  88572. 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;
  88573. /**
  88574. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88575. *
  88576. * @param renderingGroupId The rendering group id corresponding to its index
  88577. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88578. */
  88579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88580. /**
  88581. * Clones the texture.
  88582. * @returns the cloned texture
  88583. */
  88584. clone(): RenderTargetTexture;
  88585. /**
  88586. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88587. * @returns The JSON representation of the texture
  88588. */
  88589. serialize(): any;
  88590. /**
  88591. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88592. */
  88593. disposeFramebufferObjects(): void;
  88594. /**
  88595. * Dispose the texture and release its associated resources.
  88596. */
  88597. dispose(): void;
  88598. /** @hidden */
  88599. _rebuild(): void;
  88600. /**
  88601. * Clear the info related to rendering groups preventing retention point in material dispose.
  88602. */
  88603. freeRenderingGroups(): void;
  88604. /**
  88605. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88606. * @returns the view count
  88607. */
  88608. getViewCount(): number;
  88609. }
  88610. }
  88611. declare module BABYLON {
  88612. /**
  88613. * Options for compiling materials.
  88614. */
  88615. export interface IMaterialCompilationOptions {
  88616. /**
  88617. * Defines whether clip planes are enabled.
  88618. */
  88619. clipPlane: boolean;
  88620. /**
  88621. * Defines whether instances are enabled.
  88622. */
  88623. useInstances: boolean;
  88624. }
  88625. /**
  88626. * Base class for the main features of a material in Babylon.js
  88627. */
  88628. export class Material implements IAnimatable {
  88629. /**
  88630. * Returns the triangle fill mode
  88631. */
  88632. static readonly TriangleFillMode: number;
  88633. /**
  88634. * Returns the wireframe mode
  88635. */
  88636. static readonly WireFrameFillMode: number;
  88637. /**
  88638. * Returns the point fill mode
  88639. */
  88640. static readonly PointFillMode: number;
  88641. /**
  88642. * Returns the point list draw mode
  88643. */
  88644. static readonly PointListDrawMode: number;
  88645. /**
  88646. * Returns the line list draw mode
  88647. */
  88648. static readonly LineListDrawMode: number;
  88649. /**
  88650. * Returns the line loop draw mode
  88651. */
  88652. static readonly LineLoopDrawMode: number;
  88653. /**
  88654. * Returns the line strip draw mode
  88655. */
  88656. static readonly LineStripDrawMode: number;
  88657. /**
  88658. * Returns the triangle strip draw mode
  88659. */
  88660. static readonly TriangleStripDrawMode: number;
  88661. /**
  88662. * Returns the triangle fan draw mode
  88663. */
  88664. static readonly TriangleFanDrawMode: number;
  88665. /**
  88666. * Stores the clock-wise side orientation
  88667. */
  88668. static readonly ClockWiseSideOrientation: number;
  88669. /**
  88670. * Stores the counter clock-wise side orientation
  88671. */
  88672. static readonly CounterClockWiseSideOrientation: number;
  88673. /**
  88674. * The dirty texture flag value
  88675. */
  88676. static readonly TextureDirtyFlag: number;
  88677. /**
  88678. * The dirty light flag value
  88679. */
  88680. static readonly LightDirtyFlag: number;
  88681. /**
  88682. * The dirty fresnel flag value
  88683. */
  88684. static readonly FresnelDirtyFlag: number;
  88685. /**
  88686. * The dirty attribute flag value
  88687. */
  88688. static readonly AttributesDirtyFlag: number;
  88689. /**
  88690. * The dirty misc flag value
  88691. */
  88692. static readonly MiscDirtyFlag: number;
  88693. /**
  88694. * The all dirty flag value
  88695. */
  88696. static readonly AllDirtyFlag: number;
  88697. /**
  88698. * The ID of the material
  88699. */
  88700. id: string;
  88701. /**
  88702. * Gets or sets the unique id of the material
  88703. */
  88704. uniqueId: number;
  88705. /**
  88706. * The name of the material
  88707. */
  88708. name: string;
  88709. /**
  88710. * Gets or sets user defined metadata
  88711. */
  88712. metadata: any;
  88713. /**
  88714. * For internal use only. Please do not use.
  88715. */
  88716. reservedDataStore: any;
  88717. /**
  88718. * Specifies if the ready state should be checked on each call
  88719. */
  88720. checkReadyOnEveryCall: boolean;
  88721. /**
  88722. * Specifies if the ready state should be checked once
  88723. */
  88724. checkReadyOnlyOnce: boolean;
  88725. /**
  88726. * The state of the material
  88727. */
  88728. state: string;
  88729. /**
  88730. * The alpha value of the material
  88731. */
  88732. protected _alpha: number;
  88733. /**
  88734. * List of inspectable custom properties (used by the Inspector)
  88735. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88736. */
  88737. inspectableCustomProperties: IInspectable[];
  88738. /**
  88739. * Sets the alpha value of the material
  88740. */
  88741. /**
  88742. * Gets the alpha value of the material
  88743. */
  88744. alpha: number;
  88745. /**
  88746. * Specifies if back face culling is enabled
  88747. */
  88748. protected _backFaceCulling: boolean;
  88749. /**
  88750. * Sets the back-face culling state
  88751. */
  88752. /**
  88753. * Gets the back-face culling state
  88754. */
  88755. backFaceCulling: boolean;
  88756. /**
  88757. * Stores the value for side orientation
  88758. */
  88759. sideOrientation: number;
  88760. /**
  88761. * Callback triggered when the material is compiled
  88762. */
  88763. onCompiled: Nullable<(effect: Effect) => void>;
  88764. /**
  88765. * Callback triggered when an error occurs
  88766. */
  88767. onError: Nullable<(effect: Effect, errors: string) => void>;
  88768. /**
  88769. * Callback triggered to get the render target textures
  88770. */
  88771. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88772. /**
  88773. * Gets a boolean indicating that current material needs to register RTT
  88774. */
  88775. readonly hasRenderTargetTextures: boolean;
  88776. /**
  88777. * Specifies if the material should be serialized
  88778. */
  88779. doNotSerialize: boolean;
  88780. /**
  88781. * @hidden
  88782. */
  88783. _storeEffectOnSubMeshes: boolean;
  88784. /**
  88785. * Stores the animations for the material
  88786. */
  88787. animations: Nullable<Array<Animation>>;
  88788. /**
  88789. * An event triggered when the material is disposed
  88790. */
  88791. onDisposeObservable: Observable<Material>;
  88792. /**
  88793. * An observer which watches for dispose events
  88794. */
  88795. private _onDisposeObserver;
  88796. private _onUnBindObservable;
  88797. /**
  88798. * Called during a dispose event
  88799. */
  88800. onDispose: () => void;
  88801. private _onBindObservable;
  88802. /**
  88803. * An event triggered when the material is bound
  88804. */
  88805. readonly onBindObservable: Observable<AbstractMesh>;
  88806. /**
  88807. * An observer which watches for bind events
  88808. */
  88809. private _onBindObserver;
  88810. /**
  88811. * Called during a bind event
  88812. */
  88813. onBind: (Mesh: AbstractMesh) => void;
  88814. /**
  88815. * An event triggered when the material is unbound
  88816. */
  88817. readonly onUnBindObservable: Observable<Material>;
  88818. /**
  88819. * Stores the value of the alpha mode
  88820. */
  88821. private _alphaMode;
  88822. /**
  88823. * Sets the value of the alpha mode.
  88824. *
  88825. * | Value | Type | Description |
  88826. * | --- | --- | --- |
  88827. * | 0 | ALPHA_DISABLE | |
  88828. * | 1 | ALPHA_ADD | |
  88829. * | 2 | ALPHA_COMBINE | |
  88830. * | 3 | ALPHA_SUBTRACT | |
  88831. * | 4 | ALPHA_MULTIPLY | |
  88832. * | 5 | ALPHA_MAXIMIZED | |
  88833. * | 6 | ALPHA_ONEONE | |
  88834. * | 7 | ALPHA_PREMULTIPLIED | |
  88835. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88836. * | 9 | ALPHA_INTERPOLATE | |
  88837. * | 10 | ALPHA_SCREENMODE | |
  88838. *
  88839. */
  88840. /**
  88841. * Gets the value of the alpha mode
  88842. */
  88843. alphaMode: number;
  88844. /**
  88845. * Stores the state of the need depth pre-pass value
  88846. */
  88847. private _needDepthPrePass;
  88848. /**
  88849. * Sets the need depth pre-pass value
  88850. */
  88851. /**
  88852. * Gets the depth pre-pass value
  88853. */
  88854. needDepthPrePass: boolean;
  88855. /**
  88856. * Specifies if depth writing should be disabled
  88857. */
  88858. disableDepthWrite: boolean;
  88859. /**
  88860. * Specifies if depth writing should be forced
  88861. */
  88862. forceDepthWrite: boolean;
  88863. /**
  88864. * Specifies the depth function that should be used. 0 means the default engine function
  88865. */
  88866. depthFunction: number;
  88867. /**
  88868. * Specifies if there should be a separate pass for culling
  88869. */
  88870. separateCullingPass: boolean;
  88871. /**
  88872. * Stores the state specifing if fog should be enabled
  88873. */
  88874. private _fogEnabled;
  88875. /**
  88876. * Sets the state for enabling fog
  88877. */
  88878. /**
  88879. * Gets the value of the fog enabled state
  88880. */
  88881. fogEnabled: boolean;
  88882. /**
  88883. * Stores the size of points
  88884. */
  88885. pointSize: number;
  88886. /**
  88887. * Stores the z offset value
  88888. */
  88889. zOffset: number;
  88890. /**
  88891. * Gets a value specifying if wireframe mode is enabled
  88892. */
  88893. /**
  88894. * Sets the state of wireframe mode
  88895. */
  88896. wireframe: boolean;
  88897. /**
  88898. * Gets the value specifying if point clouds are enabled
  88899. */
  88900. /**
  88901. * Sets the state of point cloud mode
  88902. */
  88903. pointsCloud: boolean;
  88904. /**
  88905. * Gets the material fill mode
  88906. */
  88907. /**
  88908. * Sets the material fill mode
  88909. */
  88910. fillMode: number;
  88911. /**
  88912. * @hidden
  88913. * Stores the effects for the material
  88914. */
  88915. _effect: Nullable<Effect>;
  88916. /**
  88917. * @hidden
  88918. * Specifies if the material was previously ready
  88919. */
  88920. _wasPreviouslyReady: boolean;
  88921. /**
  88922. * Specifies if uniform buffers should be used
  88923. */
  88924. private _useUBO;
  88925. /**
  88926. * Stores a reference to the scene
  88927. */
  88928. private _scene;
  88929. /**
  88930. * Stores the fill mode state
  88931. */
  88932. private _fillMode;
  88933. /**
  88934. * Specifies if the depth write state should be cached
  88935. */
  88936. private _cachedDepthWriteState;
  88937. /**
  88938. * Specifies if the depth function state should be cached
  88939. */
  88940. private _cachedDepthFunctionState;
  88941. /**
  88942. * Stores the uniform buffer
  88943. */
  88944. protected _uniformBuffer: UniformBuffer;
  88945. /** @hidden */
  88946. _indexInSceneMaterialArray: number;
  88947. /** @hidden */
  88948. meshMap: Nullable<{
  88949. [id: string]: AbstractMesh | undefined;
  88950. }>;
  88951. /**
  88952. * Creates a material instance
  88953. * @param name defines the name of the material
  88954. * @param scene defines the scene to reference
  88955. * @param doNotAdd specifies if the material should be added to the scene
  88956. */
  88957. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88958. /**
  88959. * Returns a string representation of the current material
  88960. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88961. * @returns a string with material information
  88962. */
  88963. toString(fullDetails?: boolean): string;
  88964. /**
  88965. * Gets the class name of the material
  88966. * @returns a string with the class name of the material
  88967. */
  88968. getClassName(): string;
  88969. /**
  88970. * Specifies if updates for the material been locked
  88971. */
  88972. readonly isFrozen: boolean;
  88973. /**
  88974. * Locks updates for the material
  88975. */
  88976. freeze(): void;
  88977. /**
  88978. * Unlocks updates for the material
  88979. */
  88980. unfreeze(): void;
  88981. /**
  88982. * Specifies if the material is ready to be used
  88983. * @param mesh defines the mesh to check
  88984. * @param useInstances specifies if instances should be used
  88985. * @returns a boolean indicating if the material is ready to be used
  88986. */
  88987. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88988. /**
  88989. * Specifies that the submesh is ready to be used
  88990. * @param mesh defines the mesh to check
  88991. * @param subMesh defines which submesh to check
  88992. * @param useInstances specifies that instances should be used
  88993. * @returns a boolean indicating that the submesh is ready or not
  88994. */
  88995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88996. /**
  88997. * Returns the material effect
  88998. * @returns the effect associated with the material
  88999. */
  89000. getEffect(): Nullable<Effect>;
  89001. /**
  89002. * Returns the current scene
  89003. * @returns a Scene
  89004. */
  89005. getScene(): Scene;
  89006. /**
  89007. * Specifies if the material will require alpha blending
  89008. * @returns a boolean specifying if alpha blending is needed
  89009. */
  89010. needAlphaBlending(): boolean;
  89011. /**
  89012. * Specifies if the mesh will require alpha blending
  89013. * @param mesh defines the mesh to check
  89014. * @returns a boolean specifying if alpha blending is needed for the mesh
  89015. */
  89016. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89017. /**
  89018. * Specifies if this material should be rendered in alpha test mode
  89019. * @returns a boolean specifying if an alpha test is needed.
  89020. */
  89021. needAlphaTesting(): boolean;
  89022. /**
  89023. * Gets the texture used for the alpha test
  89024. * @returns the texture to use for alpha testing
  89025. */
  89026. getAlphaTestTexture(): Nullable<BaseTexture>;
  89027. /**
  89028. * Marks the material to indicate that it needs to be re-calculated
  89029. */
  89030. markDirty(): void;
  89031. /** @hidden */
  89032. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89033. /**
  89034. * Binds the material to the mesh
  89035. * @param world defines the world transformation matrix
  89036. * @param mesh defines the mesh to bind the material to
  89037. */
  89038. bind(world: Matrix, mesh?: Mesh): void;
  89039. /**
  89040. * Binds the submesh to the material
  89041. * @param world defines the world transformation matrix
  89042. * @param mesh defines the mesh containing the submesh
  89043. * @param subMesh defines the submesh to bind the material to
  89044. */
  89045. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89046. /**
  89047. * Binds the world matrix to the material
  89048. * @param world defines the world transformation matrix
  89049. */
  89050. bindOnlyWorldMatrix(world: Matrix): void;
  89051. /**
  89052. * Binds the scene's uniform buffer to the effect.
  89053. * @param effect defines the effect to bind to the scene uniform buffer
  89054. * @param sceneUbo defines the uniform buffer storing scene data
  89055. */
  89056. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89057. /**
  89058. * Binds the view matrix to the effect
  89059. * @param effect defines the effect to bind the view matrix to
  89060. */
  89061. bindView(effect: Effect): void;
  89062. /**
  89063. * Binds the view projection matrix to the effect
  89064. * @param effect defines the effect to bind the view projection matrix to
  89065. */
  89066. bindViewProjection(effect: Effect): void;
  89067. /**
  89068. * Specifies if material alpha testing should be turned on for the mesh
  89069. * @param mesh defines the mesh to check
  89070. */
  89071. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89072. /**
  89073. * Processes to execute after binding the material to a mesh
  89074. * @param mesh defines the rendered mesh
  89075. */
  89076. protected _afterBind(mesh?: Mesh): void;
  89077. /**
  89078. * Unbinds the material from the mesh
  89079. */
  89080. unbind(): void;
  89081. /**
  89082. * Gets the active textures from the material
  89083. * @returns an array of textures
  89084. */
  89085. getActiveTextures(): BaseTexture[];
  89086. /**
  89087. * Specifies if the material uses a texture
  89088. * @param texture defines the texture to check against the material
  89089. * @returns a boolean specifying if the material uses the texture
  89090. */
  89091. hasTexture(texture: BaseTexture): boolean;
  89092. /**
  89093. * Makes a duplicate of the material, and gives it a new name
  89094. * @param name defines the new name for the duplicated material
  89095. * @returns the cloned material
  89096. */
  89097. clone(name: string): Nullable<Material>;
  89098. /**
  89099. * Gets the meshes bound to the material
  89100. * @returns an array of meshes bound to the material
  89101. */
  89102. getBindedMeshes(): AbstractMesh[];
  89103. /**
  89104. * Force shader compilation
  89105. * @param mesh defines the mesh associated with this material
  89106. * @param onCompiled defines a function to execute once the material is compiled
  89107. * @param options defines the options to configure the compilation
  89108. * @param onError defines a function to execute if the material fails compiling
  89109. */
  89110. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89111. /**
  89112. * Force shader compilation
  89113. * @param mesh defines the mesh that will use this material
  89114. * @param options defines additional options for compiling the shaders
  89115. * @returns a promise that resolves when the compilation completes
  89116. */
  89117. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89118. private static readonly _AllDirtyCallBack;
  89119. private static readonly _ImageProcessingDirtyCallBack;
  89120. private static readonly _TextureDirtyCallBack;
  89121. private static readonly _FresnelDirtyCallBack;
  89122. private static readonly _MiscDirtyCallBack;
  89123. private static readonly _LightsDirtyCallBack;
  89124. private static readonly _AttributeDirtyCallBack;
  89125. private static _FresnelAndMiscDirtyCallBack;
  89126. private static _TextureAndMiscDirtyCallBack;
  89127. private static readonly _DirtyCallbackArray;
  89128. private static readonly _RunDirtyCallBacks;
  89129. /**
  89130. * Marks a define in the material to indicate that it needs to be re-computed
  89131. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89132. */
  89133. markAsDirty(flag: number): void;
  89134. /**
  89135. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89136. * @param func defines a function which checks material defines against the submeshes
  89137. */
  89138. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89139. /**
  89140. * Indicates that we need to re-calculated for all submeshes
  89141. */
  89142. protected _markAllSubMeshesAsAllDirty(): void;
  89143. /**
  89144. * Indicates that image processing needs to be re-calculated for all submeshes
  89145. */
  89146. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89147. /**
  89148. * Indicates that textures need to be re-calculated for all submeshes
  89149. */
  89150. protected _markAllSubMeshesAsTexturesDirty(): void;
  89151. /**
  89152. * Indicates that fresnel needs to be re-calculated for all submeshes
  89153. */
  89154. protected _markAllSubMeshesAsFresnelDirty(): void;
  89155. /**
  89156. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89157. */
  89158. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89159. /**
  89160. * Indicates that lights need to be re-calculated for all submeshes
  89161. */
  89162. protected _markAllSubMeshesAsLightsDirty(): void;
  89163. /**
  89164. * Indicates that attributes need to be re-calculated for all submeshes
  89165. */
  89166. protected _markAllSubMeshesAsAttributesDirty(): void;
  89167. /**
  89168. * Indicates that misc needs to be re-calculated for all submeshes
  89169. */
  89170. protected _markAllSubMeshesAsMiscDirty(): void;
  89171. /**
  89172. * Indicates that textures and misc need to be re-calculated for all submeshes
  89173. */
  89174. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89175. /**
  89176. * Disposes the material
  89177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89180. */
  89181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89182. /** @hidden */
  89183. private releaseVertexArrayObject;
  89184. /**
  89185. * Serializes this material
  89186. * @returns the serialized material object
  89187. */
  89188. serialize(): any;
  89189. /**
  89190. * Creates a material from parsed material data
  89191. * @param parsedMaterial defines parsed material data
  89192. * @param scene defines the hosting scene
  89193. * @param rootUrl defines the root URL to use to load textures
  89194. * @returns a new material
  89195. */
  89196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89197. }
  89198. }
  89199. declare module BABYLON {
  89200. /**
  89201. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89202. * separate meshes. This can be use to improve performances.
  89203. * @see http://doc.babylonjs.com/how_to/multi_materials
  89204. */
  89205. export class MultiMaterial extends Material {
  89206. private _subMaterials;
  89207. /**
  89208. * Gets or Sets the list of Materials used within the multi material.
  89209. * They need to be ordered according to the submeshes order in the associated mesh
  89210. */
  89211. subMaterials: Nullable<Material>[];
  89212. /**
  89213. * Function used to align with Node.getChildren()
  89214. * @returns the list of Materials used within the multi material
  89215. */
  89216. getChildren(): Nullable<Material>[];
  89217. /**
  89218. * Instantiates a new Multi Material
  89219. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89220. * separate meshes. This can be use to improve performances.
  89221. * @see http://doc.babylonjs.com/how_to/multi_materials
  89222. * @param name Define the name in the scene
  89223. * @param scene Define the scene the material belongs to
  89224. */
  89225. constructor(name: string, scene: Scene);
  89226. private _hookArray;
  89227. /**
  89228. * Get one of the submaterial by its index in the submaterials array
  89229. * @param index The index to look the sub material at
  89230. * @returns The Material if the index has been defined
  89231. */
  89232. getSubMaterial(index: number): Nullable<Material>;
  89233. /**
  89234. * Get the list of active textures for the whole sub materials list.
  89235. * @returns All the textures that will be used during the rendering
  89236. */
  89237. getActiveTextures(): BaseTexture[];
  89238. /**
  89239. * Gets the current class name of the material e.g. "MultiMaterial"
  89240. * Mainly use in serialization.
  89241. * @returns the class name
  89242. */
  89243. getClassName(): string;
  89244. /**
  89245. * Checks if the material is ready to render the requested sub mesh
  89246. * @param mesh Define the mesh the submesh belongs to
  89247. * @param subMesh Define the sub mesh to look readyness for
  89248. * @param useInstances Define whether or not the material is used with instances
  89249. * @returns true if ready, otherwise false
  89250. */
  89251. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89252. /**
  89253. * Clones the current material and its related sub materials
  89254. * @param name Define the name of the newly cloned material
  89255. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89256. * @returns the cloned material
  89257. */
  89258. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89259. /**
  89260. * Serializes the materials into a JSON representation.
  89261. * @returns the JSON representation
  89262. */
  89263. serialize(): any;
  89264. /**
  89265. * Dispose the material and release its associated resources
  89266. * @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)
  89267. * @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)
  89268. * @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)
  89269. */
  89270. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89271. /**
  89272. * Creates a MultiMaterial from parsed MultiMaterial data.
  89273. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89274. * @param scene defines the hosting scene
  89275. * @returns a new MultiMaterial
  89276. */
  89277. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89278. }
  89279. }
  89280. declare module BABYLON {
  89281. /**
  89282. * Base class for submeshes
  89283. */
  89284. export class BaseSubMesh {
  89285. /** @hidden */
  89286. _materialDefines: Nullable<MaterialDefines>;
  89287. /** @hidden */
  89288. _materialEffect: Nullable<Effect>;
  89289. /**
  89290. * Gets associated effect
  89291. */
  89292. readonly effect: Nullable<Effect>;
  89293. /**
  89294. * Sets associated effect (effect used to render this submesh)
  89295. * @param effect defines the effect to associate with
  89296. * @param defines defines the set of defines used to compile this effect
  89297. */
  89298. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89299. }
  89300. /**
  89301. * Defines a subdivision inside a mesh
  89302. */
  89303. export class SubMesh extends BaseSubMesh implements ICullable {
  89304. /** the material index to use */
  89305. materialIndex: number;
  89306. /** vertex index start */
  89307. verticesStart: number;
  89308. /** vertices count */
  89309. verticesCount: number;
  89310. /** index start */
  89311. indexStart: number;
  89312. /** indices count */
  89313. indexCount: number;
  89314. /** @hidden */
  89315. _linesIndexCount: number;
  89316. private _mesh;
  89317. private _renderingMesh;
  89318. private _boundingInfo;
  89319. private _linesIndexBuffer;
  89320. /** @hidden */
  89321. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89322. /** @hidden */
  89323. _trianglePlanes: Plane[];
  89324. /** @hidden */
  89325. _lastColliderTransformMatrix: Nullable<Matrix>;
  89326. /** @hidden */
  89327. _renderId: number;
  89328. /** @hidden */
  89329. _alphaIndex: number;
  89330. /** @hidden */
  89331. _distanceToCamera: number;
  89332. /** @hidden */
  89333. _id: number;
  89334. private _currentMaterial;
  89335. /**
  89336. * Add a new submesh to a mesh
  89337. * @param materialIndex defines the material index to use
  89338. * @param verticesStart defines vertex index start
  89339. * @param verticesCount defines vertices count
  89340. * @param indexStart defines index start
  89341. * @param indexCount defines indices count
  89342. * @param mesh defines the parent mesh
  89343. * @param renderingMesh defines an optional rendering mesh
  89344. * @param createBoundingBox defines if bounding box should be created for this submesh
  89345. * @returns the new submesh
  89346. */
  89347. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89348. /**
  89349. * Creates a new submesh
  89350. * @param materialIndex defines the material index to use
  89351. * @param verticesStart defines vertex index start
  89352. * @param verticesCount defines vertices count
  89353. * @param indexStart defines index start
  89354. * @param indexCount defines indices count
  89355. * @param mesh defines the parent mesh
  89356. * @param renderingMesh defines an optional rendering mesh
  89357. * @param createBoundingBox defines if bounding box should be created for this submesh
  89358. */
  89359. constructor(
  89360. /** the material index to use */
  89361. materialIndex: number,
  89362. /** vertex index start */
  89363. verticesStart: number,
  89364. /** vertices count */
  89365. verticesCount: number,
  89366. /** index start */
  89367. indexStart: number,
  89368. /** indices count */
  89369. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89370. /**
  89371. * Returns true if this submesh covers the entire parent mesh
  89372. * @ignorenaming
  89373. */
  89374. readonly IsGlobal: boolean;
  89375. /**
  89376. * Returns the submesh BoudingInfo object
  89377. * @returns current bounding info (or mesh's one if the submesh is global)
  89378. */
  89379. getBoundingInfo(): BoundingInfo;
  89380. /**
  89381. * Sets the submesh BoundingInfo
  89382. * @param boundingInfo defines the new bounding info to use
  89383. * @returns the SubMesh
  89384. */
  89385. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89386. /**
  89387. * Returns the mesh of the current submesh
  89388. * @return the parent mesh
  89389. */
  89390. getMesh(): AbstractMesh;
  89391. /**
  89392. * Returns the rendering mesh of the submesh
  89393. * @returns the rendering mesh (could be different from parent mesh)
  89394. */
  89395. getRenderingMesh(): Mesh;
  89396. /**
  89397. * Returns the submesh material
  89398. * @returns null or the current material
  89399. */
  89400. getMaterial(): Nullable<Material>;
  89401. /**
  89402. * Sets a new updated BoundingInfo object to the submesh
  89403. * @param data defines an optional position array to use to determine the bounding info
  89404. * @returns the SubMesh
  89405. */
  89406. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89407. /** @hidden */
  89408. _checkCollision(collider: Collider): boolean;
  89409. /**
  89410. * Updates the submesh BoundingInfo
  89411. * @param world defines the world matrix to use to update the bounding info
  89412. * @returns the submesh
  89413. */
  89414. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89415. /**
  89416. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89417. * @param frustumPlanes defines the frustum planes
  89418. * @returns true if the submesh is intersecting with the frustum
  89419. */
  89420. isInFrustum(frustumPlanes: Plane[]): boolean;
  89421. /**
  89422. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89423. * @param frustumPlanes defines the frustum planes
  89424. * @returns true if the submesh is inside the frustum
  89425. */
  89426. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89427. /**
  89428. * Renders the submesh
  89429. * @param enableAlphaMode defines if alpha needs to be used
  89430. * @returns the submesh
  89431. */
  89432. render(enableAlphaMode: boolean): SubMesh;
  89433. /**
  89434. * @hidden
  89435. */
  89436. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89437. /**
  89438. * Checks if the submesh intersects with a ray
  89439. * @param ray defines the ray to test
  89440. * @returns true is the passed ray intersects the submesh bounding box
  89441. */
  89442. canIntersects(ray: Ray): boolean;
  89443. /**
  89444. * Intersects current submesh with a ray
  89445. * @param ray defines the ray to test
  89446. * @param positions defines mesh's positions array
  89447. * @param indices defines mesh's indices array
  89448. * @param fastCheck defines if only bounding info should be used
  89449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89450. * @returns intersection info or null if no intersection
  89451. */
  89452. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89453. /** @hidden */
  89454. private _intersectLines;
  89455. /** @hidden */
  89456. private _intersectUnIndexedLines;
  89457. /** @hidden */
  89458. private _intersectTriangles;
  89459. /** @hidden */
  89460. private _intersectUnIndexedTriangles;
  89461. /** @hidden */
  89462. _rebuild(): void;
  89463. /**
  89464. * Creates a new submesh from the passed mesh
  89465. * @param newMesh defines the new hosting mesh
  89466. * @param newRenderingMesh defines an optional rendering mesh
  89467. * @returns the new submesh
  89468. */
  89469. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89470. /**
  89471. * Release associated resources
  89472. */
  89473. dispose(): void;
  89474. /**
  89475. * Gets the class name
  89476. * @returns the string "SubMesh".
  89477. */
  89478. getClassName(): string;
  89479. /**
  89480. * Creates a new submesh from indices data
  89481. * @param materialIndex the index of the main mesh material
  89482. * @param startIndex the index where to start the copy in the mesh indices array
  89483. * @param indexCount the number of indices to copy then from the startIndex
  89484. * @param mesh the main mesh to create the submesh from
  89485. * @param renderingMesh the optional rendering mesh
  89486. * @returns a new submesh
  89487. */
  89488. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89489. }
  89490. }
  89491. declare module BABYLON {
  89492. /**
  89493. * Class used to represent data loading progression
  89494. */
  89495. export class SceneLoaderFlags {
  89496. private static _ForceFullSceneLoadingForIncremental;
  89497. private static _ShowLoadingScreen;
  89498. private static _CleanBoneMatrixWeights;
  89499. private static _loggingLevel;
  89500. /**
  89501. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89502. */
  89503. static ForceFullSceneLoadingForIncremental: boolean;
  89504. /**
  89505. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89506. */
  89507. static ShowLoadingScreen: boolean;
  89508. /**
  89509. * Defines the current logging level (while loading the scene)
  89510. * @ignorenaming
  89511. */
  89512. static loggingLevel: number;
  89513. /**
  89514. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89515. */
  89516. static CleanBoneMatrixWeights: boolean;
  89517. }
  89518. }
  89519. declare module BABYLON {
  89520. /**
  89521. * Class used to store geometry data (vertex buffers + index buffer)
  89522. */
  89523. export class Geometry implements IGetSetVerticesData {
  89524. /**
  89525. * Gets or sets the ID of the geometry
  89526. */
  89527. id: string;
  89528. /**
  89529. * Gets or sets the unique ID of the geometry
  89530. */
  89531. uniqueId: number;
  89532. /**
  89533. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89534. */
  89535. delayLoadState: number;
  89536. /**
  89537. * Gets the file containing the data to load when running in delay load state
  89538. */
  89539. delayLoadingFile: Nullable<string>;
  89540. /**
  89541. * Callback called when the geometry is updated
  89542. */
  89543. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89544. private _scene;
  89545. private _engine;
  89546. private _meshes;
  89547. private _totalVertices;
  89548. /** @hidden */
  89549. _indices: IndicesArray;
  89550. /** @hidden */
  89551. _vertexBuffers: {
  89552. [key: string]: VertexBuffer;
  89553. };
  89554. private _isDisposed;
  89555. private _extend;
  89556. private _boundingBias;
  89557. /** @hidden */
  89558. _delayInfo: Array<string>;
  89559. private _indexBuffer;
  89560. private _indexBufferIsUpdatable;
  89561. /** @hidden */
  89562. _boundingInfo: Nullable<BoundingInfo>;
  89563. /** @hidden */
  89564. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89565. /** @hidden */
  89566. _softwareSkinningFrameId: number;
  89567. private _vertexArrayObjects;
  89568. private _updatable;
  89569. /** @hidden */
  89570. _positions: Nullable<Vector3[]>;
  89571. /**
  89572. * 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
  89573. */
  89574. /**
  89575. * 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
  89576. */
  89577. boundingBias: Vector2;
  89578. /**
  89579. * Static function used to attach a new empty geometry to a mesh
  89580. * @param mesh defines the mesh to attach the geometry to
  89581. * @returns the new Geometry
  89582. */
  89583. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89584. /**
  89585. * Creates a new geometry
  89586. * @param id defines the unique ID
  89587. * @param scene defines the hosting scene
  89588. * @param vertexData defines the VertexData used to get geometry data
  89589. * @param updatable defines if geometry must be updatable (false by default)
  89590. * @param mesh defines the mesh that will be associated with the geometry
  89591. */
  89592. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89593. /**
  89594. * Gets the current extend of the geometry
  89595. */
  89596. readonly extend: {
  89597. minimum: Vector3;
  89598. maximum: Vector3;
  89599. };
  89600. /**
  89601. * Gets the hosting scene
  89602. * @returns the hosting Scene
  89603. */
  89604. getScene(): Scene;
  89605. /**
  89606. * Gets the hosting engine
  89607. * @returns the hosting Engine
  89608. */
  89609. getEngine(): Engine;
  89610. /**
  89611. * Defines if the geometry is ready to use
  89612. * @returns true if the geometry is ready to be used
  89613. */
  89614. isReady(): boolean;
  89615. /**
  89616. * Gets a value indicating that the geometry should not be serialized
  89617. */
  89618. readonly doNotSerialize: boolean;
  89619. /** @hidden */
  89620. _rebuild(): void;
  89621. /**
  89622. * Affects all geometry data in one call
  89623. * @param vertexData defines the geometry data
  89624. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89625. */
  89626. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89627. /**
  89628. * Set specific vertex data
  89629. * @param kind defines the data kind (Position, normal, etc...)
  89630. * @param data defines the vertex data to use
  89631. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89632. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89633. */
  89634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89635. /**
  89636. * Removes a specific vertex data
  89637. * @param kind defines the data kind (Position, normal, etc...)
  89638. */
  89639. removeVerticesData(kind: string): void;
  89640. /**
  89641. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89642. * @param buffer defines the vertex buffer to use
  89643. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89644. */
  89645. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89646. /**
  89647. * Update a specific vertex buffer
  89648. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89649. * It will do nothing if the buffer is not updatable
  89650. * @param kind defines the data kind (Position, normal, etc...)
  89651. * @param data defines the data to use
  89652. * @param offset defines the offset in the target buffer where to store the data
  89653. * @param useBytes set to true if the offset is in bytes
  89654. */
  89655. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89656. /**
  89657. * Update a specific vertex buffer
  89658. * This function will create a new buffer if the current one is not updatable
  89659. * @param kind defines the data kind (Position, normal, etc...)
  89660. * @param data defines the data to use
  89661. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89662. */
  89663. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89664. private _updateBoundingInfo;
  89665. /** @hidden */
  89666. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89667. /**
  89668. * Gets total number of vertices
  89669. * @returns the total number of vertices
  89670. */
  89671. getTotalVertices(): number;
  89672. /**
  89673. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89674. * @param kind defines the data kind (Position, normal, etc...)
  89675. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89677. * @returns a float array containing vertex data
  89678. */
  89679. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89680. /**
  89681. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89682. * @param kind defines the data kind (Position, normal, etc...)
  89683. * @returns true if the vertex buffer with the specified kind is updatable
  89684. */
  89685. isVertexBufferUpdatable(kind: string): boolean;
  89686. /**
  89687. * Gets a specific vertex buffer
  89688. * @param kind defines the data kind (Position, normal, etc...)
  89689. * @returns a VertexBuffer
  89690. */
  89691. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89692. /**
  89693. * Returns all vertex buffers
  89694. * @return an object holding all vertex buffers indexed by kind
  89695. */
  89696. getVertexBuffers(): Nullable<{
  89697. [key: string]: VertexBuffer;
  89698. }>;
  89699. /**
  89700. * Gets a boolean indicating if specific vertex buffer is present
  89701. * @param kind defines the data kind (Position, normal, etc...)
  89702. * @returns true if data is present
  89703. */
  89704. isVerticesDataPresent(kind: string): boolean;
  89705. /**
  89706. * Gets a list of all attached data kinds (Position, normal, etc...)
  89707. * @returns a list of string containing all kinds
  89708. */
  89709. getVerticesDataKinds(): string[];
  89710. /**
  89711. * Update index buffer
  89712. * @param indices defines the indices to store in the index buffer
  89713. * @param offset defines the offset in the target buffer where to store the data
  89714. * @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)
  89715. */
  89716. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89717. /**
  89718. * Creates a new index buffer
  89719. * @param indices defines the indices to store in the index buffer
  89720. * @param totalVertices defines the total number of vertices (could be null)
  89721. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89722. */
  89723. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89724. /**
  89725. * Return the total number of indices
  89726. * @returns the total number of indices
  89727. */
  89728. getTotalIndices(): number;
  89729. /**
  89730. * Gets the index buffer array
  89731. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89732. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89733. * @returns the index buffer array
  89734. */
  89735. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89736. /**
  89737. * Gets the index buffer
  89738. * @return the index buffer
  89739. */
  89740. getIndexBuffer(): Nullable<DataBuffer>;
  89741. /** @hidden */
  89742. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89743. /**
  89744. * Release the associated resources for a specific mesh
  89745. * @param mesh defines the source mesh
  89746. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89747. */
  89748. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89749. /**
  89750. * Apply current geometry to a given mesh
  89751. * @param mesh defines the mesh to apply geometry to
  89752. */
  89753. applyToMesh(mesh: Mesh): void;
  89754. private _updateExtend;
  89755. private _applyToMesh;
  89756. private notifyUpdate;
  89757. /**
  89758. * Load the geometry if it was flagged as delay loaded
  89759. * @param scene defines the hosting scene
  89760. * @param onLoaded defines a callback called when the geometry is loaded
  89761. */
  89762. load(scene: Scene, onLoaded?: () => void): void;
  89763. private _queueLoad;
  89764. /**
  89765. * Invert the geometry to move from a right handed system to a left handed one.
  89766. */
  89767. toLeftHanded(): void;
  89768. /** @hidden */
  89769. _resetPointsArrayCache(): void;
  89770. /** @hidden */
  89771. _generatePointsArray(): boolean;
  89772. /**
  89773. * Gets a value indicating if the geometry is disposed
  89774. * @returns true if the geometry was disposed
  89775. */
  89776. isDisposed(): boolean;
  89777. private _disposeVertexArrayObjects;
  89778. /**
  89779. * Free all associated resources
  89780. */
  89781. dispose(): void;
  89782. /**
  89783. * Clone the current geometry into a new geometry
  89784. * @param id defines the unique ID of the new geometry
  89785. * @returns a new geometry object
  89786. */
  89787. copy(id: string): Geometry;
  89788. /**
  89789. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89790. * @return a JSON representation of the current geometry data (without the vertices data)
  89791. */
  89792. serialize(): any;
  89793. private toNumberArray;
  89794. /**
  89795. * Serialize all vertices data into a JSON oject
  89796. * @returns a JSON representation of the current geometry data
  89797. */
  89798. serializeVerticeData(): any;
  89799. /**
  89800. * Extracts a clone of a mesh geometry
  89801. * @param mesh defines the source mesh
  89802. * @param id defines the unique ID of the new geometry object
  89803. * @returns the new geometry object
  89804. */
  89805. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89806. /**
  89807. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89808. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89809. * Be aware Math.random() could cause collisions, but:
  89810. * "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"
  89811. * @returns a string containing a new GUID
  89812. */
  89813. static RandomId(): string;
  89814. /** @hidden */
  89815. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89816. private static _CleanMatricesWeights;
  89817. /**
  89818. * Create a new geometry from persisted data (Using .babylon file format)
  89819. * @param parsedVertexData defines the persisted data
  89820. * @param scene defines the hosting scene
  89821. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89822. * @returns the new geometry object
  89823. */
  89824. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89825. }
  89826. }
  89827. declare module BABYLON {
  89828. /**
  89829. * Define an interface for all classes that will get and set the data on vertices
  89830. */
  89831. export interface IGetSetVerticesData {
  89832. /**
  89833. * Gets a boolean indicating if specific vertex data is present
  89834. * @param kind defines the vertex data kind to use
  89835. * @returns true is data kind is present
  89836. */
  89837. isVerticesDataPresent(kind: string): boolean;
  89838. /**
  89839. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89840. * @param kind defines the data kind (Position, normal, etc...)
  89841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89843. * @returns a float array containing vertex data
  89844. */
  89845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89846. /**
  89847. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89848. * @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.
  89849. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89850. * @returns the indices array or an empty array if the mesh has no geometry
  89851. */
  89852. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89853. /**
  89854. * Set specific vertex data
  89855. * @param kind defines the data kind (Position, normal, etc...)
  89856. * @param data defines the vertex data to use
  89857. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89858. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89859. */
  89860. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89861. /**
  89862. * Update a specific associated vertex buffer
  89863. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89864. * - VertexBuffer.PositionKind
  89865. * - VertexBuffer.UVKind
  89866. * - VertexBuffer.UV2Kind
  89867. * - VertexBuffer.UV3Kind
  89868. * - VertexBuffer.UV4Kind
  89869. * - VertexBuffer.UV5Kind
  89870. * - VertexBuffer.UV6Kind
  89871. * - VertexBuffer.ColorKind
  89872. * - VertexBuffer.MatricesIndicesKind
  89873. * - VertexBuffer.MatricesIndicesExtraKind
  89874. * - VertexBuffer.MatricesWeightsKind
  89875. * - VertexBuffer.MatricesWeightsExtraKind
  89876. * @param data defines the data source
  89877. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89878. * @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)
  89879. */
  89880. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89881. /**
  89882. * Creates a new index buffer
  89883. * @param indices defines the indices to store in the index buffer
  89884. * @param totalVertices defines the total number of vertices (could be null)
  89885. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89886. */
  89887. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89888. }
  89889. /**
  89890. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89891. */
  89892. export class VertexData {
  89893. /**
  89894. * Mesh side orientation : usually the external or front surface
  89895. */
  89896. static readonly FRONTSIDE: number;
  89897. /**
  89898. * Mesh side orientation : usually the internal or back surface
  89899. */
  89900. static readonly BACKSIDE: number;
  89901. /**
  89902. * Mesh side orientation : both internal and external or front and back surfaces
  89903. */
  89904. static readonly DOUBLESIDE: number;
  89905. /**
  89906. * Mesh side orientation : by default, `FRONTSIDE`
  89907. */
  89908. static readonly DEFAULTSIDE: number;
  89909. /**
  89910. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89911. */
  89912. positions: Nullable<FloatArray>;
  89913. /**
  89914. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89915. */
  89916. normals: Nullable<FloatArray>;
  89917. /**
  89918. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89919. */
  89920. tangents: Nullable<FloatArray>;
  89921. /**
  89922. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89923. */
  89924. uvs: Nullable<FloatArray>;
  89925. /**
  89926. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89927. */
  89928. uvs2: Nullable<FloatArray>;
  89929. /**
  89930. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89931. */
  89932. uvs3: Nullable<FloatArray>;
  89933. /**
  89934. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89935. */
  89936. uvs4: Nullable<FloatArray>;
  89937. /**
  89938. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89939. */
  89940. uvs5: Nullable<FloatArray>;
  89941. /**
  89942. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89943. */
  89944. uvs6: Nullable<FloatArray>;
  89945. /**
  89946. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89947. */
  89948. colors: Nullable<FloatArray>;
  89949. /**
  89950. * 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).
  89951. */
  89952. matricesIndices: Nullable<FloatArray>;
  89953. /**
  89954. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89955. */
  89956. matricesWeights: Nullable<FloatArray>;
  89957. /**
  89958. * An array extending the number of possible indices
  89959. */
  89960. matricesIndicesExtra: Nullable<FloatArray>;
  89961. /**
  89962. * An array extending the number of possible weights when the number of indices is extended
  89963. */
  89964. matricesWeightsExtra: Nullable<FloatArray>;
  89965. /**
  89966. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89967. */
  89968. indices: Nullable<IndicesArray>;
  89969. /**
  89970. * Uses the passed data array to set the set the values for the specified kind of data
  89971. * @param data a linear array of floating numbers
  89972. * @param kind the type of data that is being set, eg positions, colors etc
  89973. */
  89974. set(data: FloatArray, kind: string): void;
  89975. /**
  89976. * Associates the vertexData to the passed Mesh.
  89977. * Sets it as updatable or not (default `false`)
  89978. * @param mesh the mesh the vertexData is applied to
  89979. * @param updatable when used and having the value true allows new data to update the vertexData
  89980. * @returns the VertexData
  89981. */
  89982. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89983. /**
  89984. * Associates the vertexData to the passed Geometry.
  89985. * Sets it as updatable or not (default `false`)
  89986. * @param geometry the geometry the vertexData is applied to
  89987. * @param updatable when used and having the value true allows new data to update the vertexData
  89988. * @returns VertexData
  89989. */
  89990. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89991. /**
  89992. * Updates the associated mesh
  89993. * @param mesh the mesh to be updated
  89994. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89995. * @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
  89996. * @returns VertexData
  89997. */
  89998. updateMesh(mesh: Mesh): VertexData;
  89999. /**
  90000. * Updates the associated geometry
  90001. * @param geometry the geometry to be updated
  90002. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90003. * @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
  90004. * @returns VertexData.
  90005. */
  90006. updateGeometry(geometry: Geometry): VertexData;
  90007. private _applyTo;
  90008. private _update;
  90009. /**
  90010. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90011. * @param matrix the transforming matrix
  90012. * @returns the VertexData
  90013. */
  90014. transform(matrix: Matrix): VertexData;
  90015. /**
  90016. * Merges the passed VertexData into the current one
  90017. * @param other the VertexData to be merged into the current one
  90018. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90019. * @returns the modified VertexData
  90020. */
  90021. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90022. private _mergeElement;
  90023. private _validate;
  90024. /**
  90025. * Serializes the VertexData
  90026. * @returns a serialized object
  90027. */
  90028. serialize(): any;
  90029. /**
  90030. * Extracts the vertexData from a mesh
  90031. * @param mesh the mesh from which to extract the VertexData
  90032. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90033. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90034. * @returns the object VertexData associated to the passed mesh
  90035. */
  90036. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90037. /**
  90038. * Extracts the vertexData from the geometry
  90039. * @param geometry the geometry from which to extract the VertexData
  90040. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90041. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90042. * @returns the object VertexData associated to the passed mesh
  90043. */
  90044. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90045. private static _ExtractFrom;
  90046. /**
  90047. * Creates the VertexData for a Ribbon
  90048. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90049. * * pathArray array of paths, each of which an array of successive Vector3
  90050. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90051. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90052. * * 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
  90053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90054. * * 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)
  90055. * * 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)
  90056. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90057. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90058. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90059. * @returns the VertexData of the ribbon
  90060. */
  90061. static CreateRibbon(options: {
  90062. pathArray: Vector3[][];
  90063. closeArray?: boolean;
  90064. closePath?: boolean;
  90065. offset?: number;
  90066. sideOrientation?: number;
  90067. frontUVs?: Vector4;
  90068. backUVs?: Vector4;
  90069. invertUV?: boolean;
  90070. uvs?: Vector2[];
  90071. colors?: Color4[];
  90072. }): VertexData;
  90073. /**
  90074. * Creates the VertexData for a box
  90075. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90076. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90077. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90078. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90079. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90080. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90081. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90083. * * 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)
  90084. * * 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)
  90085. * @returns the VertexData of the box
  90086. */
  90087. static CreateBox(options: {
  90088. size?: number;
  90089. width?: number;
  90090. height?: number;
  90091. depth?: number;
  90092. faceUV?: Vector4[];
  90093. faceColors?: Color4[];
  90094. sideOrientation?: number;
  90095. frontUVs?: Vector4;
  90096. backUVs?: Vector4;
  90097. }): VertexData;
  90098. /**
  90099. * Creates the VertexData for a tiled box
  90100. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90101. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90102. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90103. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90105. * @returns the VertexData of the box
  90106. */
  90107. static CreateTiledBox(options: {
  90108. pattern?: number;
  90109. width?: number;
  90110. height?: number;
  90111. depth?: number;
  90112. tileSize?: number;
  90113. tileWidth?: number;
  90114. tileHeight?: number;
  90115. alignHorizontal?: number;
  90116. alignVertical?: number;
  90117. faceUV?: Vector4[];
  90118. faceColors?: Color4[];
  90119. sideOrientation?: number;
  90120. }): VertexData;
  90121. /**
  90122. * Creates the VertexData for a tiled plane
  90123. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90124. * * pattern a limited pattern arrangement depending on the number
  90125. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90126. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90127. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90129. * * 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)
  90130. * * 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)
  90131. * @returns the VertexData of the tiled plane
  90132. */
  90133. static CreateTiledPlane(options: {
  90134. pattern?: number;
  90135. tileSize?: number;
  90136. tileWidth?: number;
  90137. tileHeight?: number;
  90138. size?: number;
  90139. width?: number;
  90140. height?: number;
  90141. alignHorizontal?: number;
  90142. alignVertical?: number;
  90143. sideOrientation?: number;
  90144. frontUVs?: Vector4;
  90145. backUVs?: Vector4;
  90146. }): VertexData;
  90147. /**
  90148. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90150. * * segments sets the number of horizontal strips optional, default 32
  90151. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90152. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90153. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90154. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90155. * * 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
  90156. * * 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
  90157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90158. * * 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)
  90159. * * 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)
  90160. * @returns the VertexData of the ellipsoid
  90161. */
  90162. static CreateSphere(options: {
  90163. segments?: number;
  90164. diameter?: number;
  90165. diameterX?: number;
  90166. diameterY?: number;
  90167. diameterZ?: number;
  90168. arc?: number;
  90169. slice?: number;
  90170. sideOrientation?: number;
  90171. frontUVs?: Vector4;
  90172. backUVs?: Vector4;
  90173. }): VertexData;
  90174. /**
  90175. * Creates the VertexData for a cylinder, cone or prism
  90176. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90177. * * height sets the height (y direction) of the cylinder, optional, default 2
  90178. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90179. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90180. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90181. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90182. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90183. * * 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
  90184. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90185. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90186. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90187. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90189. * * 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)
  90190. * * 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)
  90191. * @returns the VertexData of the cylinder, cone or prism
  90192. */
  90193. static CreateCylinder(options: {
  90194. height?: number;
  90195. diameterTop?: number;
  90196. diameterBottom?: number;
  90197. diameter?: number;
  90198. tessellation?: number;
  90199. subdivisions?: number;
  90200. arc?: number;
  90201. faceColors?: Color4[];
  90202. faceUV?: Vector4[];
  90203. hasRings?: boolean;
  90204. enclose?: boolean;
  90205. sideOrientation?: number;
  90206. frontUVs?: Vector4;
  90207. backUVs?: Vector4;
  90208. }): VertexData;
  90209. /**
  90210. * Creates the VertexData for a torus
  90211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90212. * * diameter the diameter of the torus, optional default 1
  90213. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90214. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90216. * * 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)
  90217. * * 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)
  90218. * @returns the VertexData of the torus
  90219. */
  90220. static CreateTorus(options: {
  90221. diameter?: number;
  90222. thickness?: number;
  90223. tessellation?: number;
  90224. sideOrientation?: number;
  90225. frontUVs?: Vector4;
  90226. backUVs?: Vector4;
  90227. }): VertexData;
  90228. /**
  90229. * Creates the VertexData of the LineSystem
  90230. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90231. * - lines an array of lines, each line being an array of successive Vector3
  90232. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90233. * @returns the VertexData of the LineSystem
  90234. */
  90235. static CreateLineSystem(options: {
  90236. lines: Vector3[][];
  90237. colors?: Nullable<Color4[][]>;
  90238. }): VertexData;
  90239. /**
  90240. * Create the VertexData for a DashedLines
  90241. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90242. * - points an array successive Vector3
  90243. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90244. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90245. * - dashNb the intended total number of dashes, optional, default 200
  90246. * @returns the VertexData for the DashedLines
  90247. */
  90248. static CreateDashedLines(options: {
  90249. points: Vector3[];
  90250. dashSize?: number;
  90251. gapSize?: number;
  90252. dashNb?: number;
  90253. }): VertexData;
  90254. /**
  90255. * Creates the VertexData for a Ground
  90256. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90257. * - width the width (x direction) of the ground, optional, default 1
  90258. * - height the height (z direction) of the ground, optional, default 1
  90259. * - subdivisions the number of subdivisions per side, optional, default 1
  90260. * @returns the VertexData of the Ground
  90261. */
  90262. static CreateGround(options: {
  90263. width?: number;
  90264. height?: number;
  90265. subdivisions?: number;
  90266. subdivisionsX?: number;
  90267. subdivisionsY?: number;
  90268. }): VertexData;
  90269. /**
  90270. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90271. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90272. * * xmin the ground minimum X coordinate, optional, default -1
  90273. * * zmin the ground minimum Z coordinate, optional, default -1
  90274. * * xmax the ground maximum X coordinate, optional, default 1
  90275. * * zmax the ground maximum Z coordinate, optional, default 1
  90276. * * 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}
  90277. * * 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}
  90278. * @returns the VertexData of the TiledGround
  90279. */
  90280. static CreateTiledGround(options: {
  90281. xmin: number;
  90282. zmin: number;
  90283. xmax: number;
  90284. zmax: number;
  90285. subdivisions?: {
  90286. w: number;
  90287. h: number;
  90288. };
  90289. precision?: {
  90290. w: number;
  90291. h: number;
  90292. };
  90293. }): VertexData;
  90294. /**
  90295. * Creates the VertexData of the Ground designed from a heightmap
  90296. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90297. * * width the width (x direction) of the ground
  90298. * * height the height (z direction) of the ground
  90299. * * subdivisions the number of subdivisions per side
  90300. * * minHeight the minimum altitude on the ground, optional, default 0
  90301. * * maxHeight the maximum altitude on the ground, optional default 1
  90302. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90303. * * buffer the array holding the image color data
  90304. * * bufferWidth the width of image
  90305. * * bufferHeight the height of image
  90306. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90307. * @returns the VertexData of the Ground designed from a heightmap
  90308. */
  90309. static CreateGroundFromHeightMap(options: {
  90310. width: number;
  90311. height: number;
  90312. subdivisions: number;
  90313. minHeight: number;
  90314. maxHeight: number;
  90315. colorFilter: Color3;
  90316. buffer: Uint8Array;
  90317. bufferWidth: number;
  90318. bufferHeight: number;
  90319. alphaFilter: number;
  90320. }): VertexData;
  90321. /**
  90322. * Creates the VertexData for a Plane
  90323. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90324. * * size sets the width and height of the plane to the value of size, optional default 1
  90325. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90326. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90327. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90328. * * 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)
  90329. * * 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)
  90330. * @returns the VertexData of the box
  90331. */
  90332. static CreatePlane(options: {
  90333. size?: number;
  90334. width?: number;
  90335. height?: number;
  90336. sideOrientation?: number;
  90337. frontUVs?: Vector4;
  90338. backUVs?: Vector4;
  90339. }): VertexData;
  90340. /**
  90341. * Creates the VertexData of the Disc or regular Polygon
  90342. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90343. * * radius the radius of the disc, optional default 0.5
  90344. * * tessellation the number of polygon sides, optional, default 64
  90345. * * 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
  90346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90347. * * 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)
  90348. * * 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)
  90349. * @returns the VertexData of the box
  90350. */
  90351. static CreateDisc(options: {
  90352. radius?: number;
  90353. tessellation?: number;
  90354. arc?: number;
  90355. sideOrientation?: number;
  90356. frontUVs?: Vector4;
  90357. backUVs?: Vector4;
  90358. }): VertexData;
  90359. /**
  90360. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90361. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90362. * @param polygon a mesh built from polygonTriangulation.build()
  90363. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90364. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90365. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90366. * @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)
  90367. * @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)
  90368. * @returns the VertexData of the Polygon
  90369. */
  90370. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90371. /**
  90372. * Creates the VertexData of the IcoSphere
  90373. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90374. * * radius the radius of the IcoSphere, optional default 1
  90375. * * radiusX allows stretching in the x direction, optional, default radius
  90376. * * radiusY allows stretching in the y direction, optional, default radius
  90377. * * radiusZ allows stretching in the z direction, optional, default radius
  90378. * * flat when true creates a flat shaded mesh, optional, default true
  90379. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90381. * * 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)
  90382. * * 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)
  90383. * @returns the VertexData of the IcoSphere
  90384. */
  90385. static CreateIcoSphere(options: {
  90386. radius?: number;
  90387. radiusX?: number;
  90388. radiusY?: number;
  90389. radiusZ?: number;
  90390. flat?: boolean;
  90391. subdivisions?: number;
  90392. sideOrientation?: number;
  90393. frontUVs?: Vector4;
  90394. backUVs?: Vector4;
  90395. }): VertexData;
  90396. /**
  90397. * Creates the VertexData for a Polyhedron
  90398. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90399. * * type provided types are:
  90400. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90401. * * 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)
  90402. * * size the size of the IcoSphere, optional default 1
  90403. * * sizeX allows stretching in the x direction, optional, default size
  90404. * * sizeY allows stretching in the y direction, optional, default size
  90405. * * sizeZ allows stretching in the z direction, optional, default size
  90406. * * 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
  90407. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90408. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90409. * * flat when true creates a flat shaded mesh, optional, default true
  90410. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90412. * * 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)
  90413. * * 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)
  90414. * @returns the VertexData of the Polyhedron
  90415. */
  90416. static CreatePolyhedron(options: {
  90417. type?: number;
  90418. size?: number;
  90419. sizeX?: number;
  90420. sizeY?: number;
  90421. sizeZ?: number;
  90422. custom?: any;
  90423. faceUV?: Vector4[];
  90424. faceColors?: Color4[];
  90425. flat?: boolean;
  90426. sideOrientation?: number;
  90427. frontUVs?: Vector4;
  90428. backUVs?: Vector4;
  90429. }): VertexData;
  90430. /**
  90431. * Creates the VertexData for a TorusKnot
  90432. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90433. * * radius the radius of the torus knot, optional, default 2
  90434. * * tube the thickness of the tube, optional, default 0.5
  90435. * * radialSegments the number of sides on each tube segments, optional, default 32
  90436. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90437. * * p the number of windings around the z axis, optional, default 2
  90438. * * q the number of windings around the x axis, optional, default 3
  90439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90440. * * 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)
  90441. * * 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)
  90442. * @returns the VertexData of the Torus Knot
  90443. */
  90444. static CreateTorusKnot(options: {
  90445. radius?: number;
  90446. tube?: number;
  90447. radialSegments?: number;
  90448. tubularSegments?: number;
  90449. p?: number;
  90450. q?: number;
  90451. sideOrientation?: number;
  90452. frontUVs?: Vector4;
  90453. backUVs?: Vector4;
  90454. }): VertexData;
  90455. /**
  90456. * Compute normals for given positions and indices
  90457. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90458. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90459. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90460. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90461. * * facetNormals : optional array of facet normals (vector3)
  90462. * * facetPositions : optional array of facet positions (vector3)
  90463. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90464. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90465. * * bInfo : optional bounding info, required for facetPartitioning computation
  90466. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90467. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90468. * * useRightHandedSystem: optional boolean to for right handed system computation
  90469. * * depthSort : optional boolean to enable the facet depth sort computation
  90470. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90471. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90472. */
  90473. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90474. facetNormals?: any;
  90475. facetPositions?: any;
  90476. facetPartitioning?: any;
  90477. ratio?: number;
  90478. bInfo?: any;
  90479. bbSize?: Vector3;
  90480. subDiv?: any;
  90481. useRightHandedSystem?: boolean;
  90482. depthSort?: boolean;
  90483. distanceTo?: Vector3;
  90484. depthSortedFacets?: any;
  90485. }): void;
  90486. /** @hidden */
  90487. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90488. /**
  90489. * Applies VertexData created from the imported parameters to the geometry
  90490. * @param parsedVertexData the parsed data from an imported file
  90491. * @param geometry the geometry to apply the VertexData to
  90492. */
  90493. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90494. }
  90495. }
  90496. declare module BABYLON {
  90497. /**
  90498. * Defines a target to use with MorphTargetManager
  90499. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90500. */
  90501. export class MorphTarget implements IAnimatable {
  90502. /** defines the name of the target */
  90503. name: string;
  90504. /**
  90505. * Gets or sets the list of animations
  90506. */
  90507. animations: Animation[];
  90508. private _scene;
  90509. private _positions;
  90510. private _normals;
  90511. private _tangents;
  90512. private _uvs;
  90513. private _influence;
  90514. private _uniqueId;
  90515. /**
  90516. * Observable raised when the influence changes
  90517. */
  90518. onInfluenceChanged: Observable<boolean>;
  90519. /** @hidden */
  90520. _onDataLayoutChanged: Observable<void>;
  90521. /**
  90522. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90523. */
  90524. influence: number;
  90525. /**
  90526. * Gets or sets the id of the morph Target
  90527. */
  90528. id: string;
  90529. private _animationPropertiesOverride;
  90530. /**
  90531. * Gets or sets the animation properties override
  90532. */
  90533. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90534. /**
  90535. * Creates a new MorphTarget
  90536. * @param name defines the name of the target
  90537. * @param influence defines the influence to use
  90538. * @param scene defines the scene the morphtarget belongs to
  90539. */
  90540. constructor(
  90541. /** defines the name of the target */
  90542. name: string, influence?: number, scene?: Nullable<Scene>);
  90543. /**
  90544. * Gets the unique ID of this manager
  90545. */
  90546. readonly uniqueId: number;
  90547. /**
  90548. * Gets a boolean defining if the target contains position data
  90549. */
  90550. readonly hasPositions: boolean;
  90551. /**
  90552. * Gets a boolean defining if the target contains normal data
  90553. */
  90554. readonly hasNormals: boolean;
  90555. /**
  90556. * Gets a boolean defining if the target contains tangent data
  90557. */
  90558. readonly hasTangents: boolean;
  90559. /**
  90560. * Gets a boolean defining if the target contains texture coordinates data
  90561. */
  90562. readonly hasUVs: boolean;
  90563. /**
  90564. * Affects position data to this target
  90565. * @param data defines the position data to use
  90566. */
  90567. setPositions(data: Nullable<FloatArray>): void;
  90568. /**
  90569. * Gets the position data stored in this target
  90570. * @returns a FloatArray containing the position data (or null if not present)
  90571. */
  90572. getPositions(): Nullable<FloatArray>;
  90573. /**
  90574. * Affects normal data to this target
  90575. * @param data defines the normal data to use
  90576. */
  90577. setNormals(data: Nullable<FloatArray>): void;
  90578. /**
  90579. * Gets the normal data stored in this target
  90580. * @returns a FloatArray containing the normal data (or null if not present)
  90581. */
  90582. getNormals(): Nullable<FloatArray>;
  90583. /**
  90584. * Affects tangent data to this target
  90585. * @param data defines the tangent data to use
  90586. */
  90587. setTangents(data: Nullable<FloatArray>): void;
  90588. /**
  90589. * Gets the tangent data stored in this target
  90590. * @returns a FloatArray containing the tangent data (or null if not present)
  90591. */
  90592. getTangents(): Nullable<FloatArray>;
  90593. /**
  90594. * Affects texture coordinates data to this target
  90595. * @param data defines the texture coordinates data to use
  90596. */
  90597. setUVs(data: Nullable<FloatArray>): void;
  90598. /**
  90599. * Gets the texture coordinates data stored in this target
  90600. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90601. */
  90602. getUVs(): Nullable<FloatArray>;
  90603. /**
  90604. * Clone the current target
  90605. * @returns a new MorphTarget
  90606. */
  90607. clone(): MorphTarget;
  90608. /**
  90609. * Serializes the current target into a Serialization object
  90610. * @returns the serialized object
  90611. */
  90612. serialize(): any;
  90613. /**
  90614. * Returns the string "MorphTarget"
  90615. * @returns "MorphTarget"
  90616. */
  90617. getClassName(): string;
  90618. /**
  90619. * Creates a new target from serialized data
  90620. * @param serializationObject defines the serialized data to use
  90621. * @returns a new MorphTarget
  90622. */
  90623. static Parse(serializationObject: any): MorphTarget;
  90624. /**
  90625. * Creates a MorphTarget from mesh data
  90626. * @param mesh defines the source mesh
  90627. * @param name defines the name to use for the new target
  90628. * @param influence defines the influence to attach to the target
  90629. * @returns a new MorphTarget
  90630. */
  90631. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90632. }
  90633. }
  90634. declare module BABYLON {
  90635. /**
  90636. * This class is used to deform meshes using morphing between different targets
  90637. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90638. */
  90639. export class MorphTargetManager {
  90640. private _targets;
  90641. private _targetInfluenceChangedObservers;
  90642. private _targetDataLayoutChangedObservers;
  90643. private _activeTargets;
  90644. private _scene;
  90645. private _influences;
  90646. private _supportsNormals;
  90647. private _supportsTangents;
  90648. private _supportsUVs;
  90649. private _vertexCount;
  90650. private _uniqueId;
  90651. private _tempInfluences;
  90652. /**
  90653. * Gets or sets a boolean indicating if normals must be morphed
  90654. */
  90655. enableNormalMorphing: boolean;
  90656. /**
  90657. * Gets or sets a boolean indicating if tangents must be morphed
  90658. */
  90659. enableTangentMorphing: boolean;
  90660. /**
  90661. * Gets or sets a boolean indicating if UV must be morphed
  90662. */
  90663. enableUVMorphing: boolean;
  90664. /**
  90665. * Creates a new MorphTargetManager
  90666. * @param scene defines the current scene
  90667. */
  90668. constructor(scene?: Nullable<Scene>);
  90669. /**
  90670. * Gets the unique ID of this manager
  90671. */
  90672. readonly uniqueId: number;
  90673. /**
  90674. * Gets the number of vertices handled by this manager
  90675. */
  90676. readonly vertexCount: number;
  90677. /**
  90678. * Gets a boolean indicating if this manager supports morphing of normals
  90679. */
  90680. readonly supportsNormals: boolean;
  90681. /**
  90682. * Gets a boolean indicating if this manager supports morphing of tangents
  90683. */
  90684. readonly supportsTangents: boolean;
  90685. /**
  90686. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90687. */
  90688. readonly supportsUVs: boolean;
  90689. /**
  90690. * Gets the number of targets stored in this manager
  90691. */
  90692. readonly numTargets: number;
  90693. /**
  90694. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90695. */
  90696. readonly numInfluencers: number;
  90697. /**
  90698. * Gets the list of influences (one per target)
  90699. */
  90700. readonly influences: Float32Array;
  90701. /**
  90702. * Gets the active target at specified index. An active target is a target with an influence > 0
  90703. * @param index defines the index to check
  90704. * @returns the requested target
  90705. */
  90706. getActiveTarget(index: number): MorphTarget;
  90707. /**
  90708. * Gets the target at specified index
  90709. * @param index defines the index to check
  90710. * @returns the requested target
  90711. */
  90712. getTarget(index: number): MorphTarget;
  90713. /**
  90714. * Add a new target to this manager
  90715. * @param target defines the target to add
  90716. */
  90717. addTarget(target: MorphTarget): void;
  90718. /**
  90719. * Removes a target from the manager
  90720. * @param target defines the target to remove
  90721. */
  90722. removeTarget(target: MorphTarget): void;
  90723. /**
  90724. * Clone the current manager
  90725. * @returns a new MorphTargetManager
  90726. */
  90727. clone(): MorphTargetManager;
  90728. /**
  90729. * Serializes the current manager into a Serialization object
  90730. * @returns the serialized object
  90731. */
  90732. serialize(): any;
  90733. private _syncActiveTargets;
  90734. /**
  90735. * Syncrhonize the targets with all the meshes using this morph target manager
  90736. */
  90737. synchronize(): void;
  90738. /**
  90739. * Creates a new MorphTargetManager from serialized data
  90740. * @param serializationObject defines the serialized data
  90741. * @param scene defines the hosting scene
  90742. * @returns the new MorphTargetManager
  90743. */
  90744. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90745. }
  90746. }
  90747. declare module BABYLON {
  90748. /**
  90749. * Class used to represent a specific level of detail of a mesh
  90750. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90751. */
  90752. export class MeshLODLevel {
  90753. /** Defines the distance where this level should start being displayed */
  90754. distance: number;
  90755. /** Defines the mesh to use to render this level */
  90756. mesh: Nullable<Mesh>;
  90757. /**
  90758. * Creates a new LOD level
  90759. * @param distance defines the distance where this level should star being displayed
  90760. * @param mesh defines the mesh to use to render this level
  90761. */
  90762. constructor(
  90763. /** Defines the distance where this level should start being displayed */
  90764. distance: number,
  90765. /** Defines the mesh to use to render this level */
  90766. mesh: Nullable<Mesh>);
  90767. }
  90768. }
  90769. declare module BABYLON {
  90770. /**
  90771. * Mesh representing the gorund
  90772. */
  90773. export class GroundMesh extends Mesh {
  90774. /** If octree should be generated */
  90775. generateOctree: boolean;
  90776. private _heightQuads;
  90777. /** @hidden */
  90778. _subdivisionsX: number;
  90779. /** @hidden */
  90780. _subdivisionsY: number;
  90781. /** @hidden */
  90782. _width: number;
  90783. /** @hidden */
  90784. _height: number;
  90785. /** @hidden */
  90786. _minX: number;
  90787. /** @hidden */
  90788. _maxX: number;
  90789. /** @hidden */
  90790. _minZ: number;
  90791. /** @hidden */
  90792. _maxZ: number;
  90793. constructor(name: string, scene: Scene);
  90794. /**
  90795. * "GroundMesh"
  90796. * @returns "GroundMesh"
  90797. */
  90798. getClassName(): string;
  90799. /**
  90800. * The minimum of x and y subdivisions
  90801. */
  90802. readonly subdivisions: number;
  90803. /**
  90804. * X subdivisions
  90805. */
  90806. readonly subdivisionsX: number;
  90807. /**
  90808. * Y subdivisions
  90809. */
  90810. readonly subdivisionsY: number;
  90811. /**
  90812. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90813. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90814. * @param chunksCount the number of subdivisions for x and y
  90815. * @param octreeBlocksSize (Default: 32)
  90816. */
  90817. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90818. /**
  90819. * Returns a height (y) value in the Worl system :
  90820. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90821. * @param x x coordinate
  90822. * @param z z coordinate
  90823. * @returns the ground y position if (x, z) are outside the ground surface.
  90824. */
  90825. getHeightAtCoordinates(x: number, z: number): number;
  90826. /**
  90827. * Returns a normalized vector (Vector3) orthogonal to the ground
  90828. * at the ground coordinates (x, z) expressed in the World system.
  90829. * @param x x coordinate
  90830. * @param z z coordinate
  90831. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90832. */
  90833. getNormalAtCoordinates(x: number, z: number): Vector3;
  90834. /**
  90835. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90836. * at the ground coordinates (x, z) expressed in the World system.
  90837. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90838. * @param x x coordinate
  90839. * @param z z coordinate
  90840. * @param ref vector to store the result
  90841. * @returns the GroundMesh.
  90842. */
  90843. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90844. /**
  90845. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90846. * if the ground has been updated.
  90847. * This can be used in the render loop.
  90848. * @returns the GroundMesh.
  90849. */
  90850. updateCoordinateHeights(): GroundMesh;
  90851. private _getFacetAt;
  90852. private _initHeightQuads;
  90853. private _computeHeightQuads;
  90854. /**
  90855. * Serializes this ground mesh
  90856. * @param serializationObject object to write serialization to
  90857. */
  90858. serialize(serializationObject: any): void;
  90859. /**
  90860. * Parses a serialized ground mesh
  90861. * @param parsedMesh the serialized mesh
  90862. * @param scene the scene to create the ground mesh in
  90863. * @returns the created ground mesh
  90864. */
  90865. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90866. }
  90867. }
  90868. declare module BABYLON {
  90869. /**
  90870. * Interface for Physics-Joint data
  90871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90872. */
  90873. export interface PhysicsJointData {
  90874. /**
  90875. * The main pivot of the joint
  90876. */
  90877. mainPivot?: Vector3;
  90878. /**
  90879. * The connected pivot of the joint
  90880. */
  90881. connectedPivot?: Vector3;
  90882. /**
  90883. * The main axis of the joint
  90884. */
  90885. mainAxis?: Vector3;
  90886. /**
  90887. * The connected axis of the joint
  90888. */
  90889. connectedAxis?: Vector3;
  90890. /**
  90891. * The collision of the joint
  90892. */
  90893. collision?: boolean;
  90894. /**
  90895. * Native Oimo/Cannon/Energy data
  90896. */
  90897. nativeParams?: any;
  90898. }
  90899. /**
  90900. * This is a holder class for the physics joint created by the physics plugin
  90901. * It holds a set of functions to control the underlying joint
  90902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90903. */
  90904. export class PhysicsJoint {
  90905. /**
  90906. * The type of the physics joint
  90907. */
  90908. type: number;
  90909. /**
  90910. * The data for the physics joint
  90911. */
  90912. jointData: PhysicsJointData;
  90913. private _physicsJoint;
  90914. protected _physicsPlugin: IPhysicsEnginePlugin;
  90915. /**
  90916. * Initializes the physics joint
  90917. * @param type The type of the physics joint
  90918. * @param jointData The data for the physics joint
  90919. */
  90920. constructor(
  90921. /**
  90922. * The type of the physics joint
  90923. */
  90924. type: number,
  90925. /**
  90926. * The data for the physics joint
  90927. */
  90928. jointData: PhysicsJointData);
  90929. /**
  90930. * Gets the physics joint
  90931. */
  90932. /**
  90933. * Sets the physics joint
  90934. */
  90935. physicsJoint: any;
  90936. /**
  90937. * Sets the physics plugin
  90938. */
  90939. physicsPlugin: IPhysicsEnginePlugin;
  90940. /**
  90941. * Execute a function that is physics-plugin specific.
  90942. * @param {Function} func the function that will be executed.
  90943. * It accepts two parameters: the physics world and the physics joint
  90944. */
  90945. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90946. /**
  90947. * Distance-Joint type
  90948. */
  90949. static DistanceJoint: number;
  90950. /**
  90951. * Hinge-Joint type
  90952. */
  90953. static HingeJoint: number;
  90954. /**
  90955. * Ball-and-Socket joint type
  90956. */
  90957. static BallAndSocketJoint: number;
  90958. /**
  90959. * Wheel-Joint type
  90960. */
  90961. static WheelJoint: number;
  90962. /**
  90963. * Slider-Joint type
  90964. */
  90965. static SliderJoint: number;
  90966. /**
  90967. * Prismatic-Joint type
  90968. */
  90969. static PrismaticJoint: number;
  90970. /**
  90971. * Universal-Joint type
  90972. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90973. */
  90974. static UniversalJoint: number;
  90975. /**
  90976. * Hinge-Joint 2 type
  90977. */
  90978. static Hinge2Joint: number;
  90979. /**
  90980. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90981. */
  90982. static PointToPointJoint: number;
  90983. /**
  90984. * Spring-Joint type
  90985. */
  90986. static SpringJoint: number;
  90987. /**
  90988. * Lock-Joint type
  90989. */
  90990. static LockJoint: number;
  90991. }
  90992. /**
  90993. * A class representing a physics distance joint
  90994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90995. */
  90996. export class DistanceJoint extends PhysicsJoint {
  90997. /**
  90998. *
  90999. * @param jointData The data for the Distance-Joint
  91000. */
  91001. constructor(jointData: DistanceJointData);
  91002. /**
  91003. * Update the predefined distance.
  91004. * @param maxDistance The maximum preferred distance
  91005. * @param minDistance The minimum preferred distance
  91006. */
  91007. updateDistance(maxDistance: number, minDistance?: number): void;
  91008. }
  91009. /**
  91010. * Represents a Motor-Enabled Joint
  91011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91012. */
  91013. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91014. /**
  91015. * Initializes the Motor-Enabled Joint
  91016. * @param type The type of the joint
  91017. * @param jointData The physica joint data for the joint
  91018. */
  91019. constructor(type: number, jointData: PhysicsJointData);
  91020. /**
  91021. * Set the motor values.
  91022. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91023. * @param force the force to apply
  91024. * @param maxForce max force for this motor.
  91025. */
  91026. setMotor(force?: number, maxForce?: number): void;
  91027. /**
  91028. * Set the motor's limits.
  91029. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91030. * @param upperLimit The upper limit of the motor
  91031. * @param lowerLimit The lower limit of the motor
  91032. */
  91033. setLimit(upperLimit: number, lowerLimit?: number): void;
  91034. }
  91035. /**
  91036. * This class represents a single physics Hinge-Joint
  91037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91038. */
  91039. export class HingeJoint extends MotorEnabledJoint {
  91040. /**
  91041. * Initializes the Hinge-Joint
  91042. * @param jointData The joint data for the Hinge-Joint
  91043. */
  91044. constructor(jointData: PhysicsJointData);
  91045. /**
  91046. * Set the motor values.
  91047. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91048. * @param {number} force the force to apply
  91049. * @param {number} maxForce max force for this motor.
  91050. */
  91051. setMotor(force?: number, maxForce?: number): void;
  91052. /**
  91053. * Set the motor's limits.
  91054. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91055. * @param upperLimit The upper limit of the motor
  91056. * @param lowerLimit The lower limit of the motor
  91057. */
  91058. setLimit(upperLimit: number, lowerLimit?: number): void;
  91059. }
  91060. /**
  91061. * This class represents a dual hinge physics joint (same as wheel joint)
  91062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91063. */
  91064. export class Hinge2Joint extends MotorEnabledJoint {
  91065. /**
  91066. * Initializes the Hinge2-Joint
  91067. * @param jointData The joint data for the Hinge2-Joint
  91068. */
  91069. constructor(jointData: PhysicsJointData);
  91070. /**
  91071. * Set the motor values.
  91072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91073. * @param {number} targetSpeed the speed the motor is to reach
  91074. * @param {number} maxForce max force for this motor.
  91075. * @param {motorIndex} the motor's index, 0 or 1.
  91076. */
  91077. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91078. /**
  91079. * Set the motor limits.
  91080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91081. * @param {number} upperLimit the upper limit
  91082. * @param {number} lowerLimit lower limit
  91083. * @param {motorIndex} the motor's index, 0 or 1.
  91084. */
  91085. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91086. }
  91087. /**
  91088. * Interface for a motor enabled joint
  91089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91090. */
  91091. export interface IMotorEnabledJoint {
  91092. /**
  91093. * Physics joint
  91094. */
  91095. physicsJoint: any;
  91096. /**
  91097. * Sets the motor of the motor-enabled joint
  91098. * @param force The force of the motor
  91099. * @param maxForce The maximum force of the motor
  91100. * @param motorIndex The index of the motor
  91101. */
  91102. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91103. /**
  91104. * Sets the limit of the motor
  91105. * @param upperLimit The upper limit of the motor
  91106. * @param lowerLimit The lower limit of the motor
  91107. * @param motorIndex The index of the motor
  91108. */
  91109. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91110. }
  91111. /**
  91112. * Joint data for a Distance-Joint
  91113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91114. */
  91115. export interface DistanceJointData extends PhysicsJointData {
  91116. /**
  91117. * Max distance the 2 joint objects can be apart
  91118. */
  91119. maxDistance: number;
  91120. }
  91121. /**
  91122. * Joint data from a spring joint
  91123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91124. */
  91125. export interface SpringJointData extends PhysicsJointData {
  91126. /**
  91127. * Length of the spring
  91128. */
  91129. length: number;
  91130. /**
  91131. * Stiffness of the spring
  91132. */
  91133. stiffness: number;
  91134. /**
  91135. * Damping of the spring
  91136. */
  91137. damping: number;
  91138. /** this callback will be called when applying the force to the impostors. */
  91139. forceApplicationCallback: () => void;
  91140. }
  91141. }
  91142. declare module BABYLON {
  91143. /**
  91144. * Holds the data for the raycast result
  91145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91146. */
  91147. export class PhysicsRaycastResult {
  91148. private _hasHit;
  91149. private _hitDistance;
  91150. private _hitNormalWorld;
  91151. private _hitPointWorld;
  91152. private _rayFromWorld;
  91153. private _rayToWorld;
  91154. /**
  91155. * Gets if there was a hit
  91156. */
  91157. readonly hasHit: boolean;
  91158. /**
  91159. * Gets the distance from the hit
  91160. */
  91161. readonly hitDistance: number;
  91162. /**
  91163. * Gets the hit normal/direction in the world
  91164. */
  91165. readonly hitNormalWorld: Vector3;
  91166. /**
  91167. * Gets the hit point in the world
  91168. */
  91169. readonly hitPointWorld: Vector3;
  91170. /**
  91171. * Gets the ray "start point" of the ray in the world
  91172. */
  91173. readonly rayFromWorld: Vector3;
  91174. /**
  91175. * Gets the ray "end point" of the ray in the world
  91176. */
  91177. readonly rayToWorld: Vector3;
  91178. /**
  91179. * Sets the hit data (normal & point in world space)
  91180. * @param hitNormalWorld defines the normal in world space
  91181. * @param hitPointWorld defines the point in world space
  91182. */
  91183. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91184. /**
  91185. * Sets the distance from the start point to the hit point
  91186. * @param distance
  91187. */
  91188. setHitDistance(distance: number): void;
  91189. /**
  91190. * Calculates the distance manually
  91191. */
  91192. calculateHitDistance(): void;
  91193. /**
  91194. * Resets all the values to default
  91195. * @param from The from point on world space
  91196. * @param to The to point on world space
  91197. */
  91198. reset(from?: Vector3, to?: Vector3): void;
  91199. }
  91200. /**
  91201. * Interface for the size containing width and height
  91202. */
  91203. interface IXYZ {
  91204. /**
  91205. * X
  91206. */
  91207. x: number;
  91208. /**
  91209. * Y
  91210. */
  91211. y: number;
  91212. /**
  91213. * Z
  91214. */
  91215. z: number;
  91216. }
  91217. }
  91218. declare module BABYLON {
  91219. /**
  91220. * Interface used to describe a physics joint
  91221. */
  91222. export interface PhysicsImpostorJoint {
  91223. /** Defines the main impostor to which the joint is linked */
  91224. mainImpostor: PhysicsImpostor;
  91225. /** Defines the impostor that is connected to the main impostor using this joint */
  91226. connectedImpostor: PhysicsImpostor;
  91227. /** Defines the joint itself */
  91228. joint: PhysicsJoint;
  91229. }
  91230. /** @hidden */
  91231. export interface IPhysicsEnginePlugin {
  91232. world: any;
  91233. name: string;
  91234. setGravity(gravity: Vector3): void;
  91235. setTimeStep(timeStep: number): void;
  91236. getTimeStep(): number;
  91237. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91238. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91239. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91240. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91241. removePhysicsBody(impostor: PhysicsImpostor): void;
  91242. generateJoint(joint: PhysicsImpostorJoint): void;
  91243. removeJoint(joint: PhysicsImpostorJoint): void;
  91244. isSupported(): boolean;
  91245. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91246. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91247. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91248. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91249. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91250. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91251. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91252. getBodyMass(impostor: PhysicsImpostor): number;
  91253. getBodyFriction(impostor: PhysicsImpostor): number;
  91254. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91255. getBodyRestitution(impostor: PhysicsImpostor): number;
  91256. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91257. getBodyPressure?(impostor: PhysicsImpostor): number;
  91258. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91259. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91260. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91261. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91262. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91263. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91264. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91265. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91266. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91267. sleepBody(impostor: PhysicsImpostor): void;
  91268. wakeUpBody(impostor: PhysicsImpostor): void;
  91269. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91270. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91271. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91272. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91273. getRadius(impostor: PhysicsImpostor): number;
  91274. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91275. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91276. dispose(): void;
  91277. }
  91278. /**
  91279. * Interface used to define a physics engine
  91280. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91281. */
  91282. export interface IPhysicsEngine {
  91283. /**
  91284. * Gets the gravity vector used by the simulation
  91285. */
  91286. gravity: Vector3;
  91287. /**
  91288. * Sets the gravity vector used by the simulation
  91289. * @param gravity defines the gravity vector to use
  91290. */
  91291. setGravity(gravity: Vector3): void;
  91292. /**
  91293. * Set the time step of the physics engine.
  91294. * Default is 1/60.
  91295. * To slow it down, enter 1/600 for example.
  91296. * To speed it up, 1/30
  91297. * @param newTimeStep the new timestep to apply to this world.
  91298. */
  91299. setTimeStep(newTimeStep: number): void;
  91300. /**
  91301. * Get the time step of the physics engine.
  91302. * @returns the current time step
  91303. */
  91304. getTimeStep(): number;
  91305. /**
  91306. * Release all resources
  91307. */
  91308. dispose(): void;
  91309. /**
  91310. * Gets the name of the current physics plugin
  91311. * @returns the name of the plugin
  91312. */
  91313. getPhysicsPluginName(): string;
  91314. /**
  91315. * Adding a new impostor for the impostor tracking.
  91316. * This will be done by the impostor itself.
  91317. * @param impostor the impostor to add
  91318. */
  91319. addImpostor(impostor: PhysicsImpostor): void;
  91320. /**
  91321. * Remove an impostor from the engine.
  91322. * This impostor and its mesh will not longer be updated by the physics engine.
  91323. * @param impostor the impostor to remove
  91324. */
  91325. removeImpostor(impostor: PhysicsImpostor): void;
  91326. /**
  91327. * Add a joint to the physics engine
  91328. * @param mainImpostor defines the main impostor to which the joint is added.
  91329. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91330. * @param joint defines the joint that will connect both impostors.
  91331. */
  91332. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91333. /**
  91334. * Removes a joint from the simulation
  91335. * @param mainImpostor defines the impostor used with the joint
  91336. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91337. * @param joint defines the joint to remove
  91338. */
  91339. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91340. /**
  91341. * Gets the current plugin used to run the simulation
  91342. * @returns current plugin
  91343. */
  91344. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91345. /**
  91346. * Gets the list of physic impostors
  91347. * @returns an array of PhysicsImpostor
  91348. */
  91349. getImpostors(): Array<PhysicsImpostor>;
  91350. /**
  91351. * Gets the impostor for a physics enabled object
  91352. * @param object defines the object impersonated by the impostor
  91353. * @returns the PhysicsImpostor or null if not found
  91354. */
  91355. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91356. /**
  91357. * Gets the impostor for a physics body object
  91358. * @param body defines physics body used by the impostor
  91359. * @returns the PhysicsImpostor or null if not found
  91360. */
  91361. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91362. /**
  91363. * Does a raycast in the physics world
  91364. * @param from when should the ray start?
  91365. * @param to when should the ray end?
  91366. * @returns PhysicsRaycastResult
  91367. */
  91368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91369. /**
  91370. * Called by the scene. No need to call it.
  91371. * @param delta defines the timespam between frames
  91372. */
  91373. _step(delta: number): void;
  91374. }
  91375. }
  91376. declare module BABYLON {
  91377. /**
  91378. * The interface for the physics imposter parameters
  91379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91380. */
  91381. export interface PhysicsImpostorParameters {
  91382. /**
  91383. * The mass of the physics imposter
  91384. */
  91385. mass: number;
  91386. /**
  91387. * The friction of the physics imposter
  91388. */
  91389. friction?: number;
  91390. /**
  91391. * The coefficient of restitution of the physics imposter
  91392. */
  91393. restitution?: number;
  91394. /**
  91395. * The native options of the physics imposter
  91396. */
  91397. nativeOptions?: any;
  91398. /**
  91399. * Specifies if the parent should be ignored
  91400. */
  91401. ignoreParent?: boolean;
  91402. /**
  91403. * Specifies if bi-directional transformations should be disabled
  91404. */
  91405. disableBidirectionalTransformation?: boolean;
  91406. /**
  91407. * The pressure inside the physics imposter, soft object only
  91408. */
  91409. pressure?: number;
  91410. /**
  91411. * The stiffness the physics imposter, soft object only
  91412. */
  91413. stiffness?: number;
  91414. /**
  91415. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91416. */
  91417. velocityIterations?: number;
  91418. /**
  91419. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91420. */
  91421. positionIterations?: number;
  91422. /**
  91423. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91424. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91425. * Add to fix multiple points
  91426. */
  91427. fixedPoints?: number;
  91428. /**
  91429. * The collision margin around a soft object
  91430. */
  91431. margin?: number;
  91432. /**
  91433. * The collision margin around a soft object
  91434. */
  91435. damping?: number;
  91436. /**
  91437. * The path for a rope based on an extrusion
  91438. */
  91439. path?: any;
  91440. /**
  91441. * The shape of an extrusion used for a rope based on an extrusion
  91442. */
  91443. shape?: any;
  91444. }
  91445. /**
  91446. * Interface for a physics-enabled object
  91447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91448. */
  91449. export interface IPhysicsEnabledObject {
  91450. /**
  91451. * The position of the physics-enabled object
  91452. */
  91453. position: Vector3;
  91454. /**
  91455. * The rotation of the physics-enabled object
  91456. */
  91457. rotationQuaternion: Nullable<Quaternion>;
  91458. /**
  91459. * The scale of the physics-enabled object
  91460. */
  91461. scaling: Vector3;
  91462. /**
  91463. * The rotation of the physics-enabled object
  91464. */
  91465. rotation?: Vector3;
  91466. /**
  91467. * The parent of the physics-enabled object
  91468. */
  91469. parent?: any;
  91470. /**
  91471. * The bounding info of the physics-enabled object
  91472. * @returns The bounding info of the physics-enabled object
  91473. */
  91474. getBoundingInfo(): BoundingInfo;
  91475. /**
  91476. * Computes the world matrix
  91477. * @param force Specifies if the world matrix should be computed by force
  91478. * @returns A world matrix
  91479. */
  91480. computeWorldMatrix(force: boolean): Matrix;
  91481. /**
  91482. * Gets the world matrix
  91483. * @returns A world matrix
  91484. */
  91485. getWorldMatrix?(): Matrix;
  91486. /**
  91487. * Gets the child meshes
  91488. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91489. * @returns An array of abstract meshes
  91490. */
  91491. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91492. /**
  91493. * Gets the vertex data
  91494. * @param kind The type of vertex data
  91495. * @returns A nullable array of numbers, or a float32 array
  91496. */
  91497. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91498. /**
  91499. * Gets the indices from the mesh
  91500. * @returns A nullable array of index arrays
  91501. */
  91502. getIndices?(): Nullable<IndicesArray>;
  91503. /**
  91504. * Gets the scene from the mesh
  91505. * @returns the indices array or null
  91506. */
  91507. getScene?(): Scene;
  91508. /**
  91509. * Gets the absolute position from the mesh
  91510. * @returns the absolute position
  91511. */
  91512. getAbsolutePosition(): Vector3;
  91513. /**
  91514. * Gets the absolute pivot point from the mesh
  91515. * @returns the absolute pivot point
  91516. */
  91517. getAbsolutePivotPoint(): Vector3;
  91518. /**
  91519. * Rotates the mesh
  91520. * @param axis The axis of rotation
  91521. * @param amount The amount of rotation
  91522. * @param space The space of the rotation
  91523. * @returns The rotation transform node
  91524. */
  91525. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91526. /**
  91527. * Translates the mesh
  91528. * @param axis The axis of translation
  91529. * @param distance The distance of translation
  91530. * @param space The space of the translation
  91531. * @returns The transform node
  91532. */
  91533. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91534. /**
  91535. * Sets the absolute position of the mesh
  91536. * @param absolutePosition The absolute position of the mesh
  91537. * @returns The transform node
  91538. */
  91539. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91540. /**
  91541. * Gets the class name of the mesh
  91542. * @returns The class name
  91543. */
  91544. getClassName(): string;
  91545. }
  91546. /**
  91547. * Represents a physics imposter
  91548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91549. */
  91550. export class PhysicsImpostor {
  91551. /**
  91552. * The physics-enabled object used as the physics imposter
  91553. */
  91554. object: IPhysicsEnabledObject;
  91555. /**
  91556. * The type of the physics imposter
  91557. */
  91558. type: number;
  91559. private _options;
  91560. private _scene?;
  91561. /**
  91562. * The default object size of the imposter
  91563. */
  91564. static DEFAULT_OBJECT_SIZE: Vector3;
  91565. /**
  91566. * The identity quaternion of the imposter
  91567. */
  91568. static IDENTITY_QUATERNION: Quaternion;
  91569. /** @hidden */
  91570. _pluginData: any;
  91571. private _physicsEngine;
  91572. private _physicsBody;
  91573. private _bodyUpdateRequired;
  91574. private _onBeforePhysicsStepCallbacks;
  91575. private _onAfterPhysicsStepCallbacks;
  91576. /** @hidden */
  91577. _onPhysicsCollideCallbacks: Array<{
  91578. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91579. otherImpostors: Array<PhysicsImpostor>;
  91580. }>;
  91581. private _deltaPosition;
  91582. private _deltaRotation;
  91583. private _deltaRotationConjugated;
  91584. /** @hidden */
  91585. _isFromLine: boolean;
  91586. private _parent;
  91587. private _isDisposed;
  91588. private static _tmpVecs;
  91589. private static _tmpQuat;
  91590. /**
  91591. * Specifies if the physics imposter is disposed
  91592. */
  91593. readonly isDisposed: boolean;
  91594. /**
  91595. * Gets the mass of the physics imposter
  91596. */
  91597. mass: number;
  91598. /**
  91599. * Gets the coefficient of friction
  91600. */
  91601. /**
  91602. * Sets the coefficient of friction
  91603. */
  91604. friction: number;
  91605. /**
  91606. * Gets the coefficient of restitution
  91607. */
  91608. /**
  91609. * Sets the coefficient of restitution
  91610. */
  91611. restitution: number;
  91612. /**
  91613. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91614. */
  91615. /**
  91616. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91617. */
  91618. pressure: number;
  91619. /**
  91620. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91621. */
  91622. /**
  91623. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91624. */
  91625. stiffness: number;
  91626. /**
  91627. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91628. */
  91629. /**
  91630. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91631. */
  91632. velocityIterations: number;
  91633. /**
  91634. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91635. */
  91636. /**
  91637. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91638. */
  91639. positionIterations: number;
  91640. /**
  91641. * The unique id of the physics imposter
  91642. * set by the physics engine when adding this impostor to the array
  91643. */
  91644. uniqueId: number;
  91645. /**
  91646. * @hidden
  91647. */
  91648. soft: boolean;
  91649. /**
  91650. * @hidden
  91651. */
  91652. segments: number;
  91653. private _joints;
  91654. /**
  91655. * Initializes the physics imposter
  91656. * @param object The physics-enabled object used as the physics imposter
  91657. * @param type The type of the physics imposter
  91658. * @param _options The options for the physics imposter
  91659. * @param _scene The Babylon scene
  91660. */
  91661. constructor(
  91662. /**
  91663. * The physics-enabled object used as the physics imposter
  91664. */
  91665. object: IPhysicsEnabledObject,
  91666. /**
  91667. * The type of the physics imposter
  91668. */
  91669. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91670. /**
  91671. * This function will completly initialize this impostor.
  91672. * It will create a new body - but only if this mesh has no parent.
  91673. * If it has, this impostor will not be used other than to define the impostor
  91674. * of the child mesh.
  91675. * @hidden
  91676. */
  91677. _init(): void;
  91678. private _getPhysicsParent;
  91679. /**
  91680. * Should a new body be generated.
  91681. * @returns boolean specifying if body initialization is required
  91682. */
  91683. isBodyInitRequired(): boolean;
  91684. /**
  91685. * Sets the updated scaling
  91686. * @param updated Specifies if the scaling is updated
  91687. */
  91688. setScalingUpdated(): void;
  91689. /**
  91690. * Force a regeneration of this or the parent's impostor's body.
  91691. * Use under cautious - This will remove all joints already implemented.
  91692. */
  91693. forceUpdate(): void;
  91694. /**
  91695. * Gets the body that holds this impostor. Either its own, or its parent.
  91696. */
  91697. /**
  91698. * Set the physics body. Used mainly by the physics engine/plugin
  91699. */
  91700. physicsBody: any;
  91701. /**
  91702. * Get the parent of the physics imposter
  91703. * @returns Physics imposter or null
  91704. */
  91705. /**
  91706. * Sets the parent of the physics imposter
  91707. */
  91708. parent: Nullable<PhysicsImpostor>;
  91709. /**
  91710. * Resets the update flags
  91711. */
  91712. resetUpdateFlags(): void;
  91713. /**
  91714. * Gets the object extend size
  91715. * @returns the object extend size
  91716. */
  91717. getObjectExtendSize(): Vector3;
  91718. /**
  91719. * Gets the object center
  91720. * @returns The object center
  91721. */
  91722. getObjectCenter(): Vector3;
  91723. /**
  91724. * Get a specific parametes from the options parameter
  91725. * @param paramName The object parameter name
  91726. * @returns The object parameter
  91727. */
  91728. getParam(paramName: string): any;
  91729. /**
  91730. * Sets a specific parameter in the options given to the physics plugin
  91731. * @param paramName The parameter name
  91732. * @param value The value of the parameter
  91733. */
  91734. setParam(paramName: string, value: number): void;
  91735. /**
  91736. * Specifically change the body's mass option. Won't recreate the physics body object
  91737. * @param mass The mass of the physics imposter
  91738. */
  91739. setMass(mass: number): void;
  91740. /**
  91741. * Gets the linear velocity
  91742. * @returns linear velocity or null
  91743. */
  91744. getLinearVelocity(): Nullable<Vector3>;
  91745. /**
  91746. * Sets the linear velocity
  91747. * @param velocity linear velocity or null
  91748. */
  91749. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91750. /**
  91751. * Gets the angular velocity
  91752. * @returns angular velocity or null
  91753. */
  91754. getAngularVelocity(): Nullable<Vector3>;
  91755. /**
  91756. * Sets the angular velocity
  91757. * @param velocity The velocity or null
  91758. */
  91759. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91760. /**
  91761. * Execute a function with the physics plugin native code
  91762. * Provide a function the will have two variables - the world object and the physics body object
  91763. * @param func The function to execute with the physics plugin native code
  91764. */
  91765. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91766. /**
  91767. * Register a function that will be executed before the physics world is stepping forward
  91768. * @param func The function to execute before the physics world is stepped forward
  91769. */
  91770. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91771. /**
  91772. * Unregister a function that will be executed before the physics world is stepping forward
  91773. * @param func The function to execute before the physics world is stepped forward
  91774. */
  91775. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91776. /**
  91777. * Register a function that will be executed after the physics step
  91778. * @param func The function to execute after physics step
  91779. */
  91780. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91781. /**
  91782. * Unregisters a function that will be executed after the physics step
  91783. * @param func The function to execute after physics step
  91784. */
  91785. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91786. /**
  91787. * register a function that will be executed when this impostor collides against a different body
  91788. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91789. * @param func Callback that is executed on collision
  91790. */
  91791. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91792. /**
  91793. * Unregisters the physics imposter on contact
  91794. * @param collideAgainst The physics object to collide against
  91795. * @param func Callback to execute on collision
  91796. */
  91797. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91798. private _tmpQuat;
  91799. private _tmpQuat2;
  91800. /**
  91801. * Get the parent rotation
  91802. * @returns The parent rotation
  91803. */
  91804. getParentsRotation(): Quaternion;
  91805. /**
  91806. * this function is executed by the physics engine.
  91807. */
  91808. beforeStep: () => void;
  91809. /**
  91810. * this function is executed by the physics engine
  91811. */
  91812. afterStep: () => void;
  91813. /**
  91814. * Legacy collision detection event support
  91815. */
  91816. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91817. /**
  91818. * event and body object due to cannon's event-based architecture.
  91819. */
  91820. onCollide: (e: {
  91821. body: any;
  91822. }) => void;
  91823. /**
  91824. * Apply a force
  91825. * @param force The force to apply
  91826. * @param contactPoint The contact point for the force
  91827. * @returns The physics imposter
  91828. */
  91829. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91830. /**
  91831. * Apply an impulse
  91832. * @param force The impulse force
  91833. * @param contactPoint The contact point for the impulse force
  91834. * @returns The physics imposter
  91835. */
  91836. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91837. /**
  91838. * A help function to create a joint
  91839. * @param otherImpostor A physics imposter used to create a joint
  91840. * @param jointType The type of joint
  91841. * @param jointData The data for the joint
  91842. * @returns The physics imposter
  91843. */
  91844. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91845. /**
  91846. * Add a joint to this impostor with a different impostor
  91847. * @param otherImpostor A physics imposter used to add a joint
  91848. * @param joint The joint to add
  91849. * @returns The physics imposter
  91850. */
  91851. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91852. /**
  91853. * Add an anchor to a cloth impostor
  91854. * @param otherImpostor rigid impostor to anchor to
  91855. * @param width ratio across width from 0 to 1
  91856. * @param height ratio up height from 0 to 1
  91857. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91858. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91859. * @returns impostor the soft imposter
  91860. */
  91861. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91862. /**
  91863. * Add a hook to a rope impostor
  91864. * @param otherImpostor rigid impostor to anchor to
  91865. * @param length ratio across rope from 0 to 1
  91866. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91867. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91868. * @returns impostor the rope imposter
  91869. */
  91870. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91871. /**
  91872. * Will keep this body still, in a sleep mode.
  91873. * @returns the physics imposter
  91874. */
  91875. sleep(): PhysicsImpostor;
  91876. /**
  91877. * Wake the body up.
  91878. * @returns The physics imposter
  91879. */
  91880. wakeUp(): PhysicsImpostor;
  91881. /**
  91882. * Clones the physics imposter
  91883. * @param newObject The physics imposter clones to this physics-enabled object
  91884. * @returns A nullable physics imposter
  91885. */
  91886. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91887. /**
  91888. * Disposes the physics imposter
  91889. */
  91890. dispose(): void;
  91891. /**
  91892. * Sets the delta position
  91893. * @param position The delta position amount
  91894. */
  91895. setDeltaPosition(position: Vector3): void;
  91896. /**
  91897. * Sets the delta rotation
  91898. * @param rotation The delta rotation amount
  91899. */
  91900. setDeltaRotation(rotation: Quaternion): void;
  91901. /**
  91902. * Gets the box size of the physics imposter and stores the result in the input parameter
  91903. * @param result Stores the box size
  91904. * @returns The physics imposter
  91905. */
  91906. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91907. /**
  91908. * Gets the radius of the physics imposter
  91909. * @returns Radius of the physics imposter
  91910. */
  91911. getRadius(): number;
  91912. /**
  91913. * Sync a bone with this impostor
  91914. * @param bone The bone to sync to the impostor.
  91915. * @param boneMesh The mesh that the bone is influencing.
  91916. * @param jointPivot The pivot of the joint / bone in local space.
  91917. * @param distToJoint Optional distance from the impostor to the joint.
  91918. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91919. */
  91920. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91921. /**
  91922. * Sync impostor to a bone
  91923. * @param bone The bone that the impostor will be synced to.
  91924. * @param boneMesh The mesh that the bone is influencing.
  91925. * @param jointPivot The pivot of the joint / bone in local space.
  91926. * @param distToJoint Optional distance from the impostor to the joint.
  91927. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91928. * @param boneAxis Optional vector3 axis the bone is aligned with
  91929. */
  91930. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91931. /**
  91932. * No-Imposter type
  91933. */
  91934. static NoImpostor: number;
  91935. /**
  91936. * Sphere-Imposter type
  91937. */
  91938. static SphereImpostor: number;
  91939. /**
  91940. * Box-Imposter type
  91941. */
  91942. static BoxImpostor: number;
  91943. /**
  91944. * Plane-Imposter type
  91945. */
  91946. static PlaneImpostor: number;
  91947. /**
  91948. * Mesh-imposter type
  91949. */
  91950. static MeshImpostor: number;
  91951. /**
  91952. * Capsule-Impostor type (Ammo.js plugin only)
  91953. */
  91954. static CapsuleImpostor: number;
  91955. /**
  91956. * Cylinder-Imposter type
  91957. */
  91958. static CylinderImpostor: number;
  91959. /**
  91960. * Particle-Imposter type
  91961. */
  91962. static ParticleImpostor: number;
  91963. /**
  91964. * Heightmap-Imposter type
  91965. */
  91966. static HeightmapImpostor: number;
  91967. /**
  91968. * ConvexHull-Impostor type (Ammo.js plugin only)
  91969. */
  91970. static ConvexHullImpostor: number;
  91971. /**
  91972. * Rope-Imposter type
  91973. */
  91974. static RopeImpostor: number;
  91975. /**
  91976. * Cloth-Imposter type
  91977. */
  91978. static ClothImpostor: number;
  91979. /**
  91980. * Softbody-Imposter type
  91981. */
  91982. static SoftbodyImpostor: number;
  91983. }
  91984. }
  91985. declare module BABYLON {
  91986. /**
  91987. * @hidden
  91988. **/
  91989. export class _CreationDataStorage {
  91990. closePath?: boolean;
  91991. closeArray?: boolean;
  91992. idx: number[];
  91993. dashSize: number;
  91994. gapSize: number;
  91995. path3D: Path3D;
  91996. pathArray: Vector3[][];
  91997. arc: number;
  91998. radius: number;
  91999. cap: number;
  92000. tessellation: number;
  92001. }
  92002. /**
  92003. * @hidden
  92004. **/
  92005. class _InstanceDataStorage {
  92006. visibleInstances: any;
  92007. batchCache: _InstancesBatch;
  92008. instancesBufferSize: number;
  92009. instancesBuffer: Nullable<Buffer>;
  92010. instancesData: Float32Array;
  92011. overridenInstanceCount: number;
  92012. isFrozen: boolean;
  92013. previousBatch: Nullable<_InstancesBatch>;
  92014. hardwareInstancedRendering: boolean;
  92015. sideOrientation: number;
  92016. manualUpdate: boolean;
  92017. }
  92018. /**
  92019. * @hidden
  92020. **/
  92021. export class _InstancesBatch {
  92022. mustReturn: boolean;
  92023. visibleInstances: Nullable<InstancedMesh[]>[];
  92024. renderSelf: boolean[];
  92025. hardwareInstancedRendering: boolean[];
  92026. }
  92027. /**
  92028. * Class used to represent renderable models
  92029. */
  92030. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92031. /**
  92032. * Mesh side orientation : usually the external or front surface
  92033. */
  92034. static readonly FRONTSIDE: number;
  92035. /**
  92036. * Mesh side orientation : usually the internal or back surface
  92037. */
  92038. static readonly BACKSIDE: number;
  92039. /**
  92040. * Mesh side orientation : both internal and external or front and back surfaces
  92041. */
  92042. static readonly DOUBLESIDE: number;
  92043. /**
  92044. * Mesh side orientation : by default, `FRONTSIDE`
  92045. */
  92046. static readonly DEFAULTSIDE: number;
  92047. /**
  92048. * Mesh cap setting : no cap
  92049. */
  92050. static readonly NO_CAP: number;
  92051. /**
  92052. * Mesh cap setting : one cap at the beginning of the mesh
  92053. */
  92054. static readonly CAP_START: number;
  92055. /**
  92056. * Mesh cap setting : one cap at the end of the mesh
  92057. */
  92058. static readonly CAP_END: number;
  92059. /**
  92060. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92061. */
  92062. static readonly CAP_ALL: number;
  92063. /**
  92064. * Mesh pattern setting : no flip or rotate
  92065. */
  92066. static readonly NO_FLIP: number;
  92067. /**
  92068. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92069. */
  92070. static readonly FLIP_TILE: number;
  92071. /**
  92072. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92073. */
  92074. static readonly ROTATE_TILE: number;
  92075. /**
  92076. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92077. */
  92078. static readonly FLIP_ROW: number;
  92079. /**
  92080. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92081. */
  92082. static readonly ROTATE_ROW: number;
  92083. /**
  92084. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92085. */
  92086. static readonly FLIP_N_ROTATE_TILE: number;
  92087. /**
  92088. * Mesh pattern setting : rotate pattern and rotate
  92089. */
  92090. static readonly FLIP_N_ROTATE_ROW: number;
  92091. /**
  92092. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92093. */
  92094. static readonly CENTER: number;
  92095. /**
  92096. * Mesh tile positioning : part tiles on left
  92097. */
  92098. static readonly LEFT: number;
  92099. /**
  92100. * Mesh tile positioning : part tiles on right
  92101. */
  92102. static readonly RIGHT: number;
  92103. /**
  92104. * Mesh tile positioning : part tiles on top
  92105. */
  92106. static readonly TOP: number;
  92107. /**
  92108. * Mesh tile positioning : part tiles on bottom
  92109. */
  92110. static readonly BOTTOM: number;
  92111. /**
  92112. * Gets the default side orientation.
  92113. * @param orientation the orientation to value to attempt to get
  92114. * @returns the default orientation
  92115. * @hidden
  92116. */
  92117. static _GetDefaultSideOrientation(orientation?: number): number;
  92118. private _internalMeshDataInfo;
  92119. /**
  92120. * An event triggered before rendering the mesh
  92121. */
  92122. readonly onBeforeRenderObservable: Observable<Mesh>;
  92123. /**
  92124. * An event triggered before binding the mesh
  92125. */
  92126. readonly onBeforeBindObservable: Observable<Mesh>;
  92127. /**
  92128. * An event triggered after rendering the mesh
  92129. */
  92130. readonly onAfterRenderObservable: Observable<Mesh>;
  92131. /**
  92132. * An event triggered before drawing the mesh
  92133. */
  92134. readonly onBeforeDrawObservable: Observable<Mesh>;
  92135. private _onBeforeDrawObserver;
  92136. /**
  92137. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92138. */
  92139. onBeforeDraw: () => void;
  92140. readonly hasInstances: boolean;
  92141. /**
  92142. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92143. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92144. */
  92145. delayLoadState: number;
  92146. /**
  92147. * Gets the list of instances created from this mesh
  92148. * it is not supposed to be modified manually.
  92149. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92151. */
  92152. instances: InstancedMesh[];
  92153. /**
  92154. * Gets the file containing delay loading data for this mesh
  92155. */
  92156. delayLoadingFile: string;
  92157. /** @hidden */
  92158. _binaryInfo: any;
  92159. /**
  92160. * User defined function used to change how LOD level selection is done
  92161. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92162. */
  92163. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92164. /**
  92165. * Gets or sets the morph target manager
  92166. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92167. */
  92168. morphTargetManager: Nullable<MorphTargetManager>;
  92169. /** @hidden */
  92170. _creationDataStorage: Nullable<_CreationDataStorage>;
  92171. /** @hidden */
  92172. _geometry: Nullable<Geometry>;
  92173. /** @hidden */
  92174. _delayInfo: Array<string>;
  92175. /** @hidden */
  92176. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92177. /** @hidden */
  92178. _instanceDataStorage: _InstanceDataStorage;
  92179. private _effectiveMaterial;
  92180. /** @hidden */
  92181. _shouldGenerateFlatShading: boolean;
  92182. /** @hidden */
  92183. _originalBuilderSideOrientation: number;
  92184. /**
  92185. * Use this property to change the original side orientation defined at construction time
  92186. */
  92187. overrideMaterialSideOrientation: Nullable<number>;
  92188. /**
  92189. * Gets the source mesh (the one used to clone this one from)
  92190. */
  92191. readonly source: Nullable<Mesh>;
  92192. /**
  92193. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92194. */
  92195. isUnIndexed: boolean;
  92196. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92197. readonly worldMatrixInstancedBuffer: Float32Array;
  92198. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92199. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92200. /**
  92201. * @constructor
  92202. * @param name The value used by scene.getMeshByName() to do a lookup.
  92203. * @param scene The scene to add this mesh to.
  92204. * @param parent The parent of this mesh, if it has one
  92205. * @param source An optional Mesh from which geometry is shared, cloned.
  92206. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92207. * When false, achieved by calling a clone(), also passing False.
  92208. * This will make creation of children, recursive.
  92209. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92210. */
  92211. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92212. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92213. doNotInstantiate: boolean;
  92214. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92215. /**
  92216. * Gets the class name
  92217. * @returns the string "Mesh".
  92218. */
  92219. getClassName(): string;
  92220. /** @hidden */
  92221. readonly _isMesh: boolean;
  92222. /**
  92223. * Returns a description of this mesh
  92224. * @param fullDetails define if full details about this mesh must be used
  92225. * @returns a descriptive string representing this mesh
  92226. */
  92227. toString(fullDetails?: boolean): string;
  92228. /** @hidden */
  92229. _unBindEffect(): void;
  92230. /**
  92231. * Gets a boolean indicating if this mesh has LOD
  92232. */
  92233. readonly hasLODLevels: boolean;
  92234. /**
  92235. * Gets the list of MeshLODLevel associated with the current mesh
  92236. * @returns an array of MeshLODLevel
  92237. */
  92238. getLODLevels(): MeshLODLevel[];
  92239. private _sortLODLevels;
  92240. /**
  92241. * Add a mesh as LOD level triggered at the given distance.
  92242. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92243. * @param distance The distance from the center of the object to show this level
  92244. * @param mesh The mesh to be added as LOD level (can be null)
  92245. * @return This mesh (for chaining)
  92246. */
  92247. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92248. /**
  92249. * Returns the LOD level mesh at the passed distance or null if not found.
  92250. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92251. * @param distance The distance from the center of the object to show this level
  92252. * @returns a Mesh or `null`
  92253. */
  92254. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92255. /**
  92256. * Remove a mesh from the LOD array
  92257. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92258. * @param mesh defines the mesh to be removed
  92259. * @return This mesh (for chaining)
  92260. */
  92261. removeLODLevel(mesh: Mesh): Mesh;
  92262. /**
  92263. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92264. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92265. * @param camera defines the camera to use to compute distance
  92266. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92267. * @return This mesh (for chaining)
  92268. */
  92269. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92270. /**
  92271. * Gets the mesh internal Geometry object
  92272. */
  92273. readonly geometry: Nullable<Geometry>;
  92274. /**
  92275. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92276. * @returns the total number of vertices
  92277. */
  92278. getTotalVertices(): number;
  92279. /**
  92280. * Returns the content of an associated vertex buffer
  92281. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92282. * - VertexBuffer.PositionKind
  92283. * - VertexBuffer.UVKind
  92284. * - VertexBuffer.UV2Kind
  92285. * - VertexBuffer.UV3Kind
  92286. * - VertexBuffer.UV4Kind
  92287. * - VertexBuffer.UV5Kind
  92288. * - VertexBuffer.UV6Kind
  92289. * - VertexBuffer.ColorKind
  92290. * - VertexBuffer.MatricesIndicesKind
  92291. * - VertexBuffer.MatricesIndicesExtraKind
  92292. * - VertexBuffer.MatricesWeightsKind
  92293. * - VertexBuffer.MatricesWeightsExtraKind
  92294. * @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
  92295. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92296. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92297. */
  92298. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92299. /**
  92300. * Returns the mesh VertexBuffer object from the requested `kind`
  92301. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92302. * - VertexBuffer.PositionKind
  92303. * - VertexBuffer.NormalKind
  92304. * - VertexBuffer.UVKind
  92305. * - VertexBuffer.UV2Kind
  92306. * - VertexBuffer.UV3Kind
  92307. * - VertexBuffer.UV4Kind
  92308. * - VertexBuffer.UV5Kind
  92309. * - VertexBuffer.UV6Kind
  92310. * - VertexBuffer.ColorKind
  92311. * - VertexBuffer.MatricesIndicesKind
  92312. * - VertexBuffer.MatricesIndicesExtraKind
  92313. * - VertexBuffer.MatricesWeightsKind
  92314. * - VertexBuffer.MatricesWeightsExtraKind
  92315. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92316. */
  92317. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92318. /**
  92319. * Tests if a specific vertex buffer is associated with this mesh
  92320. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92321. * - VertexBuffer.PositionKind
  92322. * - VertexBuffer.NormalKind
  92323. * - VertexBuffer.UVKind
  92324. * - VertexBuffer.UV2Kind
  92325. * - VertexBuffer.UV3Kind
  92326. * - VertexBuffer.UV4Kind
  92327. * - VertexBuffer.UV5Kind
  92328. * - VertexBuffer.UV6Kind
  92329. * - VertexBuffer.ColorKind
  92330. * - VertexBuffer.MatricesIndicesKind
  92331. * - VertexBuffer.MatricesIndicesExtraKind
  92332. * - VertexBuffer.MatricesWeightsKind
  92333. * - VertexBuffer.MatricesWeightsExtraKind
  92334. * @returns a boolean
  92335. */
  92336. isVerticesDataPresent(kind: string): boolean;
  92337. /**
  92338. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92339. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92340. * - VertexBuffer.PositionKind
  92341. * - VertexBuffer.UVKind
  92342. * - VertexBuffer.UV2Kind
  92343. * - VertexBuffer.UV3Kind
  92344. * - VertexBuffer.UV4Kind
  92345. * - VertexBuffer.UV5Kind
  92346. * - VertexBuffer.UV6Kind
  92347. * - VertexBuffer.ColorKind
  92348. * - VertexBuffer.MatricesIndicesKind
  92349. * - VertexBuffer.MatricesIndicesExtraKind
  92350. * - VertexBuffer.MatricesWeightsKind
  92351. * - VertexBuffer.MatricesWeightsExtraKind
  92352. * @returns a boolean
  92353. */
  92354. isVertexBufferUpdatable(kind: string): boolean;
  92355. /**
  92356. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92357. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92358. * - VertexBuffer.PositionKind
  92359. * - VertexBuffer.NormalKind
  92360. * - VertexBuffer.UVKind
  92361. * - VertexBuffer.UV2Kind
  92362. * - VertexBuffer.UV3Kind
  92363. * - VertexBuffer.UV4Kind
  92364. * - VertexBuffer.UV5Kind
  92365. * - VertexBuffer.UV6Kind
  92366. * - VertexBuffer.ColorKind
  92367. * - VertexBuffer.MatricesIndicesKind
  92368. * - VertexBuffer.MatricesIndicesExtraKind
  92369. * - VertexBuffer.MatricesWeightsKind
  92370. * - VertexBuffer.MatricesWeightsExtraKind
  92371. * @returns an array of strings
  92372. */
  92373. getVerticesDataKinds(): string[];
  92374. /**
  92375. * Returns a positive integer : the total number of indices in this mesh geometry.
  92376. * @returns the numner of indices or zero if the mesh has no geometry.
  92377. */
  92378. getTotalIndices(): number;
  92379. /**
  92380. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92381. * @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.
  92382. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92383. * @returns the indices array or an empty array if the mesh has no geometry
  92384. */
  92385. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92386. readonly isBlocked: boolean;
  92387. /**
  92388. * Determine if the current mesh is ready to be rendered
  92389. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92390. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92391. * @returns true if all associated assets are ready (material, textures, shaders)
  92392. */
  92393. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92394. /**
  92395. * 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.
  92396. */
  92397. readonly areNormalsFrozen: boolean;
  92398. /**
  92399. * 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.
  92400. * @returns the current mesh
  92401. */
  92402. freezeNormals(): Mesh;
  92403. /**
  92404. * 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
  92405. * @returns the current mesh
  92406. */
  92407. unfreezeNormals(): Mesh;
  92408. /**
  92409. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92410. */
  92411. overridenInstanceCount: number;
  92412. /** @hidden */
  92413. _preActivate(): Mesh;
  92414. /** @hidden */
  92415. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92416. /** @hidden */
  92417. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92418. /**
  92419. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92420. * This means the mesh underlying bounding box and sphere are recomputed.
  92421. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92422. * @returns the current mesh
  92423. */
  92424. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92425. /** @hidden */
  92426. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92427. /**
  92428. * This function will subdivide the mesh into multiple submeshes
  92429. * @param count defines the expected number of submeshes
  92430. */
  92431. subdivide(count: number): void;
  92432. /**
  92433. * Copy a FloatArray into a specific associated vertex buffer
  92434. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92435. * - VertexBuffer.PositionKind
  92436. * - VertexBuffer.UVKind
  92437. * - VertexBuffer.UV2Kind
  92438. * - VertexBuffer.UV3Kind
  92439. * - VertexBuffer.UV4Kind
  92440. * - VertexBuffer.UV5Kind
  92441. * - VertexBuffer.UV6Kind
  92442. * - VertexBuffer.ColorKind
  92443. * - VertexBuffer.MatricesIndicesKind
  92444. * - VertexBuffer.MatricesIndicesExtraKind
  92445. * - VertexBuffer.MatricesWeightsKind
  92446. * - VertexBuffer.MatricesWeightsExtraKind
  92447. * @param data defines the data source
  92448. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92449. * @param stride defines the data stride size (can be null)
  92450. * @returns the current mesh
  92451. */
  92452. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92453. /**
  92454. * Delete a vertex buffer associated with this mesh
  92455. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92456. * - VertexBuffer.PositionKind
  92457. * - VertexBuffer.UVKind
  92458. * - VertexBuffer.UV2Kind
  92459. * - VertexBuffer.UV3Kind
  92460. * - VertexBuffer.UV4Kind
  92461. * - VertexBuffer.UV5Kind
  92462. * - VertexBuffer.UV6Kind
  92463. * - VertexBuffer.ColorKind
  92464. * - VertexBuffer.MatricesIndicesKind
  92465. * - VertexBuffer.MatricesIndicesExtraKind
  92466. * - VertexBuffer.MatricesWeightsKind
  92467. * - VertexBuffer.MatricesWeightsExtraKind
  92468. */
  92469. removeVerticesData(kind: string): void;
  92470. /**
  92471. * Flags an associated vertex buffer as updatable
  92472. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92473. * - VertexBuffer.PositionKind
  92474. * - VertexBuffer.UVKind
  92475. * - VertexBuffer.UV2Kind
  92476. * - VertexBuffer.UV3Kind
  92477. * - VertexBuffer.UV4Kind
  92478. * - VertexBuffer.UV5Kind
  92479. * - VertexBuffer.UV6Kind
  92480. * - VertexBuffer.ColorKind
  92481. * - VertexBuffer.MatricesIndicesKind
  92482. * - VertexBuffer.MatricesIndicesExtraKind
  92483. * - VertexBuffer.MatricesWeightsKind
  92484. * - VertexBuffer.MatricesWeightsExtraKind
  92485. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92486. */
  92487. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92488. /**
  92489. * Sets the mesh global Vertex Buffer
  92490. * @param buffer defines the buffer to use
  92491. * @returns the current mesh
  92492. */
  92493. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92494. /**
  92495. * Update a specific associated vertex buffer
  92496. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92497. * - VertexBuffer.PositionKind
  92498. * - VertexBuffer.UVKind
  92499. * - VertexBuffer.UV2Kind
  92500. * - VertexBuffer.UV3Kind
  92501. * - VertexBuffer.UV4Kind
  92502. * - VertexBuffer.UV5Kind
  92503. * - VertexBuffer.UV6Kind
  92504. * - VertexBuffer.ColorKind
  92505. * - VertexBuffer.MatricesIndicesKind
  92506. * - VertexBuffer.MatricesIndicesExtraKind
  92507. * - VertexBuffer.MatricesWeightsKind
  92508. * - VertexBuffer.MatricesWeightsExtraKind
  92509. * @param data defines the data source
  92510. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92511. * @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)
  92512. * @returns the current mesh
  92513. */
  92514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92515. /**
  92516. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92517. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92518. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92519. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92520. * @returns the current mesh
  92521. */
  92522. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92523. /**
  92524. * Creates a un-shared specific occurence of the geometry for the mesh.
  92525. * @returns the current mesh
  92526. */
  92527. makeGeometryUnique(): Mesh;
  92528. /**
  92529. * Set the index buffer of this mesh
  92530. * @param indices defines the source data
  92531. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92532. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92533. * @returns the current mesh
  92534. */
  92535. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92536. /**
  92537. * Update the current index buffer
  92538. * @param indices defines the source data
  92539. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92540. * @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)
  92541. * @returns the current mesh
  92542. */
  92543. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92544. /**
  92545. * Invert the geometry to move from a right handed system to a left handed one.
  92546. * @returns the current mesh
  92547. */
  92548. toLeftHanded(): Mesh;
  92549. /** @hidden */
  92550. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92551. /** @hidden */
  92552. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92553. /**
  92554. * Registers for this mesh a javascript function called just before the rendering process
  92555. * @param func defines the function to call before rendering this mesh
  92556. * @returns the current mesh
  92557. */
  92558. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92559. /**
  92560. * Disposes a previously registered javascript function called before the rendering
  92561. * @param func defines the function to remove
  92562. * @returns the current mesh
  92563. */
  92564. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92565. /**
  92566. * Registers for this mesh a javascript function called just after the rendering is complete
  92567. * @param func defines the function to call after rendering this mesh
  92568. * @returns the current mesh
  92569. */
  92570. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92571. /**
  92572. * Disposes a previously registered javascript function called after the rendering.
  92573. * @param func defines the function to remove
  92574. * @returns the current mesh
  92575. */
  92576. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92577. /** @hidden */
  92578. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92579. /** @hidden */
  92580. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92581. /** @hidden */
  92582. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92583. /** @hidden */
  92584. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92585. /** @hidden */
  92586. _rebuild(): void;
  92587. /** @hidden */
  92588. _freeze(): void;
  92589. /** @hidden */
  92590. _unFreeze(): void;
  92591. /**
  92592. * 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
  92593. * @param subMesh defines the subMesh to render
  92594. * @param enableAlphaMode defines if alpha mode can be changed
  92595. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92596. * @returns the current mesh
  92597. */
  92598. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92599. private _onBeforeDraw;
  92600. /**
  92601. * Renormalize the mesh and patch it up if there are no weights
  92602. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92603. * However in the case of zero weights then we set just a single influence to 1.
  92604. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92605. */
  92606. cleanMatrixWeights(): void;
  92607. private normalizeSkinFourWeights;
  92608. private normalizeSkinWeightsAndExtra;
  92609. /**
  92610. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92611. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92612. * the user know there was an issue with importing the mesh
  92613. * @returns a validation object with skinned, valid and report string
  92614. */
  92615. validateSkinning(): {
  92616. skinned: boolean;
  92617. valid: boolean;
  92618. report: string;
  92619. };
  92620. /** @hidden */
  92621. _checkDelayState(): Mesh;
  92622. private _queueLoad;
  92623. /**
  92624. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92625. * A mesh is in the frustum if its bounding box intersects the frustum
  92626. * @param frustumPlanes defines the frustum to test
  92627. * @returns true if the mesh is in the frustum planes
  92628. */
  92629. isInFrustum(frustumPlanes: Plane[]): boolean;
  92630. /**
  92631. * Sets the mesh material by the material or multiMaterial `id` property
  92632. * @param id is a string identifying the material or the multiMaterial
  92633. * @returns the current mesh
  92634. */
  92635. setMaterialByID(id: string): Mesh;
  92636. /**
  92637. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92638. * @returns an array of IAnimatable
  92639. */
  92640. getAnimatables(): IAnimatable[];
  92641. /**
  92642. * Modifies the mesh geometry according to the passed transformation matrix.
  92643. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92644. * The mesh normals are modified using the same transformation.
  92645. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92646. * @param transform defines the transform matrix to use
  92647. * @see http://doc.babylonjs.com/resources/baking_transformations
  92648. * @returns the current mesh
  92649. */
  92650. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92651. /**
  92652. * Modifies the mesh geometry according to its own current World Matrix.
  92653. * The mesh World Matrix is then reset.
  92654. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92655. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92656. * @see http://doc.babylonjs.com/resources/baking_transformations
  92657. * @returns the current mesh
  92658. */
  92659. bakeCurrentTransformIntoVertices(): Mesh;
  92660. /** @hidden */
  92661. readonly _positions: Nullable<Vector3[]>;
  92662. /** @hidden */
  92663. _resetPointsArrayCache(): Mesh;
  92664. /** @hidden */
  92665. _generatePointsArray(): boolean;
  92666. /**
  92667. * Returns a new Mesh object generated from the current mesh properties.
  92668. * This method must not get confused with createInstance()
  92669. * @param name is a string, the name given to the new mesh
  92670. * @param newParent can be any Node object (default `null`)
  92671. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92672. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92673. * @returns a new mesh
  92674. */
  92675. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92676. /**
  92677. * Releases resources associated with this mesh.
  92678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92680. */
  92681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92682. /** @hidden */
  92683. _disposeInstanceSpecificData(): void;
  92684. /**
  92685. * Modifies the mesh geometry according to a displacement map.
  92686. * 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.
  92687. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92688. * @param url is a string, the URL from the image file is to be downloaded.
  92689. * @param minHeight is the lower limit of the displacement.
  92690. * @param maxHeight is the upper limit of the displacement.
  92691. * @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.
  92692. * @param uvOffset is an optional vector2 used to offset UV.
  92693. * @param uvScale is an optional vector2 used to scale UV.
  92694. * @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.
  92695. * @returns the Mesh.
  92696. */
  92697. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92698. /**
  92699. * Modifies the mesh geometry according to a displacementMap buffer.
  92700. * 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.
  92701. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92702. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92703. * @param heightMapWidth is the width of the buffer image.
  92704. * @param heightMapHeight is the height of the buffer image.
  92705. * @param minHeight is the lower limit of the displacement.
  92706. * @param maxHeight is the upper limit of the displacement.
  92707. * @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.
  92708. * @param uvOffset is an optional vector2 used to offset UV.
  92709. * @param uvScale is an optional vector2 used to scale UV.
  92710. * @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.
  92711. * @returns the Mesh.
  92712. */
  92713. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92714. /**
  92715. * Modify the mesh to get a flat shading rendering.
  92716. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92717. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92718. * @returns current mesh
  92719. */
  92720. convertToFlatShadedMesh(): Mesh;
  92721. /**
  92722. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92723. * In other words, more vertices, no more indices and a single bigger VBO.
  92724. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92725. * @returns current mesh
  92726. */
  92727. convertToUnIndexedMesh(): Mesh;
  92728. /**
  92729. * Inverses facet orientations.
  92730. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92731. * @param flipNormals will also inverts the normals
  92732. * @returns current mesh
  92733. */
  92734. flipFaces(flipNormals?: boolean): Mesh;
  92735. /**
  92736. * Increase the number of facets and hence vertices in a mesh
  92737. * Vertex normals are interpolated from existing vertex normals
  92738. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92739. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92740. */
  92741. increaseVertices(numberPerEdge: number): void;
  92742. /**
  92743. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92744. * This will undo any application of covertToFlatShadedMesh
  92745. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92746. */
  92747. forceSharedVertices(): void;
  92748. /** @hidden */
  92749. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92750. /** @hidden */
  92751. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92752. /**
  92753. * Creates a new InstancedMesh object from the mesh model.
  92754. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92755. * @param name defines the name of the new instance
  92756. * @returns a new InstancedMesh
  92757. */
  92758. createInstance(name: string): InstancedMesh;
  92759. /**
  92760. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92761. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92762. * @returns the current mesh
  92763. */
  92764. synchronizeInstances(): Mesh;
  92765. /**
  92766. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92767. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92768. * This should be used together with the simplification to avoid disappearing triangles.
  92769. * @param successCallback an optional success callback to be called after the optimization finished.
  92770. * @returns the current mesh
  92771. */
  92772. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92773. /**
  92774. * Serialize current mesh
  92775. * @param serializationObject defines the object which will receive the serialization data
  92776. */
  92777. serialize(serializationObject: any): void;
  92778. /** @hidden */
  92779. _syncGeometryWithMorphTargetManager(): void;
  92780. /** @hidden */
  92781. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92782. /**
  92783. * Returns a new Mesh object parsed from the source provided.
  92784. * @param parsedMesh is the source
  92785. * @param scene defines the hosting scene
  92786. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92787. * @returns a new Mesh
  92788. */
  92789. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92790. /**
  92791. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92792. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92793. * @param name defines the name of the mesh to create
  92794. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92795. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92796. * @param closePath creates a seam between the first and the last points of each path of the path array
  92797. * @param offset is taken in account only if the `pathArray` is containing a single path
  92798. * @param scene defines the hosting scene
  92799. * @param updatable defines if the mesh must be flagged as updatable
  92800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92801. * @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)
  92802. * @returns a new Mesh
  92803. */
  92804. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92805. /**
  92806. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92807. * @param name defines the name of the mesh to create
  92808. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92809. * @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
  92810. * @param scene defines the hosting scene
  92811. * @param updatable defines if the mesh must be flagged as updatable
  92812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92813. * @returns a new Mesh
  92814. */
  92815. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92816. /**
  92817. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92818. * @param name defines the name of the mesh to create
  92819. * @param size sets the size (float) of each box side (default 1)
  92820. * @param scene defines the hosting scene
  92821. * @param updatable defines if the mesh must be flagged as updatable
  92822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92823. * @returns a new Mesh
  92824. */
  92825. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92826. /**
  92827. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92828. * @param name defines the name of the mesh to create
  92829. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92830. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92831. * @param scene defines the hosting scene
  92832. * @param updatable defines if the mesh must be flagged as updatable
  92833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92834. * @returns a new Mesh
  92835. */
  92836. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92837. /**
  92838. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92839. * @param name defines the name of the mesh to create
  92840. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92841. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92842. * @param scene defines the hosting scene
  92843. * @returns a new Mesh
  92844. */
  92845. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92846. /**
  92847. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92848. * @param name defines the name of the mesh to create
  92849. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92850. * @param diameterTop set the top cap diameter (floats, default 1)
  92851. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92852. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92853. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92854. * @param scene defines the hosting scene
  92855. * @param updatable defines if the mesh must be flagged as updatable
  92856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92857. * @returns a new Mesh
  92858. */
  92859. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92860. /**
  92861. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92862. * @param name defines the name of the mesh to create
  92863. * @param diameter sets the diameter size (float) of the torus (default 1)
  92864. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92865. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92866. * @param scene defines the hosting scene
  92867. * @param updatable defines if the mesh must be flagged as updatable
  92868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92869. * @returns a new Mesh
  92870. */
  92871. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92872. /**
  92873. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92874. * @param name defines the name of the mesh to create
  92875. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92876. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92877. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92878. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92879. * @param p the number of windings on X axis (positive integers, default 2)
  92880. * @param q the number of windings on Y axis (positive integers, default 3)
  92881. * @param scene defines the hosting scene
  92882. * @param updatable defines if the mesh must be flagged as updatable
  92883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92884. * @returns a new Mesh
  92885. */
  92886. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92887. /**
  92888. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92889. * @param name defines the name of the mesh to create
  92890. * @param points is an array successive Vector3
  92891. * @param scene defines the hosting scene
  92892. * @param updatable defines if the mesh must be flagged as updatable
  92893. * @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).
  92894. * @returns a new Mesh
  92895. */
  92896. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92897. /**
  92898. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92899. * @param name defines the name of the mesh to create
  92900. * @param points is an array successive Vector3
  92901. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92902. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92903. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92904. * @param scene defines the hosting scene
  92905. * @param updatable defines if the mesh must be flagged as updatable
  92906. * @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)
  92907. * @returns a new Mesh
  92908. */
  92909. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92910. /**
  92911. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92912. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92913. * 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.
  92914. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92915. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92916. * Remember you can only change the shape positions, not their number when updating a polygon.
  92917. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92918. * @param name defines the name of the mesh to create
  92919. * @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
  92920. * @param scene defines the hosting scene
  92921. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92922. * @param updatable defines if the mesh must be flagged as updatable
  92923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92924. * @param earcutInjection can be used to inject your own earcut reference
  92925. * @returns a new Mesh
  92926. */
  92927. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92928. /**
  92929. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92930. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92931. * @param name defines the name of the mesh to create
  92932. * @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
  92933. * @param depth defines the height of extrusion
  92934. * @param scene defines the hosting scene
  92935. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92936. * @param updatable defines if the mesh must be flagged as updatable
  92937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92938. * @param earcutInjection can be used to inject your own earcut reference
  92939. * @returns a new Mesh
  92940. */
  92941. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92942. /**
  92943. * Creates an extruded shape mesh.
  92944. * 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
  92945. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92946. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92947. * @param name defines the name of the mesh to create
  92948. * @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
  92949. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92950. * @param scale is the value to scale the shape
  92951. * @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
  92952. * @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
  92953. * @param scene defines the hosting scene
  92954. * @param updatable defines if the mesh must be flagged as updatable
  92955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92956. * @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)
  92957. * @returns a new Mesh
  92958. */
  92959. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92960. /**
  92961. * Creates an custom extruded shape mesh.
  92962. * The custom extrusion is a parametric shape.
  92963. * It has no predefined shape. Its final shape will depend on the input parameters.
  92964. * Please consider using the same method from the MeshBuilder class instead
  92965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92966. * @param name defines the name of the mesh to create
  92967. * @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
  92968. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92969. * @param scaleFunction is a custom Javascript function called on each path point
  92970. * @param rotationFunction is a custom Javascript function called on each path point
  92971. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92972. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92973. * @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
  92974. * @param scene defines the hosting scene
  92975. * @param updatable defines if the mesh must be flagged as updatable
  92976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92977. * @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)
  92978. * @returns a new Mesh
  92979. */
  92980. 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;
  92981. /**
  92982. * Creates lathe mesh.
  92983. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92984. * Please consider using the same method from the MeshBuilder class instead
  92985. * @param name defines the name of the mesh to create
  92986. * @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
  92987. * @param radius is the radius value of the lathe
  92988. * @param tessellation is the side number of the lathe.
  92989. * @param scene defines the hosting scene
  92990. * @param updatable defines if the mesh must be flagged as updatable
  92991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92992. * @returns a new Mesh
  92993. */
  92994. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92995. /**
  92996. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92997. * @param name defines the name of the mesh to create
  92998. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92999. * @param scene defines the hosting scene
  93000. * @param updatable defines if the mesh must be flagged as updatable
  93001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93002. * @returns a new Mesh
  93003. */
  93004. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93005. /**
  93006. * Creates a ground mesh.
  93007. * Please consider using the same method from the MeshBuilder class instead
  93008. * @param name defines the name of the mesh to create
  93009. * @param width set the width of the ground
  93010. * @param height set the height of the ground
  93011. * @param subdivisions sets the number of subdivisions per side
  93012. * @param scene defines the hosting scene
  93013. * @param updatable defines if the mesh must be flagged as updatable
  93014. * @returns a new Mesh
  93015. */
  93016. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93017. /**
  93018. * Creates a tiled ground mesh.
  93019. * Please consider using the same method from the MeshBuilder class instead
  93020. * @param name defines the name of the mesh to create
  93021. * @param xmin set the ground minimum X coordinate
  93022. * @param zmin set the ground minimum Y coordinate
  93023. * @param xmax set the ground maximum X coordinate
  93024. * @param zmax set the ground maximum Z coordinate
  93025. * @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
  93026. * @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
  93027. * @param scene defines the hosting scene
  93028. * @param updatable defines if the mesh must be flagged as updatable
  93029. * @returns a new Mesh
  93030. */
  93031. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93032. w: number;
  93033. h: number;
  93034. }, precision: {
  93035. w: number;
  93036. h: number;
  93037. }, scene: Scene, updatable?: boolean): Mesh;
  93038. /**
  93039. * Creates a ground mesh from a height map.
  93040. * Please consider using the same method from the MeshBuilder class instead
  93041. * @see http://doc.babylonjs.com/babylon101/height_map
  93042. * @param name defines the name of the mesh to create
  93043. * @param url sets the URL of the height map image resource
  93044. * @param width set the ground width size
  93045. * @param height set the ground height size
  93046. * @param subdivisions sets the number of subdivision per side
  93047. * @param minHeight is the minimum altitude on the ground
  93048. * @param maxHeight is the maximum altitude on the ground
  93049. * @param scene defines the hosting scene
  93050. * @param updatable defines if the mesh must be flagged as updatable
  93051. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93052. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93053. * @returns a new Mesh
  93054. */
  93055. 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;
  93056. /**
  93057. * Creates a tube mesh.
  93058. * The tube is a parametric shape.
  93059. * It has no predefined shape. Its final shape will depend on the input parameters.
  93060. * Please consider using the same method from the MeshBuilder class instead
  93061. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93062. * @param name defines the name of the mesh to create
  93063. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93064. * @param radius sets the tube radius size
  93065. * @param tessellation is the number of sides on the tubular surface
  93066. * @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
  93067. * @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
  93068. * @param scene defines the hosting scene
  93069. * @param updatable defines if the mesh must be flagged as updatable
  93070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93071. * @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)
  93072. * @returns a new Mesh
  93073. */
  93074. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93075. (i: number, distance: number): number;
  93076. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93077. /**
  93078. * Creates a polyhedron mesh.
  93079. * Please consider using the same method from the MeshBuilder class instead.
  93080. * * 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
  93081. * * The parameter `size` (positive float, default 1) sets the polygon size
  93082. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93083. * * 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`
  93084. * * 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
  93085. * * 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)`)
  93086. * * 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
  93087. * * 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
  93088. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93089. * * If you create a double-sided mesh, you can choose what parts of 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
  93090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93091. * @param name defines the name of the mesh to create
  93092. * @param options defines the options used to create the mesh
  93093. * @param scene defines the hosting scene
  93094. * @returns a new Mesh
  93095. */
  93096. static CreatePolyhedron(name: string, options: {
  93097. type?: number;
  93098. size?: number;
  93099. sizeX?: number;
  93100. sizeY?: number;
  93101. sizeZ?: number;
  93102. custom?: any;
  93103. faceUV?: Vector4[];
  93104. faceColors?: Color4[];
  93105. updatable?: boolean;
  93106. sideOrientation?: number;
  93107. }, scene: Scene): Mesh;
  93108. /**
  93109. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93110. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93111. * * 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`)
  93112. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93113. * * 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
  93114. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93115. * * If you create a double-sided mesh, you can choose what parts of 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
  93116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93117. * @param name defines the name of the mesh
  93118. * @param options defines the options used to create the mesh
  93119. * @param scene defines the hosting scene
  93120. * @returns a new Mesh
  93121. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93122. */
  93123. static CreateIcoSphere(name: string, options: {
  93124. radius?: number;
  93125. flat?: boolean;
  93126. subdivisions?: number;
  93127. sideOrientation?: number;
  93128. updatable?: boolean;
  93129. }, scene: Scene): Mesh;
  93130. /**
  93131. * Creates a decal mesh.
  93132. * Please consider using the same method from the MeshBuilder class instead.
  93133. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93134. * @param name defines the name of the mesh
  93135. * @param sourceMesh defines the mesh receiving the decal
  93136. * @param position sets the position of the decal in world coordinates
  93137. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93138. * @param size sets the decal scaling
  93139. * @param angle sets the angle to rotate the decal
  93140. * @returns a new Mesh
  93141. */
  93142. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93143. /**
  93144. * Prepare internal position array for software CPU skinning
  93145. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93146. */
  93147. setPositionsForCPUSkinning(): Float32Array;
  93148. /**
  93149. * Prepare internal normal array for software CPU skinning
  93150. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93151. */
  93152. setNormalsForCPUSkinning(): Float32Array;
  93153. /**
  93154. * Updates the vertex buffer by applying transformation from the bones
  93155. * @param skeleton defines the skeleton to apply to current mesh
  93156. * @returns the current mesh
  93157. */
  93158. applySkeleton(skeleton: Skeleton): Mesh;
  93159. /**
  93160. * 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
  93161. * @param meshes defines the list of meshes to scan
  93162. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93163. */
  93164. static MinMax(meshes: AbstractMesh[]): {
  93165. min: Vector3;
  93166. max: Vector3;
  93167. };
  93168. /**
  93169. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93170. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93171. * @returns a vector3
  93172. */
  93173. static Center(meshesOrMinMaxVector: {
  93174. min: Vector3;
  93175. max: Vector3;
  93176. } | AbstractMesh[]): Vector3;
  93177. /**
  93178. * Merge the array of meshes into a single mesh for performance reasons.
  93179. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93180. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93181. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93182. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93183. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93184. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93185. * @returns a new mesh
  93186. */
  93187. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93188. /** @hidden */
  93189. addInstance(instance: InstancedMesh): void;
  93190. /** @hidden */
  93191. removeInstance(instance: InstancedMesh): void;
  93192. }
  93193. }
  93194. declare module BABYLON {
  93195. /**
  93196. * This is the base class of all the camera used in the application.
  93197. * @see http://doc.babylonjs.com/features/cameras
  93198. */
  93199. export class Camera extends Node {
  93200. /** @hidden */
  93201. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93202. /**
  93203. * This is the default projection mode used by the cameras.
  93204. * It helps recreating a feeling of perspective and better appreciate depth.
  93205. * This is the best way to simulate real life cameras.
  93206. */
  93207. static readonly PERSPECTIVE_CAMERA: number;
  93208. /**
  93209. * This helps creating camera with an orthographic mode.
  93210. * 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.
  93211. */
  93212. static readonly ORTHOGRAPHIC_CAMERA: number;
  93213. /**
  93214. * This is the default FOV mode for perspective cameras.
  93215. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93216. */
  93217. static readonly FOVMODE_VERTICAL_FIXED: number;
  93218. /**
  93219. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93220. */
  93221. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93222. /**
  93223. * This specifies ther is no need for a camera rig.
  93224. * Basically only one eye is rendered corresponding to the camera.
  93225. */
  93226. static readonly RIG_MODE_NONE: number;
  93227. /**
  93228. * Simulates a camera Rig with one blue eye and one red eye.
  93229. * This can be use with 3d blue and red glasses.
  93230. */
  93231. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93232. /**
  93233. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93234. */
  93235. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93236. /**
  93237. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93238. */
  93239. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93240. /**
  93241. * Defines that both eyes of the camera will be rendered over under each other.
  93242. */
  93243. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93244. /**
  93245. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93246. */
  93247. static readonly RIG_MODE_VR: number;
  93248. /**
  93249. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93250. */
  93251. static readonly RIG_MODE_WEBVR: number;
  93252. /**
  93253. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93254. */
  93255. static readonly RIG_MODE_CUSTOM: number;
  93256. /**
  93257. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93258. */
  93259. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93260. /**
  93261. * Define the input manager associated with the camera.
  93262. */
  93263. inputs: CameraInputsManager<Camera>;
  93264. /** @hidden */
  93265. _position: Vector3;
  93266. /**
  93267. * Define the current local position of the camera in the scene
  93268. */
  93269. position: Vector3;
  93270. /**
  93271. * The vector the camera should consider as up.
  93272. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93273. */
  93274. upVector: Vector3;
  93275. /**
  93276. * Define the current limit on the left side for an orthographic camera
  93277. * In scene unit
  93278. */
  93279. orthoLeft: Nullable<number>;
  93280. /**
  93281. * Define the current limit on the right side for an orthographic camera
  93282. * In scene unit
  93283. */
  93284. orthoRight: Nullable<number>;
  93285. /**
  93286. * Define the current limit on the bottom side for an orthographic camera
  93287. * In scene unit
  93288. */
  93289. orthoBottom: Nullable<number>;
  93290. /**
  93291. * Define the current limit on the top side for an orthographic camera
  93292. * In scene unit
  93293. */
  93294. orthoTop: Nullable<number>;
  93295. /**
  93296. * Field Of View is set in Radians. (default is 0.8)
  93297. */
  93298. fov: number;
  93299. /**
  93300. * Define the minimum distance the camera can see from.
  93301. * This is important to note that the depth buffer are not infinite and the closer it starts
  93302. * the more your scene might encounter depth fighting issue.
  93303. */
  93304. minZ: number;
  93305. /**
  93306. * Define the maximum distance the camera can see to.
  93307. * This is important to note that the depth buffer are not infinite and the further it end
  93308. * the more your scene might encounter depth fighting issue.
  93309. */
  93310. maxZ: number;
  93311. /**
  93312. * Define the default inertia of the camera.
  93313. * This helps giving a smooth feeling to the camera movement.
  93314. */
  93315. inertia: number;
  93316. /**
  93317. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93318. */
  93319. mode: number;
  93320. /**
  93321. * Define wether the camera is intermediate.
  93322. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93323. */
  93324. isIntermediate: boolean;
  93325. /**
  93326. * Define the viewport of the camera.
  93327. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93328. */
  93329. viewport: Viewport;
  93330. /**
  93331. * Restricts the camera to viewing objects with the same layerMask.
  93332. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93333. */
  93334. layerMask: number;
  93335. /**
  93336. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93337. */
  93338. fovMode: number;
  93339. /**
  93340. * Rig mode of the camera.
  93341. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93342. * This is normally controlled byt the camera themselves as internal use.
  93343. */
  93344. cameraRigMode: number;
  93345. /**
  93346. * Defines the distance between both "eyes" in case of a RIG
  93347. */
  93348. interaxialDistance: number;
  93349. /**
  93350. * Defines if stereoscopic rendering is done side by side or over under.
  93351. */
  93352. isStereoscopicSideBySide: boolean;
  93353. /**
  93354. * 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
  93355. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93356. * else in the scene. (Eg. security camera)
  93357. *
  93358. * 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)
  93359. */
  93360. customRenderTargets: RenderTargetTexture[];
  93361. /**
  93362. * When set, the camera will render to this render target instead of the default canvas
  93363. *
  93364. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93365. */
  93366. outputRenderTarget: Nullable<RenderTargetTexture>;
  93367. /**
  93368. * Observable triggered when the camera view matrix has changed.
  93369. */
  93370. onViewMatrixChangedObservable: Observable<Camera>;
  93371. /**
  93372. * Observable triggered when the camera Projection matrix has changed.
  93373. */
  93374. onProjectionMatrixChangedObservable: Observable<Camera>;
  93375. /**
  93376. * Observable triggered when the inputs have been processed.
  93377. */
  93378. onAfterCheckInputsObservable: Observable<Camera>;
  93379. /**
  93380. * Observable triggered when reset has been called and applied to the camera.
  93381. */
  93382. onRestoreStateObservable: Observable<Camera>;
  93383. /** @hidden */
  93384. _cameraRigParams: any;
  93385. /** @hidden */
  93386. _rigCameras: Camera[];
  93387. /** @hidden */
  93388. _rigPostProcess: Nullable<PostProcess>;
  93389. protected _webvrViewMatrix: Matrix;
  93390. /** @hidden */
  93391. _skipRendering: boolean;
  93392. /** @hidden */
  93393. _projectionMatrix: Matrix;
  93394. /** @hidden */
  93395. _postProcesses: Nullable<PostProcess>[];
  93396. /** @hidden */
  93397. _activeMeshes: SmartArray<AbstractMesh>;
  93398. protected _globalPosition: Vector3;
  93399. /** @hidden */
  93400. _computedViewMatrix: Matrix;
  93401. private _doNotComputeProjectionMatrix;
  93402. private _transformMatrix;
  93403. private _frustumPlanes;
  93404. private _refreshFrustumPlanes;
  93405. private _storedFov;
  93406. private _stateStored;
  93407. /**
  93408. * Instantiates a new camera object.
  93409. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93410. * @see http://doc.babylonjs.com/features/cameras
  93411. * @param name Defines the name of the camera in the scene
  93412. * @param position Defines the position of the camera
  93413. * @param scene Defines the scene the camera belongs too
  93414. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93415. */
  93416. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93417. /**
  93418. * Store current camera state (fov, position, etc..)
  93419. * @returns the camera
  93420. */
  93421. storeState(): Camera;
  93422. /**
  93423. * Restores the camera state values if it has been stored. You must call storeState() first
  93424. */
  93425. protected _restoreStateValues(): boolean;
  93426. /**
  93427. * Restored camera state. You must call storeState() first.
  93428. * @returns true if restored and false otherwise
  93429. */
  93430. restoreState(): boolean;
  93431. /**
  93432. * Gets the class name of the camera.
  93433. * @returns the class name
  93434. */
  93435. getClassName(): string;
  93436. /** @hidden */
  93437. readonly _isCamera: boolean;
  93438. /**
  93439. * Gets a string representation of the camera useful for debug purpose.
  93440. * @param fullDetails Defines that a more verboe level of logging is required
  93441. * @returns the string representation
  93442. */
  93443. toString(fullDetails?: boolean): string;
  93444. /**
  93445. * Gets the current world space position of the camera.
  93446. */
  93447. readonly globalPosition: Vector3;
  93448. /**
  93449. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93450. * @returns the active meshe list
  93451. */
  93452. getActiveMeshes(): SmartArray<AbstractMesh>;
  93453. /**
  93454. * Check wether a mesh is part of the current active mesh list of the camera
  93455. * @param mesh Defines the mesh to check
  93456. * @returns true if active, false otherwise
  93457. */
  93458. isActiveMesh(mesh: Mesh): boolean;
  93459. /**
  93460. * Is this camera ready to be used/rendered
  93461. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93462. * @return true if the camera is ready
  93463. */
  93464. isReady(completeCheck?: boolean): boolean;
  93465. /** @hidden */
  93466. _initCache(): void;
  93467. /** @hidden */
  93468. _updateCache(ignoreParentClass?: boolean): void;
  93469. /** @hidden */
  93470. _isSynchronized(): boolean;
  93471. /** @hidden */
  93472. _isSynchronizedViewMatrix(): boolean;
  93473. /** @hidden */
  93474. _isSynchronizedProjectionMatrix(): boolean;
  93475. /**
  93476. * Attach the input controls to a specific dom element to get the input from.
  93477. * @param element Defines the element the controls should be listened from
  93478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93479. */
  93480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93481. /**
  93482. * Detach the current controls from the specified dom element.
  93483. * @param element Defines the element to stop listening the inputs from
  93484. */
  93485. detachControl(element: HTMLElement): void;
  93486. /**
  93487. * Update the camera state according to the different inputs gathered during the frame.
  93488. */
  93489. update(): void;
  93490. /** @hidden */
  93491. _checkInputs(): void;
  93492. /** @hidden */
  93493. readonly rigCameras: Camera[];
  93494. /**
  93495. * Gets the post process used by the rig cameras
  93496. */
  93497. readonly rigPostProcess: Nullable<PostProcess>;
  93498. /**
  93499. * Internal, gets the first post proces.
  93500. * @returns the first post process to be run on this camera.
  93501. */
  93502. _getFirstPostProcess(): Nullable<PostProcess>;
  93503. private _cascadePostProcessesToRigCams;
  93504. /**
  93505. * Attach a post process to the camera.
  93506. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93507. * @param postProcess The post process to attach to the camera
  93508. * @param insertAt The position of the post process in case several of them are in use in the scene
  93509. * @returns the position the post process has been inserted at
  93510. */
  93511. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93512. /**
  93513. * Detach a post process to the camera.
  93514. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93515. * @param postProcess The post process to detach from the camera
  93516. */
  93517. detachPostProcess(postProcess: PostProcess): void;
  93518. /**
  93519. * Gets the current world matrix of the camera
  93520. */
  93521. getWorldMatrix(): Matrix;
  93522. /** @hidden */
  93523. _getViewMatrix(): Matrix;
  93524. /**
  93525. * Gets the current view matrix of the camera.
  93526. * @param force forces the camera to recompute the matrix without looking at the cached state
  93527. * @returns the view matrix
  93528. */
  93529. getViewMatrix(force?: boolean): Matrix;
  93530. /**
  93531. * Freeze the projection matrix.
  93532. * It will prevent the cache check of the camera projection compute and can speed up perf
  93533. * if no parameter of the camera are meant to change
  93534. * @param projection Defines manually a projection if necessary
  93535. */
  93536. freezeProjectionMatrix(projection?: Matrix): void;
  93537. /**
  93538. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93539. */
  93540. unfreezeProjectionMatrix(): void;
  93541. /**
  93542. * Gets the current projection matrix of the camera.
  93543. * @param force forces the camera to recompute the matrix without looking at the cached state
  93544. * @returns the projection matrix
  93545. */
  93546. getProjectionMatrix(force?: boolean): Matrix;
  93547. /**
  93548. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93549. * @returns a Matrix
  93550. */
  93551. getTransformationMatrix(): Matrix;
  93552. private _updateFrustumPlanes;
  93553. /**
  93554. * Checks if a cullable object (mesh...) is in the camera frustum
  93555. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93556. * @param target The object to check
  93557. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93558. * @returns true if the object is in frustum otherwise false
  93559. */
  93560. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93561. /**
  93562. * Checks if a cullable object (mesh...) is in the camera frustum
  93563. * Unlike isInFrustum this cheks the full bounding box
  93564. * @param target The object to check
  93565. * @returns true if the object is in frustum otherwise false
  93566. */
  93567. isCompletelyInFrustum(target: ICullable): boolean;
  93568. /**
  93569. * Gets a ray in the forward direction from the camera.
  93570. * @param length Defines the length of the ray to create
  93571. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93572. * @param origin Defines the start point of the ray which defaults to the camera position
  93573. * @returns the forward ray
  93574. */
  93575. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93576. /**
  93577. * Releases resources associated with this node.
  93578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93580. */
  93581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93582. /** @hidden */
  93583. _isLeftCamera: boolean;
  93584. /**
  93585. * Gets the left camera of a rig setup in case of Rigged Camera
  93586. */
  93587. readonly isLeftCamera: boolean;
  93588. /** @hidden */
  93589. _isRightCamera: boolean;
  93590. /**
  93591. * Gets the right camera of a rig setup in case of Rigged Camera
  93592. */
  93593. readonly isRightCamera: boolean;
  93594. /**
  93595. * Gets the left camera of a rig setup in case of Rigged Camera
  93596. */
  93597. readonly leftCamera: Nullable<FreeCamera>;
  93598. /**
  93599. * Gets the right camera of a rig setup in case of Rigged Camera
  93600. */
  93601. readonly rightCamera: Nullable<FreeCamera>;
  93602. /**
  93603. * Gets the left camera target of a rig setup in case of Rigged Camera
  93604. * @returns the target position
  93605. */
  93606. getLeftTarget(): Nullable<Vector3>;
  93607. /**
  93608. * Gets the right camera target of a rig setup in case of Rigged Camera
  93609. * @returns the target position
  93610. */
  93611. getRightTarget(): Nullable<Vector3>;
  93612. /**
  93613. * @hidden
  93614. */
  93615. setCameraRigMode(mode: number, rigParams: any): void;
  93616. /** @hidden */
  93617. static _setStereoscopicRigMode(camera: Camera): void;
  93618. /** @hidden */
  93619. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93620. /** @hidden */
  93621. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93622. /** @hidden */
  93623. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93624. /** @hidden */
  93625. _getVRProjectionMatrix(): Matrix;
  93626. protected _updateCameraRotationMatrix(): void;
  93627. protected _updateWebVRCameraRotationMatrix(): void;
  93628. /**
  93629. * This function MUST be overwritten by the different WebVR cameras available.
  93630. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93631. * @hidden
  93632. */
  93633. _getWebVRProjectionMatrix(): Matrix;
  93634. /**
  93635. * This function MUST be overwritten by the different WebVR cameras available.
  93636. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93637. * @hidden
  93638. */
  93639. _getWebVRViewMatrix(): Matrix;
  93640. /** @hidden */
  93641. setCameraRigParameter(name: string, value: any): void;
  93642. /**
  93643. * needs to be overridden by children so sub has required properties to be copied
  93644. * @hidden
  93645. */
  93646. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93647. /**
  93648. * May need to be overridden by children
  93649. * @hidden
  93650. */
  93651. _updateRigCameras(): void;
  93652. /** @hidden */
  93653. _setupInputs(): void;
  93654. /**
  93655. * Serialiaze the camera setup to a json represention
  93656. * @returns the JSON representation
  93657. */
  93658. serialize(): any;
  93659. /**
  93660. * Clones the current camera.
  93661. * @param name The cloned camera name
  93662. * @returns the cloned camera
  93663. */
  93664. clone(name: string): Camera;
  93665. /**
  93666. * Gets the direction of the camera relative to a given local axis.
  93667. * @param localAxis Defines the reference axis to provide a relative direction.
  93668. * @return the direction
  93669. */
  93670. getDirection(localAxis: Vector3): Vector3;
  93671. /**
  93672. * Returns the current camera absolute rotation
  93673. */
  93674. readonly absoluteRotation: Quaternion;
  93675. /**
  93676. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93677. * @param localAxis Defines the reference axis to provide a relative direction.
  93678. * @param result Defines the vector to store the result in
  93679. */
  93680. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93681. /**
  93682. * Gets a camera constructor for a given camera type
  93683. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93684. * @param name The name of the camera the result will be able to instantiate
  93685. * @param scene The scene the result will construct the camera in
  93686. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93687. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93688. * @returns a factory method to construc the camera
  93689. */
  93690. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93691. /**
  93692. * Compute the world matrix of the camera.
  93693. * @returns the camera world matrix
  93694. */
  93695. computeWorldMatrix(): Matrix;
  93696. /**
  93697. * Parse a JSON and creates the camera from the parsed information
  93698. * @param parsedCamera The JSON to parse
  93699. * @param scene The scene to instantiate the camera in
  93700. * @returns the newly constructed camera
  93701. */
  93702. static Parse(parsedCamera: any, scene: Scene): Camera;
  93703. }
  93704. }
  93705. declare module BABYLON {
  93706. /**
  93707. * Class containing static functions to help procedurally build meshes
  93708. */
  93709. export class DiscBuilder {
  93710. /**
  93711. * Creates a plane polygonal mesh. By default, this is a disc
  93712. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93713. * * 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
  93714. * * 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
  93715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93718. * @param name defines the name of the mesh
  93719. * @param options defines the options used to create the mesh
  93720. * @param scene defines the hosting scene
  93721. * @returns the plane polygonal mesh
  93722. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93723. */
  93724. static CreateDisc(name: string, options: {
  93725. radius?: number;
  93726. tessellation?: number;
  93727. arc?: number;
  93728. updatable?: boolean;
  93729. sideOrientation?: number;
  93730. frontUVs?: Vector4;
  93731. backUVs?: Vector4;
  93732. }, scene?: Nullable<Scene>): Mesh;
  93733. }
  93734. }
  93735. declare module BABYLON {
  93736. /**
  93737. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93738. *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.
  93739. * The SPS is also a particle system. It provides some methods to manage the particles.
  93740. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93741. *
  93742. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93743. */
  93744. export class SolidParticleSystem implements IDisposable {
  93745. /**
  93746. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93747. * Example : var p = SPS.particles[i];
  93748. */
  93749. particles: SolidParticle[];
  93750. /**
  93751. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93752. */
  93753. nbParticles: number;
  93754. /**
  93755. * If the particles must ever face the camera (default false). Useful for planar particles.
  93756. */
  93757. billboard: boolean;
  93758. /**
  93759. * Recompute normals when adding a shape
  93760. */
  93761. recomputeNormals: boolean;
  93762. /**
  93763. * This a counter ofr your own usage. It's not set by any SPS functions.
  93764. */
  93765. counter: number;
  93766. /**
  93767. * The SPS name. This name is also given to the underlying mesh.
  93768. */
  93769. name: string;
  93770. /**
  93771. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93772. */
  93773. mesh: Mesh;
  93774. /**
  93775. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93776. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93777. */
  93778. vars: any;
  93779. /**
  93780. * This array is populated when the SPS is set as 'pickable'.
  93781. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93782. * Each element of this array is an object `{idx: int, faceId: int}`.
  93783. * `idx` is the picked particle index in the `SPS.particles` array
  93784. * `faceId` is the picked face index counted within this particle.
  93785. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93786. */
  93787. pickedParticles: {
  93788. idx: number;
  93789. faceId: number;
  93790. }[];
  93791. /**
  93792. * This array is populated when `enableDepthSort` is set to true.
  93793. * Each element of this array is an instance of the class DepthSortedParticle.
  93794. */
  93795. depthSortedParticles: DepthSortedParticle[];
  93796. /**
  93797. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93798. * @hidden
  93799. */
  93800. _bSphereOnly: boolean;
  93801. /**
  93802. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93803. * @hidden
  93804. */
  93805. _bSphereRadiusFactor: number;
  93806. private _scene;
  93807. private _positions;
  93808. private _indices;
  93809. private _normals;
  93810. private _colors;
  93811. private _uvs;
  93812. private _indices32;
  93813. private _positions32;
  93814. private _normals32;
  93815. private _fixedNormal32;
  93816. private _colors32;
  93817. private _uvs32;
  93818. private _index;
  93819. private _updatable;
  93820. private _pickable;
  93821. private _isVisibilityBoxLocked;
  93822. private _alwaysVisible;
  93823. private _depthSort;
  93824. private _expandable;
  93825. private _shapeCounter;
  93826. private _copy;
  93827. private _color;
  93828. private _computeParticleColor;
  93829. private _computeParticleTexture;
  93830. private _computeParticleRotation;
  93831. private _computeParticleVertex;
  93832. private _computeBoundingBox;
  93833. private _depthSortParticles;
  93834. private _camera;
  93835. private _mustUnrotateFixedNormals;
  93836. private _particlesIntersect;
  93837. private _needs32Bits;
  93838. private _isNotBuilt;
  93839. private _lastParticleId;
  93840. private _idxOfId;
  93841. /**
  93842. * Creates a SPS (Solid Particle System) object.
  93843. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93844. * @param scene (Scene) is the scene in which the SPS is added.
  93845. * @param options defines the options of the sps e.g.
  93846. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93847. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93848. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93849. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93850. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93851. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93852. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93853. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93854. */
  93855. constructor(name: string, scene: Scene, options?: {
  93856. updatable?: boolean;
  93857. isPickable?: boolean;
  93858. enableDepthSort?: boolean;
  93859. particleIntersection?: boolean;
  93860. boundingSphereOnly?: boolean;
  93861. bSphereRadiusFactor?: number;
  93862. expandable?: boolean;
  93863. });
  93864. /**
  93865. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93866. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93867. * @returns the created mesh
  93868. */
  93869. buildMesh(): Mesh;
  93870. /**
  93871. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93872. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93873. * Thus the particles generated from `digest()` have their property `position` set yet.
  93874. * @param mesh ( Mesh ) is the mesh to be digested
  93875. * @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
  93876. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93877. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93878. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93879. * @returns the current SPS
  93880. */
  93881. digest(mesh: Mesh, options?: {
  93882. facetNb?: number;
  93883. number?: number;
  93884. delta?: number;
  93885. storage?: [];
  93886. }): SolidParticleSystem;
  93887. /**
  93888. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93889. * @hidden
  93890. */
  93891. private _unrotateFixedNormals;
  93892. /**
  93893. * Resets the temporary working copy particle
  93894. * @hidden
  93895. */
  93896. private _resetCopy;
  93897. /**
  93898. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93899. * @param p the current index in the positions array to be updated
  93900. * @param shape a Vector3 array, the shape geometry
  93901. * @param positions the positions array to be updated
  93902. * @param meshInd the shape indices array
  93903. * @param indices the indices array to be updated
  93904. * @param meshUV the shape uv array
  93905. * @param uvs the uv array to be updated
  93906. * @param meshCol the shape color array
  93907. * @param colors the color array to be updated
  93908. * @param meshNor the shape normals array
  93909. * @param normals the normals array to be updated
  93910. * @param idx the particle index
  93911. * @param idxInShape the particle index in its shape
  93912. * @param options the addShape() method passed options
  93913. * @hidden
  93914. */
  93915. private _meshBuilder;
  93916. /**
  93917. * Returns a shape Vector3 array from positions float array
  93918. * @param positions float array
  93919. * @returns a vector3 array
  93920. * @hidden
  93921. */
  93922. private _posToShape;
  93923. /**
  93924. * Returns a shapeUV array from a float uvs (array deep copy)
  93925. * @param uvs as a float array
  93926. * @returns a shapeUV array
  93927. * @hidden
  93928. */
  93929. private _uvsToShapeUV;
  93930. /**
  93931. * Adds a new particle object in the particles array
  93932. * @param idx particle index in particles array
  93933. * @param id particle id
  93934. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93935. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93936. * @param model particle ModelShape object
  93937. * @param shapeId model shape identifier
  93938. * @param idxInShape index of the particle in the current model
  93939. * @param bInfo model bounding info object
  93940. * @param storage target storage array, if any
  93941. * @hidden
  93942. */
  93943. private _addParticle;
  93944. /**
  93945. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93946. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93947. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93948. * @param nb (positive integer) the number of particles to be created from this model
  93949. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93950. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93951. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93952. * @returns the number of shapes in the system
  93953. */
  93954. addShape(mesh: Mesh, nb: number, options?: {
  93955. positionFunction?: any;
  93956. vertexFunction?: any;
  93957. storage?: [];
  93958. }): number;
  93959. /**
  93960. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93961. * @hidden
  93962. */
  93963. private _rebuildParticle;
  93964. /**
  93965. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93966. * @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.
  93967. * @returns the SPS.
  93968. */
  93969. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93970. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93971. * Returns an array with the removed particles.
  93972. * 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.
  93973. * The SPS can't be empty so at least one particle needs to remain in place.
  93974. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93975. * @param start index of the first particle to remove
  93976. * @param end index of the last particle to remove (included)
  93977. * @returns an array populated with the removed particles
  93978. */
  93979. removeParticles(start: number, end: number): SolidParticle[];
  93980. /**
  93981. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93982. * @param solidParticleArray an array populated with Solid Particles objects
  93983. * @returns the SPS
  93984. */
  93985. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93986. /**
  93987. * Creates a new particle and modifies the SPS mesh geometry :
  93988. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93989. * - calls _addParticle() to populate the particle array
  93990. * factorized code from addShape() and insertParticlesFromArray()
  93991. * @param idx particle index in the particles array
  93992. * @param i particle index in its shape
  93993. * @param modelShape particle ModelShape object
  93994. * @param shape shape vertex array
  93995. * @param meshInd shape indices array
  93996. * @param meshUV shape uv array
  93997. * @param meshCol shape color array
  93998. * @param meshNor shape normals array
  93999. * @param bbInfo shape bounding info
  94000. * @param storage target particle storage
  94001. * @options addShape() passed options
  94002. * @hidden
  94003. */
  94004. private _insertNewParticle;
  94005. /**
  94006. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  94007. * This method calls `updateParticle()` for each particle of the SPS.
  94008. * For an animated SPS, it is usually called within the render loop.
  94009. * 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.
  94010. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  94011. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  94012. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  94013. * @returns the SPS.
  94014. */
  94015. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  94016. /**
  94017. * Disposes the SPS.
  94018. */
  94019. dispose(): void;
  94020. /**
  94021. * Returns a SolidParticle object from its identifier : particle.id
  94022. * @param id (integer) the particle Id
  94023. * @returns the searched particle or null if not found in the SPS.
  94024. */
  94025. getParticleById(id: number): Nullable<SolidParticle>;
  94026. /**
  94027. * Returns a new array populated with the particles having the passed shapeId.
  94028. * @param shapeId (integer) the shape identifier
  94029. * @returns a new solid particle array
  94030. */
  94031. getParticlesByShapeId(shapeId: number): SolidParticle[];
  94032. /**
  94033. * Populates the passed array "ref" with the particles having the passed shapeId.
  94034. * @param shapeId the shape identifier
  94035. * @returns the SPS
  94036. * @param ref
  94037. */
  94038. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  94039. /**
  94040. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  94041. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94042. * @returns the SPS.
  94043. */
  94044. refreshVisibleSize(): SolidParticleSystem;
  94045. /**
  94046. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  94047. * @param size the size (float) of the visibility box
  94048. * note : this doesn't lock the SPS mesh bounding box.
  94049. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94050. */
  94051. setVisibilityBox(size: number): void;
  94052. /**
  94053. * Gets whether the SPS as always visible or not
  94054. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94055. */
  94056. /**
  94057. * Sets the SPS as always visible or not
  94058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94059. */
  94060. isAlwaysVisible: boolean;
  94061. /**
  94062. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94064. */
  94065. /**
  94066. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94068. */
  94069. isVisibilityBoxLocked: boolean;
  94070. /**
  94071. * Tells to `setParticles()` to compute the particle rotations or not.
  94072. * Default value : true. The SPS is faster when it's set to false.
  94073. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94074. */
  94075. /**
  94076. * Gets if `setParticles()` computes the particle rotations or not.
  94077. * Default value : true. The SPS is faster when it's set to false.
  94078. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94079. */
  94080. computeParticleRotation: boolean;
  94081. /**
  94082. * Tells to `setParticles()` to compute the particle colors or not.
  94083. * Default value : true. The SPS is faster when it's set to false.
  94084. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94085. */
  94086. /**
  94087. * Gets if `setParticles()` computes the particle colors or not.
  94088. * Default value : true. The SPS is faster when it's set to false.
  94089. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94090. */
  94091. computeParticleColor: boolean;
  94092. /**
  94093. * Gets if `setParticles()` computes the particle textures or not.
  94094. * Default value : true. The SPS is faster when it's set to false.
  94095. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94096. */
  94097. computeParticleTexture: boolean;
  94098. /**
  94099. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94100. * Default value : false. The SPS is faster when it's set to false.
  94101. * Note : the particle custom vertex positions aren't stored values.
  94102. */
  94103. /**
  94104. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94105. * Default value : false. The SPS is faster when it's set to false.
  94106. * Note : the particle custom vertex positions aren't stored values.
  94107. */
  94108. computeParticleVertex: boolean;
  94109. /**
  94110. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94111. */
  94112. /**
  94113. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94114. */
  94115. computeBoundingBox: boolean;
  94116. /**
  94117. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94118. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94119. * Default : `true`
  94120. */
  94121. /**
  94122. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94123. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94124. * Default : `true`
  94125. */
  94126. depthSortParticles: boolean;
  94127. /**
  94128. * Gets if the SPS is created as expandable at construction time.
  94129. * Default : `false`
  94130. */
  94131. readonly expandable: boolean;
  94132. /**
  94133. * This function does nothing. It may be overwritten to set all the particle first values.
  94134. * The SPS doesn't call this function, you may have to call it by your own.
  94135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94136. */
  94137. initParticles(): void;
  94138. /**
  94139. * This function does nothing. It may be overwritten to recycle a particle.
  94140. * The SPS doesn't call this function, you may have to call it by your own.
  94141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94142. * @param particle The particle to recycle
  94143. * @returns the recycled particle
  94144. */
  94145. recycleParticle(particle: SolidParticle): SolidParticle;
  94146. /**
  94147. * Updates a particle : this function should be overwritten by the user.
  94148. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94150. * @example : just set a particle position or velocity and recycle conditions
  94151. * @param particle The particle to update
  94152. * @returns the updated particle
  94153. */
  94154. updateParticle(particle: SolidParticle): SolidParticle;
  94155. /**
  94156. * Updates a vertex of a particle : it can be overwritten by the user.
  94157. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94158. * @param particle the current particle
  94159. * @param vertex the current index of the current particle
  94160. * @param pt the index of the current vertex in the particle shape
  94161. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94162. * @example : just set a vertex particle position
  94163. * @returns the updated vertex
  94164. */
  94165. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94166. /**
  94167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94168. * This does nothing and may be overwritten by the user.
  94169. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94171. * @param update the boolean update value actually passed to setParticles()
  94172. */
  94173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94174. /**
  94175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94176. * This will be passed three parameters.
  94177. * This does nothing and may be overwritten by the user.
  94178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94180. * @param update the boolean update value actually passed to setParticles()
  94181. */
  94182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94183. }
  94184. }
  94185. declare module BABYLON {
  94186. /**
  94187. * Represents one particle of a solid particle system.
  94188. */
  94189. export class SolidParticle {
  94190. /**
  94191. * particle global index
  94192. */
  94193. idx: number;
  94194. /**
  94195. * particle identifier
  94196. */
  94197. id: number;
  94198. /**
  94199. * The color of the particle
  94200. */
  94201. color: Nullable<Color4>;
  94202. /**
  94203. * The world space position of the particle.
  94204. */
  94205. position: Vector3;
  94206. /**
  94207. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94208. */
  94209. rotation: Vector3;
  94210. /**
  94211. * The world space rotation quaternion of the particle.
  94212. */
  94213. rotationQuaternion: Nullable<Quaternion>;
  94214. /**
  94215. * The scaling of the particle.
  94216. */
  94217. scaling: Vector3;
  94218. /**
  94219. * The uvs of the particle.
  94220. */
  94221. uvs: Vector4;
  94222. /**
  94223. * The current speed of the particle.
  94224. */
  94225. velocity: Vector3;
  94226. /**
  94227. * The pivot point in the particle local space.
  94228. */
  94229. pivot: Vector3;
  94230. /**
  94231. * Must the particle be translated from its pivot point in its local space ?
  94232. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94233. * Default : false
  94234. */
  94235. translateFromPivot: boolean;
  94236. /**
  94237. * Is the particle active or not ?
  94238. */
  94239. alive: boolean;
  94240. /**
  94241. * Is the particle visible or not ?
  94242. */
  94243. isVisible: boolean;
  94244. /**
  94245. * Index of this particle in the global "positions" array (Internal use)
  94246. * @hidden
  94247. */
  94248. _pos: number;
  94249. /**
  94250. * @hidden Index of this particle in the global "indices" array (Internal use)
  94251. */
  94252. _ind: number;
  94253. /**
  94254. * @hidden ModelShape of this particle (Internal use)
  94255. */
  94256. _model: ModelShape;
  94257. /**
  94258. * ModelShape id of this particle
  94259. */
  94260. shapeId: number;
  94261. /**
  94262. * Index of the particle in its shape id
  94263. */
  94264. idxInShape: number;
  94265. /**
  94266. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94267. */
  94268. _modelBoundingInfo: BoundingInfo;
  94269. /**
  94270. * @hidden Particle BoundingInfo object (Internal use)
  94271. */
  94272. _boundingInfo: BoundingInfo;
  94273. /**
  94274. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94275. */
  94276. _sps: SolidParticleSystem;
  94277. /**
  94278. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94279. */
  94280. _stillInvisible: boolean;
  94281. /**
  94282. * @hidden Last computed particle rotation matrix
  94283. */
  94284. _rotationMatrix: number[];
  94285. /**
  94286. * Parent particle Id, if any.
  94287. * Default null.
  94288. */
  94289. parentId: Nullable<number>;
  94290. /**
  94291. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94292. * The possible values are :
  94293. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94294. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94295. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94296. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94297. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94298. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94299. * */
  94300. cullingStrategy: number;
  94301. /**
  94302. * @hidden Internal global position in the SPS.
  94303. */
  94304. _globalPosition: Vector3;
  94305. /**
  94306. * Creates a Solid Particle object.
  94307. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94308. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94309. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94310. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94311. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94312. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94313. * @param shapeId (integer) is the model shape identifier in the SPS.
  94314. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94315. * @param sps defines the sps it is associated to
  94316. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94317. */
  94318. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94319. /**
  94320. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94321. * @param target the particle target
  94322. * @returns the current particle
  94323. */
  94324. copyToRef(target: SolidParticle): SolidParticle;
  94325. /**
  94326. * Legacy support, changed scale to scaling
  94327. */
  94328. /**
  94329. * Legacy support, changed scale to scaling
  94330. */
  94331. scale: Vector3;
  94332. /**
  94333. * Legacy support, changed quaternion to rotationQuaternion
  94334. */
  94335. /**
  94336. * Legacy support, changed quaternion to rotationQuaternion
  94337. */
  94338. quaternion: Nullable<Quaternion>;
  94339. /**
  94340. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94341. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94342. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94343. * @returns true if it intersects
  94344. */
  94345. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94346. /**
  94347. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94348. * A particle is in the frustum if its bounding box intersects the frustum
  94349. * @param frustumPlanes defines the frustum to test
  94350. * @returns true if the particle is in the frustum planes
  94351. */
  94352. isInFrustum(frustumPlanes: Plane[]): boolean;
  94353. /**
  94354. * get the rotation matrix of the particle
  94355. * @hidden
  94356. */
  94357. getRotationMatrix(m: Matrix): void;
  94358. }
  94359. /**
  94360. * Represents the shape of the model used by one particle of a solid particle system.
  94361. * SPS internal tool, don't use it manually.
  94362. */
  94363. export class ModelShape {
  94364. /**
  94365. * The shape id
  94366. * @hidden
  94367. */
  94368. shapeID: number;
  94369. /**
  94370. * flat array of model positions (internal use)
  94371. * @hidden
  94372. */
  94373. _shape: Vector3[];
  94374. /**
  94375. * flat array of model UVs (internal use)
  94376. * @hidden
  94377. */
  94378. _shapeUV: number[];
  94379. /**
  94380. * color array of the model
  94381. * @hidden
  94382. */
  94383. _shapeColors: number[];
  94384. /**
  94385. * indices array of the model
  94386. * @hidden
  94387. */
  94388. _indices: number[];
  94389. /**
  94390. * normals array of the model
  94391. * @hidden
  94392. */
  94393. _normals: number[];
  94394. /**
  94395. * length of the shape in the model indices array (internal use)
  94396. * @hidden
  94397. */
  94398. _indicesLength: number;
  94399. /**
  94400. * Custom position function (internal use)
  94401. * @hidden
  94402. */
  94403. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94404. /**
  94405. * Custom vertex function (internal use)
  94406. * @hidden
  94407. */
  94408. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94409. /**
  94410. * 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.
  94411. * SPS internal tool, don't use it manually.
  94412. * @hidden
  94413. */
  94414. 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>);
  94415. }
  94416. /**
  94417. * Represents a Depth Sorted Particle in the solid particle system.
  94418. */
  94419. export class DepthSortedParticle {
  94420. /**
  94421. * Index of the particle in the "indices" array
  94422. */
  94423. ind: number;
  94424. /**
  94425. * Length of the particle shape in the "indices" array
  94426. */
  94427. indicesLength: number;
  94428. /**
  94429. * Squared distance from the particle to the camera
  94430. */
  94431. sqDistance: number;
  94432. }
  94433. }
  94434. declare module BABYLON {
  94435. /**
  94436. * @hidden
  94437. */
  94438. export class _MeshCollisionData {
  94439. _checkCollisions: boolean;
  94440. _collisionMask: number;
  94441. _collisionGroup: number;
  94442. _collider: Nullable<Collider>;
  94443. _oldPositionForCollisions: Vector3;
  94444. _diffPositionForCollisions: Vector3;
  94445. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94446. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /** @hidden */
  94451. class _FacetDataStorage {
  94452. facetPositions: Vector3[];
  94453. facetNormals: Vector3[];
  94454. facetPartitioning: number[][];
  94455. facetNb: number;
  94456. partitioningSubdivisions: number;
  94457. partitioningBBoxRatio: number;
  94458. facetDataEnabled: boolean;
  94459. facetParameters: any;
  94460. bbSize: Vector3;
  94461. subDiv: {
  94462. max: number;
  94463. X: number;
  94464. Y: number;
  94465. Z: number;
  94466. };
  94467. facetDepthSort: boolean;
  94468. facetDepthSortEnabled: boolean;
  94469. depthSortedIndices: IndicesArray;
  94470. depthSortedFacets: {
  94471. ind: number;
  94472. sqDistance: number;
  94473. }[];
  94474. facetDepthSortFunction: (f1: {
  94475. ind: number;
  94476. sqDistance: number;
  94477. }, f2: {
  94478. ind: number;
  94479. sqDistance: number;
  94480. }) => number;
  94481. facetDepthSortFrom: Vector3;
  94482. facetDepthSortOrigin: Vector3;
  94483. invertedMatrix: Matrix;
  94484. }
  94485. /**
  94486. * @hidden
  94487. **/
  94488. class _InternalAbstractMeshDataInfo {
  94489. _hasVertexAlpha: boolean;
  94490. _useVertexColors: boolean;
  94491. _numBoneInfluencers: number;
  94492. _applyFog: boolean;
  94493. _receiveShadows: boolean;
  94494. _facetData: _FacetDataStorage;
  94495. _visibility: number;
  94496. _skeleton: Nullable<Skeleton>;
  94497. _layerMask: number;
  94498. _computeBonesUsingShaders: boolean;
  94499. _isActive: boolean;
  94500. _onlyForInstances: boolean;
  94501. _isActiveIntermediate: boolean;
  94502. _onlyForInstancesIntermediate: boolean;
  94503. _actAsRegularMesh: boolean;
  94504. }
  94505. /**
  94506. * Class used to store all common mesh properties
  94507. */
  94508. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94509. /** No occlusion */
  94510. static OCCLUSION_TYPE_NONE: number;
  94511. /** Occlusion set to optimisitic */
  94512. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94513. /** Occlusion set to strict */
  94514. static OCCLUSION_TYPE_STRICT: number;
  94515. /** Use an accurante occlusion algorithm */
  94516. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94517. /** Use a conservative occlusion algorithm */
  94518. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94519. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94520. * Test order :
  94521. * Is the bounding sphere outside the frustum ?
  94522. * If not, are the bounding box vertices outside the frustum ?
  94523. * It not, then the cullable object is in the frustum.
  94524. */
  94525. static readonly CULLINGSTRATEGY_STANDARD: number;
  94526. /** Culling strategy : Bounding Sphere Only.
  94527. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94528. * It's also less accurate than the standard because some not visible objects can still be selected.
  94529. * Test : is the bounding sphere outside the frustum ?
  94530. * If not, then the cullable object is in the frustum.
  94531. */
  94532. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94533. /** Culling strategy : Optimistic Inclusion.
  94534. * This in an inclusion test first, then the standard exclusion test.
  94535. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94536. * 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.
  94537. * Anyway, it's as accurate as the standard strategy.
  94538. * Test :
  94539. * Is the cullable object bounding sphere center in the frustum ?
  94540. * If not, apply the default culling strategy.
  94541. */
  94542. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94543. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94544. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94545. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94546. * 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.
  94547. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94548. * Test :
  94549. * Is the cullable object bounding sphere center in the frustum ?
  94550. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94551. */
  94552. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94553. /**
  94554. * No billboard
  94555. */
  94556. static readonly BILLBOARDMODE_NONE: number;
  94557. /** Billboard on X axis */
  94558. static readonly BILLBOARDMODE_X: number;
  94559. /** Billboard on Y axis */
  94560. static readonly BILLBOARDMODE_Y: number;
  94561. /** Billboard on Z axis */
  94562. static readonly BILLBOARDMODE_Z: number;
  94563. /** Billboard on all axes */
  94564. static readonly BILLBOARDMODE_ALL: number;
  94565. /** Billboard on using position instead of orientation */
  94566. static readonly BILLBOARDMODE_USE_POSITION: number;
  94567. /** @hidden */
  94568. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94569. /**
  94570. * The culling strategy to use to check whether the mesh must be rendered or not.
  94571. * This value can be changed at any time and will be used on the next render mesh selection.
  94572. * The possible values are :
  94573. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94574. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94575. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94576. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94577. * Please read each static variable documentation to get details about the culling process.
  94578. * */
  94579. cullingStrategy: number;
  94580. /**
  94581. * Gets the number of facets in the mesh
  94582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94583. */
  94584. readonly facetNb: number;
  94585. /**
  94586. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94588. */
  94589. partitioningSubdivisions: number;
  94590. /**
  94591. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94592. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94594. */
  94595. partitioningBBoxRatio: number;
  94596. /**
  94597. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94598. * Works only for updatable meshes.
  94599. * Doesn't work with multi-materials
  94600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94601. */
  94602. mustDepthSortFacets: boolean;
  94603. /**
  94604. * The location (Vector3) where the facet depth sort must be computed from.
  94605. * By default, the active camera position.
  94606. * Used only when facet depth sort is enabled
  94607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94608. */
  94609. facetDepthSortFrom: Vector3;
  94610. /**
  94611. * gets a boolean indicating if facetData is enabled
  94612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94613. */
  94614. readonly isFacetDataEnabled: boolean;
  94615. /** @hidden */
  94616. _updateNonUniformScalingState(value: boolean): boolean;
  94617. /**
  94618. * An event triggered when this mesh collides with another one
  94619. */
  94620. onCollideObservable: Observable<AbstractMesh>;
  94621. /** Set a function to call when this mesh collides with another one */
  94622. onCollide: () => void;
  94623. /**
  94624. * An event triggered when the collision's position changes
  94625. */
  94626. onCollisionPositionChangeObservable: Observable<Vector3>;
  94627. /** Set a function to call when the collision's position changes */
  94628. onCollisionPositionChange: () => void;
  94629. /**
  94630. * An event triggered when material is changed
  94631. */
  94632. onMaterialChangedObservable: Observable<AbstractMesh>;
  94633. /**
  94634. * Gets or sets the orientation for POV movement & rotation
  94635. */
  94636. definedFacingForward: boolean;
  94637. /** @hidden */
  94638. _occlusionQuery: Nullable<WebGLQuery>;
  94639. /** @hidden */
  94640. _renderingGroup: Nullable<RenderingGroup>;
  94641. /**
  94642. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94643. */
  94644. /**
  94645. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94646. */
  94647. visibility: number;
  94648. /** Gets or sets the alpha index used to sort transparent meshes
  94649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94650. */
  94651. alphaIndex: number;
  94652. /**
  94653. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94654. */
  94655. isVisible: boolean;
  94656. /**
  94657. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94658. */
  94659. isPickable: boolean;
  94660. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94661. showSubMeshesBoundingBox: boolean;
  94662. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94664. */
  94665. isBlocker: boolean;
  94666. /**
  94667. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94668. */
  94669. enablePointerMoveEvents: boolean;
  94670. /**
  94671. * Specifies the rendering group id for this mesh (0 by default)
  94672. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94673. */
  94674. renderingGroupId: number;
  94675. private _material;
  94676. /** Gets or sets current material */
  94677. material: Nullable<Material>;
  94678. /**
  94679. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94680. * @see http://doc.babylonjs.com/babylon101/shadows
  94681. */
  94682. receiveShadows: boolean;
  94683. /** Defines color to use when rendering outline */
  94684. outlineColor: Color3;
  94685. /** Define width to use when rendering outline */
  94686. outlineWidth: number;
  94687. /** Defines color to use when rendering overlay */
  94688. overlayColor: Color3;
  94689. /** Defines alpha to use when rendering overlay */
  94690. overlayAlpha: number;
  94691. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94692. hasVertexAlpha: boolean;
  94693. /** 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) */
  94694. useVertexColors: boolean;
  94695. /**
  94696. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94697. */
  94698. computeBonesUsingShaders: boolean;
  94699. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94700. numBoneInfluencers: number;
  94701. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94702. applyFog: boolean;
  94703. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94704. useOctreeForRenderingSelection: boolean;
  94705. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94706. useOctreeForPicking: boolean;
  94707. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94708. useOctreeForCollisions: boolean;
  94709. /**
  94710. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94711. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94712. */
  94713. layerMask: number;
  94714. /**
  94715. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94716. */
  94717. alwaysSelectAsActiveMesh: boolean;
  94718. /**
  94719. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94720. */
  94721. doNotSyncBoundingInfo: boolean;
  94722. /**
  94723. * Gets or sets the current action manager
  94724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94725. */
  94726. actionManager: Nullable<AbstractActionManager>;
  94727. private _meshCollisionData;
  94728. /**
  94729. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94731. */
  94732. ellipsoid: Vector3;
  94733. /**
  94734. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94736. */
  94737. ellipsoidOffset: Vector3;
  94738. /**
  94739. * Gets or sets a collision mask used to mask collisions (default is -1).
  94740. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94741. */
  94742. collisionMask: number;
  94743. /**
  94744. * Gets or sets the current collision group mask (-1 by default).
  94745. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94746. */
  94747. collisionGroup: number;
  94748. /**
  94749. * Defines edge width used when edgesRenderer is enabled
  94750. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94751. */
  94752. edgesWidth: number;
  94753. /**
  94754. * Defines edge color used when edgesRenderer is enabled
  94755. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94756. */
  94757. edgesColor: Color4;
  94758. /** @hidden */
  94759. _edgesRenderer: Nullable<IEdgesRenderer>;
  94760. /** @hidden */
  94761. _masterMesh: Nullable<AbstractMesh>;
  94762. /** @hidden */
  94763. _boundingInfo: Nullable<BoundingInfo>;
  94764. /** @hidden */
  94765. _renderId: number;
  94766. /**
  94767. * Gets or sets the list of subMeshes
  94768. * @see http://doc.babylonjs.com/how_to/multi_materials
  94769. */
  94770. subMeshes: SubMesh[];
  94771. /** @hidden */
  94772. _intersectionsInProgress: AbstractMesh[];
  94773. /** @hidden */
  94774. _unIndexed: boolean;
  94775. /** @hidden */
  94776. _lightSources: Light[];
  94777. /** Gets the list of lights affecting that mesh */
  94778. readonly lightSources: Light[];
  94779. /** @hidden */
  94780. readonly _positions: Nullable<Vector3[]>;
  94781. /** @hidden */
  94782. _waitingData: {
  94783. lods: Nullable<any>;
  94784. actions: Nullable<any>;
  94785. freezeWorldMatrix: Nullable<boolean>;
  94786. };
  94787. /** @hidden */
  94788. _bonesTransformMatrices: Nullable<Float32Array>;
  94789. /** @hidden */
  94790. _transformMatrixTexture: Nullable<RawTexture>;
  94791. /**
  94792. * Gets or sets a skeleton to apply skining transformations
  94793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94794. */
  94795. skeleton: Nullable<Skeleton>;
  94796. /**
  94797. * An event triggered when the mesh is rebuilt.
  94798. */
  94799. onRebuildObservable: Observable<AbstractMesh>;
  94800. /**
  94801. * Creates a new AbstractMesh
  94802. * @param name defines the name of the mesh
  94803. * @param scene defines the hosting scene
  94804. */
  94805. constructor(name: string, scene?: Nullable<Scene>);
  94806. /**
  94807. * Returns the string "AbstractMesh"
  94808. * @returns "AbstractMesh"
  94809. */
  94810. getClassName(): string;
  94811. /**
  94812. * Gets a string representation of the current mesh
  94813. * @param fullDetails defines a boolean indicating if full details must be included
  94814. * @returns a string representation of the current mesh
  94815. */
  94816. toString(fullDetails?: boolean): string;
  94817. /**
  94818. * @hidden
  94819. */
  94820. protected _getEffectiveParent(): Nullable<Node>;
  94821. /** @hidden */
  94822. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94823. /** @hidden */
  94824. _rebuild(): void;
  94825. /** @hidden */
  94826. _resyncLightSources(): void;
  94827. /** @hidden */
  94828. _resyncLighSource(light: Light): void;
  94829. /** @hidden */
  94830. _unBindEffect(): void;
  94831. /** @hidden */
  94832. _removeLightSource(light: Light, dispose: boolean): void;
  94833. private _markSubMeshesAsDirty;
  94834. /** @hidden */
  94835. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94836. /** @hidden */
  94837. _markSubMeshesAsAttributesDirty(): void;
  94838. /** @hidden */
  94839. _markSubMeshesAsMiscDirty(): void;
  94840. /**
  94841. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94842. */
  94843. scaling: Vector3;
  94844. /**
  94845. * Returns true if the mesh is blocked. Implemented by child classes
  94846. */
  94847. readonly isBlocked: boolean;
  94848. /**
  94849. * Returns the mesh itself by default. Implemented by child classes
  94850. * @param camera defines the camera to use to pick the right LOD level
  94851. * @returns the currentAbstractMesh
  94852. */
  94853. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94854. /**
  94855. * Returns 0 by default. Implemented by child classes
  94856. * @returns an integer
  94857. */
  94858. getTotalVertices(): number;
  94859. /**
  94860. * Returns a positive integer : the total number of indices in this mesh geometry.
  94861. * @returns the numner of indices or zero if the mesh has no geometry.
  94862. */
  94863. getTotalIndices(): number;
  94864. /**
  94865. * Returns null by default. Implemented by child classes
  94866. * @returns null
  94867. */
  94868. getIndices(): Nullable<IndicesArray>;
  94869. /**
  94870. * Returns the array of the requested vertex data kind. Implemented by child classes
  94871. * @param kind defines the vertex data kind to use
  94872. * @returns null
  94873. */
  94874. getVerticesData(kind: string): Nullable<FloatArray>;
  94875. /**
  94876. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94877. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94878. * Note that a new underlying VertexBuffer object is created each call.
  94879. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94880. * @param kind defines vertex data kind:
  94881. * * VertexBuffer.PositionKind
  94882. * * VertexBuffer.UVKind
  94883. * * VertexBuffer.UV2Kind
  94884. * * VertexBuffer.UV3Kind
  94885. * * VertexBuffer.UV4Kind
  94886. * * VertexBuffer.UV5Kind
  94887. * * VertexBuffer.UV6Kind
  94888. * * VertexBuffer.ColorKind
  94889. * * VertexBuffer.MatricesIndicesKind
  94890. * * VertexBuffer.MatricesIndicesExtraKind
  94891. * * VertexBuffer.MatricesWeightsKind
  94892. * * VertexBuffer.MatricesWeightsExtraKind
  94893. * @param data defines the data source
  94894. * @param updatable defines if the data must be flagged as updatable (or static)
  94895. * @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
  94896. * @returns the current mesh
  94897. */
  94898. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94899. /**
  94900. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94901. * If the mesh has no geometry, it is simply returned as it is.
  94902. * @param kind defines vertex data kind:
  94903. * * VertexBuffer.PositionKind
  94904. * * VertexBuffer.UVKind
  94905. * * VertexBuffer.UV2Kind
  94906. * * VertexBuffer.UV3Kind
  94907. * * VertexBuffer.UV4Kind
  94908. * * VertexBuffer.UV5Kind
  94909. * * VertexBuffer.UV6Kind
  94910. * * VertexBuffer.ColorKind
  94911. * * VertexBuffer.MatricesIndicesKind
  94912. * * VertexBuffer.MatricesIndicesExtraKind
  94913. * * VertexBuffer.MatricesWeightsKind
  94914. * * VertexBuffer.MatricesWeightsExtraKind
  94915. * @param data defines the data source
  94916. * @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
  94917. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94918. * @returns the current mesh
  94919. */
  94920. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94921. /**
  94922. * Sets the mesh indices,
  94923. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94924. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94925. * @param totalVertices Defines the total number of vertices
  94926. * @returns the current mesh
  94927. */
  94928. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94929. /**
  94930. * Gets a boolean indicating if specific vertex data is present
  94931. * @param kind defines the vertex data kind to use
  94932. * @returns true is data kind is present
  94933. */
  94934. isVerticesDataPresent(kind: string): boolean;
  94935. /**
  94936. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94937. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94938. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94939. * @returns a BoundingInfo
  94940. */
  94941. getBoundingInfo(): BoundingInfo;
  94942. /**
  94943. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94944. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94945. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94946. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94947. * @returns the current mesh
  94948. */
  94949. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94950. /**
  94951. * Overwrite the current bounding info
  94952. * @param boundingInfo defines the new bounding info
  94953. * @returns the current mesh
  94954. */
  94955. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94956. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94957. readonly useBones: boolean;
  94958. /** @hidden */
  94959. _preActivate(): void;
  94960. /** @hidden */
  94961. _preActivateForIntermediateRendering(renderId: number): void;
  94962. /** @hidden */
  94963. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94964. /** @hidden */
  94965. _postActivate(): void;
  94966. /** @hidden */
  94967. _freeze(): void;
  94968. /** @hidden */
  94969. _unFreeze(): void;
  94970. /**
  94971. * Gets the current world matrix
  94972. * @returns a Matrix
  94973. */
  94974. getWorldMatrix(): Matrix;
  94975. /** @hidden */
  94976. _getWorldMatrixDeterminant(): number;
  94977. /**
  94978. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94979. */
  94980. readonly isAnInstance: boolean;
  94981. /**
  94982. * Gets a boolean indicating if this mesh has instances
  94983. */
  94984. readonly hasInstances: boolean;
  94985. /**
  94986. * Perform relative position change from the point of view of behind the front of the mesh.
  94987. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94988. * Supports definition of mesh facing forward or backward
  94989. * @param amountRight defines the distance on the right axis
  94990. * @param amountUp defines the distance on the up axis
  94991. * @param amountForward defines the distance on the forward axis
  94992. * @returns the current mesh
  94993. */
  94994. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94995. /**
  94996. * Calculate relative position change from the point of view of behind the front of the mesh.
  94997. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94998. * Supports definition of mesh facing forward or backward
  94999. * @param amountRight defines the distance on the right axis
  95000. * @param amountUp defines the distance on the up axis
  95001. * @param amountForward defines the distance on the forward axis
  95002. * @returns the new displacement vector
  95003. */
  95004. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  95005. /**
  95006. * Perform relative rotation change from the point of view of behind the front of the mesh.
  95007. * Supports definition of mesh facing forward or backward
  95008. * @param flipBack defines the flip
  95009. * @param twirlClockwise defines the twirl
  95010. * @param tiltRight defines the tilt
  95011. * @returns the current mesh
  95012. */
  95013. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  95014. /**
  95015. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  95016. * Supports definition of mesh facing forward or backward.
  95017. * @param flipBack defines the flip
  95018. * @param twirlClockwise defines the twirl
  95019. * @param tiltRight defines the tilt
  95020. * @returns the new rotation vector
  95021. */
  95022. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  95023. /**
  95024. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95025. * This means the mesh underlying bounding box and sphere are recomputed.
  95026. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95027. * @returns the current mesh
  95028. */
  95029. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  95030. /** @hidden */
  95031. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  95032. /** @hidden */
  95033. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  95034. /** @hidden */
  95035. _updateBoundingInfo(): AbstractMesh;
  95036. /** @hidden */
  95037. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  95038. /** @hidden */
  95039. protected _afterComputeWorldMatrix(): void;
  95040. /** @hidden */
  95041. readonly _effectiveMesh: AbstractMesh;
  95042. /**
  95043. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95044. * A mesh is in the frustum if its bounding box intersects the frustum
  95045. * @param frustumPlanes defines the frustum to test
  95046. * @returns true if the mesh is in the frustum planes
  95047. */
  95048. isInFrustum(frustumPlanes: Plane[]): boolean;
  95049. /**
  95050. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  95051. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  95052. * @param frustumPlanes defines the frustum to test
  95053. * @returns true if the mesh is completely in the frustum planes
  95054. */
  95055. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95056. /**
  95057. * True if the mesh intersects another mesh or a SolidParticle object
  95058. * @param mesh defines a target mesh or SolidParticle to test
  95059. * @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)
  95060. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  95061. * @returns true if there is an intersection
  95062. */
  95063. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  95064. /**
  95065. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  95066. * @param point defines the point to test
  95067. * @returns true if there is an intersection
  95068. */
  95069. intersectsPoint(point: Vector3): boolean;
  95070. /**
  95071. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  95072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95073. */
  95074. checkCollisions: boolean;
  95075. /**
  95076. * Gets Collider object used to compute collisions (not physics)
  95077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95078. */
  95079. readonly collider: Nullable<Collider>;
  95080. /**
  95081. * Move the mesh using collision engine
  95082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95083. * @param displacement defines the requested displacement vector
  95084. * @returns the current mesh
  95085. */
  95086. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95087. private _onCollisionPositionChange;
  95088. /** @hidden */
  95089. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95090. /** @hidden */
  95091. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95092. /** @hidden */
  95093. _checkCollision(collider: Collider): AbstractMesh;
  95094. /** @hidden */
  95095. _generatePointsArray(): boolean;
  95096. /**
  95097. * Checks if the passed Ray intersects with the mesh
  95098. * @param ray defines the ray to use
  95099. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95101. * @returns the picking info
  95102. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95103. */
  95104. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95105. /**
  95106. * Clones the current mesh
  95107. * @param name defines the mesh name
  95108. * @param newParent defines the new mesh parent
  95109. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95110. * @returns the new mesh
  95111. */
  95112. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95113. /**
  95114. * Disposes all the submeshes of the current meshnp
  95115. * @returns the current mesh
  95116. */
  95117. releaseSubMeshes(): AbstractMesh;
  95118. /**
  95119. * Releases resources associated with this abstract mesh.
  95120. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95121. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95122. */
  95123. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95124. /**
  95125. * Adds the passed mesh as a child to the current mesh
  95126. * @param mesh defines the child mesh
  95127. * @returns the current mesh
  95128. */
  95129. addChild(mesh: AbstractMesh): AbstractMesh;
  95130. /**
  95131. * Removes the passed mesh from the current mesh children list
  95132. * @param mesh defines the child mesh
  95133. * @returns the current mesh
  95134. */
  95135. removeChild(mesh: AbstractMesh): AbstractMesh;
  95136. /** @hidden */
  95137. private _initFacetData;
  95138. /**
  95139. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95140. * This method can be called within the render loop.
  95141. * 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
  95142. * @returns the current mesh
  95143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95144. */
  95145. updateFacetData(): AbstractMesh;
  95146. /**
  95147. * Returns the facetLocalNormals array.
  95148. * The normals are expressed in the mesh local spac
  95149. * @returns an array of Vector3
  95150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95151. */
  95152. getFacetLocalNormals(): Vector3[];
  95153. /**
  95154. * Returns the facetLocalPositions array.
  95155. * The facet positions are expressed in the mesh local space
  95156. * @returns an array of Vector3
  95157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95158. */
  95159. getFacetLocalPositions(): Vector3[];
  95160. /**
  95161. * Returns the facetLocalPartioning array
  95162. * @returns an array of array of numbers
  95163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95164. */
  95165. getFacetLocalPartitioning(): number[][];
  95166. /**
  95167. * Returns the i-th facet position in the world system.
  95168. * This method allocates a new Vector3 per call
  95169. * @param i defines the facet index
  95170. * @returns a new Vector3
  95171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95172. */
  95173. getFacetPosition(i: number): Vector3;
  95174. /**
  95175. * Sets the reference Vector3 with the i-th facet position in the world system
  95176. * @param i defines the facet index
  95177. * @param ref defines the target vector
  95178. * @returns the current mesh
  95179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95180. */
  95181. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95182. /**
  95183. * Returns the i-th facet normal in the world system.
  95184. * This method allocates a new Vector3 per call
  95185. * @param i defines the facet index
  95186. * @returns a new Vector3
  95187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95188. */
  95189. getFacetNormal(i: number): Vector3;
  95190. /**
  95191. * Sets the reference Vector3 with the i-th facet normal in the world system
  95192. * @param i defines the facet index
  95193. * @param ref defines the target vector
  95194. * @returns the current mesh
  95195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95196. */
  95197. getFacetNormalToRef(i: number, ref: Vector3): this;
  95198. /**
  95199. * 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)
  95200. * @param x defines x coordinate
  95201. * @param y defines y coordinate
  95202. * @param z defines z coordinate
  95203. * @returns the array of facet indexes
  95204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95205. */
  95206. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95207. /**
  95208. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95209. * @param projected sets as the (x,y,z) world projection on the facet
  95210. * @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
  95211. * @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
  95212. * @param x defines x coordinate
  95213. * @param y defines y coordinate
  95214. * @param z defines z coordinate
  95215. * @returns the face index if found (or null instead)
  95216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95217. */
  95218. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95219. /**
  95220. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95221. * @param projected sets as the (x,y,z) local projection on the facet
  95222. * @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
  95223. * @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
  95224. * @param x defines x coordinate
  95225. * @param y defines y coordinate
  95226. * @param z defines z coordinate
  95227. * @returns the face index if found (or null instead)
  95228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95229. */
  95230. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95231. /**
  95232. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95233. * @returns the parameters
  95234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95235. */
  95236. getFacetDataParameters(): any;
  95237. /**
  95238. * Disables the feature FacetData and frees the related memory
  95239. * @returns the current mesh
  95240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95241. */
  95242. disableFacetData(): AbstractMesh;
  95243. /**
  95244. * Updates the AbstractMesh indices array
  95245. * @param indices defines the data source
  95246. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95247. * @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)
  95248. * @returns the current mesh
  95249. */
  95250. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95251. /**
  95252. * Creates new normals data for the mesh
  95253. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95254. * @returns the current mesh
  95255. */
  95256. createNormals(updatable: boolean): AbstractMesh;
  95257. /**
  95258. * Align the mesh with a normal
  95259. * @param normal defines the normal to use
  95260. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95261. * @returns the current mesh
  95262. */
  95263. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95264. /** @hidden */
  95265. _checkOcclusionQuery(): boolean;
  95266. /**
  95267. * Disables the mesh edge rendering mode
  95268. * @returns the currentAbstractMesh
  95269. */
  95270. disableEdgesRendering(): AbstractMesh;
  95271. /**
  95272. * Enables the edge rendering mode on the mesh.
  95273. * This mode makes the mesh edges visible
  95274. * @param epsilon defines the maximal distance between two angles to detect a face
  95275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95276. * @returns the currentAbstractMesh
  95277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95278. */
  95279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95280. }
  95281. }
  95282. declare module BABYLON {
  95283. /**
  95284. * Interface used to define ActionEvent
  95285. */
  95286. export interface IActionEvent {
  95287. /** The mesh or sprite that triggered the action */
  95288. source: any;
  95289. /** The X mouse cursor position at the time of the event */
  95290. pointerX: number;
  95291. /** The Y mouse cursor position at the time of the event */
  95292. pointerY: number;
  95293. /** The mesh that is currently pointed at (can be null) */
  95294. meshUnderPointer: Nullable<AbstractMesh>;
  95295. /** the original (browser) event that triggered the ActionEvent */
  95296. sourceEvent?: any;
  95297. /** additional data for the event */
  95298. additionalData?: any;
  95299. }
  95300. /**
  95301. * ActionEvent is the event being sent when an action is triggered.
  95302. */
  95303. export class ActionEvent implements IActionEvent {
  95304. /** The mesh or sprite that triggered the action */
  95305. source: any;
  95306. /** The X mouse cursor position at the time of the event */
  95307. pointerX: number;
  95308. /** The Y mouse cursor position at the time of the event */
  95309. pointerY: number;
  95310. /** The mesh that is currently pointed at (can be null) */
  95311. meshUnderPointer: Nullable<AbstractMesh>;
  95312. /** the original (browser) event that triggered the ActionEvent */
  95313. sourceEvent?: any;
  95314. /** additional data for the event */
  95315. additionalData?: any;
  95316. /**
  95317. * Creates a new ActionEvent
  95318. * @param source The mesh or sprite that triggered the action
  95319. * @param pointerX The X mouse cursor position at the time of the event
  95320. * @param pointerY The Y mouse cursor position at the time of the event
  95321. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95322. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95323. * @param additionalData additional data for the event
  95324. */
  95325. constructor(
  95326. /** The mesh or sprite that triggered the action */
  95327. source: any,
  95328. /** The X mouse cursor position at the time of the event */
  95329. pointerX: number,
  95330. /** The Y mouse cursor position at the time of the event */
  95331. pointerY: number,
  95332. /** The mesh that is currently pointed at (can be null) */
  95333. meshUnderPointer: Nullable<AbstractMesh>,
  95334. /** the original (browser) event that triggered the ActionEvent */
  95335. sourceEvent?: any,
  95336. /** additional data for the event */
  95337. additionalData?: any);
  95338. /**
  95339. * Helper function to auto-create an ActionEvent from a source mesh.
  95340. * @param source The source mesh that triggered the event
  95341. * @param evt The original (browser) event
  95342. * @param additionalData additional data for the event
  95343. * @returns the new ActionEvent
  95344. */
  95345. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95346. /**
  95347. * Helper function to auto-create an ActionEvent from a source sprite
  95348. * @param source The source sprite that triggered the event
  95349. * @param scene Scene associated with the sprite
  95350. * @param evt The original (browser) event
  95351. * @param additionalData additional data for the event
  95352. * @returns the new ActionEvent
  95353. */
  95354. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95355. /**
  95356. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95357. * @param scene the scene where the event occurred
  95358. * @param evt The original (browser) event
  95359. * @returns the new ActionEvent
  95360. */
  95361. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95362. /**
  95363. * Helper function to auto-create an ActionEvent from a primitive
  95364. * @param prim defines the target primitive
  95365. * @param pointerPos defines the pointer position
  95366. * @param evt The original (browser) event
  95367. * @param additionalData additional data for the event
  95368. * @returns the new ActionEvent
  95369. */
  95370. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95371. }
  95372. }
  95373. declare module BABYLON {
  95374. /**
  95375. * Abstract class used to decouple action Manager from scene and meshes.
  95376. * Do not instantiate.
  95377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95378. */
  95379. export abstract class AbstractActionManager implements IDisposable {
  95380. /** Gets the list of active triggers */
  95381. static Triggers: {
  95382. [key: string]: number;
  95383. };
  95384. /** Gets the cursor to use when hovering items */
  95385. hoverCursor: string;
  95386. /** Gets the list of actions */
  95387. actions: IAction[];
  95388. /**
  95389. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95390. */
  95391. isRecursive: boolean;
  95392. /**
  95393. * Releases all associated resources
  95394. */
  95395. abstract dispose(): void;
  95396. /**
  95397. * Does this action manager has pointer triggers
  95398. */
  95399. abstract readonly hasPointerTriggers: boolean;
  95400. /**
  95401. * Does this action manager has pick triggers
  95402. */
  95403. abstract readonly hasPickTriggers: boolean;
  95404. /**
  95405. * Process a specific trigger
  95406. * @param trigger defines the trigger to process
  95407. * @param evt defines the event details to be processed
  95408. */
  95409. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95410. /**
  95411. * Does this action manager handles actions of any of the given triggers
  95412. * @param triggers defines the triggers to be tested
  95413. * @return a boolean indicating whether one (or more) of the triggers is handled
  95414. */
  95415. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95416. /**
  95417. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95418. * speed.
  95419. * @param triggerA defines the trigger to be tested
  95420. * @param triggerB defines the trigger to be tested
  95421. * @return a boolean indicating whether one (or more) of the triggers is handled
  95422. */
  95423. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95424. /**
  95425. * Does this action manager handles actions of a given trigger
  95426. * @param trigger defines the trigger to be tested
  95427. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95428. * @return whether the trigger is handled
  95429. */
  95430. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95431. /**
  95432. * Serialize this manager to a JSON object
  95433. * @param name defines the property name to store this manager
  95434. * @returns a JSON representation of this manager
  95435. */
  95436. abstract serialize(name: string): any;
  95437. /**
  95438. * Registers an action to this action manager
  95439. * @param action defines the action to be registered
  95440. * @return the action amended (prepared) after registration
  95441. */
  95442. abstract registerAction(action: IAction): Nullable<IAction>;
  95443. /**
  95444. * Unregisters an action to this action manager
  95445. * @param action defines the action to be unregistered
  95446. * @return a boolean indicating whether the action has been unregistered
  95447. */
  95448. abstract unregisterAction(action: IAction): Boolean;
  95449. /**
  95450. * Does exist one action manager with at least one trigger
  95451. **/
  95452. static readonly HasTriggers: boolean;
  95453. /**
  95454. * Does exist one action manager with at least one pick trigger
  95455. **/
  95456. static readonly HasPickTriggers: boolean;
  95457. /**
  95458. * Does exist one action manager that handles actions of a given trigger
  95459. * @param trigger defines the trigger to be tested
  95460. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95461. **/
  95462. static HasSpecificTrigger(trigger: number): boolean;
  95463. }
  95464. }
  95465. declare module BABYLON {
  95466. /**
  95467. * Defines how a node can be built from a string name.
  95468. */
  95469. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95470. /**
  95471. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95472. */
  95473. export class Node implements IBehaviorAware<Node> {
  95474. /** @hidden */
  95475. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95476. private static _NodeConstructors;
  95477. /**
  95478. * Add a new node constructor
  95479. * @param type defines the type name of the node to construct
  95480. * @param constructorFunc defines the constructor function
  95481. */
  95482. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95483. /**
  95484. * Returns a node constructor based on type name
  95485. * @param type defines the type name
  95486. * @param name defines the new node name
  95487. * @param scene defines the hosting scene
  95488. * @param options defines optional options to transmit to constructors
  95489. * @returns the new constructor or null
  95490. */
  95491. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95492. /**
  95493. * Gets or sets the name of the node
  95494. */
  95495. name: string;
  95496. /**
  95497. * Gets or sets the id of the node
  95498. */
  95499. id: string;
  95500. /**
  95501. * Gets or sets the unique id of the node
  95502. */
  95503. uniqueId: number;
  95504. /**
  95505. * Gets or sets a string used to store user defined state for the node
  95506. */
  95507. state: string;
  95508. /**
  95509. * Gets or sets an object used to store user defined information for the node
  95510. */
  95511. metadata: any;
  95512. /**
  95513. * For internal use only. Please do not use.
  95514. */
  95515. reservedDataStore: any;
  95516. /**
  95517. * List of inspectable custom properties (used by the Inspector)
  95518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95519. */
  95520. inspectableCustomProperties: IInspectable[];
  95521. private _doNotSerialize;
  95522. /**
  95523. * Gets or sets a boolean used to define if the node must be serialized
  95524. */
  95525. doNotSerialize: boolean;
  95526. /** @hidden */
  95527. _isDisposed: boolean;
  95528. /**
  95529. * Gets a list of Animations associated with the node
  95530. */
  95531. animations: Animation[];
  95532. protected _ranges: {
  95533. [name: string]: Nullable<AnimationRange>;
  95534. };
  95535. /**
  95536. * Callback raised when the node is ready to be used
  95537. */
  95538. onReady: Nullable<(node: Node) => void>;
  95539. private _isEnabled;
  95540. private _isParentEnabled;
  95541. private _isReady;
  95542. /** @hidden */
  95543. _currentRenderId: number;
  95544. private _parentUpdateId;
  95545. /** @hidden */
  95546. _childUpdateId: number;
  95547. /** @hidden */
  95548. _waitingParentId: Nullable<string>;
  95549. /** @hidden */
  95550. _scene: Scene;
  95551. /** @hidden */
  95552. _cache: any;
  95553. private _parentNode;
  95554. private _children;
  95555. /** @hidden */
  95556. _worldMatrix: Matrix;
  95557. /** @hidden */
  95558. _worldMatrixDeterminant: number;
  95559. /** @hidden */
  95560. _worldMatrixDeterminantIsDirty: boolean;
  95561. /** @hidden */
  95562. private _sceneRootNodesIndex;
  95563. /**
  95564. * Gets a boolean indicating if the node has been disposed
  95565. * @returns true if the node was disposed
  95566. */
  95567. isDisposed(): boolean;
  95568. /**
  95569. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95570. * @see https://doc.babylonjs.com/how_to/parenting
  95571. */
  95572. parent: Nullable<Node>;
  95573. /** @hidden */
  95574. _addToSceneRootNodes(): void;
  95575. /** @hidden */
  95576. _removeFromSceneRootNodes(): void;
  95577. private _animationPropertiesOverride;
  95578. /**
  95579. * Gets or sets the animation properties override
  95580. */
  95581. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95582. /**
  95583. * Gets a string idenfifying the name of the class
  95584. * @returns "Node" string
  95585. */
  95586. getClassName(): string;
  95587. /** @hidden */
  95588. readonly _isNode: boolean;
  95589. /**
  95590. * An event triggered when the mesh is disposed
  95591. */
  95592. onDisposeObservable: Observable<Node>;
  95593. private _onDisposeObserver;
  95594. /**
  95595. * Sets a callback that will be raised when the node will be disposed
  95596. */
  95597. onDispose: () => void;
  95598. /**
  95599. * Creates a new Node
  95600. * @param name the name and id to be given to this node
  95601. * @param scene the scene this node will be added to
  95602. */
  95603. constructor(name: string, scene?: Nullable<Scene>);
  95604. /**
  95605. * Gets the scene of the node
  95606. * @returns a scene
  95607. */
  95608. getScene(): Scene;
  95609. /**
  95610. * Gets the engine of the node
  95611. * @returns a Engine
  95612. */
  95613. getEngine(): Engine;
  95614. private _behaviors;
  95615. /**
  95616. * Attach a behavior to the node
  95617. * @see http://doc.babylonjs.com/features/behaviour
  95618. * @param behavior defines the behavior to attach
  95619. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95620. * @returns the current Node
  95621. */
  95622. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95623. /**
  95624. * Remove an attached behavior
  95625. * @see http://doc.babylonjs.com/features/behaviour
  95626. * @param behavior defines the behavior to attach
  95627. * @returns the current Node
  95628. */
  95629. removeBehavior(behavior: Behavior<Node>): Node;
  95630. /**
  95631. * Gets the list of attached behaviors
  95632. * @see http://doc.babylonjs.com/features/behaviour
  95633. */
  95634. readonly behaviors: Behavior<Node>[];
  95635. /**
  95636. * Gets an attached behavior by name
  95637. * @param name defines the name of the behavior to look for
  95638. * @see http://doc.babylonjs.com/features/behaviour
  95639. * @returns null if behavior was not found else the requested behavior
  95640. */
  95641. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95642. /**
  95643. * Returns the latest update of the World matrix
  95644. * @returns a Matrix
  95645. */
  95646. getWorldMatrix(): Matrix;
  95647. /** @hidden */
  95648. _getWorldMatrixDeterminant(): number;
  95649. /**
  95650. * Returns directly the latest state of the mesh World matrix.
  95651. * A Matrix is returned.
  95652. */
  95653. readonly worldMatrixFromCache: Matrix;
  95654. /** @hidden */
  95655. _initCache(): void;
  95656. /** @hidden */
  95657. updateCache(force?: boolean): void;
  95658. /** @hidden */
  95659. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95660. /** @hidden */
  95661. _updateCache(ignoreParentClass?: boolean): void;
  95662. /** @hidden */
  95663. _isSynchronized(): boolean;
  95664. /** @hidden */
  95665. _markSyncedWithParent(): void;
  95666. /** @hidden */
  95667. isSynchronizedWithParent(): boolean;
  95668. /** @hidden */
  95669. isSynchronized(): boolean;
  95670. /**
  95671. * Is this node ready to be used/rendered
  95672. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95673. * @return true if the node is ready
  95674. */
  95675. isReady(completeCheck?: boolean): boolean;
  95676. /**
  95677. * Is this node enabled?
  95678. * 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
  95679. * @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
  95680. * @return whether this node (and its parent) is enabled
  95681. */
  95682. isEnabled(checkAncestors?: boolean): boolean;
  95683. /** @hidden */
  95684. protected _syncParentEnabledState(): void;
  95685. /**
  95686. * Set the enabled state of this node
  95687. * @param value defines the new enabled state
  95688. */
  95689. setEnabled(value: boolean): void;
  95690. /**
  95691. * Is this node a descendant of the given node?
  95692. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95693. * @param ancestor defines the parent node to inspect
  95694. * @returns a boolean indicating if this node is a descendant of the given node
  95695. */
  95696. isDescendantOf(ancestor: Node): boolean;
  95697. /** @hidden */
  95698. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95699. /**
  95700. * Will return all nodes that have this node as ascendant
  95701. * @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
  95702. * @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
  95703. * @return all children nodes of all types
  95704. */
  95705. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95706. /**
  95707. * Get all child-meshes of this node
  95708. * @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)
  95709. * @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
  95710. * @returns an array of AbstractMesh
  95711. */
  95712. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95713. /**
  95714. * Get all direct children of this node
  95715. * @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
  95716. * @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)
  95717. * @returns an array of Node
  95718. */
  95719. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95720. /** @hidden */
  95721. _setReady(state: boolean): void;
  95722. /**
  95723. * Get an animation by name
  95724. * @param name defines the name of the animation to look for
  95725. * @returns null if not found else the requested animation
  95726. */
  95727. getAnimationByName(name: string): Nullable<Animation>;
  95728. /**
  95729. * Creates an animation range for this node
  95730. * @param name defines the name of the range
  95731. * @param from defines the starting key
  95732. * @param to defines the end key
  95733. */
  95734. createAnimationRange(name: string, from: number, to: number): void;
  95735. /**
  95736. * Delete a specific animation range
  95737. * @param name defines the name of the range to delete
  95738. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95739. */
  95740. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95741. /**
  95742. * Get an animation range by name
  95743. * @param name defines the name of the animation range to look for
  95744. * @returns null if not found else the requested animation range
  95745. */
  95746. getAnimationRange(name: string): Nullable<AnimationRange>;
  95747. /**
  95748. * Gets the list of all animation ranges defined on this node
  95749. * @returns an array
  95750. */
  95751. getAnimationRanges(): Nullable<AnimationRange>[];
  95752. /**
  95753. * Will start the animation sequence
  95754. * @param name defines the range frames for animation sequence
  95755. * @param loop defines if the animation should loop (false by default)
  95756. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95757. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95758. * @returns the object created for this animation. If range does not exist, it will return null
  95759. */
  95760. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95761. /**
  95762. * Serialize animation ranges into a JSON compatible object
  95763. * @returns serialization object
  95764. */
  95765. serializeAnimationRanges(): any;
  95766. /**
  95767. * Computes the world matrix of the node
  95768. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95769. * @returns the world matrix
  95770. */
  95771. computeWorldMatrix(force?: boolean): Matrix;
  95772. /**
  95773. * Releases resources associated with this node.
  95774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95776. */
  95777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95778. /**
  95779. * Parse animation range data from a serialization object and store them into a given node
  95780. * @param node defines where to store the animation ranges
  95781. * @param parsedNode defines the serialization object to read data from
  95782. * @param scene defines the hosting scene
  95783. */
  95784. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95785. /**
  95786. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95787. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95788. * @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
  95789. * @returns the new bounding vectors
  95790. */
  95791. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95792. min: Vector3;
  95793. max: Vector3;
  95794. };
  95795. }
  95796. }
  95797. declare module BABYLON {
  95798. /**
  95799. * @hidden
  95800. */
  95801. export class _IAnimationState {
  95802. key: number;
  95803. repeatCount: number;
  95804. workValue?: any;
  95805. loopMode?: number;
  95806. offsetValue?: any;
  95807. highLimitValue?: any;
  95808. }
  95809. /**
  95810. * Class used to store any kind of animation
  95811. */
  95812. export class Animation {
  95813. /**Name of the animation */
  95814. name: string;
  95815. /**Property to animate */
  95816. targetProperty: string;
  95817. /**The frames per second of the animation */
  95818. framePerSecond: number;
  95819. /**The data type of the animation */
  95820. dataType: number;
  95821. /**The loop mode of the animation */
  95822. loopMode?: number | undefined;
  95823. /**Specifies if blending should be enabled */
  95824. enableBlending?: boolean | undefined;
  95825. /**
  95826. * Use matrix interpolation instead of using direct key value when animating matrices
  95827. */
  95828. static AllowMatricesInterpolation: boolean;
  95829. /**
  95830. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95831. */
  95832. static AllowMatrixDecomposeForInterpolation: boolean;
  95833. /**
  95834. * Stores the key frames of the animation
  95835. */
  95836. private _keys;
  95837. /**
  95838. * Stores the easing function of the animation
  95839. */
  95840. private _easingFunction;
  95841. /**
  95842. * @hidden Internal use only
  95843. */
  95844. _runtimeAnimations: RuntimeAnimation[];
  95845. /**
  95846. * The set of event that will be linked to this animation
  95847. */
  95848. private _events;
  95849. /**
  95850. * Stores an array of target property paths
  95851. */
  95852. targetPropertyPath: string[];
  95853. /**
  95854. * Stores the blending speed of the animation
  95855. */
  95856. blendingSpeed: number;
  95857. /**
  95858. * Stores the animation ranges for the animation
  95859. */
  95860. private _ranges;
  95861. /**
  95862. * @hidden Internal use
  95863. */
  95864. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95865. /**
  95866. * Sets up an animation
  95867. * @param property The property to animate
  95868. * @param animationType The animation type to apply
  95869. * @param framePerSecond The frames per second of the animation
  95870. * @param easingFunction The easing function used in the animation
  95871. * @returns The created animation
  95872. */
  95873. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95874. /**
  95875. * Create and start an animation on a node
  95876. * @param name defines the name of the global animation that will be run on all nodes
  95877. * @param node defines the root node where the animation will take place
  95878. * @param targetProperty defines property to animate
  95879. * @param framePerSecond defines the number of frame per second yo use
  95880. * @param totalFrame defines the number of frames in total
  95881. * @param from defines the initial value
  95882. * @param to defines the final value
  95883. * @param loopMode defines which loop mode you want to use (off by default)
  95884. * @param easingFunction defines the easing function to use (linear by default)
  95885. * @param onAnimationEnd defines the callback to call when animation end
  95886. * @returns the animatable created for this animation
  95887. */
  95888. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95889. /**
  95890. * Create and start an animation on a node and its descendants
  95891. * @param name defines the name of the global animation that will be run on all nodes
  95892. * @param node defines the root node where the animation will take place
  95893. * @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
  95894. * @param targetProperty defines property to animate
  95895. * @param framePerSecond defines the number of frame per second to use
  95896. * @param totalFrame defines the number of frames in total
  95897. * @param from defines the initial value
  95898. * @param to defines the final value
  95899. * @param loopMode defines which loop mode you want to use (off by default)
  95900. * @param easingFunction defines the easing function to use (linear by default)
  95901. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95902. * @returns the list of animatables created for all nodes
  95903. * @example https://www.babylonjs-playground.com/#MH0VLI
  95904. */
  95905. 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[]>;
  95906. /**
  95907. * Creates a new animation, merges it with the existing animations and starts it
  95908. * @param name Name of the animation
  95909. * @param node Node which contains the scene that begins the animations
  95910. * @param targetProperty Specifies which property to animate
  95911. * @param framePerSecond The frames per second of the animation
  95912. * @param totalFrame The total number of frames
  95913. * @param from The frame at the beginning of the animation
  95914. * @param to The frame at the end of the animation
  95915. * @param loopMode Specifies the loop mode of the animation
  95916. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95917. * @param onAnimationEnd Callback to run once the animation is complete
  95918. * @returns Nullable animation
  95919. */
  95920. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95921. /**
  95922. * Transition property of an host to the target Value
  95923. * @param property The property to transition
  95924. * @param targetValue The target Value of the property
  95925. * @param host The object where the property to animate belongs
  95926. * @param scene Scene used to run the animation
  95927. * @param frameRate Framerate (in frame/s) to use
  95928. * @param transition The transition type we want to use
  95929. * @param duration The duration of the animation, in milliseconds
  95930. * @param onAnimationEnd Callback trigger at the end of the animation
  95931. * @returns Nullable animation
  95932. */
  95933. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95934. /**
  95935. * Return the array of runtime animations currently using this animation
  95936. */
  95937. readonly runtimeAnimations: RuntimeAnimation[];
  95938. /**
  95939. * Specifies if any of the runtime animations are currently running
  95940. */
  95941. readonly hasRunningRuntimeAnimations: boolean;
  95942. /**
  95943. * Initializes the animation
  95944. * @param name Name of the animation
  95945. * @param targetProperty Property to animate
  95946. * @param framePerSecond The frames per second of the animation
  95947. * @param dataType The data type of the animation
  95948. * @param loopMode The loop mode of the animation
  95949. * @param enableBlending Specifies if blending should be enabled
  95950. */
  95951. constructor(
  95952. /**Name of the animation */
  95953. name: string,
  95954. /**Property to animate */
  95955. targetProperty: string,
  95956. /**The frames per second of the animation */
  95957. framePerSecond: number,
  95958. /**The data type of the animation */
  95959. dataType: number,
  95960. /**The loop mode of the animation */
  95961. loopMode?: number | undefined,
  95962. /**Specifies if blending should be enabled */
  95963. enableBlending?: boolean | undefined);
  95964. /**
  95965. * Converts the animation to a string
  95966. * @param fullDetails support for multiple levels of logging within scene loading
  95967. * @returns String form of the animation
  95968. */
  95969. toString(fullDetails?: boolean): string;
  95970. /**
  95971. * Add an event to this animation
  95972. * @param event Event to add
  95973. */
  95974. addEvent(event: AnimationEvent): void;
  95975. /**
  95976. * Remove all events found at the given frame
  95977. * @param frame The frame to remove events from
  95978. */
  95979. removeEvents(frame: number): void;
  95980. /**
  95981. * Retrieves all the events from the animation
  95982. * @returns Events from the animation
  95983. */
  95984. getEvents(): AnimationEvent[];
  95985. /**
  95986. * Creates an animation range
  95987. * @param name Name of the animation range
  95988. * @param from Starting frame of the animation range
  95989. * @param to Ending frame of the animation
  95990. */
  95991. createRange(name: string, from: number, to: number): void;
  95992. /**
  95993. * Deletes an animation range by name
  95994. * @param name Name of the animation range to delete
  95995. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95996. */
  95997. deleteRange(name: string, deleteFrames?: boolean): void;
  95998. /**
  95999. * Gets the animation range by name, or null if not defined
  96000. * @param name Name of the animation range
  96001. * @returns Nullable animation range
  96002. */
  96003. getRange(name: string): Nullable<AnimationRange>;
  96004. /**
  96005. * Gets the key frames from the animation
  96006. * @returns The key frames of the animation
  96007. */
  96008. getKeys(): Array<IAnimationKey>;
  96009. /**
  96010. * Gets the highest frame rate of the animation
  96011. * @returns Highest frame rate of the animation
  96012. */
  96013. getHighestFrame(): number;
  96014. /**
  96015. * Gets the easing function of the animation
  96016. * @returns Easing function of the animation
  96017. */
  96018. getEasingFunction(): IEasingFunction;
  96019. /**
  96020. * Sets the easing function of the animation
  96021. * @param easingFunction A custom mathematical formula for animation
  96022. */
  96023. setEasingFunction(easingFunction: EasingFunction): void;
  96024. /**
  96025. * Interpolates a scalar linearly
  96026. * @param startValue Start value of the animation curve
  96027. * @param endValue End value of the animation curve
  96028. * @param gradient Scalar amount to interpolate
  96029. * @returns Interpolated scalar value
  96030. */
  96031. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  96032. /**
  96033. * Interpolates a scalar cubically
  96034. * @param startValue Start value of the animation curve
  96035. * @param outTangent End tangent of the animation
  96036. * @param endValue End value of the animation curve
  96037. * @param inTangent Start tangent of the animation curve
  96038. * @param gradient Scalar amount to interpolate
  96039. * @returns Interpolated scalar value
  96040. */
  96041. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  96042. /**
  96043. * Interpolates a quaternion using a spherical linear interpolation
  96044. * @param startValue Start value of the animation curve
  96045. * @param endValue End value of the animation curve
  96046. * @param gradient Scalar amount to interpolate
  96047. * @returns Interpolated quaternion value
  96048. */
  96049. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  96050. /**
  96051. * Interpolates a quaternion cubically
  96052. * @param startValue Start value of the animation curve
  96053. * @param outTangent End tangent of the animation curve
  96054. * @param endValue End value of the animation curve
  96055. * @param inTangent Start tangent of the animation curve
  96056. * @param gradient Scalar amount to interpolate
  96057. * @returns Interpolated quaternion value
  96058. */
  96059. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  96060. /**
  96061. * Interpolates a Vector3 linearl
  96062. * @param startValue Start value of the animation curve
  96063. * @param endValue End value of the animation curve
  96064. * @param gradient Scalar amount to interpolate
  96065. * @returns Interpolated scalar value
  96066. */
  96067. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  96068. /**
  96069. * Interpolates a Vector3 cubically
  96070. * @param startValue Start value of the animation curve
  96071. * @param outTangent End tangent of the animation
  96072. * @param endValue End value of the animation curve
  96073. * @param inTangent Start tangent of the animation curve
  96074. * @param gradient Scalar amount to interpolate
  96075. * @returns InterpolatedVector3 value
  96076. */
  96077. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  96078. /**
  96079. * Interpolates a Vector2 linearly
  96080. * @param startValue Start value of the animation curve
  96081. * @param endValue End value of the animation curve
  96082. * @param gradient Scalar amount to interpolate
  96083. * @returns Interpolated Vector2 value
  96084. */
  96085. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96086. /**
  96087. * Interpolates a Vector2 cubically
  96088. * @param startValue Start value of the animation curve
  96089. * @param outTangent End tangent of the animation
  96090. * @param endValue End value of the animation curve
  96091. * @param inTangent Start tangent of the animation curve
  96092. * @param gradient Scalar amount to interpolate
  96093. * @returns Interpolated Vector2 value
  96094. */
  96095. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96096. /**
  96097. * Interpolates a size linearly
  96098. * @param startValue Start value of the animation curve
  96099. * @param endValue End value of the animation curve
  96100. * @param gradient Scalar amount to interpolate
  96101. * @returns Interpolated Size value
  96102. */
  96103. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96104. /**
  96105. * Interpolates a Color3 linearly
  96106. * @param startValue Start value of the animation curve
  96107. * @param endValue End value of the animation curve
  96108. * @param gradient Scalar amount to interpolate
  96109. * @returns Interpolated Color3 value
  96110. */
  96111. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96112. /**
  96113. * Interpolates a Color4 linearly
  96114. * @param startValue Start value of the animation curve
  96115. * @param endValue End value of the animation curve
  96116. * @param gradient Scalar amount to interpolate
  96117. * @returns Interpolated Color3 value
  96118. */
  96119. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96120. /**
  96121. * @hidden Internal use only
  96122. */
  96123. _getKeyValue(value: any): any;
  96124. /**
  96125. * @hidden Internal use only
  96126. */
  96127. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96128. /**
  96129. * Defines the function to use to interpolate matrices
  96130. * @param startValue defines the start matrix
  96131. * @param endValue defines the end matrix
  96132. * @param gradient defines the gradient between both matrices
  96133. * @param result defines an optional target matrix where to store the interpolation
  96134. * @returns the interpolated matrix
  96135. */
  96136. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96137. /**
  96138. * Makes a copy of the animation
  96139. * @returns Cloned animation
  96140. */
  96141. clone(): Animation;
  96142. /**
  96143. * Sets the key frames of the animation
  96144. * @param values The animation key frames to set
  96145. */
  96146. setKeys(values: Array<IAnimationKey>): void;
  96147. /**
  96148. * Serializes the animation to an object
  96149. * @returns Serialized object
  96150. */
  96151. serialize(): any;
  96152. /**
  96153. * Float animation type
  96154. */
  96155. static readonly ANIMATIONTYPE_FLOAT: number;
  96156. /**
  96157. * Vector3 animation type
  96158. */
  96159. static readonly ANIMATIONTYPE_VECTOR3: number;
  96160. /**
  96161. * Quaternion animation type
  96162. */
  96163. static readonly ANIMATIONTYPE_QUATERNION: number;
  96164. /**
  96165. * Matrix animation type
  96166. */
  96167. static readonly ANIMATIONTYPE_MATRIX: number;
  96168. /**
  96169. * Color3 animation type
  96170. */
  96171. static readonly ANIMATIONTYPE_COLOR3: number;
  96172. /**
  96173. * Color3 animation type
  96174. */
  96175. static readonly ANIMATIONTYPE_COLOR4: number;
  96176. /**
  96177. * Vector2 animation type
  96178. */
  96179. static readonly ANIMATIONTYPE_VECTOR2: number;
  96180. /**
  96181. * Size animation type
  96182. */
  96183. static readonly ANIMATIONTYPE_SIZE: number;
  96184. /**
  96185. * Relative Loop Mode
  96186. */
  96187. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96188. /**
  96189. * Cycle Loop Mode
  96190. */
  96191. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96192. /**
  96193. * Constant Loop Mode
  96194. */
  96195. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96196. /** @hidden */
  96197. static _UniversalLerp(left: any, right: any, amount: number): any;
  96198. /**
  96199. * Parses an animation object and creates an animation
  96200. * @param parsedAnimation Parsed animation object
  96201. * @returns Animation object
  96202. */
  96203. static Parse(parsedAnimation: any): Animation;
  96204. /**
  96205. * Appends the serialized animations from the source animations
  96206. * @param source Source containing the animations
  96207. * @param destination Target to store the animations
  96208. */
  96209. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96210. }
  96211. }
  96212. declare module BABYLON {
  96213. /**
  96214. * Interface containing an array of animations
  96215. */
  96216. export interface IAnimatable {
  96217. /**
  96218. * Array of animations
  96219. */
  96220. animations: Nullable<Array<Animation>>;
  96221. }
  96222. }
  96223. declare module BABYLON {
  96224. /**
  96225. * This represents all the required information to add a fresnel effect on a material:
  96226. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96227. */
  96228. export class FresnelParameters {
  96229. private _isEnabled;
  96230. /**
  96231. * Define if the fresnel effect is enable or not.
  96232. */
  96233. isEnabled: boolean;
  96234. /**
  96235. * Define the color used on edges (grazing angle)
  96236. */
  96237. leftColor: Color3;
  96238. /**
  96239. * Define the color used on center
  96240. */
  96241. rightColor: Color3;
  96242. /**
  96243. * Define bias applied to computed fresnel term
  96244. */
  96245. bias: number;
  96246. /**
  96247. * Defined the power exponent applied to fresnel term
  96248. */
  96249. power: number;
  96250. /**
  96251. * Clones the current fresnel and its valuues
  96252. * @returns a clone fresnel configuration
  96253. */
  96254. clone(): FresnelParameters;
  96255. /**
  96256. * Serializes the current fresnel parameters to a JSON representation.
  96257. * @return the JSON serialization
  96258. */
  96259. serialize(): any;
  96260. /**
  96261. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96262. * @param parsedFresnelParameters Define the JSON representation
  96263. * @returns the parsed parameters
  96264. */
  96265. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96266. }
  96267. }
  96268. declare module BABYLON {
  96269. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96270. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96271. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96272. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96273. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96274. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96275. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96276. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96277. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96278. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96279. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96280. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96281. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96282. /**
  96283. * Decorator used to define property that can be serialized as reference to a camera
  96284. * @param sourceName defines the name of the property to decorate
  96285. */
  96286. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96287. /**
  96288. * Class used to help serialization objects
  96289. */
  96290. export class SerializationHelper {
  96291. /** @hidden */
  96292. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96293. /** @hidden */
  96294. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96295. /** @hidden */
  96296. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96297. /** @hidden */
  96298. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96299. /**
  96300. * Appends the serialized animations from the source animations
  96301. * @param source Source containing the animations
  96302. * @param destination Target to store the animations
  96303. */
  96304. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96305. /**
  96306. * Static function used to serialized a specific entity
  96307. * @param entity defines the entity to serialize
  96308. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96309. * @returns a JSON compatible object representing the serialization of the entity
  96310. */
  96311. static Serialize<T>(entity: T, serializationObject?: any): any;
  96312. /**
  96313. * Creates a new entity from a serialization data object
  96314. * @param creationFunction defines a function used to instanciated the new entity
  96315. * @param source defines the source serialization data
  96316. * @param scene defines the hosting scene
  96317. * @param rootUrl defines the root url for resources
  96318. * @returns a new entity
  96319. */
  96320. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96321. /**
  96322. * Clones an object
  96323. * @param creationFunction defines the function used to instanciate the new object
  96324. * @param source defines the source object
  96325. * @returns the cloned object
  96326. */
  96327. static Clone<T>(creationFunction: () => T, source: T): T;
  96328. /**
  96329. * Instanciates a new object based on a source one (some data will be shared between both object)
  96330. * @param creationFunction defines the function used to instanciate the new object
  96331. * @param source defines the source object
  96332. * @returns the new object
  96333. */
  96334. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96335. }
  96336. }
  96337. declare module BABYLON {
  96338. /**
  96339. * Class used to manipulate GUIDs
  96340. */
  96341. export class GUID {
  96342. /**
  96343. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96344. * Be aware Math.random() could cause collisions, but:
  96345. * "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"
  96346. * @returns a pseudo random id
  96347. */
  96348. static RandomId(): string;
  96349. }
  96350. }
  96351. declare module BABYLON {
  96352. /**
  96353. * Base class of all the textures in babylon.
  96354. * It groups all the common properties the materials, post process, lights... might need
  96355. * in order to make a correct use of the texture.
  96356. */
  96357. export class BaseTexture implements IAnimatable {
  96358. /**
  96359. * Default anisotropic filtering level for the application.
  96360. * It is set to 4 as a good tradeoff between perf and quality.
  96361. */
  96362. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96363. /**
  96364. * Gets or sets the unique id of the texture
  96365. */
  96366. uniqueId: number;
  96367. /**
  96368. * Define the name of the texture.
  96369. */
  96370. name: string;
  96371. /**
  96372. * Gets or sets an object used to store user defined information.
  96373. */
  96374. metadata: any;
  96375. /**
  96376. * For internal use only. Please do not use.
  96377. */
  96378. reservedDataStore: any;
  96379. private _hasAlpha;
  96380. /**
  96381. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96382. */
  96383. hasAlpha: boolean;
  96384. /**
  96385. * Defines if the alpha value should be determined via the rgb values.
  96386. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96387. */
  96388. getAlphaFromRGB: boolean;
  96389. /**
  96390. * Intensity or strength of the texture.
  96391. * It is commonly used by materials to fine tune the intensity of the texture
  96392. */
  96393. level: number;
  96394. /**
  96395. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96396. * This is part of the texture as textures usually maps to one uv set.
  96397. */
  96398. coordinatesIndex: number;
  96399. private _coordinatesMode;
  96400. /**
  96401. * How a texture is mapped.
  96402. *
  96403. * | Value | Type | Description |
  96404. * | ----- | ----------------------------------- | ----------- |
  96405. * | 0 | EXPLICIT_MODE | |
  96406. * | 1 | SPHERICAL_MODE | |
  96407. * | 2 | PLANAR_MODE | |
  96408. * | 3 | CUBIC_MODE | |
  96409. * | 4 | PROJECTION_MODE | |
  96410. * | 5 | SKYBOX_MODE | |
  96411. * | 6 | INVCUBIC_MODE | |
  96412. * | 7 | EQUIRECTANGULAR_MODE | |
  96413. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96414. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96415. */
  96416. coordinatesMode: number;
  96417. /**
  96418. * | Value | Type | Description |
  96419. * | ----- | ------------------ | ----------- |
  96420. * | 0 | CLAMP_ADDRESSMODE | |
  96421. * | 1 | WRAP_ADDRESSMODE | |
  96422. * | 2 | MIRROR_ADDRESSMODE | |
  96423. */
  96424. wrapU: number;
  96425. /**
  96426. * | Value | Type | Description |
  96427. * | ----- | ------------------ | ----------- |
  96428. * | 0 | CLAMP_ADDRESSMODE | |
  96429. * | 1 | WRAP_ADDRESSMODE | |
  96430. * | 2 | MIRROR_ADDRESSMODE | |
  96431. */
  96432. wrapV: number;
  96433. /**
  96434. * | Value | Type | Description |
  96435. * | ----- | ------------------ | ----------- |
  96436. * | 0 | CLAMP_ADDRESSMODE | |
  96437. * | 1 | WRAP_ADDRESSMODE | |
  96438. * | 2 | MIRROR_ADDRESSMODE | |
  96439. */
  96440. wrapR: number;
  96441. /**
  96442. * With compliant hardware and browser (supporting anisotropic filtering)
  96443. * this defines the level of anisotropic filtering in the texture.
  96444. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96445. */
  96446. anisotropicFilteringLevel: number;
  96447. /**
  96448. * Define if the texture is a cube texture or if false a 2d texture.
  96449. */
  96450. isCube: boolean;
  96451. /**
  96452. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96453. */
  96454. is3D: boolean;
  96455. /**
  96456. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96457. */
  96458. is2DArray: boolean;
  96459. /**
  96460. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96461. * HDR texture are usually stored in linear space.
  96462. * This only impacts the PBR and Background materials
  96463. */
  96464. gammaSpace: boolean;
  96465. /**
  96466. * Gets or sets whether or not the texture contains RGBD data.
  96467. */
  96468. isRGBD: boolean;
  96469. /**
  96470. * Is Z inverted in the texture (useful in a cube texture).
  96471. */
  96472. invertZ: boolean;
  96473. /**
  96474. * Are mip maps generated for this texture or not.
  96475. */
  96476. readonly noMipmap: boolean;
  96477. /**
  96478. * @hidden
  96479. */
  96480. lodLevelInAlpha: boolean;
  96481. /**
  96482. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96483. */
  96484. lodGenerationOffset: number;
  96485. /**
  96486. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96487. */
  96488. lodGenerationScale: number;
  96489. /**
  96490. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96491. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96492. * average roughness values.
  96493. */
  96494. linearSpecularLOD: boolean;
  96495. /**
  96496. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96497. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96498. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96499. */
  96500. irradianceTexture: Nullable<BaseTexture>;
  96501. /**
  96502. * Define if the texture is a render target.
  96503. */
  96504. isRenderTarget: boolean;
  96505. /**
  96506. * Define the unique id of the texture in the scene.
  96507. */
  96508. readonly uid: string;
  96509. /**
  96510. * Return a string representation of the texture.
  96511. * @returns the texture as a string
  96512. */
  96513. toString(): string;
  96514. /**
  96515. * Get the class name of the texture.
  96516. * @returns "BaseTexture"
  96517. */
  96518. getClassName(): string;
  96519. /**
  96520. * Define the list of animation attached to the texture.
  96521. */
  96522. animations: Animation[];
  96523. /**
  96524. * An event triggered when the texture is disposed.
  96525. */
  96526. onDisposeObservable: Observable<BaseTexture>;
  96527. private _onDisposeObserver;
  96528. /**
  96529. * Callback triggered when the texture has been disposed.
  96530. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96531. */
  96532. onDispose: () => void;
  96533. /**
  96534. * Define the current state of the loading sequence when in delayed load mode.
  96535. */
  96536. delayLoadState: number;
  96537. private _scene;
  96538. /** @hidden */
  96539. _texture: Nullable<InternalTexture>;
  96540. private _uid;
  96541. /**
  96542. * Define if the texture is preventinga material to render or not.
  96543. * If not and the texture is not ready, the engine will use a default black texture instead.
  96544. */
  96545. readonly isBlocking: boolean;
  96546. /**
  96547. * Instantiates a new BaseTexture.
  96548. * Base class of all the textures in babylon.
  96549. * It groups all the common properties the materials, post process, lights... might need
  96550. * in order to make a correct use of the texture.
  96551. * @param scene Define the scene the texture blongs to
  96552. */
  96553. constructor(scene: Nullable<Scene>);
  96554. /**
  96555. * Get the scene the texture belongs to.
  96556. * @returns the scene or null if undefined
  96557. */
  96558. getScene(): Nullable<Scene>;
  96559. /**
  96560. * Get the texture transform matrix used to offset tile the texture for istance.
  96561. * @returns the transformation matrix
  96562. */
  96563. getTextureMatrix(): Matrix;
  96564. /**
  96565. * Get the texture reflection matrix used to rotate/transform the reflection.
  96566. * @returns the reflection matrix
  96567. */
  96568. getReflectionTextureMatrix(): Matrix;
  96569. /**
  96570. * Get the underlying lower level texture from Babylon.
  96571. * @returns the insternal texture
  96572. */
  96573. getInternalTexture(): Nullable<InternalTexture>;
  96574. /**
  96575. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96576. * @returns true if ready or not blocking
  96577. */
  96578. isReadyOrNotBlocking(): boolean;
  96579. /**
  96580. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96581. * @returns true if fully ready
  96582. */
  96583. isReady(): boolean;
  96584. private _cachedSize;
  96585. /**
  96586. * Get the size of the texture.
  96587. * @returns the texture size.
  96588. */
  96589. getSize(): ISize;
  96590. /**
  96591. * Get the base size of the texture.
  96592. * It can be different from the size if the texture has been resized for POT for instance
  96593. * @returns the base size
  96594. */
  96595. getBaseSize(): ISize;
  96596. /**
  96597. * Update the sampling mode of the texture.
  96598. * Default is Trilinear mode.
  96599. *
  96600. * | Value | Type | Description |
  96601. * | ----- | ------------------ | ----------- |
  96602. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96603. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96604. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96605. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96606. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96607. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96608. * | 7 | NEAREST_LINEAR | |
  96609. * | 8 | NEAREST_NEAREST | |
  96610. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96611. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96612. * | 11 | LINEAR_LINEAR | |
  96613. * | 12 | LINEAR_NEAREST | |
  96614. *
  96615. * > _mag_: magnification filter (close to the viewer)
  96616. * > _min_: minification filter (far from the viewer)
  96617. * > _mip_: filter used between mip map levels
  96618. *@param samplingMode Define the new sampling mode of the texture
  96619. */
  96620. updateSamplingMode(samplingMode: number): void;
  96621. /**
  96622. * Scales the texture if is `canRescale()`
  96623. * @param ratio the resize factor we want to use to rescale
  96624. */
  96625. scale(ratio: number): void;
  96626. /**
  96627. * Get if the texture can rescale.
  96628. */
  96629. readonly canRescale: boolean;
  96630. /** @hidden */
  96631. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96632. /** @hidden */
  96633. _rebuild(): void;
  96634. /**
  96635. * Triggers the load sequence in delayed load mode.
  96636. */
  96637. delayLoad(): void;
  96638. /**
  96639. * Clones the texture.
  96640. * @returns the cloned texture
  96641. */
  96642. clone(): Nullable<BaseTexture>;
  96643. /**
  96644. * Get the texture underlying type (INT, FLOAT...)
  96645. */
  96646. readonly textureType: number;
  96647. /**
  96648. * Get the texture underlying format (RGB, RGBA...)
  96649. */
  96650. readonly textureFormat: number;
  96651. /**
  96652. * Indicates that textures need to be re-calculated for all materials
  96653. */
  96654. protected _markAllSubMeshesAsTexturesDirty(): void;
  96655. /**
  96656. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96657. * This will returns an RGBA array buffer containing either in values (0-255) or
  96658. * float values (0-1) depending of the underlying buffer type.
  96659. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96660. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96661. * @param buffer defines a user defined buffer to fill with data (can be null)
  96662. * @returns The Array buffer containing the pixels data.
  96663. */
  96664. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96665. /**
  96666. * Release and destroy the underlying lower level texture aka internalTexture.
  96667. */
  96668. releaseInternalTexture(): void;
  96669. /** @hidden */
  96670. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96671. /** @hidden */
  96672. readonly _lodTextureMid: Nullable<BaseTexture>;
  96673. /** @hidden */
  96674. readonly _lodTextureLow: Nullable<BaseTexture>;
  96675. /**
  96676. * Dispose the texture and release its associated resources.
  96677. */
  96678. dispose(): void;
  96679. /**
  96680. * Serialize the texture into a JSON representation that can be parsed later on.
  96681. * @returns the JSON representation of the texture
  96682. */
  96683. serialize(): any;
  96684. /**
  96685. * Helper function to be called back once a list of texture contains only ready textures.
  96686. * @param textures Define the list of textures to wait for
  96687. * @param callback Define the callback triggered once the entire list will be ready
  96688. */
  96689. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96690. }
  96691. }
  96692. declare module BABYLON {
  96693. /**
  96694. * Options to be used when creating an effect.
  96695. */
  96696. export interface IEffectCreationOptions {
  96697. /**
  96698. * Atrributes that will be used in the shader.
  96699. */
  96700. attributes: string[];
  96701. /**
  96702. * Uniform varible names that will be set in the shader.
  96703. */
  96704. uniformsNames: string[];
  96705. /**
  96706. * Uniform buffer variable names that will be set in the shader.
  96707. */
  96708. uniformBuffersNames: string[];
  96709. /**
  96710. * Sampler texture variable names that will be set in the shader.
  96711. */
  96712. samplers: string[];
  96713. /**
  96714. * Define statements that will be set in the shader.
  96715. */
  96716. defines: any;
  96717. /**
  96718. * Possible fallbacks for this effect to improve performance when needed.
  96719. */
  96720. fallbacks: Nullable<IEffectFallbacks>;
  96721. /**
  96722. * Callback that will be called when the shader is compiled.
  96723. */
  96724. onCompiled: Nullable<(effect: Effect) => void>;
  96725. /**
  96726. * Callback that will be called if an error occurs during shader compilation.
  96727. */
  96728. onError: Nullable<(effect: Effect, errors: string) => void>;
  96729. /**
  96730. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96731. */
  96732. indexParameters?: any;
  96733. /**
  96734. * Max number of lights that can be used in the shader.
  96735. */
  96736. maxSimultaneousLights?: number;
  96737. /**
  96738. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96739. */
  96740. transformFeedbackVaryings?: Nullable<string[]>;
  96741. }
  96742. /**
  96743. * Effect containing vertex and fragment shader that can be executed on an object.
  96744. */
  96745. export class Effect implements IDisposable {
  96746. /**
  96747. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96748. */
  96749. static ShadersRepository: string;
  96750. /**
  96751. * Name of the effect.
  96752. */
  96753. name: any;
  96754. /**
  96755. * String container all the define statements that should be set on the shader.
  96756. */
  96757. defines: string;
  96758. /**
  96759. * Callback that will be called when the shader is compiled.
  96760. */
  96761. onCompiled: Nullable<(effect: Effect) => void>;
  96762. /**
  96763. * Callback that will be called if an error occurs during shader compilation.
  96764. */
  96765. onError: Nullable<(effect: Effect, errors: string) => void>;
  96766. /**
  96767. * Callback that will be called when effect is bound.
  96768. */
  96769. onBind: Nullable<(effect: Effect) => void>;
  96770. /**
  96771. * Unique ID of the effect.
  96772. */
  96773. uniqueId: number;
  96774. /**
  96775. * Observable that will be called when the shader is compiled.
  96776. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96777. */
  96778. onCompileObservable: Observable<Effect>;
  96779. /**
  96780. * Observable that will be called if an error occurs during shader compilation.
  96781. */
  96782. onErrorObservable: Observable<Effect>;
  96783. /** @hidden */
  96784. _onBindObservable: Nullable<Observable<Effect>>;
  96785. /**
  96786. * Observable that will be called when effect is bound.
  96787. */
  96788. readonly onBindObservable: Observable<Effect>;
  96789. /** @hidden */
  96790. _bonesComputationForcedToCPU: boolean;
  96791. private static _uniqueIdSeed;
  96792. private _engine;
  96793. private _uniformBuffersNames;
  96794. private _uniformsNames;
  96795. private _samplerList;
  96796. private _samplers;
  96797. private _isReady;
  96798. private _compilationError;
  96799. private _allFallbacksProcessed;
  96800. private _attributesNames;
  96801. private _attributes;
  96802. private _uniforms;
  96803. /**
  96804. * Key for the effect.
  96805. * @hidden
  96806. */
  96807. _key: string;
  96808. private _indexParameters;
  96809. private _fallbacks;
  96810. private _vertexSourceCode;
  96811. private _fragmentSourceCode;
  96812. private _vertexSourceCodeOverride;
  96813. private _fragmentSourceCodeOverride;
  96814. private _transformFeedbackVaryings;
  96815. /**
  96816. * Compiled shader to webGL program.
  96817. * @hidden
  96818. */
  96819. _pipelineContext: Nullable<IPipelineContext>;
  96820. private _valueCache;
  96821. private static _baseCache;
  96822. /**
  96823. * Instantiates an effect.
  96824. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96825. * @param baseName Name of the effect.
  96826. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96827. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96828. * @param samplers List of sampler variables that will be passed to the shader.
  96829. * @param engine Engine to be used to render the effect
  96830. * @param defines Define statements to be added to the shader.
  96831. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96832. * @param onCompiled Callback that will be called when the shader is compiled.
  96833. * @param onError Callback that will be called if an error occurs during shader compilation.
  96834. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96835. */
  96836. 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);
  96837. private _useFinalCode;
  96838. /**
  96839. * Unique key for this effect
  96840. */
  96841. readonly key: string;
  96842. /**
  96843. * If the effect has been compiled and prepared.
  96844. * @returns if the effect is compiled and prepared.
  96845. */
  96846. isReady(): boolean;
  96847. private _isReadyInternal;
  96848. /**
  96849. * The engine the effect was initialized with.
  96850. * @returns the engine.
  96851. */
  96852. getEngine(): Engine;
  96853. /**
  96854. * The pipeline context for this effect
  96855. * @returns the associated pipeline context
  96856. */
  96857. getPipelineContext(): Nullable<IPipelineContext>;
  96858. /**
  96859. * The set of names of attribute variables for the shader.
  96860. * @returns An array of attribute names.
  96861. */
  96862. getAttributesNames(): string[];
  96863. /**
  96864. * Returns the attribute at the given index.
  96865. * @param index The index of the attribute.
  96866. * @returns The location of the attribute.
  96867. */
  96868. getAttributeLocation(index: number): number;
  96869. /**
  96870. * Returns the attribute based on the name of the variable.
  96871. * @param name of the attribute to look up.
  96872. * @returns the attribute location.
  96873. */
  96874. getAttributeLocationByName(name: string): number;
  96875. /**
  96876. * The number of attributes.
  96877. * @returns the numnber of attributes.
  96878. */
  96879. getAttributesCount(): number;
  96880. /**
  96881. * Gets the index of a uniform variable.
  96882. * @param uniformName of the uniform to look up.
  96883. * @returns the index.
  96884. */
  96885. getUniformIndex(uniformName: string): number;
  96886. /**
  96887. * Returns the attribute based on the name of the variable.
  96888. * @param uniformName of the uniform to look up.
  96889. * @returns the location of the uniform.
  96890. */
  96891. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96892. /**
  96893. * Returns an array of sampler variable names
  96894. * @returns The array of sampler variable neames.
  96895. */
  96896. getSamplers(): string[];
  96897. /**
  96898. * The error from the last compilation.
  96899. * @returns the error string.
  96900. */
  96901. getCompilationError(): string;
  96902. /**
  96903. * Gets a boolean indicating that all fallbacks were used during compilation
  96904. * @returns true if all fallbacks were used
  96905. */
  96906. allFallbacksProcessed(): boolean;
  96907. /**
  96908. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96909. * @param func The callback to be used.
  96910. */
  96911. executeWhenCompiled(func: (effect: Effect) => void): void;
  96912. private _checkIsReady;
  96913. private _loadShader;
  96914. /**
  96915. * Recompiles the webGL program
  96916. * @param vertexSourceCode The source code for the vertex shader.
  96917. * @param fragmentSourceCode The source code for the fragment shader.
  96918. * @param onCompiled Callback called when completed.
  96919. * @param onError Callback called on error.
  96920. * @hidden
  96921. */
  96922. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96923. /**
  96924. * Prepares the effect
  96925. * @hidden
  96926. */
  96927. _prepareEffect(): void;
  96928. private _processCompilationErrors;
  96929. /**
  96930. * Checks if the effect is supported. (Must be called after compilation)
  96931. */
  96932. readonly isSupported: boolean;
  96933. /**
  96934. * Binds a texture to the engine to be used as output of the shader.
  96935. * @param channel Name of the output variable.
  96936. * @param texture Texture to bind.
  96937. * @hidden
  96938. */
  96939. _bindTexture(channel: string, texture: InternalTexture): void;
  96940. /**
  96941. * Sets a texture on the engine to be used in the shader.
  96942. * @param channel Name of the sampler variable.
  96943. * @param texture Texture to set.
  96944. */
  96945. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96946. /**
  96947. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96948. * @param channel Name of the sampler variable.
  96949. * @param texture Texture to set.
  96950. */
  96951. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96952. /**
  96953. * Sets an array of textures on the engine to be used in the shader.
  96954. * @param channel Name of the variable.
  96955. * @param textures Textures to set.
  96956. */
  96957. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96958. /**
  96959. * 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)
  96960. * @param channel Name of the sampler variable.
  96961. * @param postProcess Post process to get the input texture from.
  96962. */
  96963. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96964. /**
  96965. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96966. * 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)
  96967. * @param channel Name of the sampler variable.
  96968. * @param postProcess Post process to get the output texture from.
  96969. */
  96970. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96971. /** @hidden */
  96972. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96973. /** @hidden */
  96974. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96975. /** @hidden */
  96976. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96977. /** @hidden */
  96978. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96979. /**
  96980. * Binds a buffer to a uniform.
  96981. * @param buffer Buffer to bind.
  96982. * @param name Name of the uniform variable to bind to.
  96983. */
  96984. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96985. /**
  96986. * Binds block to a uniform.
  96987. * @param blockName Name of the block to bind.
  96988. * @param index Index to bind.
  96989. */
  96990. bindUniformBlock(blockName: string, index: number): void;
  96991. /**
  96992. * Sets an interger value on a uniform variable.
  96993. * @param uniformName Name of the variable.
  96994. * @param value Value to be set.
  96995. * @returns this effect.
  96996. */
  96997. setInt(uniformName: string, value: number): Effect;
  96998. /**
  96999. * Sets an int array on a uniform variable.
  97000. * @param uniformName Name of the variable.
  97001. * @param array array to be set.
  97002. * @returns this effect.
  97003. */
  97004. setIntArray(uniformName: string, array: Int32Array): Effect;
  97005. /**
  97006. * 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)
  97007. * @param uniformName Name of the variable.
  97008. * @param array array to be set.
  97009. * @returns this effect.
  97010. */
  97011. setIntArray2(uniformName: string, array: Int32Array): Effect;
  97012. /**
  97013. * 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)
  97014. * @param uniformName Name of the variable.
  97015. * @param array array to be set.
  97016. * @returns this effect.
  97017. */
  97018. setIntArray3(uniformName: string, array: Int32Array): Effect;
  97019. /**
  97020. * 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)
  97021. * @param uniformName Name of the variable.
  97022. * @param array array to be set.
  97023. * @returns this effect.
  97024. */
  97025. setIntArray4(uniformName: string, array: Int32Array): Effect;
  97026. /**
  97027. * Sets an float array on a uniform variable.
  97028. * @param uniformName Name of the variable.
  97029. * @param array array to be set.
  97030. * @returns this effect.
  97031. */
  97032. setFloatArray(uniformName: string, array: Float32Array): Effect;
  97033. /**
  97034. * 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)
  97035. * @param uniformName Name of the variable.
  97036. * @param array array to be set.
  97037. * @returns this effect.
  97038. */
  97039. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  97040. /**
  97041. * 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)
  97042. * @param uniformName Name of the variable.
  97043. * @param array array to be set.
  97044. * @returns this effect.
  97045. */
  97046. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  97047. /**
  97048. * 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)
  97049. * @param uniformName Name of the variable.
  97050. * @param array array to be set.
  97051. * @returns this effect.
  97052. */
  97053. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  97054. /**
  97055. * Sets an array on a uniform variable.
  97056. * @param uniformName Name of the variable.
  97057. * @param array array to be set.
  97058. * @returns this effect.
  97059. */
  97060. setArray(uniformName: string, array: number[]): Effect;
  97061. /**
  97062. * 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)
  97063. * @param uniformName Name of the variable.
  97064. * @param array array to be set.
  97065. * @returns this effect.
  97066. */
  97067. setArray2(uniformName: string, array: number[]): Effect;
  97068. /**
  97069. * 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)
  97070. * @param uniformName Name of the variable.
  97071. * @param array array to be set.
  97072. * @returns this effect.
  97073. */
  97074. setArray3(uniformName: string, array: number[]): Effect;
  97075. /**
  97076. * 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)
  97077. * @param uniformName Name of the variable.
  97078. * @param array array to be set.
  97079. * @returns this effect.
  97080. */
  97081. setArray4(uniformName: string, array: number[]): Effect;
  97082. /**
  97083. * Sets matrices on a uniform variable.
  97084. * @param uniformName Name of the variable.
  97085. * @param matrices matrices to be set.
  97086. * @returns this effect.
  97087. */
  97088. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97089. /**
  97090. * Sets matrix on a uniform variable.
  97091. * @param uniformName Name of the variable.
  97092. * @param matrix matrix to be set.
  97093. * @returns this effect.
  97094. */
  97095. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97096. /**
  97097. * 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)
  97098. * @param uniformName Name of the variable.
  97099. * @param matrix matrix to be set.
  97100. * @returns this effect.
  97101. */
  97102. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97103. /**
  97104. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97105. * @param uniformName Name of the variable.
  97106. * @param matrix matrix to be set.
  97107. * @returns this effect.
  97108. */
  97109. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97110. /**
  97111. * Sets a float on a uniform variable.
  97112. * @param uniformName Name of the variable.
  97113. * @param value value to be set.
  97114. * @returns this effect.
  97115. */
  97116. setFloat(uniformName: string, value: number): Effect;
  97117. /**
  97118. * Sets a boolean on a uniform variable.
  97119. * @param uniformName Name of the variable.
  97120. * @param bool value to be set.
  97121. * @returns this effect.
  97122. */
  97123. setBool(uniformName: string, bool: boolean): Effect;
  97124. /**
  97125. * Sets a Vector2 on a uniform variable.
  97126. * @param uniformName Name of the variable.
  97127. * @param vector2 vector2 to be set.
  97128. * @returns this effect.
  97129. */
  97130. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97131. /**
  97132. * Sets a float2 on a uniform variable.
  97133. * @param uniformName Name of the variable.
  97134. * @param x First float in float2.
  97135. * @param y Second float in float2.
  97136. * @returns this effect.
  97137. */
  97138. setFloat2(uniformName: string, x: number, y: number): Effect;
  97139. /**
  97140. * Sets a Vector3 on a uniform variable.
  97141. * @param uniformName Name of the variable.
  97142. * @param vector3 Value to be set.
  97143. * @returns this effect.
  97144. */
  97145. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97146. /**
  97147. * Sets a float3 on a uniform variable.
  97148. * @param uniformName Name of the variable.
  97149. * @param x First float in float3.
  97150. * @param y Second float in float3.
  97151. * @param z Third float in float3.
  97152. * @returns this effect.
  97153. */
  97154. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97155. /**
  97156. * Sets a Vector4 on a uniform variable.
  97157. * @param uniformName Name of the variable.
  97158. * @param vector4 Value to be set.
  97159. * @returns this effect.
  97160. */
  97161. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97162. /**
  97163. * Sets a float4 on a uniform variable.
  97164. * @param uniformName Name of the variable.
  97165. * @param x First float in float4.
  97166. * @param y Second float in float4.
  97167. * @param z Third float in float4.
  97168. * @param w Fourth float in float4.
  97169. * @returns this effect.
  97170. */
  97171. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97172. /**
  97173. * Sets a Color3 on a uniform variable.
  97174. * @param uniformName Name of the variable.
  97175. * @param color3 Value to be set.
  97176. * @returns this effect.
  97177. */
  97178. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97179. /**
  97180. * Sets a Color4 on a uniform variable.
  97181. * @param uniformName Name of the variable.
  97182. * @param color3 Value to be set.
  97183. * @param alpha Alpha value to be set.
  97184. * @returns this effect.
  97185. */
  97186. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97187. /**
  97188. * Sets a Color4 on a uniform variable
  97189. * @param uniformName defines the name of the variable
  97190. * @param color4 defines the value to be set
  97191. * @returns this effect.
  97192. */
  97193. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97194. /** Release all associated resources */
  97195. dispose(): void;
  97196. /**
  97197. * This function will add a new shader to the shader store
  97198. * @param name the name of the shader
  97199. * @param pixelShader optional pixel shader content
  97200. * @param vertexShader optional vertex shader content
  97201. */
  97202. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97203. /**
  97204. * Store of each shader (The can be looked up using effect.key)
  97205. */
  97206. static ShadersStore: {
  97207. [key: string]: string;
  97208. };
  97209. /**
  97210. * Store of each included file for a shader (The can be looked up using effect.key)
  97211. */
  97212. static IncludesShadersStore: {
  97213. [key: string]: string;
  97214. };
  97215. /**
  97216. * Resets the cache of effects.
  97217. */
  97218. static ResetCache(): void;
  97219. }
  97220. }
  97221. declare module BABYLON {
  97222. /**
  97223. * Interface used to describe the capabilities of the engine relatively to the current browser
  97224. */
  97225. export interface EngineCapabilities {
  97226. /** Maximum textures units per fragment shader */
  97227. maxTexturesImageUnits: number;
  97228. /** Maximum texture units per vertex shader */
  97229. maxVertexTextureImageUnits: number;
  97230. /** Maximum textures units in the entire pipeline */
  97231. maxCombinedTexturesImageUnits: number;
  97232. /** Maximum texture size */
  97233. maxTextureSize: number;
  97234. /** Maximum texture samples */
  97235. maxSamples?: number;
  97236. /** Maximum cube texture size */
  97237. maxCubemapTextureSize: number;
  97238. /** Maximum render texture size */
  97239. maxRenderTextureSize: number;
  97240. /** Maximum number of vertex attributes */
  97241. maxVertexAttribs: number;
  97242. /** Maximum number of varyings */
  97243. maxVaryingVectors: number;
  97244. /** Maximum number of uniforms per vertex shader */
  97245. maxVertexUniformVectors: number;
  97246. /** Maximum number of uniforms per fragment shader */
  97247. maxFragmentUniformVectors: number;
  97248. /** Defines if standard derivates (dx/dy) are supported */
  97249. standardDerivatives: boolean;
  97250. /** Defines if s3tc texture compression is supported */
  97251. s3tc?: WEBGL_compressed_texture_s3tc;
  97252. /** Defines if pvrtc texture compression is supported */
  97253. pvrtc: any;
  97254. /** Defines if etc1 texture compression is supported */
  97255. etc1: any;
  97256. /** Defines if etc2 texture compression is supported */
  97257. etc2: any;
  97258. /** Defines if astc texture compression is supported */
  97259. astc: any;
  97260. /** Defines if float textures are supported */
  97261. textureFloat: boolean;
  97262. /** Defines if vertex array objects are supported */
  97263. vertexArrayObject: boolean;
  97264. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97265. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97266. /** Gets the maximum level of anisotropy supported */
  97267. maxAnisotropy: number;
  97268. /** Defines if instancing is supported */
  97269. instancedArrays: boolean;
  97270. /** Defines if 32 bits indices are supported */
  97271. uintIndices: boolean;
  97272. /** Defines if high precision shaders are supported */
  97273. highPrecisionShaderSupported: boolean;
  97274. /** Defines if depth reading in the fragment shader is supported */
  97275. fragmentDepthSupported: boolean;
  97276. /** Defines if float texture linear filtering is supported*/
  97277. textureFloatLinearFiltering: boolean;
  97278. /** Defines if rendering to float textures is supported */
  97279. textureFloatRender: boolean;
  97280. /** Defines if half float textures are supported*/
  97281. textureHalfFloat: boolean;
  97282. /** Defines if half float texture linear filtering is supported*/
  97283. textureHalfFloatLinearFiltering: boolean;
  97284. /** Defines if rendering to half float textures is supported */
  97285. textureHalfFloatRender: boolean;
  97286. /** Defines if textureLOD shader command is supported */
  97287. textureLOD: boolean;
  97288. /** Defines if draw buffers extension is supported */
  97289. drawBuffersExtension: boolean;
  97290. /** Defines if depth textures are supported */
  97291. depthTextureExtension: boolean;
  97292. /** Defines if float color buffer are supported */
  97293. colorBufferFloat: boolean;
  97294. /** Gets disjoint timer query extension (null if not supported) */
  97295. timerQuery?: EXT_disjoint_timer_query;
  97296. /** Defines if timestamp can be used with timer query */
  97297. canUseTimestampForTimerQuery: boolean;
  97298. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97299. multiview?: any;
  97300. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  97301. oculusMultiview?: any;
  97302. /** Function used to let the system compiles shaders in background */
  97303. parallelShaderCompile?: {
  97304. COMPLETION_STATUS_KHR: number;
  97305. };
  97306. /** Max number of texture samples for MSAA */
  97307. maxMSAASamples: number;
  97308. /** Defines if the blend min max extension is supported */
  97309. blendMinMax: boolean;
  97310. }
  97311. }
  97312. declare module BABYLON {
  97313. /**
  97314. * @hidden
  97315. **/
  97316. export class DepthCullingState {
  97317. private _isDepthTestDirty;
  97318. private _isDepthMaskDirty;
  97319. private _isDepthFuncDirty;
  97320. private _isCullFaceDirty;
  97321. private _isCullDirty;
  97322. private _isZOffsetDirty;
  97323. private _isFrontFaceDirty;
  97324. private _depthTest;
  97325. private _depthMask;
  97326. private _depthFunc;
  97327. private _cull;
  97328. private _cullFace;
  97329. private _zOffset;
  97330. private _frontFace;
  97331. /**
  97332. * Initializes the state.
  97333. */
  97334. constructor();
  97335. readonly isDirty: boolean;
  97336. zOffset: number;
  97337. cullFace: Nullable<number>;
  97338. cull: Nullable<boolean>;
  97339. depthFunc: Nullable<number>;
  97340. depthMask: boolean;
  97341. depthTest: boolean;
  97342. frontFace: Nullable<number>;
  97343. reset(): void;
  97344. apply(gl: WebGLRenderingContext): void;
  97345. }
  97346. }
  97347. declare module BABYLON {
  97348. /**
  97349. * @hidden
  97350. **/
  97351. export class StencilState {
  97352. /** 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 */
  97353. static readonly ALWAYS: number;
  97354. /** Passed to stencilOperation to specify that stencil value must be kept */
  97355. static readonly KEEP: number;
  97356. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97357. static readonly REPLACE: number;
  97358. private _isStencilTestDirty;
  97359. private _isStencilMaskDirty;
  97360. private _isStencilFuncDirty;
  97361. private _isStencilOpDirty;
  97362. private _stencilTest;
  97363. private _stencilMask;
  97364. private _stencilFunc;
  97365. private _stencilFuncRef;
  97366. private _stencilFuncMask;
  97367. private _stencilOpStencilFail;
  97368. private _stencilOpDepthFail;
  97369. private _stencilOpStencilDepthPass;
  97370. readonly isDirty: boolean;
  97371. stencilFunc: number;
  97372. stencilFuncRef: number;
  97373. stencilFuncMask: number;
  97374. stencilOpStencilFail: number;
  97375. stencilOpDepthFail: number;
  97376. stencilOpStencilDepthPass: number;
  97377. stencilMask: number;
  97378. stencilTest: boolean;
  97379. constructor();
  97380. reset(): void;
  97381. apply(gl: WebGLRenderingContext): void;
  97382. }
  97383. }
  97384. declare module BABYLON {
  97385. /**
  97386. * @hidden
  97387. **/
  97388. export class AlphaState {
  97389. private _isAlphaBlendDirty;
  97390. private _isBlendFunctionParametersDirty;
  97391. private _isBlendEquationParametersDirty;
  97392. private _isBlendConstantsDirty;
  97393. private _alphaBlend;
  97394. private _blendFunctionParameters;
  97395. private _blendEquationParameters;
  97396. private _blendConstants;
  97397. /**
  97398. * Initializes the state.
  97399. */
  97400. constructor();
  97401. readonly isDirty: boolean;
  97402. alphaBlend: boolean;
  97403. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97404. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97405. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97406. reset(): void;
  97407. apply(gl: WebGLRenderingContext): void;
  97408. }
  97409. }
  97410. declare module BABYLON {
  97411. /** @hidden */
  97412. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97413. attributeProcessor(attribute: string): string;
  97414. varyingProcessor(varying: string, isFragment: boolean): string;
  97415. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97416. }
  97417. }
  97418. declare module BABYLON {
  97419. /**
  97420. * Interface for attribute information associated with buffer instanciation
  97421. */
  97422. export interface InstancingAttributeInfo {
  97423. /**
  97424. * Index/offset of the attribute in the vertex shader
  97425. */
  97426. index: number;
  97427. /**
  97428. * size of the attribute, 1, 2, 3 or 4
  97429. */
  97430. attributeSize: number;
  97431. /**
  97432. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97433. * default is FLOAT
  97434. */
  97435. attributeType: number;
  97436. /**
  97437. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97438. */
  97439. normalized: boolean;
  97440. /**
  97441. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97442. */
  97443. offset: number;
  97444. /**
  97445. * Name of the GLSL attribute, for debugging purpose only
  97446. */
  97447. attributeName: string;
  97448. }
  97449. }
  97450. declare module BABYLON {
  97451. interface ThinEngine {
  97452. /**
  97453. * Update a video texture
  97454. * @param texture defines the texture to update
  97455. * @param video defines the video element to use
  97456. * @param invertY defines if data must be stored with Y axis inverted
  97457. */
  97458. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97459. }
  97460. }
  97461. declare module BABYLON {
  97462. /**
  97463. * Settings for finer control over video usage
  97464. */
  97465. export interface VideoTextureSettings {
  97466. /**
  97467. * Applies `autoplay` to video, if specified
  97468. */
  97469. autoPlay?: boolean;
  97470. /**
  97471. * Applies `loop` to video, if specified
  97472. */
  97473. loop?: boolean;
  97474. /**
  97475. * Automatically updates internal texture from video at every frame in the render loop
  97476. */
  97477. autoUpdateTexture: boolean;
  97478. /**
  97479. * Image src displayed during the video loading or until the user interacts with the video.
  97480. */
  97481. poster?: string;
  97482. }
  97483. /**
  97484. * If you want to display a video in your scene, this is the special texture for that.
  97485. * This special texture works similar to other textures, with the exception of a few parameters.
  97486. * @see https://doc.babylonjs.com/how_to/video_texture
  97487. */
  97488. export class VideoTexture extends Texture {
  97489. /**
  97490. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97491. */
  97492. readonly autoUpdateTexture: boolean;
  97493. /**
  97494. * The video instance used by the texture internally
  97495. */
  97496. readonly video: HTMLVideoElement;
  97497. private _onUserActionRequestedObservable;
  97498. /**
  97499. * Event triggerd when a dom action is required by the user to play the video.
  97500. * This happens due to recent changes in browser policies preventing video to auto start.
  97501. */
  97502. readonly onUserActionRequestedObservable: Observable<Texture>;
  97503. private _generateMipMaps;
  97504. private _engine;
  97505. private _stillImageCaptured;
  97506. private _displayingPosterTexture;
  97507. private _settings;
  97508. private _createInternalTextureOnEvent;
  97509. private _frameId;
  97510. /**
  97511. * Creates a video texture.
  97512. * If you want to display a video in your scene, this is the special texture for that.
  97513. * This special texture works similar to other textures, with the exception of a few parameters.
  97514. * @see https://doc.babylonjs.com/how_to/video_texture
  97515. * @param name optional name, will detect from video source, if not defined
  97516. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97517. * @param scene is obviously the current scene.
  97518. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97519. * @param invertY is false by default but can be used to invert video on Y axis
  97520. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97521. * @param settings allows finer control over video usage
  97522. */
  97523. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97524. private _getName;
  97525. private _getVideo;
  97526. private _createInternalTexture;
  97527. private reset;
  97528. /**
  97529. * @hidden Internal method to initiate `update`.
  97530. */
  97531. _rebuild(): void;
  97532. /**
  97533. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97534. */
  97535. update(): void;
  97536. /**
  97537. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97538. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97539. */
  97540. updateTexture(isVisible: boolean): void;
  97541. protected _updateInternalTexture: () => void;
  97542. /**
  97543. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97544. * @param url New url.
  97545. */
  97546. updateURL(url: string): void;
  97547. /**
  97548. * Dispose the texture and release its associated resources.
  97549. */
  97550. dispose(): void;
  97551. /**
  97552. * Creates a video texture straight from a stream.
  97553. * @param scene Define the scene the texture should be created in
  97554. * @param stream Define the stream the texture should be created from
  97555. * @returns The created video texture as a promise
  97556. */
  97557. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97558. /**
  97559. * Creates a video texture straight from your WebCam video feed.
  97560. * @param scene Define the scene the texture should be created in
  97561. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97562. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97563. * @returns The created video texture as a promise
  97564. */
  97565. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97566. minWidth: number;
  97567. maxWidth: number;
  97568. minHeight: number;
  97569. maxHeight: number;
  97570. deviceId: string;
  97571. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97572. /**
  97573. * Creates a video texture straight from your WebCam video feed.
  97574. * @param scene Define the scene the texture should be created in
  97575. * @param onReady Define a callback to triggered once the texture will be ready
  97576. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97577. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97578. */
  97579. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97580. minWidth: number;
  97581. maxWidth: number;
  97582. minHeight: number;
  97583. maxHeight: number;
  97584. deviceId: string;
  97585. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97586. }
  97587. }
  97588. declare module BABYLON {
  97589. /**
  97590. * Defines the interface used by objects working like Scene
  97591. * @hidden
  97592. */
  97593. interface ISceneLike {
  97594. _addPendingData(data: any): void;
  97595. _removePendingData(data: any): void;
  97596. offlineProvider: IOfflineProvider;
  97597. }
  97598. /** Interface defining initialization parameters for Engine class */
  97599. export interface EngineOptions extends WebGLContextAttributes {
  97600. /**
  97601. * Defines if the engine should no exceed a specified device ratio
  97602. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97603. */
  97604. limitDeviceRatio?: number;
  97605. /**
  97606. * Defines if webvr should be enabled automatically
  97607. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97608. */
  97609. autoEnableWebVR?: boolean;
  97610. /**
  97611. * Defines if webgl2 should be turned off even if supported
  97612. * @see http://doc.babylonjs.com/features/webgl2
  97613. */
  97614. disableWebGL2Support?: boolean;
  97615. /**
  97616. * Defines if webaudio should be initialized as well
  97617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97618. */
  97619. audioEngine?: boolean;
  97620. /**
  97621. * Defines if animations should run using a deterministic lock step
  97622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97623. */
  97624. deterministicLockstep?: boolean;
  97625. /** Defines the maximum steps to use with deterministic lock step mode */
  97626. lockstepMaxSteps?: number;
  97627. /**
  97628. * Defines that engine should ignore context lost events
  97629. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97630. */
  97631. doNotHandleContextLost?: boolean;
  97632. /**
  97633. * Defines that engine should ignore modifying touch action attribute and style
  97634. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97635. */
  97636. doNotHandleTouchAction?: boolean;
  97637. /**
  97638. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97639. */
  97640. useHighPrecisionFloats?: boolean;
  97641. }
  97642. /**
  97643. * The base engine class (root of all engines)
  97644. */
  97645. export class ThinEngine {
  97646. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97647. static ExceptionList: ({
  97648. key: string;
  97649. capture: string;
  97650. captureConstraint: number;
  97651. targets: string[];
  97652. } | {
  97653. key: string;
  97654. capture: null;
  97655. captureConstraint: null;
  97656. targets: string[];
  97657. })[];
  97658. /** @hidden */
  97659. static _TextureLoaders: IInternalTextureLoader[];
  97660. /**
  97661. * Returns the current npm package of the sdk
  97662. */
  97663. static readonly NpmPackage: string;
  97664. /**
  97665. * Returns the current version of the framework
  97666. */
  97667. static readonly Version: string;
  97668. /**
  97669. * Returns a string describing the current engine
  97670. */
  97671. readonly description: string;
  97672. /**
  97673. * Gets or sets the epsilon value used by collision engine
  97674. */
  97675. static CollisionsEpsilon: number;
  97676. /**
  97677. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97678. */
  97679. static ShadersRepository: string;
  97680. /** @hidden */
  97681. _shaderProcessor: IShaderProcessor;
  97682. /**
  97683. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97684. */
  97685. forcePOTTextures: boolean;
  97686. /**
  97687. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97688. */
  97689. isFullscreen: boolean;
  97690. /**
  97691. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97692. */
  97693. cullBackFaces: boolean;
  97694. /**
  97695. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97696. */
  97697. renderEvenInBackground: boolean;
  97698. /**
  97699. * Gets or sets a boolean indicating that cache can be kept between frames
  97700. */
  97701. preventCacheWipeBetweenFrames: boolean;
  97702. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97703. validateShaderPrograms: boolean;
  97704. /**
  97705. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97706. */
  97707. disableUniformBuffers: boolean;
  97708. /** @hidden */
  97709. _uniformBuffers: UniformBuffer[];
  97710. /**
  97711. * Gets a boolean indicating that the engine supports uniform buffers
  97712. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97713. */
  97714. readonly supportsUniformBuffers: boolean;
  97715. /** @hidden */
  97716. _gl: WebGLRenderingContext;
  97717. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97718. protected _windowIsBackground: boolean;
  97719. protected _webGLVersion: number;
  97720. protected _creationOptions: EngineOptions;
  97721. protected _highPrecisionShadersAllowed: boolean;
  97722. /** @hidden */
  97723. readonly _shouldUseHighPrecisionShader: boolean;
  97724. /**
  97725. * Gets a boolean indicating that only power of 2 textures are supported
  97726. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97727. */
  97728. readonly needPOTTextures: boolean;
  97729. /** @hidden */
  97730. _badOS: boolean;
  97731. /** @hidden */
  97732. _badDesktopOS: boolean;
  97733. private _hardwareScalingLevel;
  97734. /** @hidden */
  97735. _caps: EngineCapabilities;
  97736. private _isStencilEnable;
  97737. protected _colorWrite: boolean;
  97738. private _glVersion;
  97739. private _glRenderer;
  97740. private _glVendor;
  97741. /** @hidden */
  97742. _videoTextureSupported: boolean;
  97743. protected _renderingQueueLaunched: boolean;
  97744. protected _activeRenderLoops: (() => void)[];
  97745. /**
  97746. * Observable signaled when a context lost event is raised
  97747. */
  97748. onContextLostObservable: Observable<ThinEngine>;
  97749. /**
  97750. * Observable signaled when a context restored event is raised
  97751. */
  97752. onContextRestoredObservable: Observable<ThinEngine>;
  97753. private _onContextLost;
  97754. private _onContextRestored;
  97755. protected _contextWasLost: boolean;
  97756. /** @hidden */
  97757. _doNotHandleContextLost: boolean;
  97758. /**
  97759. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97760. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97761. */
  97762. doNotHandleContextLost: boolean;
  97763. /**
  97764. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97765. */
  97766. disableVertexArrayObjects: boolean;
  97767. /** @hidden */
  97768. protected _depthCullingState: DepthCullingState;
  97769. /** @hidden */
  97770. protected _stencilState: StencilState;
  97771. /** @hidden */
  97772. protected _alphaState: AlphaState;
  97773. /** @hidden */
  97774. _internalTexturesCache: InternalTexture[];
  97775. /** @hidden */
  97776. protected _activeChannel: number;
  97777. private _currentTextureChannel;
  97778. /** @hidden */
  97779. protected _boundTexturesCache: {
  97780. [key: string]: Nullable<InternalTexture>;
  97781. };
  97782. /** @hidden */
  97783. protected _currentEffect: Nullable<Effect>;
  97784. /** @hidden */
  97785. protected _currentProgram: Nullable<WebGLProgram>;
  97786. private _compiledEffects;
  97787. private _vertexAttribArraysEnabled;
  97788. /** @hidden */
  97789. protected _cachedViewport: Nullable<IViewportLike>;
  97790. private _cachedVertexArrayObject;
  97791. /** @hidden */
  97792. protected _cachedVertexBuffers: any;
  97793. /** @hidden */
  97794. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97795. /** @hidden */
  97796. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97797. /** @hidden */
  97798. _currentRenderTarget: Nullable<InternalTexture>;
  97799. private _uintIndicesCurrentlySet;
  97800. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97801. /** @hidden */
  97802. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97803. private _currentBufferPointers;
  97804. private _currentInstanceLocations;
  97805. private _currentInstanceBuffers;
  97806. private _textureUnits;
  97807. /** @hidden */
  97808. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97809. /** @hidden */
  97810. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97811. /** @hidden */
  97812. _boundRenderFunction: any;
  97813. private _vaoRecordInProgress;
  97814. private _mustWipeVertexAttributes;
  97815. private _emptyTexture;
  97816. private _emptyCubeTexture;
  97817. private _emptyTexture3D;
  97818. private _emptyTexture2DArray;
  97819. /** @hidden */
  97820. _frameHandler: number;
  97821. private _nextFreeTextureSlots;
  97822. private _maxSimultaneousTextures;
  97823. private _activeRequests;
  97824. protected _texturesSupported: string[];
  97825. /** @hidden */
  97826. _textureFormatInUse: Nullable<string>;
  97827. protected readonly _supportsHardwareTextureRescaling: boolean;
  97828. /**
  97829. * Gets the list of texture formats supported
  97830. */
  97831. readonly texturesSupported: Array<string>;
  97832. /**
  97833. * Gets the list of texture formats in use
  97834. */
  97835. readonly textureFormatInUse: Nullable<string>;
  97836. /**
  97837. * Gets the current viewport
  97838. */
  97839. readonly currentViewport: Nullable<IViewportLike>;
  97840. /**
  97841. * Gets the default empty texture
  97842. */
  97843. readonly emptyTexture: InternalTexture;
  97844. /**
  97845. * Gets the default empty 3D texture
  97846. */
  97847. readonly emptyTexture3D: InternalTexture;
  97848. /**
  97849. * Gets the default empty 2D array texture
  97850. */
  97851. readonly emptyTexture2DArray: InternalTexture;
  97852. /**
  97853. * Gets the default empty cube texture
  97854. */
  97855. readonly emptyCubeTexture: InternalTexture;
  97856. /**
  97857. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97858. */
  97859. readonly premultipliedAlpha: boolean;
  97860. /**
  97861. * Observable event triggered before each texture is initialized
  97862. */
  97863. onBeforeTextureInitObservable: Observable<Texture>;
  97864. /**
  97865. * Creates a new engine
  97866. * @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
  97867. * @param antialias defines enable antialiasing (default: false)
  97868. * @param options defines further options to be sent to the getContext() function
  97869. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97870. */
  97871. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97872. private _rebuildInternalTextures;
  97873. private _rebuildEffects;
  97874. /**
  97875. * Gets a boolean indicating if all created effects are ready
  97876. * @returns true if all effects are ready
  97877. */
  97878. areAllEffectsReady(): boolean;
  97879. protected _rebuildBuffers(): void;
  97880. private _initGLContext;
  97881. /**
  97882. * Gets version of the current webGL context
  97883. */
  97884. readonly webGLVersion: number;
  97885. /**
  97886. * Gets a string idenfifying the name of the class
  97887. * @returns "Engine" string
  97888. */
  97889. getClassName(): string;
  97890. /**
  97891. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97892. */
  97893. readonly isStencilEnable: boolean;
  97894. /** @hidden */
  97895. _prepareWorkingCanvas(): void;
  97896. /**
  97897. * Reset the texture cache to empty state
  97898. */
  97899. resetTextureCache(): void;
  97900. /**
  97901. * Gets an object containing information about the current webGL context
  97902. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97903. */
  97904. getGlInfo(): {
  97905. vendor: string;
  97906. renderer: string;
  97907. version: string;
  97908. };
  97909. /**
  97910. * Defines the hardware scaling level.
  97911. * By default the hardware scaling level is computed from the window device ratio.
  97912. * 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.
  97913. * @param level defines the level to use
  97914. */
  97915. setHardwareScalingLevel(level: number): void;
  97916. /**
  97917. * Gets the current hardware scaling level.
  97918. * By default the hardware scaling level is computed from the window device ratio.
  97919. * 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.
  97920. * @returns a number indicating the current hardware scaling level
  97921. */
  97922. getHardwareScalingLevel(): number;
  97923. /**
  97924. * Gets the list of loaded textures
  97925. * @returns an array containing all loaded textures
  97926. */
  97927. getLoadedTexturesCache(): InternalTexture[];
  97928. /**
  97929. * Gets the object containing all engine capabilities
  97930. * @returns the EngineCapabilities object
  97931. */
  97932. getCaps(): EngineCapabilities;
  97933. /**
  97934. * stop executing a render loop function and remove it from the execution array
  97935. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97936. */
  97937. stopRenderLoop(renderFunction?: () => void): void;
  97938. /** @hidden */
  97939. _renderLoop(): void;
  97940. /**
  97941. * Gets the HTML canvas attached with the current webGL context
  97942. * @returns a HTML canvas
  97943. */
  97944. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97945. /**
  97946. * Gets host window
  97947. * @returns the host window object
  97948. */
  97949. getHostWindow(): Nullable<Window>;
  97950. /**
  97951. * Gets the current render width
  97952. * @param useScreen defines if screen size must be used (or the current render target if any)
  97953. * @returns a number defining the current render width
  97954. */
  97955. getRenderWidth(useScreen?: boolean): number;
  97956. /**
  97957. * Gets the current render height
  97958. * @param useScreen defines if screen size must be used (or the current render target if any)
  97959. * @returns a number defining the current render height
  97960. */
  97961. getRenderHeight(useScreen?: boolean): number;
  97962. /**
  97963. * Can be used to override the current requestAnimationFrame requester.
  97964. * @hidden
  97965. */
  97966. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97967. /**
  97968. * Register and execute a render loop. The engine can have more than one render function
  97969. * @param renderFunction defines the function to continuously execute
  97970. */
  97971. runRenderLoop(renderFunction: () => void): void;
  97972. /**
  97973. * Clear the current render buffer or the current render target (if any is set up)
  97974. * @param color defines the color to use
  97975. * @param backBuffer defines if the back buffer must be cleared
  97976. * @param depth defines if the depth buffer must be cleared
  97977. * @param stencil defines if the stencil buffer must be cleared
  97978. */
  97979. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97980. private _viewportCached;
  97981. /** @hidden */
  97982. _viewport(x: number, y: number, width: number, height: number): void;
  97983. /**
  97984. * Set the WebGL's viewport
  97985. * @param viewport defines the viewport element to be used
  97986. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97987. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97988. */
  97989. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97990. /**
  97991. * Begin a new frame
  97992. */
  97993. beginFrame(): void;
  97994. /**
  97995. * Enf the current frame
  97996. */
  97997. endFrame(): void;
  97998. /**
  97999. * Resize the view according to the canvas' size
  98000. */
  98001. resize(): void;
  98002. /**
  98003. * Force a specific size of the canvas
  98004. * @param width defines the new canvas' width
  98005. * @param height defines the new canvas' height
  98006. */
  98007. setSize(width: number, height: number): void;
  98008. /**
  98009. * Binds the frame buffer to the specified texture.
  98010. * @param texture The texture to render to or null for the default canvas
  98011. * @param faceIndex The face of the texture to render to in case of cube texture
  98012. * @param requiredWidth The width of the target to render to
  98013. * @param requiredHeight The height of the target to render to
  98014. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  98015. * @param depthStencilTexture The depth stencil texture to use to render
  98016. * @param lodLevel defines le lod level to bind to the frame buffer
  98017. */
  98018. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  98019. /** @hidden */
  98020. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  98021. /**
  98022. * Unbind the current render target texture from the webGL context
  98023. * @param texture defines the render target texture to unbind
  98024. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  98025. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  98026. */
  98027. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98028. /**
  98029. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  98030. */
  98031. flushFramebuffer(): void;
  98032. /**
  98033. * Unbind the current render target and bind the default framebuffer
  98034. */
  98035. restoreDefaultFramebuffer(): void;
  98036. /** @hidden */
  98037. protected _resetVertexBufferBinding(): void;
  98038. /**
  98039. * Creates a vertex buffer
  98040. * @param data the data for the vertex buffer
  98041. * @returns the new WebGL static buffer
  98042. */
  98043. createVertexBuffer(data: DataArray): DataBuffer;
  98044. private _createVertexBuffer;
  98045. /**
  98046. * Creates a dynamic vertex buffer
  98047. * @param data the data for the dynamic vertex buffer
  98048. * @returns the new WebGL dynamic buffer
  98049. */
  98050. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  98051. protected _resetIndexBufferBinding(): void;
  98052. /**
  98053. * Creates a new index buffer
  98054. * @param indices defines the content of the index buffer
  98055. * @param updatable defines if the index buffer must be updatable
  98056. * @returns a new webGL buffer
  98057. */
  98058. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  98059. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  98060. /**
  98061. * Bind a webGL buffer to the webGL context
  98062. * @param buffer defines the buffer to bind
  98063. */
  98064. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  98065. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  98066. private bindBuffer;
  98067. /**
  98068. * update the bound buffer with the given data
  98069. * @param data defines the data to update
  98070. */
  98071. updateArrayBuffer(data: Float32Array): void;
  98072. private _vertexAttribPointer;
  98073. private _bindIndexBufferWithCache;
  98074. private _bindVertexBuffersAttributes;
  98075. /**
  98076. * Records a vertex array object
  98077. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98078. * @param vertexBuffers defines the list of vertex buffers to store
  98079. * @param indexBuffer defines the index buffer to store
  98080. * @param effect defines the effect to store
  98081. * @returns the new vertex array object
  98082. */
  98083. recordVertexArrayObject(vertexBuffers: {
  98084. [key: string]: VertexBuffer;
  98085. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  98086. /**
  98087. * Bind a specific vertex array object
  98088. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98089. * @param vertexArrayObject defines the vertex array object to bind
  98090. * @param indexBuffer defines the index buffer to bind
  98091. */
  98092. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98093. /**
  98094. * Bind webGl buffers directly to the webGL context
  98095. * @param vertexBuffer defines the vertex buffer to bind
  98096. * @param indexBuffer defines the index buffer to bind
  98097. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98098. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98099. * @param effect defines the effect associated with the vertex buffer
  98100. */
  98101. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98102. private _unbindVertexArrayObject;
  98103. /**
  98104. * Bind a list of vertex buffers to the webGL context
  98105. * @param vertexBuffers defines the list of vertex buffers to bind
  98106. * @param indexBuffer defines the index buffer to bind
  98107. * @param effect defines the effect associated with the vertex buffers
  98108. */
  98109. bindBuffers(vertexBuffers: {
  98110. [key: string]: Nullable<VertexBuffer>;
  98111. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98112. /**
  98113. * Unbind all instance attributes
  98114. */
  98115. unbindInstanceAttributes(): void;
  98116. /**
  98117. * Release and free the memory of a vertex array object
  98118. * @param vao defines the vertex array object to delete
  98119. */
  98120. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98121. /** @hidden */
  98122. _releaseBuffer(buffer: DataBuffer): boolean;
  98123. protected _deleteBuffer(buffer: DataBuffer): void;
  98124. /**
  98125. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98126. * @param instancesBuffer defines the webGL buffer to update and bind
  98127. * @param data defines the data to store in the buffer
  98128. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98129. */
  98130. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98131. /**
  98132. * Apply all cached states (depth, culling, stencil and alpha)
  98133. */
  98134. applyStates(): void;
  98135. /**
  98136. * Send a draw order
  98137. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98138. * @param indexStart defines the starting index
  98139. * @param indexCount defines the number of index to draw
  98140. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98141. */
  98142. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98143. /**
  98144. * Draw a list of points
  98145. * @param verticesStart defines the index of first vertex to draw
  98146. * @param verticesCount defines the count of vertices to draw
  98147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98148. */
  98149. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98150. /**
  98151. * Draw a list of unindexed primitives
  98152. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98153. * @param verticesStart defines the index of first vertex to draw
  98154. * @param verticesCount defines the count of vertices to draw
  98155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98156. */
  98157. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98158. /**
  98159. * Draw a list of indexed primitives
  98160. * @param fillMode defines the primitive to use
  98161. * @param indexStart defines the starting index
  98162. * @param indexCount defines the number of index to draw
  98163. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98164. */
  98165. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98166. /**
  98167. * Draw a list of unindexed primitives
  98168. * @param fillMode defines the primitive to use
  98169. * @param verticesStart defines the index of first vertex to draw
  98170. * @param verticesCount defines the count of vertices to draw
  98171. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98172. */
  98173. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98174. private _drawMode;
  98175. /** @hidden */
  98176. protected _reportDrawCall(): void;
  98177. /** @hidden */
  98178. _releaseEffect(effect: Effect): void;
  98179. /** @hidden */
  98180. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98181. /**
  98182. * Create a new effect (used to store vertex/fragment shaders)
  98183. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98184. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98185. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98186. * @param samplers defines an array of string used to represent textures
  98187. * @param defines defines the string containing the defines to use to compile the shaders
  98188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98189. * @param onCompiled defines a function to call when the effect creation is successful
  98190. * @param onError defines a function to call when the effect creation has failed
  98191. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98192. * @returns the new Effect
  98193. */
  98194. 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;
  98195. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98196. private _compileShader;
  98197. private _compileRawShader;
  98198. /**
  98199. * Directly creates a webGL program
  98200. * @param pipelineContext defines the pipeline context to attach to
  98201. * @param vertexCode defines the vertex shader code to use
  98202. * @param fragmentCode defines the fragment shader code to use
  98203. * @param context defines the webGL context to use (if not set, the current one will be used)
  98204. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98205. * @returns the new webGL program
  98206. */
  98207. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98208. /**
  98209. * Creates a webGL program
  98210. * @param pipelineContext defines the pipeline context to attach to
  98211. * @param vertexCode defines the vertex shader code to use
  98212. * @param fragmentCode defines the fragment shader code to use
  98213. * @param defines defines the string containing the defines to use to compile the shaders
  98214. * @param context defines the webGL context to use (if not set, the current one will be used)
  98215. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98216. * @returns the new webGL program
  98217. */
  98218. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98219. /**
  98220. * Creates a new pipeline context
  98221. * @returns the new pipeline
  98222. */
  98223. createPipelineContext(): IPipelineContext;
  98224. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98225. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98226. /** @hidden */
  98227. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98228. /** @hidden */
  98229. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98230. /** @hidden */
  98231. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98232. /**
  98233. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98234. * @param pipelineContext defines the pipeline context to use
  98235. * @param uniformsNames defines the list of uniform names
  98236. * @returns an array of webGL uniform locations
  98237. */
  98238. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98239. /**
  98240. * Gets the lsit of active attributes for a given webGL program
  98241. * @param pipelineContext defines the pipeline context to use
  98242. * @param attributesNames defines the list of attribute names to get
  98243. * @returns an array of indices indicating the offset of each attribute
  98244. */
  98245. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98246. /**
  98247. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98248. * @param effect defines the effect to activate
  98249. */
  98250. enableEffect(effect: Nullable<Effect>): void;
  98251. /**
  98252. * Set the value of an uniform to a number (int)
  98253. * @param uniform defines the webGL uniform location where to store the value
  98254. * @param value defines the int number to store
  98255. */
  98256. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98257. /**
  98258. * Set the value of an uniform to an array of int32
  98259. * @param uniform defines the webGL uniform location where to store the value
  98260. * @param array defines the array of int32 to store
  98261. */
  98262. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98263. /**
  98264. * Set the value of an uniform to an array of int32 (stored as vec2)
  98265. * @param uniform defines the webGL uniform location where to store the value
  98266. * @param array defines the array of int32 to store
  98267. */
  98268. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98269. /**
  98270. * Set the value of an uniform to an array of int32 (stored as vec3)
  98271. * @param uniform defines the webGL uniform location where to store the value
  98272. * @param array defines the array of int32 to store
  98273. */
  98274. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98275. /**
  98276. * Set the value of an uniform to an array of int32 (stored as vec4)
  98277. * @param uniform defines the webGL uniform location where to store the value
  98278. * @param array defines the array of int32 to store
  98279. */
  98280. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98281. /**
  98282. * Set the value of an uniform to an array of number
  98283. * @param uniform defines the webGL uniform location where to store the value
  98284. * @param array defines the array of number to store
  98285. */
  98286. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98287. /**
  98288. * Set the value of an uniform to an array of number (stored as vec2)
  98289. * @param uniform defines the webGL uniform location where to store the value
  98290. * @param array defines the array of number to store
  98291. */
  98292. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98293. /**
  98294. * Set the value of an uniform to an array of number (stored as vec3)
  98295. * @param uniform defines the webGL uniform location where to store the value
  98296. * @param array defines the array of number to store
  98297. */
  98298. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98299. /**
  98300. * Set the value of an uniform to an array of number (stored as vec4)
  98301. * @param uniform defines the webGL uniform location where to store the value
  98302. * @param array defines the array of number to store
  98303. */
  98304. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98305. /**
  98306. * Set the value of an uniform to an array of float32 (stored as matrices)
  98307. * @param uniform defines the webGL uniform location where to store the value
  98308. * @param matrices defines the array of float32 to store
  98309. */
  98310. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98311. /**
  98312. * Set the value of an uniform to a matrix (3x3)
  98313. * @param uniform defines the webGL uniform location where to store the value
  98314. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98315. */
  98316. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98317. /**
  98318. * Set the value of an uniform to a matrix (2x2)
  98319. * @param uniform defines the webGL uniform location where to store the value
  98320. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98321. */
  98322. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98323. /**
  98324. * Set the value of an uniform to a number (float)
  98325. * @param uniform defines the webGL uniform location where to store the value
  98326. * @param value defines the float number to store
  98327. */
  98328. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98329. /**
  98330. * Set the value of an uniform to a vec2
  98331. * @param uniform defines the webGL uniform location where to store the value
  98332. * @param x defines the 1st component of the value
  98333. * @param y defines the 2nd component of the value
  98334. */
  98335. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98336. /**
  98337. * Set the value of an uniform to a vec3
  98338. * @param uniform defines the webGL uniform location where to store the value
  98339. * @param x defines the 1st component of the value
  98340. * @param y defines the 2nd component of the value
  98341. * @param z defines the 3rd component of the value
  98342. */
  98343. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98344. /**
  98345. * Set the value of an uniform to a vec4
  98346. * @param uniform defines the webGL uniform location where to store the value
  98347. * @param x defines the 1st component of the value
  98348. * @param y defines the 2nd component of the value
  98349. * @param z defines the 3rd component of the value
  98350. * @param w defines the 4th component of the value
  98351. */
  98352. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98353. /**
  98354. * Gets the depth culling state manager
  98355. */
  98356. readonly depthCullingState: DepthCullingState;
  98357. /**
  98358. * Gets the alpha state manager
  98359. */
  98360. readonly alphaState: AlphaState;
  98361. /**
  98362. * Gets the stencil state manager
  98363. */
  98364. readonly stencilState: StencilState;
  98365. /**
  98366. * Clears the list of texture accessible through engine.
  98367. * This can help preventing texture load conflict due to name collision.
  98368. */
  98369. clearInternalTexturesCache(): void;
  98370. /**
  98371. * Force the entire cache to be cleared
  98372. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98373. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98374. */
  98375. wipeCaches(bruteForce?: boolean): void;
  98376. /** @hidden */
  98377. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98378. min: number;
  98379. mag: number;
  98380. };
  98381. /** @hidden */
  98382. _createTexture(): WebGLTexture;
  98383. /**
  98384. * Usually called from Texture.ts.
  98385. * Passed information to create a WebGLTexture
  98386. * @param urlArg defines a value which contains one of the following:
  98387. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98388. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98389. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98391. * @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)
  98392. * @param scene needed for loading to the correct scene
  98393. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98394. * @param onLoad optional callback to be called upon successful completion
  98395. * @param onError optional callback to be called upon failure
  98396. * @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
  98397. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98398. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98399. * @param forcedExtension defines the extension to use to pick the right loader
  98400. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98401. * @param mimeType defines an optional mime type
  98402. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98403. */
  98404. 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;
  98405. /**
  98406. * @hidden
  98407. */
  98408. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98409. /**
  98410. * Creates a raw texture
  98411. * @param data defines the data to store in the texture
  98412. * @param width defines the width of the texture
  98413. * @param height defines the height of the texture
  98414. * @param format defines the format of the data
  98415. * @param generateMipMaps defines if the engine should generate the mip levels
  98416. * @param invertY defines if data must be stored with Y axis inverted
  98417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98418. * @param compression defines the compression used (null by default)
  98419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98420. * @returns the raw texture inside an InternalTexture
  98421. */
  98422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98423. /**
  98424. * Creates a new raw cube texture
  98425. * @param data defines the array of data to use to create each face
  98426. * @param size defines the size of the textures
  98427. * @param format defines the format of the data
  98428. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98429. * @param generateMipMaps defines if the engine should generate the mip levels
  98430. * @param invertY defines if data must be stored with Y axis inverted
  98431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98432. * @param compression defines the compression used (null by default)
  98433. * @returns the cube texture as an InternalTexture
  98434. */
  98435. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98436. /**
  98437. * Creates a new raw 3D texture
  98438. * @param data defines the data used to create the texture
  98439. * @param width defines the width of the texture
  98440. * @param height defines the height of the texture
  98441. * @param depth defines the depth of the texture
  98442. * @param format defines the format of the texture
  98443. * @param generateMipMaps defines if the engine must generate mip levels
  98444. * @param invertY defines if data must be stored with Y axis inverted
  98445. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98446. * @param compression defines the compressed used (can be null)
  98447. * @param textureType defines the compressed used (can be null)
  98448. * @returns a new raw 3D texture (stored in an InternalTexture)
  98449. */
  98450. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98451. /**
  98452. * Creates a new raw 2D array texture
  98453. * @param data defines the data used to create the texture
  98454. * @param width defines the width of the texture
  98455. * @param height defines the height of the texture
  98456. * @param depth defines the number of layers of the texture
  98457. * @param format defines the format of the texture
  98458. * @param generateMipMaps defines if the engine must generate mip levels
  98459. * @param invertY defines if data must be stored with Y axis inverted
  98460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98461. * @param compression defines the compressed used (can be null)
  98462. * @param textureType defines the compressed used (can be null)
  98463. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98464. */
  98465. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98466. private _unpackFlipYCached;
  98467. /**
  98468. * In case you are sharing the context with other applications, it might
  98469. * be interested to not cache the unpack flip y state to ensure a consistent
  98470. * value would be set.
  98471. */
  98472. enableUnpackFlipYCached: boolean;
  98473. /** @hidden */
  98474. _unpackFlipY(value: boolean): void;
  98475. /** @hidden */
  98476. _getUnpackAlignement(): number;
  98477. /**
  98478. * Update the sampling mode of a given texture
  98479. * @param samplingMode defines the required sampling mode
  98480. * @param texture defines the texture to update
  98481. */
  98482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98483. /** @hidden */
  98484. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98485. width: number;
  98486. height: number;
  98487. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98488. /** @hidden */
  98489. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98490. /** @hidden */
  98491. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98492. /** @hidden */
  98493. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98494. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98495. private _prepareWebGLTexture;
  98496. /** @hidden */
  98497. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98498. /** @hidden */
  98499. _releaseFramebufferObjects(texture: InternalTexture): void;
  98500. /** @hidden */
  98501. _releaseTexture(texture: InternalTexture): void;
  98502. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98503. protected _setProgram(program: WebGLProgram): void;
  98504. protected _boundUniforms: {
  98505. [key: number]: WebGLUniformLocation;
  98506. };
  98507. /**
  98508. * Binds an effect to the webGL context
  98509. * @param effect defines the effect to bind
  98510. */
  98511. bindSamplers(effect: Effect): void;
  98512. private _activateCurrentTexture;
  98513. /** @hidden */
  98514. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98515. /** @hidden */
  98516. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98517. /**
  98518. * Unbind all textures from the webGL context
  98519. */
  98520. unbindAllTextures(): void;
  98521. /**
  98522. * Sets a texture to the according uniform.
  98523. * @param channel The texture channel
  98524. * @param uniform The uniform to set
  98525. * @param texture The texture to apply
  98526. */
  98527. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98528. private _bindSamplerUniformToChannel;
  98529. private _getTextureWrapMode;
  98530. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98531. /**
  98532. * Sets an array of texture to the webGL context
  98533. * @param channel defines the channel where the texture array must be set
  98534. * @param uniform defines the associated uniform location
  98535. * @param textures defines the array of textures to bind
  98536. */
  98537. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98538. /** @hidden */
  98539. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98540. private _setTextureParameterFloat;
  98541. private _setTextureParameterInteger;
  98542. /**
  98543. * Unbind all vertex attributes from the webGL context
  98544. */
  98545. unbindAllAttributes(): void;
  98546. /**
  98547. * 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
  98548. */
  98549. releaseEffects(): void;
  98550. /**
  98551. * Dispose and release all associated resources
  98552. */
  98553. dispose(): void;
  98554. /**
  98555. * Attach a new callback raised when context lost event is fired
  98556. * @param callback defines the callback to call
  98557. */
  98558. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98559. /**
  98560. * Attach a new callback raised when context restored event is fired
  98561. * @param callback defines the callback to call
  98562. */
  98563. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98564. /**
  98565. * Get the current error code of the webGL context
  98566. * @returns the error code
  98567. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98568. */
  98569. getError(): number;
  98570. private _canRenderToFloatFramebuffer;
  98571. private _canRenderToHalfFloatFramebuffer;
  98572. private _canRenderToFramebuffer;
  98573. /** @hidden */
  98574. _getWebGLTextureType(type: number): number;
  98575. /** @hidden */
  98576. _getInternalFormat(format: number): number;
  98577. /** @hidden */
  98578. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98579. /** @hidden */
  98580. _getRGBAMultiSampleBufferFormat(type: number): number;
  98581. /** @hidden */
  98582. _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;
  98583. /**
  98584. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98585. * @returns true if the engine can be created
  98586. * @ignorenaming
  98587. */
  98588. static isSupported(): boolean;
  98589. /**
  98590. * Find the next highest power of two.
  98591. * @param x Number to start search from.
  98592. * @return Next highest power of two.
  98593. */
  98594. static CeilingPOT(x: number): number;
  98595. /**
  98596. * Find the next lowest power of two.
  98597. * @param x Number to start search from.
  98598. * @return Next lowest power of two.
  98599. */
  98600. static FloorPOT(x: number): number;
  98601. /**
  98602. * Find the nearest power of two.
  98603. * @param x Number to start search from.
  98604. * @return Next nearest power of two.
  98605. */
  98606. static NearestPOT(x: number): number;
  98607. /**
  98608. * Get the closest exponent of two
  98609. * @param value defines the value to approximate
  98610. * @param max defines the maximum value to return
  98611. * @param mode defines how to define the closest value
  98612. * @returns closest exponent of two of the given value
  98613. */
  98614. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98615. /**
  98616. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98617. * @param func - the function to be called
  98618. * @param requester - the object that will request the next frame. Falls back to window.
  98619. * @returns frame number
  98620. */
  98621. static QueueNewFrame(func: () => void, requester?: any): number;
  98622. }
  98623. }
  98624. declare module BABYLON {
  98625. /**
  98626. * Class representing spherical harmonics coefficients to the 3rd degree
  98627. */
  98628. export class SphericalHarmonics {
  98629. /**
  98630. * Defines whether or not the harmonics have been prescaled for rendering.
  98631. */
  98632. preScaled: boolean;
  98633. /**
  98634. * The l0,0 coefficients of the spherical harmonics
  98635. */
  98636. l00: Vector3;
  98637. /**
  98638. * The l1,-1 coefficients of the spherical harmonics
  98639. */
  98640. l1_1: Vector3;
  98641. /**
  98642. * The l1,0 coefficients of the spherical harmonics
  98643. */
  98644. l10: Vector3;
  98645. /**
  98646. * The l1,1 coefficients of the spherical harmonics
  98647. */
  98648. l11: Vector3;
  98649. /**
  98650. * The l2,-2 coefficients of the spherical harmonics
  98651. */
  98652. l2_2: Vector3;
  98653. /**
  98654. * The l2,-1 coefficients of the spherical harmonics
  98655. */
  98656. l2_1: Vector3;
  98657. /**
  98658. * The l2,0 coefficients of the spherical harmonics
  98659. */
  98660. l20: Vector3;
  98661. /**
  98662. * The l2,1 coefficients of the spherical harmonics
  98663. */
  98664. l21: Vector3;
  98665. /**
  98666. * The l2,2 coefficients of the spherical harmonics
  98667. */
  98668. l22: Vector3;
  98669. /**
  98670. * Adds a light to the spherical harmonics
  98671. * @param direction the direction of the light
  98672. * @param color the color of the light
  98673. * @param deltaSolidAngle the delta solid angle of the light
  98674. */
  98675. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98676. /**
  98677. * Scales the spherical harmonics by the given amount
  98678. * @param scale the amount to scale
  98679. */
  98680. scaleInPlace(scale: number): void;
  98681. /**
  98682. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98683. *
  98684. * ```
  98685. * E_lm = A_l * L_lm
  98686. * ```
  98687. *
  98688. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98689. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98690. * the scaling factors are given in equation 9.
  98691. */
  98692. convertIncidentRadianceToIrradiance(): void;
  98693. /**
  98694. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98695. *
  98696. * ```
  98697. * L = (1/pi) * E * rho
  98698. * ```
  98699. *
  98700. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98701. */
  98702. convertIrradianceToLambertianRadiance(): void;
  98703. /**
  98704. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98705. * required operations at run time.
  98706. *
  98707. * This is simply done by scaling back the SH with Ylm constants parameter.
  98708. * The trigonometric part being applied by the shader at run time.
  98709. */
  98710. preScaleForRendering(): void;
  98711. /**
  98712. * Constructs a spherical harmonics from an array.
  98713. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98714. * @returns the spherical harmonics
  98715. */
  98716. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98717. /**
  98718. * Gets the spherical harmonics from polynomial
  98719. * @param polynomial the spherical polynomial
  98720. * @returns the spherical harmonics
  98721. */
  98722. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98723. }
  98724. /**
  98725. * Class representing spherical polynomial coefficients to the 3rd degree
  98726. */
  98727. export class SphericalPolynomial {
  98728. private _harmonics;
  98729. /**
  98730. * The spherical harmonics used to create the polynomials.
  98731. */
  98732. readonly preScaledHarmonics: SphericalHarmonics;
  98733. /**
  98734. * The x coefficients of the spherical polynomial
  98735. */
  98736. x: Vector3;
  98737. /**
  98738. * The y coefficients of the spherical polynomial
  98739. */
  98740. y: Vector3;
  98741. /**
  98742. * The z coefficients of the spherical polynomial
  98743. */
  98744. z: Vector3;
  98745. /**
  98746. * The xx coefficients of the spherical polynomial
  98747. */
  98748. xx: Vector3;
  98749. /**
  98750. * The yy coefficients of the spherical polynomial
  98751. */
  98752. yy: Vector3;
  98753. /**
  98754. * The zz coefficients of the spherical polynomial
  98755. */
  98756. zz: Vector3;
  98757. /**
  98758. * The xy coefficients of the spherical polynomial
  98759. */
  98760. xy: Vector3;
  98761. /**
  98762. * The yz coefficients of the spherical polynomial
  98763. */
  98764. yz: Vector3;
  98765. /**
  98766. * The zx coefficients of the spherical polynomial
  98767. */
  98768. zx: Vector3;
  98769. /**
  98770. * Adds an ambient color to the spherical polynomial
  98771. * @param color the color to add
  98772. */
  98773. addAmbient(color: Color3): void;
  98774. /**
  98775. * Scales the spherical polynomial by the given amount
  98776. * @param scale the amount to scale
  98777. */
  98778. scaleInPlace(scale: number): void;
  98779. /**
  98780. * Gets the spherical polynomial from harmonics
  98781. * @param harmonics the spherical harmonics
  98782. * @returns the spherical polynomial
  98783. */
  98784. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98785. /**
  98786. * Constructs a spherical polynomial from an array.
  98787. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98788. * @returns the spherical polynomial
  98789. */
  98790. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98791. }
  98792. }
  98793. declare module BABYLON {
  98794. /**
  98795. * Defines the source of the internal texture
  98796. */
  98797. export enum InternalTextureSource {
  98798. /**
  98799. * The source of the texture data is unknown
  98800. */
  98801. Unknown = 0,
  98802. /**
  98803. * Texture data comes from an URL
  98804. */
  98805. Url = 1,
  98806. /**
  98807. * Texture data is only used for temporary storage
  98808. */
  98809. Temp = 2,
  98810. /**
  98811. * Texture data comes from raw data (ArrayBuffer)
  98812. */
  98813. Raw = 3,
  98814. /**
  98815. * Texture content is dynamic (video or dynamic texture)
  98816. */
  98817. Dynamic = 4,
  98818. /**
  98819. * Texture content is generated by rendering to it
  98820. */
  98821. RenderTarget = 5,
  98822. /**
  98823. * Texture content is part of a multi render target process
  98824. */
  98825. MultiRenderTarget = 6,
  98826. /**
  98827. * Texture data comes from a cube data file
  98828. */
  98829. Cube = 7,
  98830. /**
  98831. * Texture data comes from a raw cube data
  98832. */
  98833. CubeRaw = 8,
  98834. /**
  98835. * Texture data come from a prefiltered cube data file
  98836. */
  98837. CubePrefiltered = 9,
  98838. /**
  98839. * Texture content is raw 3D data
  98840. */
  98841. Raw3D = 10,
  98842. /**
  98843. * Texture content is raw 2D array data
  98844. */
  98845. Raw2DArray = 11,
  98846. /**
  98847. * Texture content is a depth texture
  98848. */
  98849. Depth = 12,
  98850. /**
  98851. * Texture data comes from a raw cube data encoded with RGBD
  98852. */
  98853. CubeRawRGBD = 13
  98854. }
  98855. /**
  98856. * Class used to store data associated with WebGL texture data for the engine
  98857. * This class should not be used directly
  98858. */
  98859. export class InternalTexture {
  98860. /** @hidden */
  98861. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98862. /**
  98863. * Defines if the texture is ready
  98864. */
  98865. isReady: boolean;
  98866. /**
  98867. * Defines if the texture is a cube texture
  98868. */
  98869. isCube: boolean;
  98870. /**
  98871. * Defines if the texture contains 3D data
  98872. */
  98873. is3D: boolean;
  98874. /**
  98875. * Defines if the texture contains 2D array data
  98876. */
  98877. is2DArray: boolean;
  98878. /**
  98879. * Defines if the texture contains multiview data
  98880. */
  98881. isMultiview: boolean;
  98882. /**
  98883. * Gets the URL used to load this texture
  98884. */
  98885. url: string;
  98886. /**
  98887. * Gets the sampling mode of the texture
  98888. */
  98889. samplingMode: number;
  98890. /**
  98891. * Gets a boolean indicating if the texture needs mipmaps generation
  98892. */
  98893. generateMipMaps: boolean;
  98894. /**
  98895. * Gets the number of samples used by the texture (WebGL2+ only)
  98896. */
  98897. samples: number;
  98898. /**
  98899. * Gets the type of the texture (int, float...)
  98900. */
  98901. type: number;
  98902. /**
  98903. * Gets the format of the texture (RGB, RGBA...)
  98904. */
  98905. format: number;
  98906. /**
  98907. * Observable called when the texture is loaded
  98908. */
  98909. onLoadedObservable: Observable<InternalTexture>;
  98910. /**
  98911. * Gets the width of the texture
  98912. */
  98913. width: number;
  98914. /**
  98915. * Gets the height of the texture
  98916. */
  98917. height: number;
  98918. /**
  98919. * Gets the depth of the texture
  98920. */
  98921. depth: number;
  98922. /**
  98923. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98924. */
  98925. baseWidth: number;
  98926. /**
  98927. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98928. */
  98929. baseHeight: number;
  98930. /**
  98931. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98932. */
  98933. baseDepth: number;
  98934. /**
  98935. * Gets a boolean indicating if the texture is inverted on Y axis
  98936. */
  98937. invertY: boolean;
  98938. /** @hidden */
  98939. _invertVScale: boolean;
  98940. /** @hidden */
  98941. _associatedChannel: number;
  98942. /** @hidden */
  98943. _source: InternalTextureSource;
  98944. /** @hidden */
  98945. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98946. /** @hidden */
  98947. _bufferView: Nullable<ArrayBufferView>;
  98948. /** @hidden */
  98949. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98950. /** @hidden */
  98951. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98952. /** @hidden */
  98953. _size: number;
  98954. /** @hidden */
  98955. _extension: string;
  98956. /** @hidden */
  98957. _files: Nullable<string[]>;
  98958. /** @hidden */
  98959. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98960. /** @hidden */
  98961. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98962. /** @hidden */
  98963. _framebuffer: Nullable<WebGLFramebuffer>;
  98964. /** @hidden */
  98965. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98966. /** @hidden */
  98967. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98968. /** @hidden */
  98969. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98970. /** @hidden */
  98971. _attachments: Nullable<number[]>;
  98972. /** @hidden */
  98973. _cachedCoordinatesMode: Nullable<number>;
  98974. /** @hidden */
  98975. _cachedWrapU: Nullable<number>;
  98976. /** @hidden */
  98977. _cachedWrapV: Nullable<number>;
  98978. /** @hidden */
  98979. _cachedWrapR: Nullable<number>;
  98980. /** @hidden */
  98981. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98982. /** @hidden */
  98983. _isDisabled: boolean;
  98984. /** @hidden */
  98985. _compression: Nullable<string>;
  98986. /** @hidden */
  98987. _generateStencilBuffer: boolean;
  98988. /** @hidden */
  98989. _generateDepthBuffer: boolean;
  98990. /** @hidden */
  98991. _comparisonFunction: number;
  98992. /** @hidden */
  98993. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98994. /** @hidden */
  98995. _lodGenerationScale: number;
  98996. /** @hidden */
  98997. _lodGenerationOffset: number;
  98998. /** @hidden */
  98999. _colorTextureArray: Nullable<WebGLTexture>;
  99000. /** @hidden */
  99001. _depthStencilTextureArray: Nullable<WebGLTexture>;
  99002. /** @hidden */
  99003. _lodTextureHigh: Nullable<BaseTexture>;
  99004. /** @hidden */
  99005. _lodTextureMid: Nullable<BaseTexture>;
  99006. /** @hidden */
  99007. _lodTextureLow: Nullable<BaseTexture>;
  99008. /** @hidden */
  99009. _isRGBD: boolean;
  99010. /** @hidden */
  99011. _linearSpecularLOD: boolean;
  99012. /** @hidden */
  99013. _irradianceTexture: Nullable<BaseTexture>;
  99014. /** @hidden */
  99015. _webGLTexture: Nullable<WebGLTexture>;
  99016. /** @hidden */
  99017. _references: number;
  99018. private _engine;
  99019. /**
  99020. * Gets the Engine the texture belongs to.
  99021. * @returns The babylon engine
  99022. */
  99023. getEngine(): ThinEngine;
  99024. /**
  99025. * Gets the data source type of the texture
  99026. */
  99027. readonly source: InternalTextureSource;
  99028. /**
  99029. * Creates a new InternalTexture
  99030. * @param engine defines the engine to use
  99031. * @param source defines the type of data that will be used
  99032. * @param delayAllocation if the texture allocation should be delayed (default: false)
  99033. */
  99034. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  99035. /**
  99036. * Increments the number of references (ie. the number of Texture that point to it)
  99037. */
  99038. incrementReferences(): void;
  99039. /**
  99040. * Change the size of the texture (not the size of the content)
  99041. * @param width defines the new width
  99042. * @param height defines the new height
  99043. * @param depth defines the new depth (1 by default)
  99044. */
  99045. updateSize(width: int, height: int, depth?: int): void;
  99046. /** @hidden */
  99047. _rebuild(): void;
  99048. /** @hidden */
  99049. _swapAndDie(target: InternalTexture): void;
  99050. /**
  99051. * Dispose the current allocated resources
  99052. */
  99053. dispose(): void;
  99054. }
  99055. }
  99056. declare module BABYLON {
  99057. /**
  99058. * Class used to work with sound analyzer using fast fourier transform (FFT)
  99059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99060. */
  99061. export class Analyser {
  99062. /**
  99063. * Gets or sets the smoothing
  99064. * @ignorenaming
  99065. */
  99066. SMOOTHING: number;
  99067. /**
  99068. * Gets or sets the FFT table size
  99069. * @ignorenaming
  99070. */
  99071. FFT_SIZE: number;
  99072. /**
  99073. * Gets or sets the bar graph amplitude
  99074. * @ignorenaming
  99075. */
  99076. BARGRAPHAMPLITUDE: number;
  99077. /**
  99078. * Gets or sets the position of the debug canvas
  99079. * @ignorenaming
  99080. */
  99081. DEBUGCANVASPOS: {
  99082. x: number;
  99083. y: number;
  99084. };
  99085. /**
  99086. * Gets or sets the debug canvas size
  99087. * @ignorenaming
  99088. */
  99089. DEBUGCANVASSIZE: {
  99090. width: number;
  99091. height: number;
  99092. };
  99093. private _byteFreqs;
  99094. private _byteTime;
  99095. private _floatFreqs;
  99096. private _webAudioAnalyser;
  99097. private _debugCanvas;
  99098. private _debugCanvasContext;
  99099. private _scene;
  99100. private _registerFunc;
  99101. private _audioEngine;
  99102. /**
  99103. * Creates a new analyser
  99104. * @param scene defines hosting scene
  99105. */
  99106. constructor(scene: Scene);
  99107. /**
  99108. * Get the number of data values you will have to play with for the visualization
  99109. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99110. * @returns a number
  99111. */
  99112. getFrequencyBinCount(): number;
  99113. /**
  99114. * Gets the current frequency data as a byte array
  99115. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99116. * @returns a Uint8Array
  99117. */
  99118. getByteFrequencyData(): Uint8Array;
  99119. /**
  99120. * Gets the current waveform as a byte array
  99121. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99122. * @returns a Uint8Array
  99123. */
  99124. getByteTimeDomainData(): Uint8Array;
  99125. /**
  99126. * Gets the current frequency data as a float array
  99127. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99128. * @returns a Float32Array
  99129. */
  99130. getFloatFrequencyData(): Float32Array;
  99131. /**
  99132. * Renders the debug canvas
  99133. */
  99134. drawDebugCanvas(): void;
  99135. /**
  99136. * Stops rendering the debug canvas and removes it
  99137. */
  99138. stopDebugCanvas(): void;
  99139. /**
  99140. * Connects two audio nodes
  99141. * @param inputAudioNode defines first node to connect
  99142. * @param outputAudioNode defines second node to connect
  99143. */
  99144. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99145. /**
  99146. * Releases all associated resources
  99147. */
  99148. dispose(): void;
  99149. }
  99150. }
  99151. declare module BABYLON {
  99152. /**
  99153. * This represents an audio engine and it is responsible
  99154. * to play, synchronize and analyse sounds throughout the application.
  99155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99156. */
  99157. export interface IAudioEngine extends IDisposable {
  99158. /**
  99159. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99160. */
  99161. readonly canUseWebAudio: boolean;
  99162. /**
  99163. * Gets the current AudioContext if available.
  99164. */
  99165. readonly audioContext: Nullable<AudioContext>;
  99166. /**
  99167. * The master gain node defines the global audio volume of your audio engine.
  99168. */
  99169. readonly masterGain: GainNode;
  99170. /**
  99171. * Gets whether or not mp3 are supported by your browser.
  99172. */
  99173. readonly isMP3supported: boolean;
  99174. /**
  99175. * Gets whether or not ogg are supported by your browser.
  99176. */
  99177. readonly isOGGsupported: boolean;
  99178. /**
  99179. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99180. * @ignoreNaming
  99181. */
  99182. WarnedWebAudioUnsupported: boolean;
  99183. /**
  99184. * Defines if the audio engine relies on a custom unlocked button.
  99185. * In this case, the embedded button will not be displayed.
  99186. */
  99187. useCustomUnlockedButton: boolean;
  99188. /**
  99189. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99190. */
  99191. readonly unlocked: boolean;
  99192. /**
  99193. * Event raised when audio has been unlocked on the browser.
  99194. */
  99195. onAudioUnlockedObservable: Observable<AudioEngine>;
  99196. /**
  99197. * Event raised when audio has been locked on the browser.
  99198. */
  99199. onAudioLockedObservable: Observable<AudioEngine>;
  99200. /**
  99201. * Flags the audio engine in Locked state.
  99202. * This happens due to new browser policies preventing audio to autoplay.
  99203. */
  99204. lock(): void;
  99205. /**
  99206. * Unlocks the audio engine once a user action has been done on the dom.
  99207. * This is helpful to resume play once browser policies have been satisfied.
  99208. */
  99209. unlock(): void;
  99210. }
  99211. /**
  99212. * This represents the default audio engine used in babylon.
  99213. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99215. */
  99216. export class AudioEngine implements IAudioEngine {
  99217. private _audioContext;
  99218. private _audioContextInitialized;
  99219. private _muteButton;
  99220. private _hostElement;
  99221. /**
  99222. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99223. */
  99224. canUseWebAudio: boolean;
  99225. /**
  99226. * The master gain node defines the global audio volume of your audio engine.
  99227. */
  99228. masterGain: GainNode;
  99229. /**
  99230. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99231. * @ignoreNaming
  99232. */
  99233. WarnedWebAudioUnsupported: boolean;
  99234. /**
  99235. * Gets whether or not mp3 are supported by your browser.
  99236. */
  99237. isMP3supported: boolean;
  99238. /**
  99239. * Gets whether or not ogg are supported by your browser.
  99240. */
  99241. isOGGsupported: boolean;
  99242. /**
  99243. * Gets whether audio has been unlocked on the device.
  99244. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99245. * a user interaction has happened.
  99246. */
  99247. unlocked: boolean;
  99248. /**
  99249. * Defines if the audio engine relies on a custom unlocked button.
  99250. * In this case, the embedded button will not be displayed.
  99251. */
  99252. useCustomUnlockedButton: boolean;
  99253. /**
  99254. * Event raised when audio has been unlocked on the browser.
  99255. */
  99256. onAudioUnlockedObservable: Observable<AudioEngine>;
  99257. /**
  99258. * Event raised when audio has been locked on the browser.
  99259. */
  99260. onAudioLockedObservable: Observable<AudioEngine>;
  99261. /**
  99262. * Gets the current AudioContext if available.
  99263. */
  99264. readonly audioContext: Nullable<AudioContext>;
  99265. private _connectedAnalyser;
  99266. /**
  99267. * Instantiates a new audio engine.
  99268. *
  99269. * There should be only one per page as some browsers restrict the number
  99270. * of audio contexts you can create.
  99271. * @param hostElement defines the host element where to display the mute icon if necessary
  99272. */
  99273. constructor(hostElement?: Nullable<HTMLElement>);
  99274. /**
  99275. * Flags the audio engine in Locked state.
  99276. * This happens due to new browser policies preventing audio to autoplay.
  99277. */
  99278. lock(): void;
  99279. /**
  99280. * Unlocks the audio engine once a user action has been done on the dom.
  99281. * This is helpful to resume play once browser policies have been satisfied.
  99282. */
  99283. unlock(): void;
  99284. private _resumeAudioContext;
  99285. private _initializeAudioContext;
  99286. private _tryToRun;
  99287. private _triggerRunningState;
  99288. private _triggerSuspendedState;
  99289. private _displayMuteButton;
  99290. private _moveButtonToTopLeft;
  99291. private _onResize;
  99292. private _hideMuteButton;
  99293. /**
  99294. * Destroy and release the resources associated with the audio ccontext.
  99295. */
  99296. dispose(): void;
  99297. /**
  99298. * Gets the global volume sets on the master gain.
  99299. * @returns the global volume if set or -1 otherwise
  99300. */
  99301. getGlobalVolume(): number;
  99302. /**
  99303. * Sets the global volume of your experience (sets on the master gain).
  99304. * @param newVolume Defines the new global volume of the application
  99305. */
  99306. setGlobalVolume(newVolume: number): void;
  99307. /**
  99308. * Connect the audio engine to an audio analyser allowing some amazing
  99309. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99311. * @param analyser The analyser to connect to the engine
  99312. */
  99313. connectToAnalyser(analyser: Analyser): void;
  99314. }
  99315. }
  99316. declare module BABYLON {
  99317. /**
  99318. * Interface used to present a loading screen while loading a scene
  99319. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99320. */
  99321. export interface ILoadingScreen {
  99322. /**
  99323. * Function called to display the loading screen
  99324. */
  99325. displayLoadingUI: () => void;
  99326. /**
  99327. * Function called to hide the loading screen
  99328. */
  99329. hideLoadingUI: () => void;
  99330. /**
  99331. * Gets or sets the color to use for the background
  99332. */
  99333. loadingUIBackgroundColor: string;
  99334. /**
  99335. * Gets or sets the text to display while loading
  99336. */
  99337. loadingUIText: string;
  99338. }
  99339. /**
  99340. * Class used for the default loading screen
  99341. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99342. */
  99343. export class DefaultLoadingScreen implements ILoadingScreen {
  99344. private _renderingCanvas;
  99345. private _loadingText;
  99346. private _loadingDivBackgroundColor;
  99347. private _loadingDiv;
  99348. private _loadingTextDiv;
  99349. /** Gets or sets the logo url to use for the default loading screen */
  99350. static DefaultLogoUrl: string;
  99351. /** Gets or sets the spinner url to use for the default loading screen */
  99352. static DefaultSpinnerUrl: string;
  99353. /**
  99354. * Creates a new default loading screen
  99355. * @param _renderingCanvas defines the canvas used to render the scene
  99356. * @param _loadingText defines the default text to display
  99357. * @param _loadingDivBackgroundColor defines the default background color
  99358. */
  99359. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99360. /**
  99361. * Function called to display the loading screen
  99362. */
  99363. displayLoadingUI(): void;
  99364. /**
  99365. * Function called to hide the loading screen
  99366. */
  99367. hideLoadingUI(): void;
  99368. /**
  99369. * Gets or sets the text to display while loading
  99370. */
  99371. loadingUIText: string;
  99372. /**
  99373. * Gets or sets the color to use for the background
  99374. */
  99375. loadingUIBackgroundColor: string;
  99376. private _resizeLoadingUI;
  99377. }
  99378. }
  99379. declare module BABYLON {
  99380. /**
  99381. * Interface for any object that can request an animation frame
  99382. */
  99383. export interface ICustomAnimationFrameRequester {
  99384. /**
  99385. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99386. */
  99387. renderFunction?: Function;
  99388. /**
  99389. * Called to request the next frame to render to
  99390. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99391. */
  99392. requestAnimationFrame: Function;
  99393. /**
  99394. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99395. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99396. */
  99397. requestID?: number;
  99398. }
  99399. }
  99400. declare module BABYLON {
  99401. /**
  99402. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99403. */
  99404. export class PerformanceMonitor {
  99405. private _enabled;
  99406. private _rollingFrameTime;
  99407. private _lastFrameTimeMs;
  99408. /**
  99409. * constructor
  99410. * @param frameSampleSize The number of samples required to saturate the sliding window
  99411. */
  99412. constructor(frameSampleSize?: number);
  99413. /**
  99414. * Samples current frame
  99415. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99416. */
  99417. sampleFrame(timeMs?: number): void;
  99418. /**
  99419. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99420. */
  99421. readonly averageFrameTime: number;
  99422. /**
  99423. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99424. */
  99425. readonly averageFrameTimeVariance: number;
  99426. /**
  99427. * Returns the frame time of the most recent frame
  99428. */
  99429. readonly instantaneousFrameTime: number;
  99430. /**
  99431. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99432. */
  99433. readonly averageFPS: number;
  99434. /**
  99435. * Returns the average framerate in frames per second using the most recent frame time
  99436. */
  99437. readonly instantaneousFPS: number;
  99438. /**
  99439. * Returns true if enough samples have been taken to completely fill the sliding window
  99440. */
  99441. readonly isSaturated: boolean;
  99442. /**
  99443. * Enables contributions to the sliding window sample set
  99444. */
  99445. enable(): void;
  99446. /**
  99447. * Disables contributions to the sliding window sample set
  99448. * Samples will not be interpolated over the disabled period
  99449. */
  99450. disable(): void;
  99451. /**
  99452. * Returns true if sampling is enabled
  99453. */
  99454. readonly isEnabled: boolean;
  99455. /**
  99456. * Resets performance monitor
  99457. */
  99458. reset(): void;
  99459. }
  99460. /**
  99461. * RollingAverage
  99462. *
  99463. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99464. */
  99465. export class RollingAverage {
  99466. /**
  99467. * Current average
  99468. */
  99469. average: number;
  99470. /**
  99471. * Current variance
  99472. */
  99473. variance: number;
  99474. protected _samples: Array<number>;
  99475. protected _sampleCount: number;
  99476. protected _pos: number;
  99477. protected _m2: number;
  99478. /**
  99479. * constructor
  99480. * @param length The number of samples required to saturate the sliding window
  99481. */
  99482. constructor(length: number);
  99483. /**
  99484. * Adds a sample to the sample set
  99485. * @param v The sample value
  99486. */
  99487. add(v: number): void;
  99488. /**
  99489. * Returns previously added values or null if outside of history or outside the sliding window domain
  99490. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99491. * @return Value previously recorded with add() or null if outside of range
  99492. */
  99493. history(i: number): number;
  99494. /**
  99495. * Returns true if enough samples have been taken to completely fill the sliding window
  99496. * @return true if sample-set saturated
  99497. */
  99498. isSaturated(): boolean;
  99499. /**
  99500. * Resets the rolling average (equivalent to 0 samples taken so far)
  99501. */
  99502. reset(): void;
  99503. /**
  99504. * Wraps a value around the sample range boundaries
  99505. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99506. * @return Wrapped position in sample range
  99507. */
  99508. protected _wrapPosition(i: number): number;
  99509. }
  99510. }
  99511. declare module BABYLON {
  99512. /**
  99513. * This class is used to track a performance counter which is number based.
  99514. * The user has access to many properties which give statistics of different nature.
  99515. *
  99516. * The implementer can track two kinds of Performance Counter: time and count.
  99517. * 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.
  99518. * 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.
  99519. */
  99520. export class PerfCounter {
  99521. /**
  99522. * Gets or sets a global boolean to turn on and off all the counters
  99523. */
  99524. static Enabled: boolean;
  99525. /**
  99526. * Returns the smallest value ever
  99527. */
  99528. readonly min: number;
  99529. /**
  99530. * Returns the biggest value ever
  99531. */
  99532. readonly max: number;
  99533. /**
  99534. * Returns the average value since the performance counter is running
  99535. */
  99536. readonly average: number;
  99537. /**
  99538. * Returns the average value of the last second the counter was monitored
  99539. */
  99540. readonly lastSecAverage: number;
  99541. /**
  99542. * Returns the current value
  99543. */
  99544. readonly current: number;
  99545. /**
  99546. * Gets the accumulated total
  99547. */
  99548. readonly total: number;
  99549. /**
  99550. * Gets the total value count
  99551. */
  99552. readonly count: number;
  99553. /**
  99554. * Creates a new counter
  99555. */
  99556. constructor();
  99557. /**
  99558. * Call this method to start monitoring a new frame.
  99559. * 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.
  99560. */
  99561. fetchNewFrame(): void;
  99562. /**
  99563. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99564. * @param newCount the count value to add to the monitored count
  99565. * @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.
  99566. */
  99567. addCount(newCount: number, fetchResult: boolean): void;
  99568. /**
  99569. * Start monitoring this performance counter
  99570. */
  99571. beginMonitoring(): void;
  99572. /**
  99573. * Compute the time lapsed since the previous beginMonitoring() call.
  99574. * @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
  99575. */
  99576. endMonitoring(newFrame?: boolean): void;
  99577. private _fetchResult;
  99578. private _startMonitoringTime;
  99579. private _min;
  99580. private _max;
  99581. private _average;
  99582. private _current;
  99583. private _totalValueCount;
  99584. private _totalAccumulated;
  99585. private _lastSecAverage;
  99586. private _lastSecAccumulated;
  99587. private _lastSecTime;
  99588. private _lastSecValueCount;
  99589. }
  99590. }
  99591. declare module BABYLON {
  99592. /**
  99593. * Defines the interface used by display changed events
  99594. */
  99595. export interface IDisplayChangedEventArgs {
  99596. /** Gets the vrDisplay object (if any) */
  99597. vrDisplay: Nullable<any>;
  99598. /** Gets a boolean indicating if webVR is supported */
  99599. vrSupported: boolean;
  99600. }
  99601. /**
  99602. * Defines the interface used by objects containing a viewport (like a camera)
  99603. */
  99604. interface IViewportOwnerLike {
  99605. /**
  99606. * Gets or sets the viewport
  99607. */
  99608. viewport: IViewportLike;
  99609. }
  99610. /**
  99611. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99612. */
  99613. export class Engine extends ThinEngine {
  99614. /** Defines that alpha blending is disabled */
  99615. static readonly ALPHA_DISABLE: number;
  99616. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99617. static readonly ALPHA_ADD: number;
  99618. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99619. static readonly ALPHA_COMBINE: number;
  99620. /** Defines that alpha blending to DEST - SRC * DEST */
  99621. static readonly ALPHA_SUBTRACT: number;
  99622. /** Defines that alpha blending to SRC * DEST */
  99623. static readonly ALPHA_MULTIPLY: number;
  99624. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99625. static readonly ALPHA_MAXIMIZED: number;
  99626. /** Defines that alpha blending to SRC + DEST */
  99627. static readonly ALPHA_ONEONE: number;
  99628. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99629. static readonly ALPHA_PREMULTIPLIED: number;
  99630. /**
  99631. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99632. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99633. */
  99634. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99635. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99636. static readonly ALPHA_INTERPOLATE: number;
  99637. /**
  99638. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99639. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99640. */
  99641. static readonly ALPHA_SCREENMODE: number;
  99642. /** Defines that the ressource is not delayed*/
  99643. static readonly DELAYLOADSTATE_NONE: number;
  99644. /** Defines that the ressource was successfully delay loaded */
  99645. static readonly DELAYLOADSTATE_LOADED: number;
  99646. /** Defines that the ressource is currently delay loading */
  99647. static readonly DELAYLOADSTATE_LOADING: number;
  99648. /** Defines that the ressource is delayed and has not started loading */
  99649. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99650. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99651. static readonly NEVER: number;
  99652. /** 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 */
  99653. static readonly ALWAYS: number;
  99654. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99655. static readonly LESS: number;
  99656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99657. static readonly EQUAL: number;
  99658. /** 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 */
  99659. static readonly LEQUAL: number;
  99660. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99661. static readonly GREATER: number;
  99662. /** 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 */
  99663. static readonly GEQUAL: number;
  99664. /** 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 */
  99665. static readonly NOTEQUAL: number;
  99666. /** Passed to stencilOperation to specify that stencil value must be kept */
  99667. static readonly KEEP: number;
  99668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99669. static readonly REPLACE: number;
  99670. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99671. static readonly INCR: number;
  99672. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99673. static readonly DECR: number;
  99674. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99675. static readonly INVERT: number;
  99676. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99677. static readonly INCR_WRAP: number;
  99678. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99679. static readonly DECR_WRAP: number;
  99680. /** Texture is not repeating outside of 0..1 UVs */
  99681. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99682. /** Texture is repeating outside of 0..1 UVs */
  99683. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99684. /** Texture is repeating and mirrored */
  99685. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99686. /** ALPHA */
  99687. static readonly TEXTUREFORMAT_ALPHA: number;
  99688. /** LUMINANCE */
  99689. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99690. /** LUMINANCE_ALPHA */
  99691. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99692. /** RGB */
  99693. static readonly TEXTUREFORMAT_RGB: number;
  99694. /** RGBA */
  99695. static readonly TEXTUREFORMAT_RGBA: number;
  99696. /** RED */
  99697. static readonly TEXTUREFORMAT_RED: number;
  99698. /** RED (2nd reference) */
  99699. static readonly TEXTUREFORMAT_R: number;
  99700. /** RG */
  99701. static readonly TEXTUREFORMAT_RG: number;
  99702. /** RED_INTEGER */
  99703. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99704. /** RED_INTEGER (2nd reference) */
  99705. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99706. /** RG_INTEGER */
  99707. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99708. /** RGB_INTEGER */
  99709. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99710. /** RGBA_INTEGER */
  99711. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99712. /** UNSIGNED_BYTE */
  99713. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99714. /** UNSIGNED_BYTE (2nd reference) */
  99715. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99716. /** FLOAT */
  99717. static readonly TEXTURETYPE_FLOAT: number;
  99718. /** HALF_FLOAT */
  99719. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99720. /** BYTE */
  99721. static readonly TEXTURETYPE_BYTE: number;
  99722. /** SHORT */
  99723. static readonly TEXTURETYPE_SHORT: number;
  99724. /** UNSIGNED_SHORT */
  99725. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99726. /** INT */
  99727. static readonly TEXTURETYPE_INT: number;
  99728. /** UNSIGNED_INT */
  99729. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99730. /** UNSIGNED_SHORT_4_4_4_4 */
  99731. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99732. /** UNSIGNED_SHORT_5_5_5_1 */
  99733. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99734. /** UNSIGNED_SHORT_5_6_5 */
  99735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99736. /** UNSIGNED_INT_2_10_10_10_REV */
  99737. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99738. /** UNSIGNED_INT_24_8 */
  99739. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99740. /** UNSIGNED_INT_10F_11F_11F_REV */
  99741. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99742. /** UNSIGNED_INT_5_9_9_9_REV */
  99743. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99744. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99745. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99746. /** nearest is mag = nearest and min = nearest and mip = linear */
  99747. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99748. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99749. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99750. /** Trilinear is mag = linear and min = linear and mip = linear */
  99751. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99752. /** nearest is mag = nearest and min = nearest and mip = linear */
  99753. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99754. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99755. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99756. /** Trilinear is mag = linear and min = linear and mip = linear */
  99757. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99758. /** mag = nearest and min = nearest and mip = nearest */
  99759. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99760. /** mag = nearest and min = linear and mip = nearest */
  99761. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99762. /** mag = nearest and min = linear and mip = linear */
  99763. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99764. /** mag = nearest and min = linear and mip = none */
  99765. static readonly TEXTURE_NEAREST_LINEAR: number;
  99766. /** mag = nearest and min = nearest and mip = none */
  99767. static readonly TEXTURE_NEAREST_NEAREST: number;
  99768. /** mag = linear and min = nearest and mip = nearest */
  99769. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99770. /** mag = linear and min = nearest and mip = linear */
  99771. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99772. /** mag = linear and min = linear and mip = none */
  99773. static readonly TEXTURE_LINEAR_LINEAR: number;
  99774. /** mag = linear and min = nearest and mip = none */
  99775. static readonly TEXTURE_LINEAR_NEAREST: number;
  99776. /** Explicit coordinates mode */
  99777. static readonly TEXTURE_EXPLICIT_MODE: number;
  99778. /** Spherical coordinates mode */
  99779. static readonly TEXTURE_SPHERICAL_MODE: number;
  99780. /** Planar coordinates mode */
  99781. static readonly TEXTURE_PLANAR_MODE: number;
  99782. /** Cubic coordinates mode */
  99783. static readonly TEXTURE_CUBIC_MODE: number;
  99784. /** Projection coordinates mode */
  99785. static readonly TEXTURE_PROJECTION_MODE: number;
  99786. /** Skybox coordinates mode */
  99787. static readonly TEXTURE_SKYBOX_MODE: number;
  99788. /** Inverse Cubic coordinates mode */
  99789. static readonly TEXTURE_INVCUBIC_MODE: number;
  99790. /** Equirectangular coordinates mode */
  99791. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99792. /** Equirectangular Fixed coordinates mode */
  99793. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99794. /** Equirectangular Fixed Mirrored coordinates mode */
  99795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99796. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99797. static readonly SCALEMODE_FLOOR: number;
  99798. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99799. static readonly SCALEMODE_NEAREST: number;
  99800. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99801. static readonly SCALEMODE_CEILING: number;
  99802. /**
  99803. * Returns the current npm package of the sdk
  99804. */
  99805. static readonly NpmPackage: string;
  99806. /**
  99807. * Returns the current version of the framework
  99808. */
  99809. static readonly Version: string;
  99810. /** Gets the list of created engines */
  99811. static readonly Instances: Engine[];
  99812. /**
  99813. * Gets the latest created engine
  99814. */
  99815. static readonly LastCreatedEngine: Nullable<Engine>;
  99816. /**
  99817. * Gets the latest created scene
  99818. */
  99819. static readonly LastCreatedScene: Nullable<Scene>;
  99820. /**
  99821. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99822. * @param flag defines which part of the materials must be marked as dirty
  99823. * @param predicate defines a predicate used to filter which materials should be affected
  99824. */
  99825. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99826. /**
  99827. * Method called to create the default loading screen.
  99828. * This can be overriden in your own app.
  99829. * @param canvas The rendering canvas element
  99830. * @returns The loading screen
  99831. */
  99832. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99833. /**
  99834. * Method called to create the default rescale post process on each engine.
  99835. */
  99836. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99837. /**
  99838. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99839. **/
  99840. enableOfflineSupport: boolean;
  99841. /**
  99842. * 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)
  99843. **/
  99844. disableManifestCheck: boolean;
  99845. /**
  99846. * Gets the list of created scenes
  99847. */
  99848. scenes: Scene[];
  99849. /**
  99850. * Event raised when a new scene is created
  99851. */
  99852. onNewSceneAddedObservable: Observable<Scene>;
  99853. /**
  99854. * Gets the list of created postprocesses
  99855. */
  99856. postProcesses: PostProcess[];
  99857. /**
  99858. * Gets a boolean indicating if the pointer is currently locked
  99859. */
  99860. isPointerLock: boolean;
  99861. /**
  99862. * Observable event triggered each time the rendering canvas is resized
  99863. */
  99864. onResizeObservable: Observable<Engine>;
  99865. /**
  99866. * Observable event triggered each time the canvas loses focus
  99867. */
  99868. onCanvasBlurObservable: Observable<Engine>;
  99869. /**
  99870. * Observable event triggered each time the canvas gains focus
  99871. */
  99872. onCanvasFocusObservable: Observable<Engine>;
  99873. /**
  99874. * Observable event triggered each time the canvas receives pointerout event
  99875. */
  99876. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99877. /**
  99878. * Observable raised when the engine begins a new frame
  99879. */
  99880. onBeginFrameObservable: Observable<Engine>;
  99881. /**
  99882. * If set, will be used to request the next animation frame for the render loop
  99883. */
  99884. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99885. /**
  99886. * Observable raised when the engine ends the current frame
  99887. */
  99888. onEndFrameObservable: Observable<Engine>;
  99889. /**
  99890. * Observable raised when the engine is about to compile a shader
  99891. */
  99892. onBeforeShaderCompilationObservable: Observable<Engine>;
  99893. /**
  99894. * Observable raised when the engine has jsut compiled a shader
  99895. */
  99896. onAfterShaderCompilationObservable: Observable<Engine>;
  99897. /**
  99898. * Gets the audio engine
  99899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99900. * @ignorenaming
  99901. */
  99902. static audioEngine: IAudioEngine;
  99903. /**
  99904. * Default AudioEngine factory responsible of creating the Audio Engine.
  99905. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99906. */
  99907. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99908. /**
  99909. * Default offline support factory responsible of creating a tool used to store data locally.
  99910. * By default, this will create a Database object if the workload has been embedded.
  99911. */
  99912. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99913. private _loadingScreen;
  99914. private _pointerLockRequested;
  99915. private _dummyFramebuffer;
  99916. private _rescalePostProcess;
  99917. /** @hidden */
  99918. protected _alphaMode: number;
  99919. /** @hidden */
  99920. protected _alphaEquation: number;
  99921. private _deterministicLockstep;
  99922. private _lockstepMaxSteps;
  99923. protected readonly _supportsHardwareTextureRescaling: boolean;
  99924. private _fps;
  99925. private _deltaTime;
  99926. /** @hidden */
  99927. _drawCalls: PerfCounter;
  99928. /**
  99929. * Turn this value on if you want to pause FPS computation when in background
  99930. */
  99931. disablePerformanceMonitorInBackground: boolean;
  99932. private _performanceMonitor;
  99933. /**
  99934. * Gets the performance monitor attached to this engine
  99935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99936. */
  99937. readonly performanceMonitor: PerformanceMonitor;
  99938. private _onFocus;
  99939. private _onBlur;
  99940. private _onCanvasPointerOut;
  99941. private _onCanvasBlur;
  99942. private _onCanvasFocus;
  99943. private _onFullscreenChange;
  99944. private _onPointerLockChange;
  99945. /**
  99946. * Gets the HTML element used to attach event listeners
  99947. * @returns a HTML element
  99948. */
  99949. getInputElement(): Nullable<HTMLElement>;
  99950. /**
  99951. * Creates a new engine
  99952. * @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
  99953. * @param antialias defines enable antialiasing (default: false)
  99954. * @param options defines further options to be sent to the getContext() function
  99955. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99956. */
  99957. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99958. /**
  99959. * Gets current aspect ratio
  99960. * @param viewportOwner defines the camera to use to get the aspect ratio
  99961. * @param useScreen defines if screen size must be used (or the current render target if any)
  99962. * @returns a number defining the aspect ratio
  99963. */
  99964. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99965. /**
  99966. * Gets current screen aspect ratio
  99967. * @returns a number defining the aspect ratio
  99968. */
  99969. getScreenAspectRatio(): number;
  99970. /**
  99971. * Gets host document
  99972. * @returns the host document object
  99973. */
  99974. getHostDocument(): Document;
  99975. /**
  99976. * Gets the client rect of the HTML canvas attached with the current webGL context
  99977. * @returns a client rectanglee
  99978. */
  99979. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99980. /**
  99981. * Gets the client rect of the HTML element used for events
  99982. * @returns a client rectanglee
  99983. */
  99984. getInputElementClientRect(): Nullable<ClientRect>;
  99985. /**
  99986. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99988. * @returns true if engine is in deterministic lock step mode
  99989. */
  99990. isDeterministicLockStep(): boolean;
  99991. /**
  99992. * Gets the max steps when engine is running in deterministic lock step
  99993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99994. * @returns the max steps
  99995. */
  99996. getLockstepMaxSteps(): number;
  99997. /**
  99998. * Force the mipmap generation for the given render target texture
  99999. * @param texture defines the render target texture to use
  100000. */
  100001. generateMipMapsForCubemap(texture: InternalTexture): void;
  100002. /** States */
  100003. /**
  100004. * Set various states to the webGL context
  100005. * @param culling defines backface culling state
  100006. * @param zOffset defines the value to apply to zOffset (0 by default)
  100007. * @param force defines if states must be applied even if cache is up to date
  100008. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  100009. */
  100010. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100011. /**
  100012. * Set the z offset to apply to current rendering
  100013. * @param value defines the offset to apply
  100014. */
  100015. setZOffset(value: number): void;
  100016. /**
  100017. * Gets the current value of the zOffset
  100018. * @returns the current zOffset state
  100019. */
  100020. getZOffset(): number;
  100021. /**
  100022. * Enable or disable depth buffering
  100023. * @param enable defines the state to set
  100024. */
  100025. setDepthBuffer(enable: boolean): void;
  100026. /**
  100027. * Gets a boolean indicating if depth writing is enabled
  100028. * @returns the current depth writing state
  100029. */
  100030. getDepthWrite(): boolean;
  100031. /**
  100032. * Enable or disable depth writing
  100033. * @param enable defines the state to set
  100034. */
  100035. setDepthWrite(enable: boolean): void;
  100036. /**
  100037. * Enable or disable color writing
  100038. * @param enable defines the state to set
  100039. */
  100040. setColorWrite(enable: boolean): void;
  100041. /**
  100042. * Gets a boolean indicating if color writing is enabled
  100043. * @returns the current color writing state
  100044. */
  100045. getColorWrite(): boolean;
  100046. /**
  100047. * Sets alpha constants used by some alpha blending modes
  100048. * @param r defines the red component
  100049. * @param g defines the green component
  100050. * @param b defines the blue component
  100051. * @param a defines the alpha component
  100052. */
  100053. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100054. /**
  100055. * Sets the current alpha mode
  100056. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100057. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100058. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100059. */
  100060. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100061. /**
  100062. * Gets the current alpha mode
  100063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100064. * @returns the current alpha mode
  100065. */
  100066. getAlphaMode(): number;
  100067. /**
  100068. * Sets the current alpha equation
  100069. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100070. */
  100071. setAlphaEquation(equation: number): void;
  100072. /**
  100073. * Gets the current alpha equation.
  100074. * @returns the current alpha equation
  100075. */
  100076. getAlphaEquation(): number;
  100077. /**
  100078. * Gets a boolean indicating if stencil buffer is enabled
  100079. * @returns the current stencil buffer state
  100080. */
  100081. getStencilBuffer(): boolean;
  100082. /**
  100083. * Enable or disable the stencil buffer
  100084. * @param enable defines if the stencil buffer must be enabled or disabled
  100085. */
  100086. setStencilBuffer(enable: boolean): void;
  100087. /**
  100088. * Gets the current stencil mask
  100089. * @returns a number defining the new stencil mask to use
  100090. */
  100091. getStencilMask(): number;
  100092. /**
  100093. * Sets the current stencil mask
  100094. * @param mask defines the new stencil mask to use
  100095. */
  100096. setStencilMask(mask: number): void;
  100097. /**
  100098. * Gets the current stencil function
  100099. * @returns a number defining the stencil function to use
  100100. */
  100101. getStencilFunction(): number;
  100102. /**
  100103. * Gets the current stencil reference value
  100104. * @returns a number defining the stencil reference value to use
  100105. */
  100106. getStencilFunctionReference(): number;
  100107. /**
  100108. * Gets the current stencil mask
  100109. * @returns a number defining the stencil mask to use
  100110. */
  100111. getStencilFunctionMask(): number;
  100112. /**
  100113. * Sets the current stencil function
  100114. * @param stencilFunc defines the new stencil function to use
  100115. */
  100116. setStencilFunction(stencilFunc: number): void;
  100117. /**
  100118. * Sets the current stencil reference
  100119. * @param reference defines the new stencil reference to use
  100120. */
  100121. setStencilFunctionReference(reference: number): void;
  100122. /**
  100123. * Sets the current stencil mask
  100124. * @param mask defines the new stencil mask to use
  100125. */
  100126. setStencilFunctionMask(mask: number): void;
  100127. /**
  100128. * Gets the current stencil operation when stencil fails
  100129. * @returns a number defining stencil operation to use when stencil fails
  100130. */
  100131. getStencilOperationFail(): number;
  100132. /**
  100133. * Gets the current stencil operation when depth fails
  100134. * @returns a number defining stencil operation to use when depth fails
  100135. */
  100136. getStencilOperationDepthFail(): number;
  100137. /**
  100138. * Gets the current stencil operation when stencil passes
  100139. * @returns a number defining stencil operation to use when stencil passes
  100140. */
  100141. getStencilOperationPass(): number;
  100142. /**
  100143. * Sets the stencil operation to use when stencil fails
  100144. * @param operation defines the stencil operation to use when stencil fails
  100145. */
  100146. setStencilOperationFail(operation: number): void;
  100147. /**
  100148. * Sets the stencil operation to use when depth fails
  100149. * @param operation defines the stencil operation to use when depth fails
  100150. */
  100151. setStencilOperationDepthFail(operation: number): void;
  100152. /**
  100153. * Sets the stencil operation to use when stencil passes
  100154. * @param operation defines the stencil operation to use when stencil passes
  100155. */
  100156. setStencilOperationPass(operation: number): void;
  100157. /**
  100158. * Sets a boolean indicating if the dithering state is enabled or disabled
  100159. * @param value defines the dithering state
  100160. */
  100161. setDitheringState(value: boolean): void;
  100162. /**
  100163. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100164. * @param value defines the rasterizer state
  100165. */
  100166. setRasterizerState(value: boolean): void;
  100167. /**
  100168. * Gets the current depth function
  100169. * @returns a number defining the depth function
  100170. */
  100171. getDepthFunction(): Nullable<number>;
  100172. /**
  100173. * Sets the current depth function
  100174. * @param depthFunc defines the function to use
  100175. */
  100176. setDepthFunction(depthFunc: number): void;
  100177. /**
  100178. * Sets the current depth function to GREATER
  100179. */
  100180. setDepthFunctionToGreater(): void;
  100181. /**
  100182. * Sets the current depth function to GEQUAL
  100183. */
  100184. setDepthFunctionToGreaterOrEqual(): void;
  100185. /**
  100186. * Sets the current depth function to LESS
  100187. */
  100188. setDepthFunctionToLess(): void;
  100189. /**
  100190. * Sets the current depth function to LEQUAL
  100191. */
  100192. setDepthFunctionToLessOrEqual(): void;
  100193. private _cachedStencilBuffer;
  100194. private _cachedStencilFunction;
  100195. private _cachedStencilMask;
  100196. private _cachedStencilOperationPass;
  100197. private _cachedStencilOperationFail;
  100198. private _cachedStencilOperationDepthFail;
  100199. private _cachedStencilReference;
  100200. /**
  100201. * Caches the the state of the stencil buffer
  100202. */
  100203. cacheStencilState(): void;
  100204. /**
  100205. * Restores the state of the stencil buffer
  100206. */
  100207. restoreStencilState(): void;
  100208. /**
  100209. * Directly set the WebGL Viewport
  100210. * @param x defines the x coordinate of the viewport (in screen space)
  100211. * @param y defines the y coordinate of the viewport (in screen space)
  100212. * @param width defines the width of the viewport (in screen space)
  100213. * @param height defines the height of the viewport (in screen space)
  100214. * @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
  100215. */
  100216. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100217. /**
  100218. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100219. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100220. * @param y defines the y-coordinate of the corner of the clear rectangle
  100221. * @param width defines the width of the clear rectangle
  100222. * @param height defines the height of the clear rectangle
  100223. * @param clearColor defines the clear color
  100224. */
  100225. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100226. /**
  100227. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100228. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100229. * @param y defines the y-coordinate of the corner of the clear rectangle
  100230. * @param width defines the width of the clear rectangle
  100231. * @param height defines the height of the clear rectangle
  100232. */
  100233. enableScissor(x: number, y: number, width: number, height: number): void;
  100234. /**
  100235. * Disable previously set scissor test rectangle
  100236. */
  100237. disableScissor(): void;
  100238. protected _reportDrawCall(): void;
  100239. /**
  100240. * Initializes a webVR display and starts listening to display change events
  100241. * The onVRDisplayChangedObservable will be notified upon these changes
  100242. * @returns The onVRDisplayChangedObservable
  100243. */
  100244. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100245. /** @hidden */
  100246. _prepareVRComponent(): void;
  100247. /** @hidden */
  100248. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100249. /** @hidden */
  100250. _submitVRFrame(): void;
  100251. /**
  100252. * Call this function to leave webVR mode
  100253. * Will do nothing if webVR is not supported or if there is no webVR device
  100254. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100255. */
  100256. disableVR(): void;
  100257. /**
  100258. * Gets a boolean indicating that the system is in VR mode and is presenting
  100259. * @returns true if VR mode is engaged
  100260. */
  100261. isVRPresenting(): boolean;
  100262. /** @hidden */
  100263. _requestVRFrame(): void;
  100264. /** @hidden */
  100265. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100266. /**
  100267. * Gets the source code of the vertex shader associated with a specific webGL program
  100268. * @param program defines the program to use
  100269. * @returns a string containing the source code of the vertex shader associated with the program
  100270. */
  100271. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100272. /**
  100273. * Gets the source code of the fragment shader associated with a specific webGL program
  100274. * @param program defines the program to use
  100275. * @returns a string containing the source code of the fragment shader associated with the program
  100276. */
  100277. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100278. /**
  100279. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100280. * @param x defines the x coordinate of the rectangle where pixels must be read
  100281. * @param y defines the y coordinate of the rectangle where pixels must be read
  100282. * @param width defines the width of the rectangle where pixels must be read
  100283. * @param height defines the height of the rectangle where pixels must be read
  100284. * @returns a Uint8Array containing RGBA colors
  100285. */
  100286. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100287. /**
  100288. * Sets a depth stencil texture from a render target to the according uniform.
  100289. * @param channel The texture channel
  100290. * @param uniform The uniform to set
  100291. * @param texture The render target texture containing the depth stencil texture to apply
  100292. */
  100293. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100294. /**
  100295. * Sets a texture to the webGL context from a postprocess
  100296. * @param channel defines the channel to use
  100297. * @param postProcess defines the source postprocess
  100298. */
  100299. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100300. /**
  100301. * Binds the output of the passed in post process to the texture channel specified
  100302. * @param channel The channel the texture should be bound to
  100303. * @param postProcess The post process which's output should be bound
  100304. */
  100305. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100306. /** @hidden */
  100307. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100308. protected _rebuildBuffers(): void;
  100309. /** @hidden */
  100310. _renderFrame(): void;
  100311. _renderLoop(): void;
  100312. /** @hidden */
  100313. _renderViews(): boolean;
  100314. /**
  100315. * Toggle full screen mode
  100316. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100317. */
  100318. switchFullscreen(requestPointerLock: boolean): void;
  100319. /**
  100320. * Enters full screen mode
  100321. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100322. */
  100323. enterFullscreen(requestPointerLock: boolean): void;
  100324. /**
  100325. * Exits full screen mode
  100326. */
  100327. exitFullscreen(): void;
  100328. /**
  100329. * Enters Pointerlock mode
  100330. */
  100331. enterPointerlock(): void;
  100332. /**
  100333. * Exits Pointerlock mode
  100334. */
  100335. exitPointerlock(): void;
  100336. /**
  100337. * Begin a new frame
  100338. */
  100339. beginFrame(): void;
  100340. /**
  100341. * Enf the current frame
  100342. */
  100343. endFrame(): void;
  100344. resize(): void;
  100345. /**
  100346. * Set the compressed texture format to use, based on the formats you have, and the formats
  100347. * supported by the hardware / browser.
  100348. *
  100349. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100350. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100351. * to API arguments needed to compressed textures. This puts the burden on the container
  100352. * generator to house the arcane code for determining these for current & future formats.
  100353. *
  100354. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100355. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100356. *
  100357. * Note: The result of this call is not taken into account when a texture is base64.
  100358. *
  100359. * @param formatsAvailable defines the list of those format families you have created
  100360. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100361. *
  100362. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100363. * @returns The extension selected.
  100364. */
  100365. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100366. /**
  100367. * Force a specific size of the canvas
  100368. * @param width defines the new canvas' width
  100369. * @param height defines the new canvas' height
  100370. */
  100371. setSize(width: number, height: number): void;
  100372. /**
  100373. * Updates a dynamic vertex buffer.
  100374. * @param vertexBuffer the vertex buffer to update
  100375. * @param data the data used to update the vertex buffer
  100376. * @param byteOffset the byte offset of the data
  100377. * @param byteLength the byte length of the data
  100378. */
  100379. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100380. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100381. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100382. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100383. _releaseTexture(texture: InternalTexture): void;
  100384. /**
  100385. * @hidden
  100386. * Rescales a texture
  100387. * @param source input texutre
  100388. * @param destination destination texture
  100389. * @param scene scene to use to render the resize
  100390. * @param internalFormat format to use when resizing
  100391. * @param onComplete callback to be called when resize has completed
  100392. */
  100393. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100394. /**
  100395. * Gets the current framerate
  100396. * @returns a number representing the framerate
  100397. */
  100398. getFps(): number;
  100399. /**
  100400. * Gets the time spent between current and previous frame
  100401. * @returns a number representing the delta time in ms
  100402. */
  100403. getDeltaTime(): number;
  100404. private _measureFps;
  100405. /** @hidden */
  100406. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100407. /**
  100408. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100409. * @param renderTarget The render target to set the frame buffer for
  100410. */
  100411. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100412. /**
  100413. * Update a dynamic index buffer
  100414. * @param indexBuffer defines the target index buffer
  100415. * @param indices defines the data to update
  100416. * @param offset defines the offset in the target index buffer where update should start
  100417. */
  100418. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100419. /**
  100420. * Updates the sample count of a render target texture
  100421. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100422. * @param texture defines the texture to update
  100423. * @param samples defines the sample count to set
  100424. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100425. */
  100426. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100427. /**
  100428. * Updates a depth texture Comparison Mode and Function.
  100429. * If the comparison Function is equal to 0, the mode will be set to none.
  100430. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100431. * @param texture The texture to set the comparison function for
  100432. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100433. */
  100434. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100435. /**
  100436. * Creates a webGL buffer to use with instanciation
  100437. * @param capacity defines the size of the buffer
  100438. * @returns the webGL buffer
  100439. */
  100440. createInstancesBuffer(capacity: number): DataBuffer;
  100441. /**
  100442. * Delete a webGL buffer used with instanciation
  100443. * @param buffer defines the webGL buffer to delete
  100444. */
  100445. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100446. /** @hidden */
  100447. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100448. dispose(): void;
  100449. private _disableTouchAction;
  100450. /**
  100451. * Display the loading screen
  100452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100453. */
  100454. displayLoadingUI(): void;
  100455. /**
  100456. * Hide the loading screen
  100457. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100458. */
  100459. hideLoadingUI(): void;
  100460. /**
  100461. * Gets the current loading screen object
  100462. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100463. */
  100464. /**
  100465. * Sets the current loading screen object
  100466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100467. */
  100468. loadingScreen: ILoadingScreen;
  100469. /**
  100470. * Sets the current loading screen text
  100471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100472. */
  100473. loadingUIText: string;
  100474. /**
  100475. * Sets the current loading screen background color
  100476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100477. */
  100478. loadingUIBackgroundColor: string;
  100479. /** Pointerlock and fullscreen */
  100480. /**
  100481. * Ask the browser to promote the current element to pointerlock mode
  100482. * @param element defines the DOM element to promote
  100483. */
  100484. static _RequestPointerlock(element: HTMLElement): void;
  100485. /**
  100486. * Asks the browser to exit pointerlock mode
  100487. */
  100488. static _ExitPointerlock(): void;
  100489. /**
  100490. * Ask the browser to promote the current element to fullscreen rendering mode
  100491. * @param element defines the DOM element to promote
  100492. */
  100493. static _RequestFullscreen(element: HTMLElement): void;
  100494. /**
  100495. * Asks the browser to exit fullscreen mode
  100496. */
  100497. static _ExitFullscreen(): void;
  100498. }
  100499. }
  100500. declare module BABYLON {
  100501. /**
  100502. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100503. * during the life time of the application.
  100504. */
  100505. export class EngineStore {
  100506. /** Gets the list of created engines */
  100507. static Instances: Engine[];
  100508. /** @hidden */
  100509. static _LastCreatedScene: Nullable<Scene>;
  100510. /**
  100511. * Gets the latest created engine
  100512. */
  100513. static readonly LastCreatedEngine: Nullable<Engine>;
  100514. /**
  100515. * Gets the latest created scene
  100516. */
  100517. static readonly LastCreatedScene: Nullable<Scene>;
  100518. /**
  100519. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100520. * @ignorenaming
  100521. */
  100522. static UseFallbackTexture: boolean;
  100523. /**
  100524. * Texture content used if a texture cannot loaded
  100525. * @ignorenaming
  100526. */
  100527. static FallbackTexture: string;
  100528. }
  100529. }
  100530. declare module BABYLON {
  100531. /**
  100532. * Helper class that provides a small promise polyfill
  100533. */
  100534. export class PromisePolyfill {
  100535. /**
  100536. * Static function used to check if the polyfill is required
  100537. * If this is the case then the function will inject the polyfill to window.Promise
  100538. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100539. */
  100540. static Apply(force?: boolean): void;
  100541. }
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * Interface for screenshot methods with describe argument called `size` as object with options
  100546. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100547. */
  100548. export interface IScreenshotSize {
  100549. /**
  100550. * number in pixels for canvas height
  100551. */
  100552. height?: number;
  100553. /**
  100554. * multiplier allowing render at a higher or lower resolution
  100555. * If value is defined then height and width will be ignored and taken from camera
  100556. */
  100557. precision?: number;
  100558. /**
  100559. * number in pixels for canvas width
  100560. */
  100561. width?: number;
  100562. }
  100563. }
  100564. declare module BABYLON {
  100565. interface IColor4Like {
  100566. r: float;
  100567. g: float;
  100568. b: float;
  100569. a: float;
  100570. }
  100571. /**
  100572. * Class containing a set of static utilities functions
  100573. */
  100574. export class Tools {
  100575. /**
  100576. * Gets or sets the base URL to use to load assets
  100577. */
  100578. static BaseUrl: string;
  100579. /**
  100580. * Enable/Disable Custom HTTP Request Headers globally.
  100581. * default = false
  100582. * @see CustomRequestHeaders
  100583. */
  100584. static UseCustomRequestHeaders: boolean;
  100585. /**
  100586. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100587. * i.e. when loading files, where the server/service expects an Authorization header
  100588. */
  100589. static CustomRequestHeaders: {
  100590. [key: string]: string;
  100591. };
  100592. /**
  100593. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100594. */
  100595. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100596. /**
  100597. * Default behaviour for cors in the application.
  100598. * It can be a string if the expected behavior is identical in the entire app.
  100599. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100600. */
  100601. static CorsBehavior: string | ((url: string | string[]) => string);
  100602. /**
  100603. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100604. * @ignorenaming
  100605. */
  100606. static UseFallbackTexture: boolean;
  100607. /**
  100608. * Use this object to register external classes like custom textures or material
  100609. * to allow the laoders to instantiate them
  100610. */
  100611. static RegisteredExternalClasses: {
  100612. [key: string]: Object;
  100613. };
  100614. /**
  100615. * Texture content used if a texture cannot loaded
  100616. * @ignorenaming
  100617. */
  100618. static fallbackTexture: string;
  100619. /**
  100620. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100621. * @param u defines the coordinate on X axis
  100622. * @param v defines the coordinate on Y axis
  100623. * @param width defines the width of the source data
  100624. * @param height defines the height of the source data
  100625. * @param pixels defines the source byte array
  100626. * @param color defines the output color
  100627. */
  100628. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100629. /**
  100630. * Interpolates between a and b via alpha
  100631. * @param a The lower value (returned when alpha = 0)
  100632. * @param b The upper value (returned when alpha = 1)
  100633. * @param alpha The interpolation-factor
  100634. * @return The mixed value
  100635. */
  100636. static Mix(a: number, b: number, alpha: number): number;
  100637. /**
  100638. * Tries to instantiate a new object from a given class name
  100639. * @param className defines the class name to instantiate
  100640. * @returns the new object or null if the system was not able to do the instantiation
  100641. */
  100642. static Instantiate(className: string): any;
  100643. /**
  100644. * Provides a slice function that will work even on IE
  100645. * @param data defines the array to slice
  100646. * @param start defines the start of the data (optional)
  100647. * @param end defines the end of the data (optional)
  100648. * @returns the new sliced array
  100649. */
  100650. static Slice<T>(data: T, start?: number, end?: number): T;
  100651. /**
  100652. * Polyfill for setImmediate
  100653. * @param action defines the action to execute after the current execution block
  100654. */
  100655. static SetImmediate(action: () => void): void;
  100656. /**
  100657. * Function indicating if a number is an exponent of 2
  100658. * @param value defines the value to test
  100659. * @returns true if the value is an exponent of 2
  100660. */
  100661. static IsExponentOfTwo(value: number): boolean;
  100662. private static _tmpFloatArray;
  100663. /**
  100664. * Returns the nearest 32-bit single precision float representation of a Number
  100665. * @param value A Number. If the parameter is of a different type, it will get converted
  100666. * to a number or to NaN if it cannot be converted
  100667. * @returns number
  100668. */
  100669. static FloatRound(value: number): number;
  100670. /**
  100671. * Extracts the filename from a path
  100672. * @param path defines the path to use
  100673. * @returns the filename
  100674. */
  100675. static GetFilename(path: string): string;
  100676. /**
  100677. * Extracts the "folder" part of a path (everything before the filename).
  100678. * @param uri The URI to extract the info from
  100679. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100680. * @returns The "folder" part of the path
  100681. */
  100682. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100683. /**
  100684. * Extracts text content from a DOM element hierarchy
  100685. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100686. */
  100687. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100688. /**
  100689. * Convert an angle in radians to degrees
  100690. * @param angle defines the angle to convert
  100691. * @returns the angle in degrees
  100692. */
  100693. static ToDegrees(angle: number): number;
  100694. /**
  100695. * Convert an angle in degrees to radians
  100696. * @param angle defines the angle to convert
  100697. * @returns the angle in radians
  100698. */
  100699. static ToRadians(angle: number): number;
  100700. /**
  100701. * Returns an array if obj is not an array
  100702. * @param obj defines the object to evaluate as an array
  100703. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100704. * @returns either obj directly if obj is an array or a new array containing obj
  100705. */
  100706. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100707. /**
  100708. * Gets the pointer prefix to use
  100709. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100710. */
  100711. static GetPointerPrefix(): string;
  100712. /**
  100713. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100714. * @param url define the url we are trying
  100715. * @param element define the dom element where to configure the cors policy
  100716. */
  100717. static SetCorsBehavior(url: string | string[], element: {
  100718. crossOrigin: string | null;
  100719. }): void;
  100720. /**
  100721. * Removes unwanted characters from an url
  100722. * @param url defines the url to clean
  100723. * @returns the cleaned url
  100724. */
  100725. static CleanUrl(url: string): string;
  100726. /**
  100727. * Gets or sets a function used to pre-process url before using them to load assets
  100728. */
  100729. static PreprocessUrl: (url: string) => string;
  100730. /**
  100731. * Loads an image as an HTMLImageElement.
  100732. * @param input url string, ArrayBuffer, or Blob to load
  100733. * @param onLoad callback called when the image successfully loads
  100734. * @param onError callback called when the image fails to load
  100735. * @param offlineProvider offline provider for caching
  100736. * @param mimeType optional mime type
  100737. * @returns the HTMLImageElement of the loaded image
  100738. */
  100739. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100740. /**
  100741. * Loads a file from a url
  100742. * @param url url string, ArrayBuffer, or Blob to load
  100743. * @param onSuccess callback called when the file successfully loads
  100744. * @param onProgress callback called while file is loading (if the server supports this mode)
  100745. * @param offlineProvider defines the offline provider for caching
  100746. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100747. * @param onError callback called when the file fails to load
  100748. * @returns a file request object
  100749. */
  100750. 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;
  100751. /**
  100752. * Loads a file from a url
  100753. * @param url the file url to load
  100754. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100755. */
  100756. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100757. /**
  100758. * Load a script (identified by an url). When the url returns, the
  100759. * content of this file is added into a new script element, attached to the DOM (body element)
  100760. * @param scriptUrl defines the url of the script to laod
  100761. * @param onSuccess defines the callback called when the script is loaded
  100762. * @param onError defines the callback to call if an error occurs
  100763. * @param scriptId defines the id of the script element
  100764. */
  100765. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100766. /**
  100767. * Load an asynchronous script (identified by an url). When the url returns, the
  100768. * content of this file is added into a new script element, attached to the DOM (body element)
  100769. * @param scriptUrl defines the url of the script to laod
  100770. * @param scriptId defines the id of the script element
  100771. * @returns a promise request object
  100772. */
  100773. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100774. /**
  100775. * Loads a file from a blob
  100776. * @param fileToLoad defines the blob to use
  100777. * @param callback defines the callback to call when data is loaded
  100778. * @param progressCallback defines the callback to call during loading process
  100779. * @returns a file request object
  100780. */
  100781. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100782. /**
  100783. * Reads a file from a File object
  100784. * @param file defines the file to load
  100785. * @param onSuccess defines the callback to call when data is loaded
  100786. * @param onProgress defines the callback to call during loading process
  100787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100788. * @param onError defines the callback to call when an error occurs
  100789. * @returns a file request object
  100790. */
  100791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100792. /**
  100793. * Creates a data url from a given string content
  100794. * @param content defines the content to convert
  100795. * @returns the new data url link
  100796. */
  100797. static FileAsURL(content: string): string;
  100798. /**
  100799. * Format the given number to a specific decimal format
  100800. * @param value defines the number to format
  100801. * @param decimals defines the number of decimals to use
  100802. * @returns the formatted string
  100803. */
  100804. static Format(value: number, decimals?: number): string;
  100805. /**
  100806. * Tries to copy an object by duplicating every property
  100807. * @param source defines the source object
  100808. * @param destination defines the target object
  100809. * @param doNotCopyList defines a list of properties to avoid
  100810. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100811. */
  100812. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100813. /**
  100814. * Gets a boolean indicating if the given object has no own property
  100815. * @param obj defines the object to test
  100816. * @returns true if object has no own property
  100817. */
  100818. static IsEmpty(obj: any): boolean;
  100819. /**
  100820. * Function used to register events at window level
  100821. * @param windowElement defines the Window object to use
  100822. * @param events defines the events to register
  100823. */
  100824. static RegisterTopRootEvents(windowElement: Window, events: {
  100825. name: string;
  100826. handler: Nullable<(e: FocusEvent) => any>;
  100827. }[]): void;
  100828. /**
  100829. * Function used to unregister events from window level
  100830. * @param windowElement defines the Window object to use
  100831. * @param events defines the events to unregister
  100832. */
  100833. static UnregisterTopRootEvents(windowElement: Window, events: {
  100834. name: string;
  100835. handler: Nullable<(e: FocusEvent) => any>;
  100836. }[]): void;
  100837. /**
  100838. * @ignore
  100839. */
  100840. static _ScreenshotCanvas: HTMLCanvasElement;
  100841. /**
  100842. * Dumps the current bound framebuffer
  100843. * @param width defines the rendering width
  100844. * @param height defines the rendering height
  100845. * @param engine defines the hosting engine
  100846. * @param successCallback defines the callback triggered once the data are available
  100847. * @param mimeType defines the mime type of the result
  100848. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100849. */
  100850. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100851. /**
  100852. * Converts the canvas data to blob.
  100853. * This acts as a polyfill for browsers not supporting the to blob function.
  100854. * @param canvas Defines the canvas to extract the data from
  100855. * @param successCallback Defines the callback triggered once the data are available
  100856. * @param mimeType Defines the mime type of the result
  100857. */
  100858. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100859. /**
  100860. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100861. * @param successCallback defines the callback triggered once the data are available
  100862. * @param mimeType defines the mime type of the result
  100863. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100864. */
  100865. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100866. /**
  100867. * Downloads a blob in the browser
  100868. * @param blob defines the blob to download
  100869. * @param fileName defines the name of the downloaded file
  100870. */
  100871. static Download(blob: Blob, fileName: string): void;
  100872. /**
  100873. * Captures a screenshot of the current rendering
  100874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100875. * @param engine defines the rendering engine
  100876. * @param camera defines the source camera
  100877. * @param size This parameter can be set to a single number or to an object with the
  100878. * following (optional) properties: precision, width, height. If a single number is passed,
  100879. * it will be used for both width and height. If an object is passed, the screenshot size
  100880. * will be derived from the parameters. The precision property is a multiplier allowing
  100881. * rendering at a higher or lower resolution
  100882. * @param successCallback defines the callback receives a single parameter which contains the
  100883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100884. * src parameter of an <img> to display it
  100885. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100886. * Check your browser for supported MIME types
  100887. */
  100888. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100889. /**
  100890. * Captures a screenshot of the current rendering
  100891. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100892. * @param engine defines the rendering engine
  100893. * @param camera defines the source camera
  100894. * @param size This parameter can be set to a single number or to an object with the
  100895. * following (optional) properties: precision, width, height. If a single number is passed,
  100896. * it will be used for both width and height. If an object is passed, the screenshot size
  100897. * will be derived from the parameters. The precision property is a multiplier allowing
  100898. * rendering at a higher or lower resolution
  100899. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100900. * Check your browser for supported MIME types
  100901. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100902. * to the src parameter of an <img> to display it
  100903. */
  100904. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100905. /**
  100906. * Generates an image screenshot from the specified camera.
  100907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100908. * @param engine The engine to use for rendering
  100909. * @param camera The camera to use for rendering
  100910. * @param size This parameter can be set to a single number or to an object with the
  100911. * following (optional) properties: precision, width, height. If a single number is passed,
  100912. * it will be used for both width and height. If an object is passed, the screenshot size
  100913. * will be derived from the parameters. The precision property is a multiplier allowing
  100914. * rendering at a higher or lower resolution
  100915. * @param successCallback The callback receives a single parameter which contains the
  100916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100917. * src parameter of an <img> to display it
  100918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100919. * Check your browser for supported MIME types
  100920. * @param samples Texture samples (default: 1)
  100921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100922. * @param fileName A name for for the downloaded file.
  100923. */
  100924. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100925. /**
  100926. * Generates an image screenshot from the specified camera.
  100927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100928. * @param engine The engine to use for rendering
  100929. * @param camera The camera to use for rendering
  100930. * @param size This parameter can be set to a single number or to an object with the
  100931. * following (optional) properties: precision, width, height. If a single number is passed,
  100932. * it will be used for both width and height. If an object is passed, the screenshot size
  100933. * will be derived from the parameters. The precision property is a multiplier allowing
  100934. * rendering at a higher or lower resolution
  100935. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100936. * Check your browser for supported MIME types
  100937. * @param samples Texture samples (default: 1)
  100938. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100939. * @param fileName A name for for the downloaded file.
  100940. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100941. * to the src parameter of an <img> to display it
  100942. */
  100943. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100944. /**
  100945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100946. * Be aware Math.random() could cause collisions, but:
  100947. * "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"
  100948. * @returns a pseudo random id
  100949. */
  100950. static RandomId(): string;
  100951. /**
  100952. * Test if the given uri is a base64 string
  100953. * @param uri The uri to test
  100954. * @return True if the uri is a base64 string or false otherwise
  100955. */
  100956. static IsBase64(uri: string): boolean;
  100957. /**
  100958. * Decode the given base64 uri.
  100959. * @param uri The uri to decode
  100960. * @return The decoded base64 data.
  100961. */
  100962. static DecodeBase64(uri: string): ArrayBuffer;
  100963. /**
  100964. * Gets the absolute url.
  100965. * @param url the input url
  100966. * @return the absolute url
  100967. */
  100968. static GetAbsoluteUrl(url: string): string;
  100969. /**
  100970. * No log
  100971. */
  100972. static readonly NoneLogLevel: number;
  100973. /**
  100974. * Only message logs
  100975. */
  100976. static readonly MessageLogLevel: number;
  100977. /**
  100978. * Only warning logs
  100979. */
  100980. static readonly WarningLogLevel: number;
  100981. /**
  100982. * Only error logs
  100983. */
  100984. static readonly ErrorLogLevel: number;
  100985. /**
  100986. * All logs
  100987. */
  100988. static readonly AllLogLevel: number;
  100989. /**
  100990. * Gets a value indicating the number of loading errors
  100991. * @ignorenaming
  100992. */
  100993. static readonly errorsCount: number;
  100994. /**
  100995. * Callback called when a new log is added
  100996. */
  100997. static OnNewCacheEntry: (entry: string) => void;
  100998. /**
  100999. * Log a message to the console
  101000. * @param message defines the message to log
  101001. */
  101002. static Log(message: string): void;
  101003. /**
  101004. * Write a warning message to the console
  101005. * @param message defines the message to log
  101006. */
  101007. static Warn(message: string): void;
  101008. /**
  101009. * Write an error message to the console
  101010. * @param message defines the message to log
  101011. */
  101012. static Error(message: string): void;
  101013. /**
  101014. * Gets current log cache (list of logs)
  101015. */
  101016. static readonly LogCache: string;
  101017. /**
  101018. * Clears the log cache
  101019. */
  101020. static ClearLogCache(): void;
  101021. /**
  101022. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101023. */
  101024. static LogLevels: number;
  101025. /**
  101026. * Checks if the window object exists
  101027. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101028. */
  101029. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  101030. /**
  101031. * No performance log
  101032. */
  101033. static readonly PerformanceNoneLogLevel: number;
  101034. /**
  101035. * Use user marks to log performance
  101036. */
  101037. static readonly PerformanceUserMarkLogLevel: number;
  101038. /**
  101039. * Log performance to the console
  101040. */
  101041. static readonly PerformanceConsoleLogLevel: number;
  101042. private static _performance;
  101043. /**
  101044. * Sets the current performance log level
  101045. */
  101046. static PerformanceLogLevel: number;
  101047. private static _StartPerformanceCounterDisabled;
  101048. private static _EndPerformanceCounterDisabled;
  101049. private static _StartUserMark;
  101050. private static _EndUserMark;
  101051. private static _StartPerformanceConsole;
  101052. private static _EndPerformanceConsole;
  101053. /**
  101054. * Starts a performance counter
  101055. */
  101056. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101057. /**
  101058. * Ends a specific performance coutner
  101059. */
  101060. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101061. /**
  101062. * Gets either window.performance.now() if supported or Date.now() else
  101063. */
  101064. static readonly Now: number;
  101065. /**
  101066. * This method will return the name of the class used to create the instance of the given object.
  101067. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101068. * @param object the object to get the class name from
  101069. * @param isType defines if the object is actually a type
  101070. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101071. */
  101072. static GetClassName(object: any, isType?: boolean): string;
  101073. /**
  101074. * Gets the first element of an array satisfying a given predicate
  101075. * @param array defines the array to browse
  101076. * @param predicate defines the predicate to use
  101077. * @returns null if not found or the element
  101078. */
  101079. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  101080. /**
  101081. * This method will return the name of the full name of the class, including its owning module (if any).
  101082. * 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).
  101083. * @param object the object to get the class name from
  101084. * @param isType defines if the object is actually a type
  101085. * @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.
  101086. * @ignorenaming
  101087. */
  101088. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  101089. /**
  101090. * Returns a promise that resolves after the given amount of time.
  101091. * @param delay Number of milliseconds to delay
  101092. * @returns Promise that resolves after the given amount of time
  101093. */
  101094. static DelayAsync(delay: number): Promise<void>;
  101095. }
  101096. /**
  101097. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101098. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101099. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101100. * @param name The name of the class, case should be preserved
  101101. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101102. */
  101103. export function className(name: string, module?: string): (target: Object) => void;
  101104. /**
  101105. * An implementation of a loop for asynchronous functions.
  101106. */
  101107. export class AsyncLoop {
  101108. /**
  101109. * Defines the number of iterations for the loop
  101110. */
  101111. iterations: number;
  101112. /**
  101113. * Defines the current index of the loop.
  101114. */
  101115. index: number;
  101116. private _done;
  101117. private _fn;
  101118. private _successCallback;
  101119. /**
  101120. * Constructor.
  101121. * @param iterations the number of iterations.
  101122. * @param func the function to run each iteration
  101123. * @param successCallback the callback that will be called upon succesful execution
  101124. * @param offset starting offset.
  101125. */
  101126. constructor(
  101127. /**
  101128. * Defines the number of iterations for the loop
  101129. */
  101130. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101131. /**
  101132. * Execute the next iteration. Must be called after the last iteration was finished.
  101133. */
  101134. executeNext(): void;
  101135. /**
  101136. * Break the loop and run the success callback.
  101137. */
  101138. breakLoop(): void;
  101139. /**
  101140. * Create and run an async loop.
  101141. * @param iterations the number of iterations.
  101142. * @param fn the function to run each iteration
  101143. * @param successCallback the callback that will be called upon succesful execution
  101144. * @param offset starting offset.
  101145. * @returns the created async loop object
  101146. */
  101147. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101148. /**
  101149. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101150. * @param iterations total number of iterations
  101151. * @param syncedIterations number of synchronous iterations in each async iteration.
  101152. * @param fn the function to call each iteration.
  101153. * @param callback a success call back that will be called when iterating stops.
  101154. * @param breakFunction a break condition (optional)
  101155. * @param timeout timeout settings for the setTimeout function. default - 0.
  101156. * @returns the created async loop object
  101157. */
  101158. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101159. }
  101160. }
  101161. declare module BABYLON {
  101162. /**
  101163. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101164. * The underlying implementation relies on an associative array to ensure the best performances.
  101165. * The value can be anything including 'null' but except 'undefined'
  101166. */
  101167. export class StringDictionary<T> {
  101168. /**
  101169. * This will clear this dictionary and copy the content from the 'source' one.
  101170. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101171. * @param source the dictionary to take the content from and copy to this dictionary
  101172. */
  101173. copyFrom(source: StringDictionary<T>): void;
  101174. /**
  101175. * Get a value based from its key
  101176. * @param key the given key to get the matching value from
  101177. * @return the value if found, otherwise undefined is returned
  101178. */
  101179. get(key: string): T | undefined;
  101180. /**
  101181. * Get a value from its key or add it if it doesn't exist.
  101182. * This method will ensure you that a given key/data will be present in the dictionary.
  101183. * @param key the given key to get the matching value from
  101184. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101185. * The factory will only be invoked if there's no data for the given key.
  101186. * @return the value corresponding to the key.
  101187. */
  101188. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101189. /**
  101190. * Get a value from its key if present in the dictionary otherwise add it
  101191. * @param key the key to get the value from
  101192. * @param val if there's no such key/value pair in the dictionary add it with this value
  101193. * @return the value corresponding to the key
  101194. */
  101195. getOrAdd(key: string, val: T): T;
  101196. /**
  101197. * Check if there's a given key in the dictionary
  101198. * @param key the key to check for
  101199. * @return true if the key is present, false otherwise
  101200. */
  101201. contains(key: string): boolean;
  101202. /**
  101203. * Add a new key and its corresponding value
  101204. * @param key the key to add
  101205. * @param value the value corresponding to the key
  101206. * @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
  101207. */
  101208. add(key: string, value: T): boolean;
  101209. /**
  101210. * Update a specific value associated to a key
  101211. * @param key defines the key to use
  101212. * @param value defines the value to store
  101213. * @returns true if the value was updated (or false if the key was not found)
  101214. */
  101215. set(key: string, value: T): boolean;
  101216. /**
  101217. * Get the element of the given key and remove it from the dictionary
  101218. * @param key defines the key to search
  101219. * @returns the value associated with the key or null if not found
  101220. */
  101221. getAndRemove(key: string): Nullable<T>;
  101222. /**
  101223. * Remove a key/value from the dictionary.
  101224. * @param key the key to remove
  101225. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101226. */
  101227. remove(key: string): boolean;
  101228. /**
  101229. * Clear the whole content of the dictionary
  101230. */
  101231. clear(): void;
  101232. /**
  101233. * Gets the current count
  101234. */
  101235. readonly count: number;
  101236. /**
  101237. * Execute a callback on each key/val of the dictionary.
  101238. * Note that you can remove any element in this dictionary in the callback implementation
  101239. * @param callback the callback to execute on a given key/value pair
  101240. */
  101241. forEach(callback: (key: string, val: T) => void): void;
  101242. /**
  101243. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101244. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101245. * Note that you can remove any element in this dictionary in the callback implementation
  101246. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101247. * @returns the first item
  101248. */
  101249. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101250. private _count;
  101251. private _data;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /** @hidden */
  101256. export interface ICollisionCoordinator {
  101257. createCollider(): Collider;
  101258. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101259. init(scene: Scene): void;
  101260. }
  101261. /** @hidden */
  101262. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101263. private _scene;
  101264. private _scaledPosition;
  101265. private _scaledVelocity;
  101266. private _finalPosition;
  101267. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101268. createCollider(): Collider;
  101269. init(scene: Scene): void;
  101270. private _collideWithWorld;
  101271. }
  101272. }
  101273. declare module BABYLON {
  101274. /**
  101275. * Class used to manage all inputs for the scene.
  101276. */
  101277. export class InputManager {
  101278. /** The distance in pixel that you have to move to prevent some events */
  101279. static DragMovementThreshold: number;
  101280. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101281. static LongPressDelay: number;
  101282. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101283. static DoubleClickDelay: number;
  101284. /** If you need to check double click without raising a single click at first click, enable this flag */
  101285. static ExclusiveDoubleClickMode: boolean;
  101286. private _wheelEventName;
  101287. private _onPointerMove;
  101288. private _onPointerDown;
  101289. private _onPointerUp;
  101290. private _initClickEvent;
  101291. private _initActionManager;
  101292. private _delayedSimpleClick;
  101293. private _delayedSimpleClickTimeout;
  101294. private _previousDelayedSimpleClickTimeout;
  101295. private _meshPickProceed;
  101296. private _previousButtonPressed;
  101297. private _currentPickResult;
  101298. private _previousPickResult;
  101299. private _totalPointersPressed;
  101300. private _doubleClickOccured;
  101301. private _pointerOverMesh;
  101302. private _pickedDownMesh;
  101303. private _pickedUpMesh;
  101304. private _pointerX;
  101305. private _pointerY;
  101306. private _unTranslatedPointerX;
  101307. private _unTranslatedPointerY;
  101308. private _startingPointerPosition;
  101309. private _previousStartingPointerPosition;
  101310. private _startingPointerTime;
  101311. private _previousStartingPointerTime;
  101312. private _pointerCaptures;
  101313. private _onKeyDown;
  101314. private _onKeyUp;
  101315. private _onCanvasFocusObserver;
  101316. private _onCanvasBlurObserver;
  101317. private _scene;
  101318. /**
  101319. * Creates a new InputManager
  101320. * @param scene defines the hosting scene
  101321. */
  101322. constructor(scene: Scene);
  101323. /**
  101324. * Gets the mesh that is currently under the pointer
  101325. */
  101326. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101327. /**
  101328. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101329. */
  101330. readonly unTranslatedPointer: Vector2;
  101331. /**
  101332. * Gets or sets the current on-screen X position of the pointer
  101333. */
  101334. pointerX: number;
  101335. /**
  101336. * Gets or sets the current on-screen Y position of the pointer
  101337. */
  101338. pointerY: number;
  101339. private _updatePointerPosition;
  101340. private _processPointerMove;
  101341. private _setRayOnPointerInfo;
  101342. private _checkPrePointerObservable;
  101343. /**
  101344. * Use this method to simulate a pointer move on a mesh
  101345. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101346. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101347. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101348. */
  101349. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101350. /**
  101351. * Use this method to simulate a pointer down on a mesh
  101352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101355. */
  101356. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101357. private _processPointerDown;
  101358. /** @hidden */
  101359. _isPointerSwiping(): boolean;
  101360. /**
  101361. * Use this method to simulate a pointer up on a mesh
  101362. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101363. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101364. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101365. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101366. */
  101367. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101368. private _processPointerUp;
  101369. /**
  101370. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101371. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101372. * @returns true if the pointer was captured
  101373. */
  101374. isPointerCaptured(pointerId?: number): boolean;
  101375. /**
  101376. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101377. * @param attachUp defines if you want to attach events to pointerup
  101378. * @param attachDown defines if you want to attach events to pointerdown
  101379. * @param attachMove defines if you want to attach events to pointermove
  101380. */
  101381. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101382. /**
  101383. * Detaches all event handlers
  101384. */
  101385. detachControl(): void;
  101386. /**
  101387. * Force the value of meshUnderPointer
  101388. * @param mesh defines the mesh to use
  101389. */
  101390. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101391. /**
  101392. * Gets the mesh under the pointer
  101393. * @returns a Mesh or null if no mesh is under the pointer
  101394. */
  101395. getPointerOverMesh(): Nullable<AbstractMesh>;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * Helper class used to generate session unique ID
  101401. */
  101402. export class UniqueIdGenerator {
  101403. private static _UniqueIdCounter;
  101404. /**
  101405. * Gets an unique (relatively to the current scene) Id
  101406. */
  101407. static readonly UniqueId: number;
  101408. }
  101409. }
  101410. declare module BABYLON {
  101411. /**
  101412. * This class defines the direct association between an animation and a target
  101413. */
  101414. export class TargetedAnimation {
  101415. /**
  101416. * Animation to perform
  101417. */
  101418. animation: Animation;
  101419. /**
  101420. * Target to animate
  101421. */
  101422. target: any;
  101423. /**
  101424. * Serialize the object
  101425. * @returns the JSON object representing the current entity
  101426. */
  101427. serialize(): any;
  101428. }
  101429. /**
  101430. * Use this class to create coordinated animations on multiple targets
  101431. */
  101432. export class AnimationGroup implements IDisposable {
  101433. /** The name of the animation group */
  101434. name: string;
  101435. private _scene;
  101436. private _targetedAnimations;
  101437. private _animatables;
  101438. private _from;
  101439. private _to;
  101440. private _isStarted;
  101441. private _isPaused;
  101442. private _speedRatio;
  101443. private _loopAnimation;
  101444. /**
  101445. * Gets or sets the unique id of the node
  101446. */
  101447. uniqueId: number;
  101448. /**
  101449. * This observable will notify when one animation have ended
  101450. */
  101451. onAnimationEndObservable: Observable<TargetedAnimation>;
  101452. /**
  101453. * Observer raised when one animation loops
  101454. */
  101455. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101456. /**
  101457. * Observer raised when all animations have looped
  101458. */
  101459. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101460. /**
  101461. * This observable will notify when all animations have ended.
  101462. */
  101463. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101464. /**
  101465. * This observable will notify when all animations have paused.
  101466. */
  101467. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101468. /**
  101469. * This observable will notify when all animations are playing.
  101470. */
  101471. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101472. /**
  101473. * Gets the first frame
  101474. */
  101475. readonly from: number;
  101476. /**
  101477. * Gets the last frame
  101478. */
  101479. readonly to: number;
  101480. /**
  101481. * Define if the animations are started
  101482. */
  101483. readonly isStarted: boolean;
  101484. /**
  101485. * Gets a value indicating that the current group is playing
  101486. */
  101487. readonly isPlaying: boolean;
  101488. /**
  101489. * Gets or sets the speed ratio to use for all animations
  101490. */
  101491. /**
  101492. * Gets or sets the speed ratio to use for all animations
  101493. */
  101494. speedRatio: number;
  101495. /**
  101496. * Gets or sets if all animations should loop or not
  101497. */
  101498. loopAnimation: boolean;
  101499. /**
  101500. * Gets the targeted animations for this animation group
  101501. */
  101502. readonly targetedAnimations: Array<TargetedAnimation>;
  101503. /**
  101504. * returning the list of animatables controlled by this animation group.
  101505. */
  101506. readonly animatables: Array<Animatable>;
  101507. /**
  101508. * Instantiates a new Animation Group.
  101509. * This helps managing several animations at once.
  101510. * @see http://doc.babylonjs.com/how_to/group
  101511. * @param name Defines the name of the group
  101512. * @param scene Defines the scene the group belongs to
  101513. */
  101514. constructor(
  101515. /** The name of the animation group */
  101516. name: string, scene?: Nullable<Scene>);
  101517. /**
  101518. * Add an animation (with its target) in the group
  101519. * @param animation defines the animation we want to add
  101520. * @param target defines the target of the animation
  101521. * @returns the TargetedAnimation object
  101522. */
  101523. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101524. /**
  101525. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101526. * It can add constant keys at begin or end
  101527. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101528. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101529. * @returns the animation group
  101530. */
  101531. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101532. private _animationLoopCount;
  101533. private _animationLoopFlags;
  101534. private _processLoop;
  101535. /**
  101536. * Start all animations on given targets
  101537. * @param loop defines if animations must loop
  101538. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101539. * @param from defines the from key (optional)
  101540. * @param to defines the to key (optional)
  101541. * @returns the current animation group
  101542. */
  101543. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101544. /**
  101545. * Pause all animations
  101546. * @returns the animation group
  101547. */
  101548. pause(): AnimationGroup;
  101549. /**
  101550. * Play all animations to initial state
  101551. * This function will start() the animations if they were not started or will restart() them if they were paused
  101552. * @param loop defines if animations must loop
  101553. * @returns the animation group
  101554. */
  101555. play(loop?: boolean): AnimationGroup;
  101556. /**
  101557. * Reset all animations to initial state
  101558. * @returns the animation group
  101559. */
  101560. reset(): AnimationGroup;
  101561. /**
  101562. * Restart animations from key 0
  101563. * @returns the animation group
  101564. */
  101565. restart(): AnimationGroup;
  101566. /**
  101567. * Stop all animations
  101568. * @returns the animation group
  101569. */
  101570. stop(): AnimationGroup;
  101571. /**
  101572. * Set animation weight for all animatables
  101573. * @param weight defines the weight to use
  101574. * @return the animationGroup
  101575. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101576. */
  101577. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101578. /**
  101579. * Synchronize and normalize all animatables with a source animatable
  101580. * @param root defines the root animatable to synchronize with
  101581. * @return the animationGroup
  101582. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101583. */
  101584. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101585. /**
  101586. * Goes to a specific frame in this animation group
  101587. * @param frame the frame number to go to
  101588. * @return the animationGroup
  101589. */
  101590. goToFrame(frame: number): AnimationGroup;
  101591. /**
  101592. * Dispose all associated resources
  101593. */
  101594. dispose(): void;
  101595. private _checkAnimationGroupEnded;
  101596. /**
  101597. * Clone the current animation group and returns a copy
  101598. * @param newName defines the name of the new group
  101599. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101600. * @returns the new aniamtion group
  101601. */
  101602. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101603. /**
  101604. * Serializes the animationGroup to an object
  101605. * @returns Serialized object
  101606. */
  101607. serialize(): any;
  101608. /**
  101609. * Returns a new AnimationGroup object parsed from the source provided.
  101610. * @param parsedAnimationGroup defines the source
  101611. * @param scene defines the scene that will receive the animationGroup
  101612. * @returns a new AnimationGroup
  101613. */
  101614. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101615. /**
  101616. * Returns the string "AnimationGroup"
  101617. * @returns "AnimationGroup"
  101618. */
  101619. getClassName(): string;
  101620. /**
  101621. * Creates a detailled string about the object
  101622. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101623. * @returns a string representing the object
  101624. */
  101625. toString(fullDetails?: boolean): string;
  101626. }
  101627. }
  101628. declare module BABYLON {
  101629. /**
  101630. * Define an interface for all classes that will hold resources
  101631. */
  101632. export interface IDisposable {
  101633. /**
  101634. * Releases all held resources
  101635. */
  101636. dispose(): void;
  101637. }
  101638. /** Interface defining initialization parameters for Scene class */
  101639. export interface SceneOptions {
  101640. /**
  101641. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101642. * It will improve performance when the number of geometries becomes important.
  101643. */
  101644. useGeometryUniqueIdsMap?: boolean;
  101645. /**
  101646. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101647. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101648. */
  101649. useMaterialMeshMap?: boolean;
  101650. /**
  101651. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101652. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101653. */
  101654. useClonedMeshhMap?: boolean;
  101655. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101656. virtual?: boolean;
  101657. }
  101658. /**
  101659. * Represents a scene to be rendered by the engine.
  101660. * @see http://doc.babylonjs.com/features/scene
  101661. */
  101662. export class Scene extends AbstractScene implements IAnimatable {
  101663. /** The fog is deactivated */
  101664. static readonly FOGMODE_NONE: number;
  101665. /** The fog density is following an exponential function */
  101666. static readonly FOGMODE_EXP: number;
  101667. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101668. static readonly FOGMODE_EXP2: number;
  101669. /** The fog density is following a linear function. */
  101670. static readonly FOGMODE_LINEAR: number;
  101671. /**
  101672. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101673. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101674. */
  101675. static MinDeltaTime: number;
  101676. /**
  101677. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101679. */
  101680. static MaxDeltaTime: number;
  101681. /**
  101682. * Factory used to create the default material.
  101683. * @param name The name of the material to create
  101684. * @param scene The scene to create the material for
  101685. * @returns The default material
  101686. */
  101687. static DefaultMaterialFactory(scene: Scene): Material;
  101688. /**
  101689. * Factory used to create the a collision coordinator.
  101690. * @returns The collision coordinator
  101691. */
  101692. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101693. /** @hidden */
  101694. _inputManager: InputManager;
  101695. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101696. cameraToUseForPointers: Nullable<Camera>;
  101697. /** @hidden */
  101698. readonly _isScene: boolean;
  101699. /**
  101700. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101701. */
  101702. autoClear: boolean;
  101703. /**
  101704. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101705. */
  101706. autoClearDepthAndStencil: boolean;
  101707. /**
  101708. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101709. */
  101710. clearColor: Color4;
  101711. /**
  101712. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101713. */
  101714. ambientColor: Color3;
  101715. /**
  101716. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101717. * It should only be one of the following (if not the default embedded one):
  101718. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101719. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101720. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101721. * The material properties need to be setup according to the type of texture in use.
  101722. */
  101723. environmentBRDFTexture: BaseTexture;
  101724. /** @hidden */
  101725. protected _environmentTexture: Nullable<BaseTexture>;
  101726. /**
  101727. * Texture used in all pbr material as the reflection texture.
  101728. * As in the majority of the scene they are the same (exception for multi room and so on),
  101729. * this is easier to reference from here than from all the materials.
  101730. */
  101731. /**
  101732. * Texture used in all pbr material as the reflection texture.
  101733. * As in the majority of the scene they are the same (exception for multi room and so on),
  101734. * this is easier to set here than in all the materials.
  101735. */
  101736. environmentTexture: Nullable<BaseTexture>;
  101737. /** @hidden */
  101738. protected _environmentIntensity: number;
  101739. /**
  101740. * Intensity of the environment in all pbr material.
  101741. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101742. * As in the majority of the scene they are the same (exception for multi room and so on),
  101743. * this is easier to reference from here than from all the materials.
  101744. */
  101745. /**
  101746. * Intensity of the environment in all pbr material.
  101747. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101748. * As in the majority of the scene they are the same (exception for multi room and so on),
  101749. * this is easier to set here than in all the materials.
  101750. */
  101751. environmentIntensity: number;
  101752. /** @hidden */
  101753. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101754. /**
  101755. * Default image processing configuration used either in the rendering
  101756. * Forward main pass or through the imageProcessingPostProcess if present.
  101757. * As in the majority of the scene they are the same (exception for multi camera),
  101758. * this is easier to reference from here than from all the materials and post process.
  101759. *
  101760. * No setter as we it is a shared configuration, you can set the values instead.
  101761. */
  101762. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101763. private _forceWireframe;
  101764. /**
  101765. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101766. */
  101767. forceWireframe: boolean;
  101768. private _forcePointsCloud;
  101769. /**
  101770. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101771. */
  101772. forcePointsCloud: boolean;
  101773. /**
  101774. * Gets or sets the active clipplane 1
  101775. */
  101776. clipPlane: Nullable<Plane>;
  101777. /**
  101778. * Gets or sets the active clipplane 2
  101779. */
  101780. clipPlane2: Nullable<Plane>;
  101781. /**
  101782. * Gets or sets the active clipplane 3
  101783. */
  101784. clipPlane3: Nullable<Plane>;
  101785. /**
  101786. * Gets or sets the active clipplane 4
  101787. */
  101788. clipPlane4: Nullable<Plane>;
  101789. /**
  101790. * Gets or sets a boolean indicating if animations are enabled
  101791. */
  101792. animationsEnabled: boolean;
  101793. private _animationPropertiesOverride;
  101794. /**
  101795. * Gets or sets the animation properties override
  101796. */
  101797. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101798. /**
  101799. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101800. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101801. */
  101802. useConstantAnimationDeltaTime: boolean;
  101803. /**
  101804. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101805. * Please note that it requires to run a ray cast through the scene on every frame
  101806. */
  101807. constantlyUpdateMeshUnderPointer: boolean;
  101808. /**
  101809. * Defines the HTML cursor to use when hovering over interactive elements
  101810. */
  101811. hoverCursor: string;
  101812. /**
  101813. * Defines the HTML default cursor to use (empty by default)
  101814. */
  101815. defaultCursor: string;
  101816. /**
  101817. * Defines wether cursors are handled by the scene.
  101818. */
  101819. doNotHandleCursors: boolean;
  101820. /**
  101821. * This is used to call preventDefault() on pointer down
  101822. * in order to block unwanted artifacts like system double clicks
  101823. */
  101824. preventDefaultOnPointerDown: boolean;
  101825. /**
  101826. * This is used to call preventDefault() on pointer up
  101827. * in order to block unwanted artifacts like system double clicks
  101828. */
  101829. preventDefaultOnPointerUp: boolean;
  101830. /**
  101831. * Gets or sets user defined metadata
  101832. */
  101833. metadata: any;
  101834. /**
  101835. * For internal use only. Please do not use.
  101836. */
  101837. reservedDataStore: any;
  101838. /**
  101839. * Gets the name of the plugin used to load this scene (null by default)
  101840. */
  101841. loadingPluginName: string;
  101842. /**
  101843. * Use this array to add regular expressions used to disable offline support for specific urls
  101844. */
  101845. disableOfflineSupportExceptionRules: RegExp[];
  101846. /**
  101847. * An event triggered when the scene is disposed.
  101848. */
  101849. onDisposeObservable: Observable<Scene>;
  101850. private _onDisposeObserver;
  101851. /** Sets a function to be executed when this scene is disposed. */
  101852. onDispose: () => void;
  101853. /**
  101854. * An event triggered before rendering the scene (right after animations and physics)
  101855. */
  101856. onBeforeRenderObservable: Observable<Scene>;
  101857. private _onBeforeRenderObserver;
  101858. /** Sets a function to be executed before rendering this scene */
  101859. beforeRender: Nullable<() => void>;
  101860. /**
  101861. * An event triggered after rendering the scene
  101862. */
  101863. onAfterRenderObservable: Observable<Scene>;
  101864. /**
  101865. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101866. */
  101867. onAfterRenderCameraObservable: Observable<Camera>;
  101868. private _onAfterRenderObserver;
  101869. /** Sets a function to be executed after rendering this scene */
  101870. afterRender: Nullable<() => void>;
  101871. /**
  101872. * An event triggered before animating the scene
  101873. */
  101874. onBeforeAnimationsObservable: Observable<Scene>;
  101875. /**
  101876. * An event triggered after animations processing
  101877. */
  101878. onAfterAnimationsObservable: Observable<Scene>;
  101879. /**
  101880. * An event triggered before draw calls are ready to be sent
  101881. */
  101882. onBeforeDrawPhaseObservable: Observable<Scene>;
  101883. /**
  101884. * An event triggered after draw calls have been sent
  101885. */
  101886. onAfterDrawPhaseObservable: Observable<Scene>;
  101887. /**
  101888. * An event triggered when the scene is ready
  101889. */
  101890. onReadyObservable: Observable<Scene>;
  101891. /**
  101892. * An event triggered before rendering a camera
  101893. */
  101894. onBeforeCameraRenderObservable: Observable<Camera>;
  101895. private _onBeforeCameraRenderObserver;
  101896. /** Sets a function to be executed before rendering a camera*/
  101897. beforeCameraRender: () => void;
  101898. /**
  101899. * An event triggered after rendering a camera
  101900. */
  101901. onAfterCameraRenderObservable: Observable<Camera>;
  101902. private _onAfterCameraRenderObserver;
  101903. /** Sets a function to be executed after rendering a camera*/
  101904. afterCameraRender: () => void;
  101905. /**
  101906. * An event triggered when active meshes evaluation is about to start
  101907. */
  101908. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101909. /**
  101910. * An event triggered when active meshes evaluation is done
  101911. */
  101912. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101913. /**
  101914. * An event triggered when particles rendering is about to start
  101915. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101916. */
  101917. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101918. /**
  101919. * An event triggered when particles rendering is done
  101920. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101921. */
  101922. onAfterParticlesRenderingObservable: Observable<Scene>;
  101923. /**
  101924. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101925. */
  101926. onDataLoadedObservable: Observable<Scene>;
  101927. /**
  101928. * An event triggered when a camera is created
  101929. */
  101930. onNewCameraAddedObservable: Observable<Camera>;
  101931. /**
  101932. * An event triggered when a camera is removed
  101933. */
  101934. onCameraRemovedObservable: Observable<Camera>;
  101935. /**
  101936. * An event triggered when a light is created
  101937. */
  101938. onNewLightAddedObservable: Observable<Light>;
  101939. /**
  101940. * An event triggered when a light is removed
  101941. */
  101942. onLightRemovedObservable: Observable<Light>;
  101943. /**
  101944. * An event triggered when a geometry is created
  101945. */
  101946. onNewGeometryAddedObservable: Observable<Geometry>;
  101947. /**
  101948. * An event triggered when a geometry is removed
  101949. */
  101950. onGeometryRemovedObservable: Observable<Geometry>;
  101951. /**
  101952. * An event triggered when a transform node is created
  101953. */
  101954. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101955. /**
  101956. * An event triggered when a transform node is removed
  101957. */
  101958. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101959. /**
  101960. * An event triggered when a mesh is created
  101961. */
  101962. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101963. /**
  101964. * An event triggered when a mesh is removed
  101965. */
  101966. onMeshRemovedObservable: Observable<AbstractMesh>;
  101967. /**
  101968. * An event triggered when a skeleton is created
  101969. */
  101970. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101971. /**
  101972. * An event triggered when a skeleton is removed
  101973. */
  101974. onSkeletonRemovedObservable: Observable<Skeleton>;
  101975. /**
  101976. * An event triggered when a material is created
  101977. */
  101978. onNewMaterialAddedObservable: Observable<Material>;
  101979. /**
  101980. * An event triggered when a material is removed
  101981. */
  101982. onMaterialRemovedObservable: Observable<Material>;
  101983. /**
  101984. * An event triggered when a texture is created
  101985. */
  101986. onNewTextureAddedObservable: Observable<BaseTexture>;
  101987. /**
  101988. * An event triggered when a texture is removed
  101989. */
  101990. onTextureRemovedObservable: Observable<BaseTexture>;
  101991. /**
  101992. * An event triggered when render targets are about to be rendered
  101993. * Can happen multiple times per frame.
  101994. */
  101995. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101996. /**
  101997. * An event triggered when render targets were rendered.
  101998. * Can happen multiple times per frame.
  101999. */
  102000. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  102001. /**
  102002. * An event triggered before calculating deterministic simulation step
  102003. */
  102004. onBeforeStepObservable: Observable<Scene>;
  102005. /**
  102006. * An event triggered after calculating deterministic simulation step
  102007. */
  102008. onAfterStepObservable: Observable<Scene>;
  102009. /**
  102010. * An event triggered when the activeCamera property is updated
  102011. */
  102012. onActiveCameraChanged: Observable<Scene>;
  102013. /**
  102014. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  102015. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102016. * 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)
  102017. */
  102018. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102019. /**
  102020. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  102021. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102022. * 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)
  102023. */
  102024. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102025. /**
  102026. * This Observable will when a mesh has been imported into the scene.
  102027. */
  102028. onMeshImportedObservable: Observable<AbstractMesh>;
  102029. /**
  102030. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  102031. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  102032. */
  102033. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  102034. /** @hidden */
  102035. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  102036. /**
  102037. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  102038. */
  102039. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  102040. /**
  102041. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  102042. */
  102043. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  102044. /**
  102045. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  102046. */
  102047. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  102048. /** Callback called when a pointer move is detected */
  102049. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102050. /** Callback called when a pointer down is detected */
  102051. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102052. /** Callback called when a pointer up is detected */
  102053. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  102054. /** Callback called when a pointer pick is detected */
  102055. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  102056. /**
  102057. * 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).
  102058. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  102059. */
  102060. onPrePointerObservable: Observable<PointerInfoPre>;
  102061. /**
  102062. * Observable event triggered each time an input event is received from the rendering canvas
  102063. */
  102064. onPointerObservable: Observable<PointerInfo>;
  102065. /**
  102066. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  102067. */
  102068. readonly unTranslatedPointer: Vector2;
  102069. /**
  102070. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  102071. */
  102072. static DragMovementThreshold: number;
  102073. /**
  102074. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  102075. */
  102076. static LongPressDelay: number;
  102077. /**
  102078. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  102079. */
  102080. static DoubleClickDelay: number;
  102081. /** If you need to check double click without raising a single click at first click, enable this flag */
  102082. static ExclusiveDoubleClickMode: boolean;
  102083. /** @hidden */
  102084. _mirroredCameraPosition: Nullable<Vector3>;
  102085. /**
  102086. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  102087. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  102088. */
  102089. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102090. /**
  102091. * Observable event triggered each time an keyboard event is received from the hosting window
  102092. */
  102093. onKeyboardObservable: Observable<KeyboardInfo>;
  102094. private _useRightHandedSystem;
  102095. /**
  102096. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102097. */
  102098. useRightHandedSystem: boolean;
  102099. private _timeAccumulator;
  102100. private _currentStepId;
  102101. private _currentInternalStep;
  102102. /**
  102103. * Sets the step Id used by deterministic lock step
  102104. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102105. * @param newStepId defines the step Id
  102106. */
  102107. setStepId(newStepId: number): void;
  102108. /**
  102109. * Gets the step Id used by deterministic lock step
  102110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102111. * @returns the step Id
  102112. */
  102113. getStepId(): number;
  102114. /**
  102115. * Gets the internal step used by deterministic lock step
  102116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102117. * @returns the internal step
  102118. */
  102119. getInternalStep(): number;
  102120. private _fogEnabled;
  102121. /**
  102122. * Gets or sets a boolean indicating if fog is enabled on this scene
  102123. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102124. * (Default is true)
  102125. */
  102126. fogEnabled: boolean;
  102127. private _fogMode;
  102128. /**
  102129. * Gets or sets the fog mode to use
  102130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102131. * | mode | value |
  102132. * | --- | --- |
  102133. * | FOGMODE_NONE | 0 |
  102134. * | FOGMODE_EXP | 1 |
  102135. * | FOGMODE_EXP2 | 2 |
  102136. * | FOGMODE_LINEAR | 3 |
  102137. */
  102138. fogMode: number;
  102139. /**
  102140. * Gets or sets the fog color to use
  102141. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102142. * (Default is Color3(0.2, 0.2, 0.3))
  102143. */
  102144. fogColor: Color3;
  102145. /**
  102146. * Gets or sets the fog density to use
  102147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102148. * (Default is 0.1)
  102149. */
  102150. fogDensity: number;
  102151. /**
  102152. * Gets or sets the fog start distance to use
  102153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102154. * (Default is 0)
  102155. */
  102156. fogStart: number;
  102157. /**
  102158. * Gets or sets the fog end distance to use
  102159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102160. * (Default is 1000)
  102161. */
  102162. fogEnd: number;
  102163. private _shadowsEnabled;
  102164. /**
  102165. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102166. */
  102167. shadowsEnabled: boolean;
  102168. private _lightsEnabled;
  102169. /**
  102170. * Gets or sets a boolean indicating if lights are enabled on this scene
  102171. */
  102172. lightsEnabled: boolean;
  102173. /** All of the active cameras added to this scene. */
  102174. activeCameras: Camera[];
  102175. /** @hidden */
  102176. _activeCamera: Nullable<Camera>;
  102177. /** Gets or sets the current active camera */
  102178. activeCamera: Nullable<Camera>;
  102179. private _defaultMaterial;
  102180. /** The default material used on meshes when no material is affected */
  102181. /** The default material used on meshes when no material is affected */
  102182. defaultMaterial: Material;
  102183. private _texturesEnabled;
  102184. /**
  102185. * Gets or sets a boolean indicating if textures are enabled on this scene
  102186. */
  102187. texturesEnabled: boolean;
  102188. /**
  102189. * Gets or sets a boolean indicating if particles are enabled on this scene
  102190. */
  102191. particlesEnabled: boolean;
  102192. /**
  102193. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102194. */
  102195. spritesEnabled: boolean;
  102196. private _skeletonsEnabled;
  102197. /**
  102198. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102199. */
  102200. skeletonsEnabled: boolean;
  102201. /**
  102202. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102203. */
  102204. lensFlaresEnabled: boolean;
  102205. /**
  102206. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102208. */
  102209. collisionsEnabled: boolean;
  102210. private _collisionCoordinator;
  102211. /** @hidden */
  102212. readonly collisionCoordinator: ICollisionCoordinator;
  102213. /**
  102214. * Defines the gravity applied to this scene (used only for collisions)
  102215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102216. */
  102217. gravity: Vector3;
  102218. /**
  102219. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102220. */
  102221. postProcessesEnabled: boolean;
  102222. /**
  102223. * The list of postprocesses added to the scene
  102224. */
  102225. postProcesses: PostProcess[];
  102226. /**
  102227. * Gets the current postprocess manager
  102228. */
  102229. postProcessManager: PostProcessManager;
  102230. /**
  102231. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102232. */
  102233. renderTargetsEnabled: boolean;
  102234. /**
  102235. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102236. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102237. */
  102238. dumpNextRenderTargets: boolean;
  102239. /**
  102240. * The list of user defined render targets added to the scene
  102241. */
  102242. customRenderTargets: RenderTargetTexture[];
  102243. /**
  102244. * Defines if texture loading must be delayed
  102245. * If true, textures will only be loaded when they need to be rendered
  102246. */
  102247. useDelayedTextureLoading: boolean;
  102248. /**
  102249. * Gets the list of meshes imported to the scene through SceneLoader
  102250. */
  102251. importedMeshesFiles: String[];
  102252. /**
  102253. * Gets or sets a boolean indicating if probes are enabled on this scene
  102254. */
  102255. probesEnabled: boolean;
  102256. /**
  102257. * Gets or sets the current offline provider to use to store scene data
  102258. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102259. */
  102260. offlineProvider: IOfflineProvider;
  102261. /**
  102262. * Gets or sets the action manager associated with the scene
  102263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102264. */
  102265. actionManager: AbstractActionManager;
  102266. private _meshesForIntersections;
  102267. /**
  102268. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102269. */
  102270. proceduralTexturesEnabled: boolean;
  102271. private _engine;
  102272. private _totalVertices;
  102273. /** @hidden */
  102274. _activeIndices: PerfCounter;
  102275. /** @hidden */
  102276. _activeParticles: PerfCounter;
  102277. /** @hidden */
  102278. _activeBones: PerfCounter;
  102279. private _animationRatio;
  102280. /** @hidden */
  102281. _animationTimeLast: number;
  102282. /** @hidden */
  102283. _animationTime: number;
  102284. /**
  102285. * Gets or sets a general scale for animation speed
  102286. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102287. */
  102288. animationTimeScale: number;
  102289. /** @hidden */
  102290. _cachedMaterial: Nullable<Material>;
  102291. /** @hidden */
  102292. _cachedEffect: Nullable<Effect>;
  102293. /** @hidden */
  102294. _cachedVisibility: Nullable<number>;
  102295. private _renderId;
  102296. private _frameId;
  102297. private _executeWhenReadyTimeoutId;
  102298. private _intermediateRendering;
  102299. private _viewUpdateFlag;
  102300. private _projectionUpdateFlag;
  102301. /** @hidden */
  102302. _toBeDisposed: Nullable<IDisposable>[];
  102303. private _activeRequests;
  102304. /** @hidden */
  102305. _pendingData: any[];
  102306. private _isDisposed;
  102307. /**
  102308. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102309. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102310. */
  102311. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102312. private _activeMeshes;
  102313. private _processedMaterials;
  102314. private _renderTargets;
  102315. /** @hidden */
  102316. _activeParticleSystems: SmartArray<IParticleSystem>;
  102317. private _activeSkeletons;
  102318. private _softwareSkinnedMeshes;
  102319. private _renderingManager;
  102320. /** @hidden */
  102321. _activeAnimatables: Animatable[];
  102322. private _transformMatrix;
  102323. private _sceneUbo;
  102324. /** @hidden */
  102325. _viewMatrix: Matrix;
  102326. private _projectionMatrix;
  102327. /** @hidden */
  102328. _forcedViewPosition: Nullable<Vector3>;
  102329. /** @hidden */
  102330. _frustumPlanes: Plane[];
  102331. /**
  102332. * Gets the list of frustum planes (built from the active camera)
  102333. */
  102334. readonly frustumPlanes: Plane[];
  102335. /**
  102336. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102337. * This is useful if there are more lights that the maximum simulteanous authorized
  102338. */
  102339. requireLightSorting: boolean;
  102340. /** @hidden */
  102341. readonly useMaterialMeshMap: boolean;
  102342. /** @hidden */
  102343. readonly useClonedMeshhMap: boolean;
  102344. private _externalData;
  102345. private _uid;
  102346. /**
  102347. * @hidden
  102348. * Backing store of defined scene components.
  102349. */
  102350. _components: ISceneComponent[];
  102351. /**
  102352. * @hidden
  102353. * Backing store of defined scene components.
  102354. */
  102355. _serializableComponents: ISceneSerializableComponent[];
  102356. /**
  102357. * List of components to register on the next registration step.
  102358. */
  102359. private _transientComponents;
  102360. /**
  102361. * Registers the transient components if needed.
  102362. */
  102363. private _registerTransientComponents;
  102364. /**
  102365. * @hidden
  102366. * Add a component to the scene.
  102367. * Note that the ccomponent could be registered on th next frame if this is called after
  102368. * the register component stage.
  102369. * @param component Defines the component to add to the scene
  102370. */
  102371. _addComponent(component: ISceneComponent): void;
  102372. /**
  102373. * @hidden
  102374. * Gets a component from the scene.
  102375. * @param name defines the name of the component to retrieve
  102376. * @returns the component or null if not present
  102377. */
  102378. _getComponent(name: string): Nullable<ISceneComponent>;
  102379. /**
  102380. * @hidden
  102381. * Defines the actions happening before camera updates.
  102382. */
  102383. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102384. /**
  102385. * @hidden
  102386. * Defines the actions happening before clear the canvas.
  102387. */
  102388. _beforeClearStage: Stage<SimpleStageAction>;
  102389. /**
  102390. * @hidden
  102391. * Defines the actions when collecting render targets for the frame.
  102392. */
  102393. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102394. /**
  102395. * @hidden
  102396. * Defines the actions happening for one camera in the frame.
  102397. */
  102398. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102399. /**
  102400. * @hidden
  102401. * Defines the actions happening during the per mesh ready checks.
  102402. */
  102403. _isReadyForMeshStage: Stage<MeshStageAction>;
  102404. /**
  102405. * @hidden
  102406. * Defines the actions happening before evaluate active mesh checks.
  102407. */
  102408. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102409. /**
  102410. * @hidden
  102411. * Defines the actions happening during the evaluate sub mesh checks.
  102412. */
  102413. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102414. /**
  102415. * @hidden
  102416. * Defines the actions happening during the active mesh stage.
  102417. */
  102418. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102419. /**
  102420. * @hidden
  102421. * Defines the actions happening during the per camera render target step.
  102422. */
  102423. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102424. /**
  102425. * @hidden
  102426. * Defines the actions happening just before the active camera is drawing.
  102427. */
  102428. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102429. /**
  102430. * @hidden
  102431. * Defines the actions happening just before a render target is drawing.
  102432. */
  102433. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102434. /**
  102435. * @hidden
  102436. * Defines the actions happening just before a rendering group is drawing.
  102437. */
  102438. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102439. /**
  102440. * @hidden
  102441. * Defines the actions happening just before a mesh is drawing.
  102442. */
  102443. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102444. /**
  102445. * @hidden
  102446. * Defines the actions happening just after a mesh has been drawn.
  102447. */
  102448. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102449. /**
  102450. * @hidden
  102451. * Defines the actions happening just after a rendering group has been drawn.
  102452. */
  102453. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102454. /**
  102455. * @hidden
  102456. * Defines the actions happening just after the active camera has been drawn.
  102457. */
  102458. _afterCameraDrawStage: Stage<CameraStageAction>;
  102459. /**
  102460. * @hidden
  102461. * Defines the actions happening just after a render target has been drawn.
  102462. */
  102463. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102464. /**
  102465. * @hidden
  102466. * Defines the actions happening just after rendering all cameras and computing intersections.
  102467. */
  102468. _afterRenderStage: Stage<SimpleStageAction>;
  102469. /**
  102470. * @hidden
  102471. * Defines the actions happening when a pointer move event happens.
  102472. */
  102473. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102474. /**
  102475. * @hidden
  102476. * Defines the actions happening when a pointer down event happens.
  102477. */
  102478. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102479. /**
  102480. * @hidden
  102481. * Defines the actions happening when a pointer up event happens.
  102482. */
  102483. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102484. /**
  102485. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102486. */
  102487. private geometriesByUniqueId;
  102488. /**
  102489. * Creates a new Scene
  102490. * @param engine defines the engine to use to render this scene
  102491. * @param options defines the scene options
  102492. */
  102493. constructor(engine: Engine, options?: SceneOptions);
  102494. /**
  102495. * Gets a string idenfifying the name of the class
  102496. * @returns "Scene" string
  102497. */
  102498. getClassName(): string;
  102499. private _defaultMeshCandidates;
  102500. /**
  102501. * @hidden
  102502. */
  102503. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102504. private _defaultSubMeshCandidates;
  102505. /**
  102506. * @hidden
  102507. */
  102508. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102509. /**
  102510. * Sets the default candidate providers for the scene.
  102511. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102512. * and getCollidingSubMeshCandidates to their default function
  102513. */
  102514. setDefaultCandidateProviders(): void;
  102515. /**
  102516. * Gets the mesh that is currently under the pointer
  102517. */
  102518. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102519. /**
  102520. * Gets or sets the current on-screen X position of the pointer
  102521. */
  102522. pointerX: number;
  102523. /**
  102524. * Gets or sets the current on-screen Y position of the pointer
  102525. */
  102526. pointerY: number;
  102527. /**
  102528. * Gets the cached material (ie. the latest rendered one)
  102529. * @returns the cached material
  102530. */
  102531. getCachedMaterial(): Nullable<Material>;
  102532. /**
  102533. * Gets the cached effect (ie. the latest rendered one)
  102534. * @returns the cached effect
  102535. */
  102536. getCachedEffect(): Nullable<Effect>;
  102537. /**
  102538. * Gets the cached visibility state (ie. the latest rendered one)
  102539. * @returns the cached visibility state
  102540. */
  102541. getCachedVisibility(): Nullable<number>;
  102542. /**
  102543. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102544. * @param material defines the current material
  102545. * @param effect defines the current effect
  102546. * @param visibility defines the current visibility state
  102547. * @returns true if one parameter is not cached
  102548. */
  102549. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102550. /**
  102551. * Gets the engine associated with the scene
  102552. * @returns an Engine
  102553. */
  102554. getEngine(): Engine;
  102555. /**
  102556. * Gets the total number of vertices rendered per frame
  102557. * @returns the total number of vertices rendered per frame
  102558. */
  102559. getTotalVertices(): number;
  102560. /**
  102561. * Gets the performance counter for total vertices
  102562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102563. */
  102564. readonly totalVerticesPerfCounter: PerfCounter;
  102565. /**
  102566. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102567. * @returns the total number of active indices rendered per frame
  102568. */
  102569. getActiveIndices(): number;
  102570. /**
  102571. * Gets the performance counter for active indices
  102572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102573. */
  102574. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102575. /**
  102576. * Gets the total number of active particles rendered per frame
  102577. * @returns the total number of active particles rendered per frame
  102578. */
  102579. getActiveParticles(): number;
  102580. /**
  102581. * Gets the performance counter for active particles
  102582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102583. */
  102584. readonly activeParticlesPerfCounter: PerfCounter;
  102585. /**
  102586. * Gets the total number of active bones rendered per frame
  102587. * @returns the total number of active bones rendered per frame
  102588. */
  102589. getActiveBones(): number;
  102590. /**
  102591. * Gets the performance counter for active bones
  102592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102593. */
  102594. readonly activeBonesPerfCounter: PerfCounter;
  102595. /**
  102596. * Gets the array of active meshes
  102597. * @returns an array of AbstractMesh
  102598. */
  102599. getActiveMeshes(): SmartArray<AbstractMesh>;
  102600. /**
  102601. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102602. * @returns a number
  102603. */
  102604. getAnimationRatio(): number;
  102605. /**
  102606. * Gets an unique Id for the current render phase
  102607. * @returns a number
  102608. */
  102609. getRenderId(): number;
  102610. /**
  102611. * Gets an unique Id for the current frame
  102612. * @returns a number
  102613. */
  102614. getFrameId(): number;
  102615. /** Call this function if you want to manually increment the render Id*/
  102616. incrementRenderId(): void;
  102617. private _createUbo;
  102618. /**
  102619. * Use this method to simulate a pointer move on a mesh
  102620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102623. * @returns the current scene
  102624. */
  102625. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102626. /**
  102627. * Use this method to simulate a pointer down on a mesh
  102628. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102629. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102630. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102631. * @returns the current scene
  102632. */
  102633. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102634. /**
  102635. * Use this method to simulate a pointer up on a mesh
  102636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102639. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102640. * @returns the current scene
  102641. */
  102642. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102643. /**
  102644. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102645. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102646. * @returns true if the pointer was captured
  102647. */
  102648. isPointerCaptured(pointerId?: number): boolean;
  102649. /**
  102650. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102651. * @param attachUp defines if you want to attach events to pointerup
  102652. * @param attachDown defines if you want to attach events to pointerdown
  102653. * @param attachMove defines if you want to attach events to pointermove
  102654. */
  102655. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102656. /** Detaches all event handlers*/
  102657. detachControl(): void;
  102658. /**
  102659. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102660. * Delay loaded resources are not taking in account
  102661. * @return true if all required resources are ready
  102662. */
  102663. isReady(): boolean;
  102664. /** Resets all cached information relative to material (including effect and visibility) */
  102665. resetCachedMaterial(): void;
  102666. /**
  102667. * Registers a function to be called before every frame render
  102668. * @param func defines the function to register
  102669. */
  102670. registerBeforeRender(func: () => void): void;
  102671. /**
  102672. * Unregisters a function called before every frame render
  102673. * @param func defines the function to unregister
  102674. */
  102675. unregisterBeforeRender(func: () => void): void;
  102676. /**
  102677. * Registers a function to be called after every frame render
  102678. * @param func defines the function to register
  102679. */
  102680. registerAfterRender(func: () => void): void;
  102681. /**
  102682. * Unregisters a function called after every frame render
  102683. * @param func defines the function to unregister
  102684. */
  102685. unregisterAfterRender(func: () => void): void;
  102686. private _executeOnceBeforeRender;
  102687. /**
  102688. * The provided function will run before render once and will be disposed afterwards.
  102689. * A timeout delay can be provided so that the function will be executed in N ms.
  102690. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102691. * @param func The function to be executed.
  102692. * @param timeout optional delay in ms
  102693. */
  102694. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102695. /** @hidden */
  102696. _addPendingData(data: any): void;
  102697. /** @hidden */
  102698. _removePendingData(data: any): void;
  102699. /**
  102700. * Returns the number of items waiting to be loaded
  102701. * @returns the number of items waiting to be loaded
  102702. */
  102703. getWaitingItemsCount(): number;
  102704. /**
  102705. * Returns a boolean indicating if the scene is still loading data
  102706. */
  102707. readonly isLoading: boolean;
  102708. /**
  102709. * Registers a function to be executed when the scene is ready
  102710. * @param {Function} func - the function to be executed
  102711. */
  102712. executeWhenReady(func: () => void): void;
  102713. /**
  102714. * Returns a promise that resolves when the scene is ready
  102715. * @returns A promise that resolves when the scene is ready
  102716. */
  102717. whenReadyAsync(): Promise<void>;
  102718. /** @hidden */
  102719. _checkIsReady(): void;
  102720. /**
  102721. * Gets all animatable attached to the scene
  102722. */
  102723. readonly animatables: Animatable[];
  102724. /**
  102725. * Resets the last animation time frame.
  102726. * Useful to override when animations start running when loading a scene for the first time.
  102727. */
  102728. resetLastAnimationTimeFrame(): void;
  102729. /**
  102730. * Gets the current view matrix
  102731. * @returns a Matrix
  102732. */
  102733. getViewMatrix(): Matrix;
  102734. /**
  102735. * Gets the current projection matrix
  102736. * @returns a Matrix
  102737. */
  102738. getProjectionMatrix(): Matrix;
  102739. /**
  102740. * Gets the current transform matrix
  102741. * @returns a Matrix made of View * Projection
  102742. */
  102743. getTransformMatrix(): Matrix;
  102744. /**
  102745. * Sets the current transform matrix
  102746. * @param viewL defines the View matrix to use
  102747. * @param projectionL defines the Projection matrix to use
  102748. * @param viewR defines the right View matrix to use (if provided)
  102749. * @param projectionR defines the right Projection matrix to use (if provided)
  102750. */
  102751. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102752. /**
  102753. * Gets the uniform buffer used to store scene data
  102754. * @returns a UniformBuffer
  102755. */
  102756. getSceneUniformBuffer(): UniformBuffer;
  102757. /**
  102758. * Gets an unique (relatively to the current scene) Id
  102759. * @returns an unique number for the scene
  102760. */
  102761. getUniqueId(): number;
  102762. /**
  102763. * Add a mesh to the list of scene's meshes
  102764. * @param newMesh defines the mesh to add
  102765. * @param recursive if all child meshes should also be added to the scene
  102766. */
  102767. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102768. /**
  102769. * Remove a mesh for the list of scene's meshes
  102770. * @param toRemove defines the mesh to remove
  102771. * @param recursive if all child meshes should also be removed from the scene
  102772. * @returns the index where the mesh was in the mesh list
  102773. */
  102774. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102775. /**
  102776. * Add a transform node to the list of scene's transform nodes
  102777. * @param newTransformNode defines the transform node to add
  102778. */
  102779. addTransformNode(newTransformNode: TransformNode): void;
  102780. /**
  102781. * Remove a transform node for the list of scene's transform nodes
  102782. * @param toRemove defines the transform node to remove
  102783. * @returns the index where the transform node was in the transform node list
  102784. */
  102785. removeTransformNode(toRemove: TransformNode): number;
  102786. /**
  102787. * Remove a skeleton for the list of scene's skeletons
  102788. * @param toRemove defines the skeleton to remove
  102789. * @returns the index where the skeleton was in the skeleton list
  102790. */
  102791. removeSkeleton(toRemove: Skeleton): number;
  102792. /**
  102793. * Remove a morph target for the list of scene's morph targets
  102794. * @param toRemove defines the morph target to remove
  102795. * @returns the index where the morph target was in the morph target list
  102796. */
  102797. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102798. /**
  102799. * Remove a light for the list of scene's lights
  102800. * @param toRemove defines the light to remove
  102801. * @returns the index where the light was in the light list
  102802. */
  102803. removeLight(toRemove: Light): number;
  102804. /**
  102805. * Remove a camera for the list of scene's cameras
  102806. * @param toRemove defines the camera to remove
  102807. * @returns the index where the camera was in the camera list
  102808. */
  102809. removeCamera(toRemove: Camera): number;
  102810. /**
  102811. * Remove a particle system for the list of scene's particle systems
  102812. * @param toRemove defines the particle system to remove
  102813. * @returns the index where the particle system was in the particle system list
  102814. */
  102815. removeParticleSystem(toRemove: IParticleSystem): number;
  102816. /**
  102817. * Remove a animation for the list of scene's animations
  102818. * @param toRemove defines the animation to remove
  102819. * @returns the index where the animation was in the animation list
  102820. */
  102821. removeAnimation(toRemove: Animation): number;
  102822. /**
  102823. * Will stop the animation of the given target
  102824. * @param target - the target
  102825. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102826. * @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)
  102827. */
  102828. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102829. /**
  102830. * Removes the given animation group from this scene.
  102831. * @param toRemove The animation group to remove
  102832. * @returns The index of the removed animation group
  102833. */
  102834. removeAnimationGroup(toRemove: AnimationGroup): number;
  102835. /**
  102836. * Removes the given multi-material from this scene.
  102837. * @param toRemove The multi-material to remove
  102838. * @returns The index of the removed multi-material
  102839. */
  102840. removeMultiMaterial(toRemove: MultiMaterial): number;
  102841. /**
  102842. * Removes the given material from this scene.
  102843. * @param toRemove The material to remove
  102844. * @returns The index of the removed material
  102845. */
  102846. removeMaterial(toRemove: Material): number;
  102847. /**
  102848. * Removes the given action manager from this scene.
  102849. * @param toRemove The action manager to remove
  102850. * @returns The index of the removed action manager
  102851. */
  102852. removeActionManager(toRemove: AbstractActionManager): number;
  102853. /**
  102854. * Removes the given texture from this scene.
  102855. * @param toRemove The texture to remove
  102856. * @returns The index of the removed texture
  102857. */
  102858. removeTexture(toRemove: BaseTexture): number;
  102859. /**
  102860. * Adds the given light to this scene
  102861. * @param newLight The light to add
  102862. */
  102863. addLight(newLight: Light): void;
  102864. /**
  102865. * Sorts the list list based on light priorities
  102866. */
  102867. sortLightsByPriority(): void;
  102868. /**
  102869. * Adds the given camera to this scene
  102870. * @param newCamera The camera to add
  102871. */
  102872. addCamera(newCamera: Camera): void;
  102873. /**
  102874. * Adds the given skeleton to this scene
  102875. * @param newSkeleton The skeleton to add
  102876. */
  102877. addSkeleton(newSkeleton: Skeleton): void;
  102878. /**
  102879. * Adds the given particle system to this scene
  102880. * @param newParticleSystem The particle system to add
  102881. */
  102882. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102883. /**
  102884. * Adds the given animation to this scene
  102885. * @param newAnimation The animation to add
  102886. */
  102887. addAnimation(newAnimation: Animation): void;
  102888. /**
  102889. * Adds the given animation group to this scene.
  102890. * @param newAnimationGroup The animation group to add
  102891. */
  102892. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102893. /**
  102894. * Adds the given multi-material to this scene
  102895. * @param newMultiMaterial The multi-material to add
  102896. */
  102897. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102898. /**
  102899. * Adds the given material to this scene
  102900. * @param newMaterial The material to add
  102901. */
  102902. addMaterial(newMaterial: Material): void;
  102903. /**
  102904. * Adds the given morph target to this scene
  102905. * @param newMorphTargetManager The morph target to add
  102906. */
  102907. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102908. /**
  102909. * Adds the given geometry to this scene
  102910. * @param newGeometry The geometry to add
  102911. */
  102912. addGeometry(newGeometry: Geometry): void;
  102913. /**
  102914. * Adds the given action manager to this scene
  102915. * @param newActionManager The action manager to add
  102916. */
  102917. addActionManager(newActionManager: AbstractActionManager): void;
  102918. /**
  102919. * Adds the given texture to this scene.
  102920. * @param newTexture The texture to add
  102921. */
  102922. addTexture(newTexture: BaseTexture): void;
  102923. /**
  102924. * Switch active camera
  102925. * @param newCamera defines the new active camera
  102926. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102927. */
  102928. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102929. /**
  102930. * sets the active camera of the scene using its ID
  102931. * @param id defines the camera's ID
  102932. * @return the new active camera or null if none found.
  102933. */
  102934. setActiveCameraByID(id: string): Nullable<Camera>;
  102935. /**
  102936. * sets the active camera of the scene using its name
  102937. * @param name defines the camera's name
  102938. * @returns the new active camera or null if none found.
  102939. */
  102940. setActiveCameraByName(name: string): Nullable<Camera>;
  102941. /**
  102942. * get an animation group using its name
  102943. * @param name defines the material's name
  102944. * @return the animation group or null if none found.
  102945. */
  102946. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102947. /**
  102948. * Get a material using its unique id
  102949. * @param uniqueId defines the material's unique id
  102950. * @return the material or null if none found.
  102951. */
  102952. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102953. /**
  102954. * get a material using its id
  102955. * @param id defines the material's ID
  102956. * @return the material or null if none found.
  102957. */
  102958. getMaterialByID(id: string): Nullable<Material>;
  102959. /**
  102960. * Gets a the last added material using a given id
  102961. * @param id defines the material's ID
  102962. * @return the last material with the given id or null if none found.
  102963. */
  102964. getLastMaterialByID(id: string): Nullable<Material>;
  102965. /**
  102966. * Gets a material using its name
  102967. * @param name defines the material's name
  102968. * @return the material or null if none found.
  102969. */
  102970. getMaterialByName(name: string): Nullable<Material>;
  102971. /**
  102972. * Get a texture using its unique id
  102973. * @param uniqueId defines the texture's unique id
  102974. * @return the texture or null if none found.
  102975. */
  102976. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102977. /**
  102978. * Gets a camera using its id
  102979. * @param id defines the id to look for
  102980. * @returns the camera or null if not found
  102981. */
  102982. getCameraByID(id: string): Nullable<Camera>;
  102983. /**
  102984. * Gets a camera using its unique id
  102985. * @param uniqueId defines the unique id to look for
  102986. * @returns the camera or null if not found
  102987. */
  102988. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102989. /**
  102990. * Gets a camera using its name
  102991. * @param name defines the camera's name
  102992. * @return the camera or null if none found.
  102993. */
  102994. getCameraByName(name: string): Nullable<Camera>;
  102995. /**
  102996. * Gets a bone using its id
  102997. * @param id defines the bone's id
  102998. * @return the bone or null if not found
  102999. */
  103000. getBoneByID(id: string): Nullable<Bone>;
  103001. /**
  103002. * Gets a bone using its id
  103003. * @param name defines the bone's name
  103004. * @return the bone or null if not found
  103005. */
  103006. getBoneByName(name: string): Nullable<Bone>;
  103007. /**
  103008. * Gets a light node using its name
  103009. * @param name defines the the light's name
  103010. * @return the light or null if none found.
  103011. */
  103012. getLightByName(name: string): Nullable<Light>;
  103013. /**
  103014. * Gets a light node using its id
  103015. * @param id defines the light's id
  103016. * @return the light or null if none found.
  103017. */
  103018. getLightByID(id: string): Nullable<Light>;
  103019. /**
  103020. * Gets a light node using its scene-generated unique ID
  103021. * @param uniqueId defines the light's unique id
  103022. * @return the light or null if none found.
  103023. */
  103024. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  103025. /**
  103026. * Gets a particle system by id
  103027. * @param id defines the particle system id
  103028. * @return the corresponding system or null if none found
  103029. */
  103030. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  103031. /**
  103032. * Gets a geometry using its ID
  103033. * @param id defines the geometry's id
  103034. * @return the geometry or null if none found.
  103035. */
  103036. getGeometryByID(id: string): Nullable<Geometry>;
  103037. private _getGeometryByUniqueID;
  103038. /**
  103039. * Add a new geometry to this scene
  103040. * @param geometry defines the geometry to be added to the scene.
  103041. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  103042. * @return a boolean defining if the geometry was added or not
  103043. */
  103044. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  103045. /**
  103046. * Removes an existing geometry
  103047. * @param geometry defines the geometry to be removed from the scene
  103048. * @return a boolean defining if the geometry was removed or not
  103049. */
  103050. removeGeometry(geometry: Geometry): boolean;
  103051. /**
  103052. * Gets the list of geometries attached to the scene
  103053. * @returns an array of Geometry
  103054. */
  103055. getGeometries(): Geometry[];
  103056. /**
  103057. * Gets the first added mesh found of a given ID
  103058. * @param id defines the id to search for
  103059. * @return the mesh found or null if not found at all
  103060. */
  103061. getMeshByID(id: string): Nullable<AbstractMesh>;
  103062. /**
  103063. * Gets a list of meshes using their id
  103064. * @param id defines the id to search for
  103065. * @returns a list of meshes
  103066. */
  103067. getMeshesByID(id: string): Array<AbstractMesh>;
  103068. /**
  103069. * Gets the first added transform node found of a given ID
  103070. * @param id defines the id to search for
  103071. * @return the found transform node or null if not found at all.
  103072. */
  103073. getTransformNodeByID(id: string): Nullable<TransformNode>;
  103074. /**
  103075. * Gets a transform node with its auto-generated unique id
  103076. * @param uniqueId efines the unique id to search for
  103077. * @return the found transform node or null if not found at all.
  103078. */
  103079. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  103080. /**
  103081. * Gets a list of transform nodes using their id
  103082. * @param id defines the id to search for
  103083. * @returns a list of transform nodes
  103084. */
  103085. getTransformNodesByID(id: string): Array<TransformNode>;
  103086. /**
  103087. * Gets a mesh with its auto-generated unique id
  103088. * @param uniqueId defines the unique id to search for
  103089. * @return the found mesh or null if not found at all.
  103090. */
  103091. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103092. /**
  103093. * Gets a the last added mesh using a given id
  103094. * @param id defines the id to search for
  103095. * @return the found mesh or null if not found at all.
  103096. */
  103097. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103098. /**
  103099. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103100. * @param id defines the id to search for
  103101. * @return the found node or null if not found at all
  103102. */
  103103. getLastEntryByID(id: string): Nullable<Node>;
  103104. /**
  103105. * Gets a node (Mesh, Camera, Light) using a given id
  103106. * @param id defines the id to search for
  103107. * @return the found node or null if not found at all
  103108. */
  103109. getNodeByID(id: string): Nullable<Node>;
  103110. /**
  103111. * Gets a node (Mesh, Camera, Light) using a given name
  103112. * @param name defines the name to search for
  103113. * @return the found node or null if not found at all.
  103114. */
  103115. getNodeByName(name: string): Nullable<Node>;
  103116. /**
  103117. * Gets a mesh using a given name
  103118. * @param name defines the name to search for
  103119. * @return the found mesh or null if not found at all.
  103120. */
  103121. getMeshByName(name: string): Nullable<AbstractMesh>;
  103122. /**
  103123. * Gets a transform node using a given name
  103124. * @param name defines the name to search for
  103125. * @return the found transform node or null if not found at all.
  103126. */
  103127. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103128. /**
  103129. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103130. * @param id defines the id to search for
  103131. * @return the found skeleton or null if not found at all.
  103132. */
  103133. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103134. /**
  103135. * Gets a skeleton using a given auto generated unique id
  103136. * @param uniqueId defines the unique id to search for
  103137. * @return the found skeleton or null if not found at all.
  103138. */
  103139. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103140. /**
  103141. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103142. * @param id defines the id to search for
  103143. * @return the found skeleton or null if not found at all.
  103144. */
  103145. getSkeletonById(id: string): Nullable<Skeleton>;
  103146. /**
  103147. * Gets a skeleton using a given name
  103148. * @param name defines the name to search for
  103149. * @return the found skeleton or null if not found at all.
  103150. */
  103151. getSkeletonByName(name: string): Nullable<Skeleton>;
  103152. /**
  103153. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103154. * @param id defines the id to search for
  103155. * @return the found morph target manager or null if not found at all.
  103156. */
  103157. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103158. /**
  103159. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103160. * @param id defines the id to search for
  103161. * @return the found morph target or null if not found at all.
  103162. */
  103163. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103164. /**
  103165. * Gets a boolean indicating if the given mesh is active
  103166. * @param mesh defines the mesh to look for
  103167. * @returns true if the mesh is in the active list
  103168. */
  103169. isActiveMesh(mesh: AbstractMesh): boolean;
  103170. /**
  103171. * Return a unique id as a string which can serve as an identifier for the scene
  103172. */
  103173. readonly uid: string;
  103174. /**
  103175. * Add an externaly attached data from its key.
  103176. * This method call will fail and return false, if such key already exists.
  103177. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103178. * @param key the unique key that identifies the data
  103179. * @param data the data object to associate to the key for this Engine instance
  103180. * @return true if no such key were already present and the data was added successfully, false otherwise
  103181. */
  103182. addExternalData<T>(key: string, data: T): boolean;
  103183. /**
  103184. * Get an externaly attached data from its key
  103185. * @param key the unique key that identifies the data
  103186. * @return the associated data, if present (can be null), or undefined if not present
  103187. */
  103188. getExternalData<T>(key: string): Nullable<T>;
  103189. /**
  103190. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103191. * @param key the unique key that identifies the data
  103192. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103193. * @return the associated data, can be null if the factory returned null.
  103194. */
  103195. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103196. /**
  103197. * Remove an externaly attached data from the Engine instance
  103198. * @param key the unique key that identifies the data
  103199. * @return true if the data was successfully removed, false if it doesn't exist
  103200. */
  103201. removeExternalData(key: string): boolean;
  103202. private _evaluateSubMesh;
  103203. /**
  103204. * Clear the processed materials smart array preventing retention point in material dispose.
  103205. */
  103206. freeProcessedMaterials(): void;
  103207. private _preventFreeActiveMeshesAndRenderingGroups;
  103208. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103209. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103210. * when disposing several meshes in a row or a hierarchy of meshes.
  103211. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103212. */
  103213. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103214. /**
  103215. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103216. */
  103217. freeActiveMeshes(): void;
  103218. /**
  103219. * Clear the info related to rendering groups preventing retention points during dispose.
  103220. */
  103221. freeRenderingGroups(): void;
  103222. /** @hidden */
  103223. _isInIntermediateRendering(): boolean;
  103224. /**
  103225. * Lambda returning the list of potentially active meshes.
  103226. */
  103227. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103228. /**
  103229. * Lambda returning the list of potentially active sub meshes.
  103230. */
  103231. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103232. /**
  103233. * Lambda returning the list of potentially intersecting sub meshes.
  103234. */
  103235. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103236. /**
  103237. * Lambda returning the list of potentially colliding sub meshes.
  103238. */
  103239. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103240. private _activeMeshesFrozen;
  103241. private _skipEvaluateActiveMeshesCompletely;
  103242. /**
  103243. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103244. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103245. * @returns the current scene
  103246. */
  103247. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103248. /**
  103249. * Use this function to restart evaluating active meshes on every frame
  103250. * @returns the current scene
  103251. */
  103252. unfreezeActiveMeshes(): Scene;
  103253. private _evaluateActiveMeshes;
  103254. private _activeMesh;
  103255. /**
  103256. * Update the transform matrix to update from the current active camera
  103257. * @param force defines a boolean used to force the update even if cache is up to date
  103258. */
  103259. updateTransformMatrix(force?: boolean): void;
  103260. private _bindFrameBuffer;
  103261. /** @hidden */
  103262. _allowPostProcessClearColor: boolean;
  103263. /** @hidden */
  103264. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103265. private _processSubCameras;
  103266. private _checkIntersections;
  103267. /** @hidden */
  103268. _advancePhysicsEngineStep(step: number): void;
  103269. /**
  103270. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103271. */
  103272. getDeterministicFrameTime: () => number;
  103273. /** @hidden */
  103274. _animate(): void;
  103275. /** Execute all animations (for a frame) */
  103276. animate(): void;
  103277. /**
  103278. * Render the scene
  103279. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103280. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103281. */
  103282. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103283. /**
  103284. * Freeze all materials
  103285. * A frozen material will not be updatable but should be faster to render
  103286. */
  103287. freezeMaterials(): void;
  103288. /**
  103289. * Unfreeze all materials
  103290. * A frozen material will not be updatable but should be faster to render
  103291. */
  103292. unfreezeMaterials(): void;
  103293. /**
  103294. * Releases all held ressources
  103295. */
  103296. dispose(): void;
  103297. /**
  103298. * Gets if the scene is already disposed
  103299. */
  103300. readonly isDisposed: boolean;
  103301. /**
  103302. * Call this function to reduce memory footprint of the scene.
  103303. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103304. */
  103305. clearCachedVertexData(): void;
  103306. /**
  103307. * This function will remove the local cached buffer data from texture.
  103308. * It will save memory but will prevent the texture from being rebuilt
  103309. */
  103310. cleanCachedTextureBuffer(): void;
  103311. /**
  103312. * Get the world extend vectors with an optional filter
  103313. *
  103314. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103315. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103316. */
  103317. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103318. min: Vector3;
  103319. max: Vector3;
  103320. };
  103321. /**
  103322. * Creates a ray that can be used to pick in the scene
  103323. * @param x defines the x coordinate of the origin (on-screen)
  103324. * @param y defines the y coordinate of the origin (on-screen)
  103325. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103326. * @param camera defines the camera to use for the picking
  103327. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103328. * @returns a Ray
  103329. */
  103330. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103331. /**
  103332. * Creates a ray that can be used to pick in the scene
  103333. * @param x defines the x coordinate of the origin (on-screen)
  103334. * @param y defines the y coordinate of the origin (on-screen)
  103335. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103336. * @param result defines the ray where to store the picking ray
  103337. * @param camera defines the camera to use for the picking
  103338. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103339. * @returns the current scene
  103340. */
  103341. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103342. /**
  103343. * Creates a ray that can be used to pick in the scene
  103344. * @param x defines the x coordinate of the origin (on-screen)
  103345. * @param y defines the y coordinate of the origin (on-screen)
  103346. * @param camera defines the camera to use for the picking
  103347. * @returns a Ray
  103348. */
  103349. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103350. /**
  103351. * Creates a ray that can be used to pick in the scene
  103352. * @param x defines the x coordinate of the origin (on-screen)
  103353. * @param y defines the y coordinate of the origin (on-screen)
  103354. * @param result defines the ray where to store the picking ray
  103355. * @param camera defines the camera to use for the picking
  103356. * @returns the current scene
  103357. */
  103358. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103359. /** Launch a ray to try to pick a mesh in the scene
  103360. * @param x position on screen
  103361. * @param y position on screen
  103362. * @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
  103363. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103364. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103365. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103366. * @returns a PickingInfo
  103367. */
  103368. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103369. /** Use the given ray to pick a mesh in the scene
  103370. * @param ray The ray to use to pick meshes
  103371. * @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
  103372. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103374. * @returns a PickingInfo
  103375. */
  103376. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103377. /**
  103378. * Launch a ray to try to pick a mesh in the scene
  103379. * @param x X position on screen
  103380. * @param y Y position on screen
  103381. * @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
  103382. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103384. * @returns an array of PickingInfo
  103385. */
  103386. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103387. /**
  103388. * Launch a ray to try to pick a mesh in the scene
  103389. * @param ray Ray to use
  103390. * @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
  103391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103392. * @returns an array of PickingInfo
  103393. */
  103394. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103395. /**
  103396. * Force the value of meshUnderPointer
  103397. * @param mesh defines the mesh to use
  103398. */
  103399. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103400. /**
  103401. * Gets the mesh under the pointer
  103402. * @returns a Mesh or null if no mesh is under the pointer
  103403. */
  103404. getPointerOverMesh(): Nullable<AbstractMesh>;
  103405. /** @hidden */
  103406. _rebuildGeometries(): void;
  103407. /** @hidden */
  103408. _rebuildTextures(): void;
  103409. private _getByTags;
  103410. /**
  103411. * Get a list of meshes by tags
  103412. * @param tagsQuery defines the tags query to use
  103413. * @param forEach defines a predicate used to filter results
  103414. * @returns an array of Mesh
  103415. */
  103416. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103417. /**
  103418. * Get a list of cameras by tags
  103419. * @param tagsQuery defines the tags query to use
  103420. * @param forEach defines a predicate used to filter results
  103421. * @returns an array of Camera
  103422. */
  103423. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103424. /**
  103425. * Get a list of lights by tags
  103426. * @param tagsQuery defines the tags query to use
  103427. * @param forEach defines a predicate used to filter results
  103428. * @returns an array of Light
  103429. */
  103430. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103431. /**
  103432. * Get a list of materials by tags
  103433. * @param tagsQuery defines the tags query to use
  103434. * @param forEach defines a predicate used to filter results
  103435. * @returns an array of Material
  103436. */
  103437. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103438. /**
  103439. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103440. * This allowed control for front to back rendering or reversly depending of the special needs.
  103441. *
  103442. * @param renderingGroupId The rendering group id corresponding to its index
  103443. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103444. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103445. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103446. */
  103447. 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;
  103448. /**
  103449. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103450. *
  103451. * @param renderingGroupId The rendering group id corresponding to its index
  103452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103453. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103454. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103455. */
  103456. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103457. /**
  103458. * Gets the current auto clear configuration for one rendering group of the rendering
  103459. * manager.
  103460. * @param index the rendering group index to get the information for
  103461. * @returns The auto clear setup for the requested rendering group
  103462. */
  103463. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103464. private _blockMaterialDirtyMechanism;
  103465. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103466. blockMaterialDirtyMechanism: boolean;
  103467. /**
  103468. * Will flag all materials as dirty to trigger new shader compilation
  103469. * @param flag defines the flag used to specify which material part must be marked as dirty
  103470. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103471. */
  103472. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103473. /** @hidden */
  103474. _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;
  103475. /** @hidden */
  103476. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103477. /** @hidden */
  103478. _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;
  103479. /** @hidden */
  103480. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103481. /** @hidden */
  103482. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103483. /** @hidden */
  103484. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103485. }
  103486. }
  103487. declare module BABYLON {
  103488. /**
  103489. * Set of assets to keep when moving a scene into an asset container.
  103490. */
  103491. export class KeepAssets extends AbstractScene {
  103492. }
  103493. /**
  103494. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103495. */
  103496. export class InstantiatedEntries {
  103497. /**
  103498. * List of new root nodes (eg. nodes with no parent)
  103499. */
  103500. rootNodes: TransformNode[];
  103501. /**
  103502. * List of new skeletons
  103503. */
  103504. skeletons: Skeleton[];
  103505. /**
  103506. * List of new animation groups
  103507. */
  103508. animationGroups: AnimationGroup[];
  103509. }
  103510. /**
  103511. * Container with a set of assets that can be added or removed from a scene.
  103512. */
  103513. export class AssetContainer extends AbstractScene {
  103514. /**
  103515. * The scene the AssetContainer belongs to.
  103516. */
  103517. scene: Scene;
  103518. /**
  103519. * Instantiates an AssetContainer.
  103520. * @param scene The scene the AssetContainer belongs to.
  103521. */
  103522. constructor(scene: Scene);
  103523. /**
  103524. * Instantiate or clone all meshes and add the new ones to the scene.
  103525. * Skeletons and animation groups will all be cloned
  103526. * @param nameFunction defines an optional function used to get new names for clones
  103527. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103528. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103529. */
  103530. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103531. /**
  103532. * Adds all the assets from the container to the scene.
  103533. */
  103534. addAllToScene(): void;
  103535. /**
  103536. * Removes all the assets in the container from the scene
  103537. */
  103538. removeAllFromScene(): void;
  103539. /**
  103540. * Disposes all the assets in the container
  103541. */
  103542. dispose(): void;
  103543. private _moveAssets;
  103544. /**
  103545. * Removes all the assets contained in the scene and adds them to the container.
  103546. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103547. */
  103548. moveAllFromScene(keepAssets?: KeepAssets): void;
  103549. /**
  103550. * 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.
  103551. * @returns the root mesh
  103552. */
  103553. createRootMesh(): Mesh;
  103554. }
  103555. }
  103556. declare module BABYLON {
  103557. /**
  103558. * Defines how the parser contract is defined.
  103559. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103560. */
  103561. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103562. /**
  103563. * Defines how the individual parser contract is defined.
  103564. * These parser can parse an individual asset
  103565. */
  103566. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103567. /**
  103568. * Base class of the scene acting as a container for the different elements composing a scene.
  103569. * This class is dynamically extended by the different components of the scene increasing
  103570. * flexibility and reducing coupling
  103571. */
  103572. export abstract class AbstractScene {
  103573. /**
  103574. * Stores the list of available parsers in the application.
  103575. */
  103576. private static _BabylonFileParsers;
  103577. /**
  103578. * Stores the list of available individual parsers in the application.
  103579. */
  103580. private static _IndividualBabylonFileParsers;
  103581. /**
  103582. * Adds a parser in the list of available ones
  103583. * @param name Defines the name of the parser
  103584. * @param parser Defines the parser to add
  103585. */
  103586. static AddParser(name: string, parser: BabylonFileParser): void;
  103587. /**
  103588. * Gets a general parser from the list of avaialble ones
  103589. * @param name Defines the name of the parser
  103590. * @returns the requested parser or null
  103591. */
  103592. static GetParser(name: string): Nullable<BabylonFileParser>;
  103593. /**
  103594. * Adds n individual parser in the list of available ones
  103595. * @param name Defines the name of the parser
  103596. * @param parser Defines the parser to add
  103597. */
  103598. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103599. /**
  103600. * Gets an individual parser from the list of avaialble ones
  103601. * @param name Defines the name of the parser
  103602. * @returns the requested parser or null
  103603. */
  103604. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103605. /**
  103606. * Parser json data and populate both a scene and its associated container object
  103607. * @param jsonData Defines the data to parse
  103608. * @param scene Defines the scene to parse the data for
  103609. * @param container Defines the container attached to the parsing sequence
  103610. * @param rootUrl Defines the root url of the data
  103611. */
  103612. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103613. /**
  103614. * Gets the list of root nodes (ie. nodes with no parent)
  103615. */
  103616. rootNodes: Node[];
  103617. /** All of the cameras added to this scene
  103618. * @see http://doc.babylonjs.com/babylon101/cameras
  103619. */
  103620. cameras: Camera[];
  103621. /**
  103622. * All of the lights added to this scene
  103623. * @see http://doc.babylonjs.com/babylon101/lights
  103624. */
  103625. lights: Light[];
  103626. /**
  103627. * All of the (abstract) meshes added to this scene
  103628. */
  103629. meshes: AbstractMesh[];
  103630. /**
  103631. * The list of skeletons added to the scene
  103632. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103633. */
  103634. skeletons: Skeleton[];
  103635. /**
  103636. * All of the particle systems added to this scene
  103637. * @see http://doc.babylonjs.com/babylon101/particles
  103638. */
  103639. particleSystems: IParticleSystem[];
  103640. /**
  103641. * Gets a list of Animations associated with the scene
  103642. */
  103643. animations: Animation[];
  103644. /**
  103645. * All of the animation groups added to this scene
  103646. * @see http://doc.babylonjs.com/how_to/group
  103647. */
  103648. animationGroups: AnimationGroup[];
  103649. /**
  103650. * All of the multi-materials added to this scene
  103651. * @see http://doc.babylonjs.com/how_to/multi_materials
  103652. */
  103653. multiMaterials: MultiMaterial[];
  103654. /**
  103655. * All of the materials added to this scene
  103656. * In the context of a Scene, it is not supposed to be modified manually.
  103657. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103658. * Note also that the order of the Material within the array is not significant and might change.
  103659. * @see http://doc.babylonjs.com/babylon101/materials
  103660. */
  103661. materials: Material[];
  103662. /**
  103663. * The list of morph target managers added to the scene
  103664. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103665. */
  103666. morphTargetManagers: MorphTargetManager[];
  103667. /**
  103668. * The list of geometries used in the scene.
  103669. */
  103670. geometries: Geometry[];
  103671. /**
  103672. * All of the tranform nodes added to this scene
  103673. * In the context of a Scene, it is not supposed to be modified manually.
  103674. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103675. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103676. * @see http://doc.babylonjs.com/how_to/transformnode
  103677. */
  103678. transformNodes: TransformNode[];
  103679. /**
  103680. * ActionManagers available on the scene.
  103681. */
  103682. actionManagers: AbstractActionManager[];
  103683. /**
  103684. * Textures to keep.
  103685. */
  103686. textures: BaseTexture[];
  103687. /**
  103688. * Environment texture for the scene
  103689. */
  103690. environmentTexture: Nullable<BaseTexture>;
  103691. }
  103692. }
  103693. declare module BABYLON {
  103694. /**
  103695. * Interface used to define options for Sound class
  103696. */
  103697. export interface ISoundOptions {
  103698. /**
  103699. * Does the sound autoplay once loaded.
  103700. */
  103701. autoplay?: boolean;
  103702. /**
  103703. * Does the sound loop after it finishes playing once.
  103704. */
  103705. loop?: boolean;
  103706. /**
  103707. * Sound's volume
  103708. */
  103709. volume?: number;
  103710. /**
  103711. * Is it a spatial sound?
  103712. */
  103713. spatialSound?: boolean;
  103714. /**
  103715. * Maximum distance to hear that sound
  103716. */
  103717. maxDistance?: number;
  103718. /**
  103719. * Uses user defined attenuation function
  103720. */
  103721. useCustomAttenuation?: boolean;
  103722. /**
  103723. * Define the roll off factor of spatial sounds.
  103724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103725. */
  103726. rolloffFactor?: number;
  103727. /**
  103728. * Define the reference distance the sound should be heard perfectly.
  103729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103730. */
  103731. refDistance?: number;
  103732. /**
  103733. * Define the distance attenuation model the sound will follow.
  103734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103735. */
  103736. distanceModel?: string;
  103737. /**
  103738. * Defines the playback speed (1 by default)
  103739. */
  103740. playbackRate?: number;
  103741. /**
  103742. * Defines if the sound is from a streaming source
  103743. */
  103744. streaming?: boolean;
  103745. /**
  103746. * Defines an optional length (in seconds) inside the sound file
  103747. */
  103748. length?: number;
  103749. /**
  103750. * Defines an optional offset (in seconds) inside the sound file
  103751. */
  103752. offset?: number;
  103753. /**
  103754. * If true, URLs will not be required to state the audio file codec to use.
  103755. */
  103756. skipCodecCheck?: boolean;
  103757. }
  103758. /**
  103759. * Defines a sound that can be played in the application.
  103760. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103762. */
  103763. export class Sound {
  103764. /**
  103765. * The name of the sound in the scene.
  103766. */
  103767. name: string;
  103768. /**
  103769. * Does the sound autoplay once loaded.
  103770. */
  103771. autoplay: boolean;
  103772. /**
  103773. * Does the sound loop after it finishes playing once.
  103774. */
  103775. loop: boolean;
  103776. /**
  103777. * Does the sound use a custom attenuation curve to simulate the falloff
  103778. * happening when the source gets further away from the camera.
  103779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103780. */
  103781. useCustomAttenuation: boolean;
  103782. /**
  103783. * The sound track id this sound belongs to.
  103784. */
  103785. soundTrackId: number;
  103786. /**
  103787. * Is this sound currently played.
  103788. */
  103789. isPlaying: boolean;
  103790. /**
  103791. * Is this sound currently paused.
  103792. */
  103793. isPaused: boolean;
  103794. /**
  103795. * Does this sound enables spatial sound.
  103796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103797. */
  103798. spatialSound: boolean;
  103799. /**
  103800. * Define the reference distance the sound should be heard perfectly.
  103801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103802. */
  103803. refDistance: number;
  103804. /**
  103805. * Define the roll off factor of spatial sounds.
  103806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103807. */
  103808. rolloffFactor: number;
  103809. /**
  103810. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103812. */
  103813. maxDistance: number;
  103814. /**
  103815. * Define the distance attenuation model the sound will follow.
  103816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103817. */
  103818. distanceModel: string;
  103819. /**
  103820. * @hidden
  103821. * Back Compat
  103822. **/
  103823. onended: () => any;
  103824. /**
  103825. * Observable event when the current playing sound finishes.
  103826. */
  103827. onEndedObservable: Observable<Sound>;
  103828. private _panningModel;
  103829. private _playbackRate;
  103830. private _streaming;
  103831. private _startTime;
  103832. private _startOffset;
  103833. private _position;
  103834. /** @hidden */
  103835. _positionInEmitterSpace: boolean;
  103836. private _localDirection;
  103837. private _volume;
  103838. private _isReadyToPlay;
  103839. private _isDirectional;
  103840. private _readyToPlayCallback;
  103841. private _audioBuffer;
  103842. private _soundSource;
  103843. private _streamingSource;
  103844. private _soundPanner;
  103845. private _soundGain;
  103846. private _inputAudioNode;
  103847. private _outputAudioNode;
  103848. private _coneInnerAngle;
  103849. private _coneOuterAngle;
  103850. private _coneOuterGain;
  103851. private _scene;
  103852. private _connectedTransformNode;
  103853. private _customAttenuationFunction;
  103854. private _registerFunc;
  103855. private _isOutputConnected;
  103856. private _htmlAudioElement;
  103857. private _urlType;
  103858. private _length?;
  103859. private _offset?;
  103860. /** @hidden */
  103861. static _SceneComponentInitialization: (scene: Scene) => void;
  103862. /**
  103863. * Create a sound and attach it to a scene
  103864. * @param name Name of your sound
  103865. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103866. * @param scene defines the scene the sound belongs to
  103867. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103868. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103869. */
  103870. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103871. /**
  103872. * Release the sound and its associated resources
  103873. */
  103874. dispose(): void;
  103875. /**
  103876. * Gets if the sounds is ready to be played or not.
  103877. * @returns true if ready, otherwise false
  103878. */
  103879. isReady(): boolean;
  103880. private _soundLoaded;
  103881. /**
  103882. * Sets the data of the sound from an audiobuffer
  103883. * @param audioBuffer The audioBuffer containing the data
  103884. */
  103885. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103886. /**
  103887. * Updates the current sounds options such as maxdistance, loop...
  103888. * @param options A JSON object containing values named as the object properties
  103889. */
  103890. updateOptions(options: ISoundOptions): void;
  103891. private _createSpatialParameters;
  103892. private _updateSpatialParameters;
  103893. /**
  103894. * Switch the panning model to HRTF:
  103895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103897. */
  103898. switchPanningModelToHRTF(): void;
  103899. /**
  103900. * Switch the panning model to Equal Power:
  103901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103903. */
  103904. switchPanningModelToEqualPower(): void;
  103905. private _switchPanningModel;
  103906. /**
  103907. * Connect this sound to a sound track audio node like gain...
  103908. * @param soundTrackAudioNode the sound track audio node to connect to
  103909. */
  103910. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103911. /**
  103912. * Transform this sound into a directional source
  103913. * @param coneInnerAngle Size of the inner cone in degree
  103914. * @param coneOuterAngle Size of the outer cone in degree
  103915. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103916. */
  103917. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103918. /**
  103919. * Gets or sets the inner angle for the directional cone.
  103920. */
  103921. /**
  103922. * Gets or sets the inner angle for the directional cone.
  103923. */
  103924. directionalConeInnerAngle: number;
  103925. /**
  103926. * Gets or sets the outer angle for the directional cone.
  103927. */
  103928. /**
  103929. * Gets or sets the outer angle for the directional cone.
  103930. */
  103931. directionalConeOuterAngle: number;
  103932. /**
  103933. * Sets the position of the emitter if spatial sound is enabled
  103934. * @param newPosition Defines the new posisiton
  103935. */
  103936. setPosition(newPosition: Vector3): void;
  103937. /**
  103938. * Sets the local direction of the emitter if spatial sound is enabled
  103939. * @param newLocalDirection Defines the new local direction
  103940. */
  103941. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103942. private _updateDirection;
  103943. /** @hidden */
  103944. updateDistanceFromListener(): void;
  103945. /**
  103946. * Sets a new custom attenuation function for the sound.
  103947. * @param callback Defines the function used for the attenuation
  103948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103949. */
  103950. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103951. /**
  103952. * Play the sound
  103953. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103954. * @param offset (optional) Start the sound at a specific time in seconds
  103955. * @param length (optional) Sound duration (in seconds)
  103956. */
  103957. play(time?: number, offset?: number, length?: number): void;
  103958. private _onended;
  103959. /**
  103960. * Stop the sound
  103961. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103962. */
  103963. stop(time?: number): void;
  103964. /**
  103965. * Put the sound in pause
  103966. */
  103967. pause(): void;
  103968. /**
  103969. * Sets a dedicated volume for this sounds
  103970. * @param newVolume Define the new volume of the sound
  103971. * @param time Define time for gradual change to new volume
  103972. */
  103973. setVolume(newVolume: number, time?: number): void;
  103974. /**
  103975. * Set the sound play back rate
  103976. * @param newPlaybackRate Define the playback rate the sound should be played at
  103977. */
  103978. setPlaybackRate(newPlaybackRate: number): void;
  103979. /**
  103980. * Gets the volume of the sound.
  103981. * @returns the volume of the sound
  103982. */
  103983. getVolume(): number;
  103984. /**
  103985. * Attach the sound to a dedicated mesh
  103986. * @param transformNode The transform node to connect the sound with
  103987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103988. */
  103989. attachToMesh(transformNode: TransformNode): void;
  103990. /**
  103991. * Detach the sound from the previously attached mesh
  103992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103993. */
  103994. detachFromMesh(): void;
  103995. private _onRegisterAfterWorldMatrixUpdate;
  103996. /**
  103997. * Clone the current sound in the scene.
  103998. * @returns the new sound clone
  103999. */
  104000. clone(): Nullable<Sound>;
  104001. /**
  104002. * Gets the current underlying audio buffer containing the data
  104003. * @returns the audio buffer
  104004. */
  104005. getAudioBuffer(): Nullable<AudioBuffer>;
  104006. /**
  104007. * Serializes the Sound in a JSON representation
  104008. * @returns the JSON representation of the sound
  104009. */
  104010. serialize(): any;
  104011. /**
  104012. * Parse a JSON representation of a sound to innstantiate in a given scene
  104013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  104014. * @param scene Define the scene the new parsed sound should be created in
  104015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  104016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  104017. * @returns the newly parsed sound
  104018. */
  104019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  104020. }
  104021. }
  104022. declare module BABYLON {
  104023. /**
  104024. * This defines an action helpful to play a defined sound on a triggered action.
  104025. */
  104026. export class PlaySoundAction extends Action {
  104027. private _sound;
  104028. /**
  104029. * Instantiate the action
  104030. * @param triggerOptions defines the trigger options
  104031. * @param sound defines the sound to play
  104032. * @param condition defines the trigger related conditions
  104033. */
  104034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104035. /** @hidden */
  104036. _prepare(): void;
  104037. /**
  104038. * Execute the action and play the sound.
  104039. */
  104040. execute(): void;
  104041. /**
  104042. * Serializes the actions and its related information.
  104043. * @param parent defines the object to serialize in
  104044. * @returns the serialized object
  104045. */
  104046. serialize(parent: any): any;
  104047. }
  104048. /**
  104049. * This defines an action helpful to stop a defined sound on a triggered action.
  104050. */
  104051. export class StopSoundAction extends Action {
  104052. private _sound;
  104053. /**
  104054. * Instantiate the action
  104055. * @param triggerOptions defines the trigger options
  104056. * @param sound defines the sound to stop
  104057. * @param condition defines the trigger related conditions
  104058. */
  104059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104060. /** @hidden */
  104061. _prepare(): void;
  104062. /**
  104063. * Execute the action and stop the sound.
  104064. */
  104065. execute(): void;
  104066. /**
  104067. * Serializes the actions and its related information.
  104068. * @param parent defines the object to serialize in
  104069. * @returns the serialized object
  104070. */
  104071. serialize(parent: any): any;
  104072. }
  104073. }
  104074. declare module BABYLON {
  104075. /**
  104076. * This defines an action responsible to change the value of a property
  104077. * by interpolating between its current value and the newly set one once triggered.
  104078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104079. */
  104080. export class InterpolateValueAction extends Action {
  104081. /**
  104082. * Defines the path of the property where the value should be interpolated
  104083. */
  104084. propertyPath: string;
  104085. /**
  104086. * Defines the target value at the end of the interpolation.
  104087. */
  104088. value: any;
  104089. /**
  104090. * Defines the time it will take for the property to interpolate to the value.
  104091. */
  104092. duration: number;
  104093. /**
  104094. * Defines if the other scene animations should be stopped when the action has been triggered
  104095. */
  104096. stopOtherAnimations?: boolean;
  104097. /**
  104098. * Defines a callback raised once the interpolation animation has been done.
  104099. */
  104100. onInterpolationDone?: () => void;
  104101. /**
  104102. * Observable triggered once the interpolation animation has been done.
  104103. */
  104104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104105. private _target;
  104106. private _effectiveTarget;
  104107. private _property;
  104108. /**
  104109. * Instantiate the action
  104110. * @param triggerOptions defines the trigger options
  104111. * @param target defines the object containing the value to interpolate
  104112. * @param propertyPath defines the path to the property in the target object
  104113. * @param value defines the target value at the end of the interpolation
  104114. * @param duration deines the time it will take for the property to interpolate to the value.
  104115. * @param condition defines the trigger related conditions
  104116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104118. */
  104119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104120. /** @hidden */
  104121. _prepare(): void;
  104122. /**
  104123. * Execute the action starts the value interpolation.
  104124. */
  104125. execute(): void;
  104126. /**
  104127. * Serializes the actions and its related information.
  104128. * @param parent defines the object to serialize in
  104129. * @returns the serialized object
  104130. */
  104131. serialize(parent: any): any;
  104132. }
  104133. }
  104134. declare module BABYLON {
  104135. /**
  104136. * Options allowed during the creation of a sound track.
  104137. */
  104138. export interface ISoundTrackOptions {
  104139. /**
  104140. * The volume the sound track should take during creation
  104141. */
  104142. volume?: number;
  104143. /**
  104144. * Define if the sound track is the main sound track of the scene
  104145. */
  104146. mainTrack?: boolean;
  104147. }
  104148. /**
  104149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104150. * It will be also used in a future release to apply effects on a specific track.
  104151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104152. */
  104153. export class SoundTrack {
  104154. /**
  104155. * The unique identifier of the sound track in the scene.
  104156. */
  104157. id: number;
  104158. /**
  104159. * The list of sounds included in the sound track.
  104160. */
  104161. soundCollection: Array<Sound>;
  104162. private _outputAudioNode;
  104163. private _scene;
  104164. private _connectedAnalyser;
  104165. private _options;
  104166. private _isInitialized;
  104167. /**
  104168. * Creates a new sound track.
  104169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104170. * @param scene Define the scene the sound track belongs to
  104171. * @param options
  104172. */
  104173. constructor(scene: Scene, options?: ISoundTrackOptions);
  104174. private _initializeSoundTrackAudioGraph;
  104175. /**
  104176. * Release the sound track and its associated resources
  104177. */
  104178. dispose(): void;
  104179. /**
  104180. * Adds a sound to this sound track
  104181. * @param sound define the cound to add
  104182. * @ignoreNaming
  104183. */
  104184. AddSound(sound: Sound): void;
  104185. /**
  104186. * Removes a sound to this sound track
  104187. * @param sound define the cound to remove
  104188. * @ignoreNaming
  104189. */
  104190. RemoveSound(sound: Sound): void;
  104191. /**
  104192. * Set a global volume for the full sound track.
  104193. * @param newVolume Define the new volume of the sound track
  104194. */
  104195. setVolume(newVolume: number): void;
  104196. /**
  104197. * Switch the panning model to HRTF:
  104198. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104200. */
  104201. switchPanningModelToHRTF(): void;
  104202. /**
  104203. * Switch the panning model to Equal Power:
  104204. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104206. */
  104207. switchPanningModelToEqualPower(): void;
  104208. /**
  104209. * Connect the sound track to an audio analyser allowing some amazing
  104210. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104212. * @param analyser The analyser to connect to the engine
  104213. */
  104214. connectToAnalyser(analyser: Analyser): void;
  104215. }
  104216. }
  104217. declare module BABYLON {
  104218. interface AbstractScene {
  104219. /**
  104220. * The list of sounds used in the scene.
  104221. */
  104222. sounds: Nullable<Array<Sound>>;
  104223. }
  104224. interface Scene {
  104225. /**
  104226. * @hidden
  104227. * Backing field
  104228. */
  104229. _mainSoundTrack: SoundTrack;
  104230. /**
  104231. * The main sound track played by the scene.
  104232. * It cotains your primary collection of sounds.
  104233. */
  104234. mainSoundTrack: SoundTrack;
  104235. /**
  104236. * The list of sound tracks added to the scene
  104237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104238. */
  104239. soundTracks: Nullable<Array<SoundTrack>>;
  104240. /**
  104241. * Gets a sound using a given name
  104242. * @param name defines the name to search for
  104243. * @return the found sound or null if not found at all.
  104244. */
  104245. getSoundByName(name: string): Nullable<Sound>;
  104246. /**
  104247. * Gets or sets if audio support is enabled
  104248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104249. */
  104250. audioEnabled: boolean;
  104251. /**
  104252. * Gets or sets if audio will be output to headphones
  104253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104254. */
  104255. headphone: boolean;
  104256. /**
  104257. * Gets or sets custom audio listener position provider
  104258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104259. */
  104260. audioListenerPositionProvider: Nullable<() => Vector3>;
  104261. /**
  104262. * Gets or sets a refresh rate when using 3D audio positioning
  104263. */
  104264. audioPositioningRefreshRate: number;
  104265. }
  104266. /**
  104267. * Defines the sound scene component responsible to manage any sounds
  104268. * in a given scene.
  104269. */
  104270. export class AudioSceneComponent implements ISceneSerializableComponent {
  104271. /**
  104272. * The component name helpfull to identify the component in the list of scene components.
  104273. */
  104274. readonly name: string;
  104275. /**
  104276. * The scene the component belongs to.
  104277. */
  104278. scene: Scene;
  104279. private _audioEnabled;
  104280. /**
  104281. * Gets whether audio is enabled or not.
  104282. * Please use related enable/disable method to switch state.
  104283. */
  104284. readonly audioEnabled: boolean;
  104285. private _headphone;
  104286. /**
  104287. * Gets whether audio is outputing to headphone or not.
  104288. * Please use the according Switch methods to change output.
  104289. */
  104290. readonly headphone: boolean;
  104291. /**
  104292. * Gets or sets a refresh rate when using 3D audio positioning
  104293. */
  104294. audioPositioningRefreshRate: number;
  104295. private _audioListenerPositionProvider;
  104296. /**
  104297. * Gets the current audio listener position provider
  104298. */
  104299. /**
  104300. * Sets a custom listener position for all sounds in the scene
  104301. * By default, this is the position of the first active camera
  104302. */
  104303. audioListenerPositionProvider: Nullable<() => Vector3>;
  104304. /**
  104305. * Creates a new instance of the component for the given scene
  104306. * @param scene Defines the scene to register the component in
  104307. */
  104308. constructor(scene: Scene);
  104309. /**
  104310. * Registers the component in a given scene
  104311. */
  104312. register(): void;
  104313. /**
  104314. * Rebuilds the elements related to this component in case of
  104315. * context lost for instance.
  104316. */
  104317. rebuild(): void;
  104318. /**
  104319. * Serializes the component data to the specified json object
  104320. * @param serializationObject The object to serialize to
  104321. */
  104322. serialize(serializationObject: any): void;
  104323. /**
  104324. * Adds all the elements from the container to the scene
  104325. * @param container the container holding the elements
  104326. */
  104327. addFromContainer(container: AbstractScene): void;
  104328. /**
  104329. * Removes all the elements in the container from the scene
  104330. * @param container contains the elements to remove
  104331. * @param dispose if the removed element should be disposed (default: false)
  104332. */
  104333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104334. /**
  104335. * Disposes the component and the associated ressources.
  104336. */
  104337. dispose(): void;
  104338. /**
  104339. * Disables audio in the associated scene.
  104340. */
  104341. disableAudio(): void;
  104342. /**
  104343. * Enables audio in the associated scene.
  104344. */
  104345. enableAudio(): void;
  104346. /**
  104347. * Switch audio to headphone output.
  104348. */
  104349. switchAudioModeForHeadphones(): void;
  104350. /**
  104351. * Switch audio to normal speakers.
  104352. */
  104353. switchAudioModeForNormalSpeakers(): void;
  104354. private _cachedCameraDirection;
  104355. private _cachedCameraPosition;
  104356. private _lastCheck;
  104357. private _afterRender;
  104358. }
  104359. }
  104360. declare module BABYLON {
  104361. /**
  104362. * Wraps one or more Sound objects and selects one with random weight for playback.
  104363. */
  104364. export class WeightedSound {
  104365. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104366. loop: boolean;
  104367. private _coneInnerAngle;
  104368. private _coneOuterAngle;
  104369. private _volume;
  104370. /** A Sound is currently playing. */
  104371. isPlaying: boolean;
  104372. /** A Sound is currently paused. */
  104373. isPaused: boolean;
  104374. private _sounds;
  104375. private _weights;
  104376. private _currentIndex?;
  104377. /**
  104378. * Creates a new WeightedSound from the list of sounds given.
  104379. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104380. * @param sounds Array of Sounds that will be selected from.
  104381. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104382. */
  104383. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104384. /**
  104385. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104386. */
  104387. /**
  104388. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104389. */
  104390. directionalConeInnerAngle: number;
  104391. /**
  104392. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104393. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104394. */
  104395. /**
  104396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104398. */
  104399. directionalConeOuterAngle: number;
  104400. /**
  104401. * Playback volume.
  104402. */
  104403. /**
  104404. * Playback volume.
  104405. */
  104406. volume: number;
  104407. private _onended;
  104408. /**
  104409. * Suspend playback
  104410. */
  104411. pause(): void;
  104412. /**
  104413. * Stop playback
  104414. */
  104415. stop(): void;
  104416. /**
  104417. * Start playback.
  104418. * @param startOffset Position the clip head at a specific time in seconds.
  104419. */
  104420. play(startOffset?: number): void;
  104421. }
  104422. }
  104423. declare module BABYLON {
  104424. /**
  104425. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104427. */
  104428. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104429. /**
  104430. * Gets the name of the behavior.
  104431. */
  104432. readonly name: string;
  104433. /**
  104434. * The easing function used by animations
  104435. */
  104436. static EasingFunction: BackEase;
  104437. /**
  104438. * The easing mode used by animations
  104439. */
  104440. static EasingMode: number;
  104441. /**
  104442. * The duration of the animation, in milliseconds
  104443. */
  104444. transitionDuration: number;
  104445. /**
  104446. * Length of the distance animated by the transition when lower radius is reached
  104447. */
  104448. lowerRadiusTransitionRange: number;
  104449. /**
  104450. * Length of the distance animated by the transition when upper radius is reached
  104451. */
  104452. upperRadiusTransitionRange: number;
  104453. private _autoTransitionRange;
  104454. /**
  104455. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104456. */
  104457. /**
  104458. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104459. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104460. */
  104461. autoTransitionRange: boolean;
  104462. private _attachedCamera;
  104463. private _onAfterCheckInputsObserver;
  104464. private _onMeshTargetChangedObserver;
  104465. /**
  104466. * Initializes the behavior.
  104467. */
  104468. init(): void;
  104469. /**
  104470. * Attaches the behavior to its arc rotate camera.
  104471. * @param camera Defines the camera to attach the behavior to
  104472. */
  104473. attach(camera: ArcRotateCamera): void;
  104474. /**
  104475. * Detaches the behavior from its current arc rotate camera.
  104476. */
  104477. detach(): void;
  104478. private _radiusIsAnimating;
  104479. private _radiusBounceTransition;
  104480. private _animatables;
  104481. private _cachedWheelPrecision;
  104482. /**
  104483. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104484. * @param radiusLimit The limit to check against.
  104485. * @return Bool to indicate if at limit.
  104486. */
  104487. private _isRadiusAtLimit;
  104488. /**
  104489. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104490. * @param radiusDelta The delta by which to animate to. Can be negative.
  104491. */
  104492. private _applyBoundRadiusAnimation;
  104493. /**
  104494. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104495. */
  104496. protected _clearAnimationLocks(): void;
  104497. /**
  104498. * Stops and removes all animations that have been applied to the camera
  104499. */
  104500. stopAllAnimations(): void;
  104501. }
  104502. }
  104503. declare module BABYLON {
  104504. /**
  104505. * 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.
  104506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104507. */
  104508. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104509. /**
  104510. * Gets the name of the behavior.
  104511. */
  104512. readonly name: string;
  104513. private _mode;
  104514. private _radiusScale;
  104515. private _positionScale;
  104516. private _defaultElevation;
  104517. private _elevationReturnTime;
  104518. private _elevationReturnWaitTime;
  104519. private _zoomStopsAnimation;
  104520. private _framingTime;
  104521. /**
  104522. * The easing function used by animations
  104523. */
  104524. static EasingFunction: ExponentialEase;
  104525. /**
  104526. * The easing mode used by animations
  104527. */
  104528. static EasingMode: number;
  104529. /**
  104530. * Sets the current mode used by the behavior
  104531. */
  104532. /**
  104533. * Gets current mode used by the behavior.
  104534. */
  104535. mode: number;
  104536. /**
  104537. * Sets the scale applied to the radius (1 by default)
  104538. */
  104539. /**
  104540. * Gets the scale applied to the radius
  104541. */
  104542. radiusScale: number;
  104543. /**
  104544. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104545. */
  104546. /**
  104547. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104548. */
  104549. positionScale: number;
  104550. /**
  104551. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104552. * behaviour is triggered, in radians.
  104553. */
  104554. /**
  104555. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104556. * behaviour is triggered, in radians.
  104557. */
  104558. defaultElevation: number;
  104559. /**
  104560. * Sets the time (in milliseconds) taken to return to the default beta position.
  104561. * Negative value indicates camera should not return to default.
  104562. */
  104563. /**
  104564. * Gets the time (in milliseconds) taken to return to the default beta position.
  104565. * Negative value indicates camera should not return to default.
  104566. */
  104567. elevationReturnTime: number;
  104568. /**
  104569. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104570. */
  104571. /**
  104572. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104573. */
  104574. elevationReturnWaitTime: number;
  104575. /**
  104576. * Sets the flag that indicates if user zooming should stop animation.
  104577. */
  104578. /**
  104579. * Gets the flag that indicates if user zooming should stop animation.
  104580. */
  104581. zoomStopsAnimation: boolean;
  104582. /**
  104583. * Sets the transition time when framing the mesh, in milliseconds
  104584. */
  104585. /**
  104586. * Gets the transition time when framing the mesh, in milliseconds
  104587. */
  104588. framingTime: number;
  104589. /**
  104590. * Define if the behavior should automatically change the configured
  104591. * camera limits and sensibilities.
  104592. */
  104593. autoCorrectCameraLimitsAndSensibility: boolean;
  104594. private _onPrePointerObservableObserver;
  104595. private _onAfterCheckInputsObserver;
  104596. private _onMeshTargetChangedObserver;
  104597. private _attachedCamera;
  104598. private _isPointerDown;
  104599. private _lastInteractionTime;
  104600. /**
  104601. * Initializes the behavior.
  104602. */
  104603. init(): void;
  104604. /**
  104605. * Attaches the behavior to its arc rotate camera.
  104606. * @param camera Defines the camera to attach the behavior to
  104607. */
  104608. attach(camera: ArcRotateCamera): void;
  104609. /**
  104610. * Detaches the behavior from its current arc rotate camera.
  104611. */
  104612. detach(): void;
  104613. private _animatables;
  104614. private _betaIsAnimating;
  104615. private _betaTransition;
  104616. private _radiusTransition;
  104617. private _vectorTransition;
  104618. /**
  104619. * Targets the given mesh and updates zoom level accordingly.
  104620. * @param mesh The mesh to target.
  104621. * @param radius Optional. If a cached radius position already exists, overrides default.
  104622. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104623. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104624. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104625. */
  104626. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104627. /**
  104628. * Targets the given mesh with its children and updates zoom level accordingly.
  104629. * @param mesh The mesh to target.
  104630. * @param radius Optional. If a cached radius position already exists, overrides default.
  104631. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104634. */
  104635. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104636. /**
  104637. * Targets the given meshes with their children and updates zoom level accordingly.
  104638. * @param meshes The mesh to target.
  104639. * @param radius Optional. If a cached radius position already exists, overrides default.
  104640. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104643. */
  104644. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104645. /**
  104646. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104647. * @param minimumWorld Determines the smaller position of the bounding box extend
  104648. * @param maximumWorld Determines the bigger position of the bounding box extend
  104649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104651. */
  104652. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104653. /**
  104654. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104655. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104656. * frustum width.
  104657. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104658. * to fully enclose the mesh in the viewing frustum.
  104659. */
  104660. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104661. /**
  104662. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104663. * is automatically returned to its default position (expected to be above ground plane).
  104664. */
  104665. private _maintainCameraAboveGround;
  104666. /**
  104667. * Returns the frustum slope based on the canvas ratio and camera FOV
  104668. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104669. */
  104670. private _getFrustumSlope;
  104671. /**
  104672. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104673. */
  104674. private _clearAnimationLocks;
  104675. /**
  104676. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104677. */
  104678. private _applyUserInteraction;
  104679. /**
  104680. * Stops and removes all animations that have been applied to the camera
  104681. */
  104682. stopAllAnimations(): void;
  104683. /**
  104684. * Gets a value indicating if the user is moving the camera
  104685. */
  104686. readonly isUserIsMoving: boolean;
  104687. /**
  104688. * The camera can move all the way towards the mesh.
  104689. */
  104690. static IgnoreBoundsSizeMode: number;
  104691. /**
  104692. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104693. */
  104694. static FitFrustumSidesMode: number;
  104695. }
  104696. }
  104697. declare module BABYLON {
  104698. /**
  104699. * Base class for Camera Pointer Inputs.
  104700. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104701. * for example usage.
  104702. */
  104703. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104704. /**
  104705. * Defines the camera the input is attached to.
  104706. */
  104707. abstract camera: Camera;
  104708. /**
  104709. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104710. */
  104711. protected _altKey: boolean;
  104712. protected _ctrlKey: boolean;
  104713. protected _metaKey: boolean;
  104714. protected _shiftKey: boolean;
  104715. /**
  104716. * Which mouse buttons were pressed at time of last mouse event.
  104717. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104718. */
  104719. protected _buttonsPressed: number;
  104720. /**
  104721. * Defines the buttons associated with the input to handle camera move.
  104722. */
  104723. buttons: number[];
  104724. /**
  104725. * Attach the input controls to a specific dom element to get the input from.
  104726. * @param element Defines the element the controls should be listened from
  104727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104728. */
  104729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104730. /**
  104731. * Detach the current controls from the specified dom element.
  104732. * @param element Defines the element to stop listening the inputs from
  104733. */
  104734. detachControl(element: Nullable<HTMLElement>): void;
  104735. /**
  104736. * Gets the class name of the current input.
  104737. * @returns the class name
  104738. */
  104739. getClassName(): string;
  104740. /**
  104741. * Get the friendly name associated with the input class.
  104742. * @returns the input friendly name
  104743. */
  104744. getSimpleName(): string;
  104745. /**
  104746. * Called on pointer POINTERDOUBLETAP event.
  104747. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104748. */
  104749. protected onDoubleTap(type: string): void;
  104750. /**
  104751. * Called on pointer POINTERMOVE event if only a single touch is active.
  104752. * Override this method to provide functionality.
  104753. */
  104754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104755. /**
  104756. * Called on pointer POINTERMOVE event if multiple touches are active.
  104757. * Override this method to provide functionality.
  104758. */
  104759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104760. /**
  104761. * Called on JS contextmenu event.
  104762. * Override this method to provide functionality.
  104763. */
  104764. protected onContextMenu(evt: PointerEvent): void;
  104765. /**
  104766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104767. * press.
  104768. * Override this method to provide functionality.
  104769. */
  104770. protected onButtonDown(evt: PointerEvent): void;
  104771. /**
  104772. * Called each time a new POINTERUP event occurs. Ie, for each button
  104773. * release.
  104774. * Override this method to provide functionality.
  104775. */
  104776. protected onButtonUp(evt: PointerEvent): void;
  104777. /**
  104778. * Called when window becomes inactive.
  104779. * Override this method to provide functionality.
  104780. */
  104781. protected onLostFocus(): void;
  104782. private _pointerInput;
  104783. private _observer;
  104784. private _onLostFocus;
  104785. private pointA;
  104786. private pointB;
  104787. }
  104788. }
  104789. declare module BABYLON {
  104790. /**
  104791. * Manage the pointers inputs to control an arc rotate camera.
  104792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104793. */
  104794. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104795. /**
  104796. * Defines the camera the input is attached to.
  104797. */
  104798. camera: ArcRotateCamera;
  104799. /**
  104800. * Gets the class name of the current input.
  104801. * @returns the class name
  104802. */
  104803. getClassName(): string;
  104804. /**
  104805. * Defines the buttons associated with the input to handle camera move.
  104806. */
  104807. buttons: number[];
  104808. /**
  104809. * Defines the pointer angular sensibility along the X axis or how fast is
  104810. * the camera rotating.
  104811. */
  104812. angularSensibilityX: number;
  104813. /**
  104814. * Defines the pointer angular sensibility along the Y axis or how fast is
  104815. * the camera rotating.
  104816. */
  104817. angularSensibilityY: number;
  104818. /**
  104819. * Defines the pointer pinch precision or how fast is the camera zooming.
  104820. */
  104821. pinchPrecision: number;
  104822. /**
  104823. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104824. * from 0.
  104825. * It defines the percentage of current camera.radius to use as delta when
  104826. * pinch zoom is used.
  104827. */
  104828. pinchDeltaPercentage: number;
  104829. /**
  104830. * Defines the pointer panning sensibility or how fast is the camera moving.
  104831. */
  104832. panningSensibility: number;
  104833. /**
  104834. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104835. */
  104836. multiTouchPanning: boolean;
  104837. /**
  104838. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104839. * zoom (pinch) through multitouch.
  104840. */
  104841. multiTouchPanAndZoom: boolean;
  104842. /**
  104843. * Revers pinch action direction.
  104844. */
  104845. pinchInwards: boolean;
  104846. private _isPanClick;
  104847. private _twoFingerActivityCount;
  104848. private _isPinching;
  104849. /**
  104850. * Called on pointer POINTERMOVE event if only a single touch is active.
  104851. */
  104852. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104853. /**
  104854. * Called on pointer POINTERDOUBLETAP event.
  104855. */
  104856. protected onDoubleTap(type: string): void;
  104857. /**
  104858. * Called on pointer POINTERMOVE event if multiple touches are active.
  104859. */
  104860. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104861. /**
  104862. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104863. * press.
  104864. */
  104865. protected onButtonDown(evt: PointerEvent): void;
  104866. /**
  104867. * Called each time a new POINTERUP event occurs. Ie, for each button
  104868. * release.
  104869. */
  104870. protected onButtonUp(evt: PointerEvent): void;
  104871. /**
  104872. * Called when window becomes inactive.
  104873. */
  104874. protected onLostFocus(): void;
  104875. }
  104876. }
  104877. declare module BABYLON {
  104878. /**
  104879. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104881. */
  104882. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104883. /**
  104884. * Defines the camera the input is attached to.
  104885. */
  104886. camera: ArcRotateCamera;
  104887. /**
  104888. * Defines the list of key codes associated with the up action (increase alpha)
  104889. */
  104890. keysUp: number[];
  104891. /**
  104892. * Defines the list of key codes associated with the down action (decrease alpha)
  104893. */
  104894. keysDown: number[];
  104895. /**
  104896. * Defines the list of key codes associated with the left action (increase beta)
  104897. */
  104898. keysLeft: number[];
  104899. /**
  104900. * Defines the list of key codes associated with the right action (decrease beta)
  104901. */
  104902. keysRight: number[];
  104903. /**
  104904. * Defines the list of key codes associated with the reset action.
  104905. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104906. */
  104907. keysReset: number[];
  104908. /**
  104909. * Defines the panning sensibility of the inputs.
  104910. * (How fast is the camera paning)
  104911. */
  104912. panningSensibility: number;
  104913. /**
  104914. * Defines the zooming sensibility of the inputs.
  104915. * (How fast is the camera zooming)
  104916. */
  104917. zoomingSensibility: number;
  104918. /**
  104919. * Defines wether maintaining the alt key down switch the movement mode from
  104920. * orientation to zoom.
  104921. */
  104922. useAltToZoom: boolean;
  104923. /**
  104924. * Rotation speed of the camera
  104925. */
  104926. angularSpeed: number;
  104927. private _keys;
  104928. private _ctrlPressed;
  104929. private _altPressed;
  104930. private _onCanvasBlurObserver;
  104931. private _onKeyboardObserver;
  104932. private _engine;
  104933. private _scene;
  104934. /**
  104935. * Attach the input controls to a specific dom element to get the input from.
  104936. * @param element Defines the element the controls should be listened from
  104937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104938. */
  104939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104940. /**
  104941. * Detach the current controls from the specified dom element.
  104942. * @param element Defines the element to stop listening the inputs from
  104943. */
  104944. detachControl(element: Nullable<HTMLElement>): void;
  104945. /**
  104946. * Update the current camera state depending on the inputs that have been used this frame.
  104947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104948. */
  104949. checkInputs(): void;
  104950. /**
  104951. * Gets the class name of the current intput.
  104952. * @returns the class name
  104953. */
  104954. getClassName(): string;
  104955. /**
  104956. * Get the friendly name associated with the input class.
  104957. * @returns the input friendly name
  104958. */
  104959. getSimpleName(): string;
  104960. }
  104961. }
  104962. declare module BABYLON {
  104963. /**
  104964. * Manage the mouse wheel inputs to control an arc rotate camera.
  104965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104966. */
  104967. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104968. /**
  104969. * Defines the camera the input is attached to.
  104970. */
  104971. camera: ArcRotateCamera;
  104972. /**
  104973. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104974. */
  104975. wheelPrecision: number;
  104976. /**
  104977. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104978. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104979. */
  104980. wheelDeltaPercentage: number;
  104981. private _wheel;
  104982. private _observer;
  104983. private computeDeltaFromMouseWheelLegacyEvent;
  104984. /**
  104985. * Attach the input controls to a specific dom element to get the input from.
  104986. * @param element Defines the element the controls should be listened from
  104987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104988. */
  104989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104990. /**
  104991. * Detach the current controls from the specified dom element.
  104992. * @param element Defines the element to stop listening the inputs from
  104993. */
  104994. detachControl(element: Nullable<HTMLElement>): void;
  104995. /**
  104996. * Gets the class name of the current intput.
  104997. * @returns the class name
  104998. */
  104999. getClassName(): string;
  105000. /**
  105001. * Get the friendly name associated with the input class.
  105002. * @returns the input friendly name
  105003. */
  105004. getSimpleName(): string;
  105005. }
  105006. }
  105007. declare module BABYLON {
  105008. /**
  105009. * Default Inputs manager for the ArcRotateCamera.
  105010. * It groups all the default supported inputs for ease of use.
  105011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105012. */
  105013. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  105014. /**
  105015. * Instantiates a new ArcRotateCameraInputsManager.
  105016. * @param camera Defines the camera the inputs belong to
  105017. */
  105018. constructor(camera: ArcRotateCamera);
  105019. /**
  105020. * Add mouse wheel input support to the input manager.
  105021. * @returns the current input manager
  105022. */
  105023. addMouseWheel(): ArcRotateCameraInputsManager;
  105024. /**
  105025. * Add pointers input support to the input manager.
  105026. * @returns the current input manager
  105027. */
  105028. addPointers(): ArcRotateCameraInputsManager;
  105029. /**
  105030. * Add keyboard input support to the input manager.
  105031. * @returns the current input manager
  105032. */
  105033. addKeyboard(): ArcRotateCameraInputsManager;
  105034. }
  105035. }
  105036. declare module BABYLON {
  105037. /**
  105038. * This represents an orbital type of camera.
  105039. *
  105040. * 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.
  105041. * 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.
  105042. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  105043. */
  105044. export class ArcRotateCamera extends TargetCamera {
  105045. /**
  105046. * Defines the rotation angle of the camera along the longitudinal axis.
  105047. */
  105048. alpha: number;
  105049. /**
  105050. * Defines the rotation angle of the camera along the latitudinal axis.
  105051. */
  105052. beta: number;
  105053. /**
  105054. * Defines the radius of the camera from it s target point.
  105055. */
  105056. radius: number;
  105057. protected _target: Vector3;
  105058. protected _targetHost: Nullable<AbstractMesh>;
  105059. /**
  105060. * Defines the target point of the camera.
  105061. * The camera looks towards it form the radius distance.
  105062. */
  105063. target: Vector3;
  105064. /**
  105065. * Define the current local position of the camera in the scene
  105066. */
  105067. position: Vector3;
  105068. protected _upVector: Vector3;
  105069. protected _upToYMatrix: Matrix;
  105070. protected _YToUpMatrix: Matrix;
  105071. /**
  105072. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  105073. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  105074. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  105075. */
  105076. upVector: Vector3;
  105077. /**
  105078. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  105079. */
  105080. setMatUp(): void;
  105081. /**
  105082. * Current inertia value on the longitudinal axis.
  105083. * The bigger this number the longer it will take for the camera to stop.
  105084. */
  105085. inertialAlphaOffset: number;
  105086. /**
  105087. * Current inertia value on the latitudinal axis.
  105088. * The bigger this number the longer it will take for the camera to stop.
  105089. */
  105090. inertialBetaOffset: number;
  105091. /**
  105092. * Current inertia value on the radius axis.
  105093. * The bigger this number the longer it will take for the camera to stop.
  105094. */
  105095. inertialRadiusOffset: number;
  105096. /**
  105097. * Minimum allowed angle on the longitudinal axis.
  105098. * This can help limiting how the Camera is able to move in the scene.
  105099. */
  105100. lowerAlphaLimit: Nullable<number>;
  105101. /**
  105102. * Maximum allowed angle on the longitudinal axis.
  105103. * This can help limiting how the Camera is able to move in the scene.
  105104. */
  105105. upperAlphaLimit: Nullable<number>;
  105106. /**
  105107. * Minimum allowed angle on the latitudinal axis.
  105108. * This can help limiting how the Camera is able to move in the scene.
  105109. */
  105110. lowerBetaLimit: number;
  105111. /**
  105112. * Maximum allowed angle on the latitudinal axis.
  105113. * This can help limiting how the Camera is able to move in the scene.
  105114. */
  105115. upperBetaLimit: number;
  105116. /**
  105117. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105118. * This can help limiting how the Camera is able to move in the scene.
  105119. */
  105120. lowerRadiusLimit: Nullable<number>;
  105121. /**
  105122. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105123. * This can help limiting how the Camera is able to move in the scene.
  105124. */
  105125. upperRadiusLimit: Nullable<number>;
  105126. /**
  105127. * Defines the current inertia value used during panning of the camera along the X axis.
  105128. */
  105129. inertialPanningX: number;
  105130. /**
  105131. * Defines the current inertia value used during panning of the camera along the Y axis.
  105132. */
  105133. inertialPanningY: number;
  105134. /**
  105135. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105136. * Basically if your fingers moves away from more than this distance you will be considered
  105137. * in pinch mode.
  105138. */
  105139. pinchToPanMaxDistance: number;
  105140. /**
  105141. * Defines the maximum distance the camera can pan.
  105142. * This could help keeping the cammera always in your scene.
  105143. */
  105144. panningDistanceLimit: Nullable<number>;
  105145. /**
  105146. * Defines the target of the camera before paning.
  105147. */
  105148. panningOriginTarget: Vector3;
  105149. /**
  105150. * Defines the value of the inertia used during panning.
  105151. * 0 would mean stop inertia and one would mean no decelleration at all.
  105152. */
  105153. panningInertia: number;
  105154. /**
  105155. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105156. */
  105157. angularSensibilityX: number;
  105158. /**
  105159. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105160. */
  105161. angularSensibilityY: number;
  105162. /**
  105163. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105164. */
  105165. pinchPrecision: number;
  105166. /**
  105167. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105168. * It will be used instead of pinchDeltaPrecision if different from 0.
  105169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105170. */
  105171. pinchDeltaPercentage: number;
  105172. /**
  105173. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105174. */
  105175. panningSensibility: number;
  105176. /**
  105177. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105178. */
  105179. keysUp: number[];
  105180. /**
  105181. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105182. */
  105183. keysDown: number[];
  105184. /**
  105185. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105186. */
  105187. keysLeft: number[];
  105188. /**
  105189. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105190. */
  105191. keysRight: number[];
  105192. /**
  105193. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105194. */
  105195. wheelPrecision: number;
  105196. /**
  105197. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105198. * It will be used instead of pinchDeltaPrecision if different from 0.
  105199. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105200. */
  105201. wheelDeltaPercentage: number;
  105202. /**
  105203. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105204. */
  105205. zoomOnFactor: number;
  105206. /**
  105207. * Defines a screen offset for the camera position.
  105208. */
  105209. targetScreenOffset: Vector2;
  105210. /**
  105211. * Allows the camera to be completely reversed.
  105212. * If false the camera can not arrive upside down.
  105213. */
  105214. allowUpsideDown: boolean;
  105215. /**
  105216. * Define if double tap/click is used to restore the previously saved state of the camera.
  105217. */
  105218. useInputToRestoreState: boolean;
  105219. /** @hidden */
  105220. _viewMatrix: Matrix;
  105221. /** @hidden */
  105222. _useCtrlForPanning: boolean;
  105223. /** @hidden */
  105224. _panningMouseButton: number;
  105225. /**
  105226. * Defines the input associated to the camera.
  105227. */
  105228. inputs: ArcRotateCameraInputsManager;
  105229. /** @hidden */
  105230. _reset: () => void;
  105231. /**
  105232. * Defines the allowed panning axis.
  105233. */
  105234. panningAxis: Vector3;
  105235. protected _localDirection: Vector3;
  105236. protected _transformedDirection: Vector3;
  105237. private _bouncingBehavior;
  105238. /**
  105239. * Gets the bouncing behavior of the camera if it has been enabled.
  105240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105241. */
  105242. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105243. /**
  105244. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105245. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105246. */
  105247. useBouncingBehavior: boolean;
  105248. private _framingBehavior;
  105249. /**
  105250. * Gets the framing behavior of the camera if it has been enabled.
  105251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105252. */
  105253. readonly framingBehavior: Nullable<FramingBehavior>;
  105254. /**
  105255. * Defines if the framing behavior of the camera is enabled on the camera.
  105256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105257. */
  105258. useFramingBehavior: boolean;
  105259. private _autoRotationBehavior;
  105260. /**
  105261. * Gets the auto rotation behavior of the camera if it has been enabled.
  105262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105263. */
  105264. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105265. /**
  105266. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105268. */
  105269. useAutoRotationBehavior: boolean;
  105270. /**
  105271. * Observable triggered when the mesh target has been changed on the camera.
  105272. */
  105273. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105274. /**
  105275. * Event raised when the camera is colliding with a mesh.
  105276. */
  105277. onCollide: (collidedMesh: AbstractMesh) => void;
  105278. /**
  105279. * Defines whether the camera should check collision with the objects oh the scene.
  105280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105281. */
  105282. checkCollisions: boolean;
  105283. /**
  105284. * Defines the collision radius of the camera.
  105285. * This simulates a sphere around the camera.
  105286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105287. */
  105288. collisionRadius: Vector3;
  105289. protected _collider: Collider;
  105290. protected _previousPosition: Vector3;
  105291. protected _collisionVelocity: Vector3;
  105292. protected _newPosition: Vector3;
  105293. protected _previousAlpha: number;
  105294. protected _previousBeta: number;
  105295. protected _previousRadius: number;
  105296. protected _collisionTriggered: boolean;
  105297. protected _targetBoundingCenter: Nullable<Vector3>;
  105298. private _computationVector;
  105299. /**
  105300. * Instantiates a new ArcRotateCamera in a given scene
  105301. * @param name Defines the name of the camera
  105302. * @param alpha Defines the camera rotation along the logitudinal axis
  105303. * @param beta Defines the camera rotation along the latitudinal axis
  105304. * @param radius Defines the camera distance from its target
  105305. * @param target Defines the camera target
  105306. * @param scene Defines the scene the camera belongs to
  105307. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105308. */
  105309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105310. /** @hidden */
  105311. _initCache(): void;
  105312. /** @hidden */
  105313. _updateCache(ignoreParentClass?: boolean): void;
  105314. protected _getTargetPosition(): Vector3;
  105315. private _storedAlpha;
  105316. private _storedBeta;
  105317. private _storedRadius;
  105318. private _storedTarget;
  105319. private _storedTargetScreenOffset;
  105320. /**
  105321. * Stores the current state of the camera (alpha, beta, radius and target)
  105322. * @returns the camera itself
  105323. */
  105324. storeState(): Camera;
  105325. /**
  105326. * @hidden
  105327. * Restored camera state. You must call storeState() first
  105328. */
  105329. _restoreStateValues(): boolean;
  105330. /** @hidden */
  105331. _isSynchronizedViewMatrix(): boolean;
  105332. /**
  105333. * Attached controls to the current camera.
  105334. * @param element Defines the element the controls should be listened from
  105335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105336. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105337. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105338. */
  105339. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105340. /**
  105341. * Detach the current controls from the camera.
  105342. * The camera will stop reacting to inputs.
  105343. * @param element Defines the element to stop listening the inputs from
  105344. */
  105345. detachControl(element: HTMLElement): void;
  105346. /** @hidden */
  105347. _checkInputs(): void;
  105348. protected _checkLimits(): void;
  105349. /**
  105350. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105351. */
  105352. rebuildAnglesAndRadius(): void;
  105353. /**
  105354. * Use a position to define the current camera related information like alpha, beta and radius
  105355. * @param position Defines the position to set the camera at
  105356. */
  105357. setPosition(position: Vector3): void;
  105358. /**
  105359. * Defines the target the camera should look at.
  105360. * This will automatically adapt alpha beta and radius to fit within the new target.
  105361. * @param target Defines the new target as a Vector or a mesh
  105362. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105363. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105364. */
  105365. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105366. /** @hidden */
  105367. _getViewMatrix(): Matrix;
  105368. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105369. /**
  105370. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105371. * @param meshes Defines the mesh to zoom on
  105372. * @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)
  105373. */
  105374. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105375. /**
  105376. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105377. * The target will be changed but the radius
  105378. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105379. * @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)
  105380. */
  105381. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105382. min: Vector3;
  105383. max: Vector3;
  105384. distance: number;
  105385. }, doNotUpdateMaxZ?: boolean): void;
  105386. /**
  105387. * @override
  105388. * Override Camera.createRigCamera
  105389. */
  105390. createRigCamera(name: string, cameraIndex: number): Camera;
  105391. /**
  105392. * @hidden
  105393. * @override
  105394. * Override Camera._updateRigCameras
  105395. */
  105396. _updateRigCameras(): void;
  105397. /**
  105398. * Destroy the camera and release the current resources hold by it.
  105399. */
  105400. dispose(): void;
  105401. /**
  105402. * Gets the current object class name.
  105403. * @return the class name
  105404. */
  105405. getClassName(): string;
  105406. }
  105407. }
  105408. declare module BABYLON {
  105409. /**
  105410. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105412. */
  105413. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105414. /**
  105415. * Gets the name of the behavior.
  105416. */
  105417. readonly name: string;
  105418. private _zoomStopsAnimation;
  105419. private _idleRotationSpeed;
  105420. private _idleRotationWaitTime;
  105421. private _idleRotationSpinupTime;
  105422. /**
  105423. * Sets the flag that indicates if user zooming should stop animation.
  105424. */
  105425. /**
  105426. * Gets the flag that indicates if user zooming should stop animation.
  105427. */
  105428. zoomStopsAnimation: boolean;
  105429. /**
  105430. * Sets the default speed at which the camera rotates around the model.
  105431. */
  105432. /**
  105433. * Gets the default speed at which the camera rotates around the model.
  105434. */
  105435. idleRotationSpeed: number;
  105436. /**
  105437. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105438. */
  105439. /**
  105440. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105441. */
  105442. idleRotationWaitTime: number;
  105443. /**
  105444. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105445. */
  105446. /**
  105447. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105448. */
  105449. idleRotationSpinupTime: number;
  105450. /**
  105451. * Gets a value indicating if the camera is currently rotating because of this behavior
  105452. */
  105453. readonly rotationInProgress: boolean;
  105454. private _onPrePointerObservableObserver;
  105455. private _onAfterCheckInputsObserver;
  105456. private _attachedCamera;
  105457. private _isPointerDown;
  105458. private _lastFrameTime;
  105459. private _lastInteractionTime;
  105460. private _cameraRotationSpeed;
  105461. /**
  105462. * Initializes the behavior.
  105463. */
  105464. init(): void;
  105465. /**
  105466. * Attaches the behavior to its arc rotate camera.
  105467. * @param camera Defines the camera to attach the behavior to
  105468. */
  105469. attach(camera: ArcRotateCamera): void;
  105470. /**
  105471. * Detaches the behavior from its current arc rotate camera.
  105472. */
  105473. detach(): void;
  105474. /**
  105475. * Returns true if user is scrolling.
  105476. * @return true if user is scrolling.
  105477. */
  105478. private _userIsZooming;
  105479. private _lastFrameRadius;
  105480. private _shouldAnimationStopForInteraction;
  105481. /**
  105482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105483. */
  105484. private _applyUserInteraction;
  105485. private _userIsMoving;
  105486. }
  105487. }
  105488. declare module BABYLON {
  105489. /**
  105490. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105491. */
  105492. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105493. private ui;
  105494. /**
  105495. * The name of the behavior
  105496. */
  105497. name: string;
  105498. /**
  105499. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105500. */
  105501. distanceAwayFromFace: number;
  105502. /**
  105503. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105504. */
  105505. distanceAwayFromBottomOfFace: number;
  105506. private _faceVectors;
  105507. private _target;
  105508. private _scene;
  105509. private _onRenderObserver;
  105510. private _tmpMatrix;
  105511. private _tmpVector;
  105512. /**
  105513. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105514. * @param ui The transform node that should be attched to the mesh
  105515. */
  105516. constructor(ui: TransformNode);
  105517. /**
  105518. * Initializes the behavior
  105519. */
  105520. init(): void;
  105521. private _closestFace;
  105522. private _zeroVector;
  105523. private _lookAtTmpMatrix;
  105524. private _lookAtToRef;
  105525. /**
  105526. * Attaches the AttachToBoxBehavior to the passed in mesh
  105527. * @param target The mesh that the specified node will be attached to
  105528. */
  105529. attach(target: Mesh): void;
  105530. /**
  105531. * Detaches the behavior from the mesh
  105532. */
  105533. detach(): void;
  105534. }
  105535. }
  105536. declare module BABYLON {
  105537. /**
  105538. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105539. */
  105540. export class FadeInOutBehavior implements Behavior<Mesh> {
  105541. /**
  105542. * Time in milliseconds to delay before fading in (Default: 0)
  105543. */
  105544. delay: number;
  105545. /**
  105546. * Time in milliseconds for the mesh to fade in (Default: 300)
  105547. */
  105548. fadeInTime: number;
  105549. private _millisecondsPerFrame;
  105550. private _hovered;
  105551. private _hoverValue;
  105552. private _ownerNode;
  105553. /**
  105554. * Instatiates the FadeInOutBehavior
  105555. */
  105556. constructor();
  105557. /**
  105558. * The name of the behavior
  105559. */
  105560. readonly name: string;
  105561. /**
  105562. * Initializes the behavior
  105563. */
  105564. init(): void;
  105565. /**
  105566. * Attaches the fade behavior on the passed in mesh
  105567. * @param ownerNode The mesh that will be faded in/out once attached
  105568. */
  105569. attach(ownerNode: Mesh): void;
  105570. /**
  105571. * Detaches the behavior from the mesh
  105572. */
  105573. detach(): void;
  105574. /**
  105575. * Triggers the mesh to begin fading in or out
  105576. * @param value if the object should fade in or out (true to fade in)
  105577. */
  105578. fadeIn(value: boolean): void;
  105579. private _update;
  105580. private _setAllVisibility;
  105581. }
  105582. }
  105583. declare module BABYLON {
  105584. /**
  105585. * Class containing a set of static utilities functions for managing Pivots
  105586. * @hidden
  105587. */
  105588. export class PivotTools {
  105589. private static _PivotCached;
  105590. private static _OldPivotPoint;
  105591. private static _PivotTranslation;
  105592. private static _PivotTmpVector;
  105593. /** @hidden */
  105594. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105595. /** @hidden */
  105596. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105597. }
  105598. }
  105599. declare module BABYLON {
  105600. /**
  105601. * Class containing static functions to help procedurally build meshes
  105602. */
  105603. export class PlaneBuilder {
  105604. /**
  105605. * Creates a plane mesh
  105606. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105607. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105608. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105612. * @param name defines the name of the mesh
  105613. * @param options defines the options used to create the mesh
  105614. * @param scene defines the hosting scene
  105615. * @returns the plane mesh
  105616. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105617. */
  105618. static CreatePlane(name: string, options: {
  105619. size?: number;
  105620. width?: number;
  105621. height?: number;
  105622. sideOrientation?: number;
  105623. frontUVs?: Vector4;
  105624. backUVs?: Vector4;
  105625. updatable?: boolean;
  105626. sourcePlane?: Plane;
  105627. }, scene?: Nullable<Scene>): Mesh;
  105628. }
  105629. }
  105630. declare module BABYLON {
  105631. /**
  105632. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105633. */
  105634. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105635. private static _AnyMouseID;
  105636. /**
  105637. * Abstract mesh the behavior is set on
  105638. */
  105639. attachedNode: AbstractMesh;
  105640. private _dragPlane;
  105641. private _scene;
  105642. private _pointerObserver;
  105643. private _beforeRenderObserver;
  105644. private static _planeScene;
  105645. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105646. /**
  105647. * 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)
  105648. */
  105649. maxDragAngle: number;
  105650. /**
  105651. * @hidden
  105652. */
  105653. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105654. /**
  105655. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105656. */
  105657. currentDraggingPointerID: number;
  105658. /**
  105659. * The last position where the pointer hit the drag plane in world space
  105660. */
  105661. lastDragPosition: Vector3;
  105662. /**
  105663. * If the behavior is currently in a dragging state
  105664. */
  105665. dragging: boolean;
  105666. /**
  105667. * 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)
  105668. */
  105669. dragDeltaRatio: number;
  105670. /**
  105671. * If the drag plane orientation should be updated during the dragging (Default: true)
  105672. */
  105673. updateDragPlane: boolean;
  105674. private _debugMode;
  105675. private _moving;
  105676. /**
  105677. * Fires each time the attached mesh is dragged with the pointer
  105678. * * delta between last drag position and current drag position in world space
  105679. * * dragDistance along the drag axis
  105680. * * dragPlaneNormal normal of the current drag plane used during the drag
  105681. * * dragPlanePoint in world space where the drag intersects the drag plane
  105682. */
  105683. onDragObservable: Observable<{
  105684. delta: Vector3;
  105685. dragPlanePoint: Vector3;
  105686. dragPlaneNormal: Vector3;
  105687. dragDistance: number;
  105688. pointerId: number;
  105689. }>;
  105690. /**
  105691. * Fires each time a drag begins (eg. mouse down on mesh)
  105692. */
  105693. onDragStartObservable: Observable<{
  105694. dragPlanePoint: Vector3;
  105695. pointerId: number;
  105696. }>;
  105697. /**
  105698. * Fires each time a drag ends (eg. mouse release after drag)
  105699. */
  105700. onDragEndObservable: Observable<{
  105701. dragPlanePoint: Vector3;
  105702. pointerId: number;
  105703. }>;
  105704. /**
  105705. * If the attached mesh should be moved when dragged
  105706. */
  105707. moveAttached: boolean;
  105708. /**
  105709. * If the drag behavior will react to drag events (Default: true)
  105710. */
  105711. enabled: boolean;
  105712. /**
  105713. * If pointer events should start and release the drag (Default: true)
  105714. */
  105715. startAndReleaseDragOnPointerEvents: boolean;
  105716. /**
  105717. * If camera controls should be detached during the drag
  105718. */
  105719. detachCameraControls: boolean;
  105720. /**
  105721. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105722. */
  105723. useObjectOrienationForDragging: boolean;
  105724. private _options;
  105725. /**
  105726. * Creates a pointer drag behavior that can be attached to a mesh
  105727. * @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)
  105728. */
  105729. constructor(options?: {
  105730. dragAxis?: Vector3;
  105731. dragPlaneNormal?: Vector3;
  105732. });
  105733. /**
  105734. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105735. */
  105736. validateDrag: (targetPosition: Vector3) => boolean;
  105737. /**
  105738. * The name of the behavior
  105739. */
  105740. readonly name: string;
  105741. /**
  105742. * Initializes the behavior
  105743. */
  105744. init(): void;
  105745. private _tmpVector;
  105746. private _alternatePickedPoint;
  105747. private _worldDragAxis;
  105748. private _targetPosition;
  105749. private _attachedElement;
  105750. /**
  105751. * Attaches the drag behavior the passed in mesh
  105752. * @param ownerNode The mesh that will be dragged around once attached
  105753. * @param predicate Predicate to use for pick filtering
  105754. */
  105755. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105756. /**
  105757. * Force relase the drag action by code.
  105758. */
  105759. releaseDrag(): void;
  105760. private _startDragRay;
  105761. private _lastPointerRay;
  105762. /**
  105763. * Simulates the start of a pointer drag event on the behavior
  105764. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105765. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105766. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105767. */
  105768. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105769. private _startDrag;
  105770. private _dragDelta;
  105771. private _moveDrag;
  105772. private _pickWithRayOnDragPlane;
  105773. private _pointA;
  105774. private _pointB;
  105775. private _pointC;
  105776. private _lineA;
  105777. private _lineB;
  105778. private _localAxis;
  105779. private _lookAt;
  105780. private _updateDragPlanePosition;
  105781. /**
  105782. * Detaches the behavior from the mesh
  105783. */
  105784. detach(): void;
  105785. }
  105786. }
  105787. declare module BABYLON {
  105788. /**
  105789. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105790. */
  105791. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105792. private _dragBehaviorA;
  105793. private _dragBehaviorB;
  105794. private _startDistance;
  105795. private _initialScale;
  105796. private _targetScale;
  105797. private _ownerNode;
  105798. private _sceneRenderObserver;
  105799. /**
  105800. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105801. */
  105802. constructor();
  105803. /**
  105804. * The name of the behavior
  105805. */
  105806. readonly name: string;
  105807. /**
  105808. * Initializes the behavior
  105809. */
  105810. init(): void;
  105811. private _getCurrentDistance;
  105812. /**
  105813. * Attaches the scale behavior the passed in mesh
  105814. * @param ownerNode The mesh that will be scaled around once attached
  105815. */
  105816. attach(ownerNode: Mesh): void;
  105817. /**
  105818. * Detaches the behavior from the mesh
  105819. */
  105820. detach(): void;
  105821. }
  105822. }
  105823. declare module BABYLON {
  105824. /**
  105825. * 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
  105826. */
  105827. export class SixDofDragBehavior implements Behavior<Mesh> {
  105828. private static _virtualScene;
  105829. private _ownerNode;
  105830. private _sceneRenderObserver;
  105831. private _scene;
  105832. private _targetPosition;
  105833. private _virtualOriginMesh;
  105834. private _virtualDragMesh;
  105835. private _pointerObserver;
  105836. private _moving;
  105837. private _startingOrientation;
  105838. /**
  105839. * 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)
  105840. */
  105841. private zDragFactor;
  105842. /**
  105843. * If the object should rotate to face the drag origin
  105844. */
  105845. rotateDraggedObject: boolean;
  105846. /**
  105847. * If the behavior is currently in a dragging state
  105848. */
  105849. dragging: boolean;
  105850. /**
  105851. * 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)
  105852. */
  105853. dragDeltaRatio: number;
  105854. /**
  105855. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105856. */
  105857. currentDraggingPointerID: number;
  105858. /**
  105859. * If camera controls should be detached during the drag
  105860. */
  105861. detachCameraControls: boolean;
  105862. /**
  105863. * Fires each time a drag starts
  105864. */
  105865. onDragStartObservable: Observable<{}>;
  105866. /**
  105867. * Fires each time a drag ends (eg. mouse release after drag)
  105868. */
  105869. onDragEndObservable: Observable<{}>;
  105870. /**
  105871. * 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
  105872. */
  105873. constructor();
  105874. /**
  105875. * The name of the behavior
  105876. */
  105877. readonly name: string;
  105878. /**
  105879. * Initializes the behavior
  105880. */
  105881. init(): void;
  105882. /**
  105883. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105884. */
  105885. private readonly _pointerCamera;
  105886. /**
  105887. * Attaches the scale behavior the passed in mesh
  105888. * @param ownerNode The mesh that will be scaled around once attached
  105889. */
  105890. attach(ownerNode: Mesh): void;
  105891. /**
  105892. * Detaches the behavior from the mesh
  105893. */
  105894. detach(): void;
  105895. }
  105896. }
  105897. declare module BABYLON {
  105898. /**
  105899. * Class used to apply inverse kinematics to bones
  105900. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105901. */
  105902. export class BoneIKController {
  105903. private static _tmpVecs;
  105904. private static _tmpQuat;
  105905. private static _tmpMats;
  105906. /**
  105907. * Gets or sets the target mesh
  105908. */
  105909. targetMesh: AbstractMesh;
  105910. /** Gets or sets the mesh used as pole */
  105911. poleTargetMesh: AbstractMesh;
  105912. /**
  105913. * Gets or sets the bone used as pole
  105914. */
  105915. poleTargetBone: Nullable<Bone>;
  105916. /**
  105917. * Gets or sets the target position
  105918. */
  105919. targetPosition: Vector3;
  105920. /**
  105921. * Gets or sets the pole target position
  105922. */
  105923. poleTargetPosition: Vector3;
  105924. /**
  105925. * Gets or sets the pole target local offset
  105926. */
  105927. poleTargetLocalOffset: Vector3;
  105928. /**
  105929. * Gets or sets the pole angle
  105930. */
  105931. poleAngle: number;
  105932. /**
  105933. * Gets or sets the mesh associated with the controller
  105934. */
  105935. mesh: AbstractMesh;
  105936. /**
  105937. * 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)
  105938. */
  105939. slerpAmount: number;
  105940. private _bone1Quat;
  105941. private _bone1Mat;
  105942. private _bone2Ang;
  105943. private _bone1;
  105944. private _bone2;
  105945. private _bone1Length;
  105946. private _bone2Length;
  105947. private _maxAngle;
  105948. private _maxReach;
  105949. private _rightHandedSystem;
  105950. private _bendAxis;
  105951. private _slerping;
  105952. private _adjustRoll;
  105953. /**
  105954. * Gets or sets maximum allowed angle
  105955. */
  105956. maxAngle: number;
  105957. /**
  105958. * Creates a new BoneIKController
  105959. * @param mesh defines the mesh to control
  105960. * @param bone defines the bone to control
  105961. * @param options defines options to set up the controller
  105962. */
  105963. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105964. targetMesh?: AbstractMesh;
  105965. poleTargetMesh?: AbstractMesh;
  105966. poleTargetBone?: Bone;
  105967. poleTargetLocalOffset?: Vector3;
  105968. poleAngle?: number;
  105969. bendAxis?: Vector3;
  105970. maxAngle?: number;
  105971. slerpAmount?: number;
  105972. });
  105973. private _setMaxAngle;
  105974. /**
  105975. * Force the controller to update the bones
  105976. */
  105977. update(): void;
  105978. }
  105979. }
  105980. declare module BABYLON {
  105981. /**
  105982. * Class used to make a bone look toward a point in space
  105983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105984. */
  105985. export class BoneLookController {
  105986. private static _tmpVecs;
  105987. private static _tmpQuat;
  105988. private static _tmpMats;
  105989. /**
  105990. * The target Vector3 that the bone will look at
  105991. */
  105992. target: Vector3;
  105993. /**
  105994. * The mesh that the bone is attached to
  105995. */
  105996. mesh: AbstractMesh;
  105997. /**
  105998. * The bone that will be looking to the target
  105999. */
  106000. bone: Bone;
  106001. /**
  106002. * The up axis of the coordinate system that is used when the bone is rotated
  106003. */
  106004. upAxis: Vector3;
  106005. /**
  106006. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  106007. */
  106008. upAxisSpace: Space;
  106009. /**
  106010. * Used to make an adjustment to the yaw of the bone
  106011. */
  106012. adjustYaw: number;
  106013. /**
  106014. * Used to make an adjustment to the pitch of the bone
  106015. */
  106016. adjustPitch: number;
  106017. /**
  106018. * Used to make an adjustment to the roll of the bone
  106019. */
  106020. adjustRoll: number;
  106021. /**
  106022. * 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)
  106023. */
  106024. slerpAmount: number;
  106025. private _minYaw;
  106026. private _maxYaw;
  106027. private _minPitch;
  106028. private _maxPitch;
  106029. private _minYawSin;
  106030. private _minYawCos;
  106031. private _maxYawSin;
  106032. private _maxYawCos;
  106033. private _midYawConstraint;
  106034. private _minPitchTan;
  106035. private _maxPitchTan;
  106036. private _boneQuat;
  106037. private _slerping;
  106038. private _transformYawPitch;
  106039. private _transformYawPitchInv;
  106040. private _firstFrameSkipped;
  106041. private _yawRange;
  106042. private _fowardAxis;
  106043. /**
  106044. * Gets or sets the minimum yaw angle that the bone can look to
  106045. */
  106046. minYaw: number;
  106047. /**
  106048. * Gets or sets the maximum yaw angle that the bone can look to
  106049. */
  106050. maxYaw: number;
  106051. /**
  106052. * Gets or sets the minimum pitch angle that the bone can look to
  106053. */
  106054. minPitch: number;
  106055. /**
  106056. * Gets or sets the maximum pitch angle that the bone can look to
  106057. */
  106058. maxPitch: number;
  106059. /**
  106060. * Create a BoneLookController
  106061. * @param mesh the mesh that the bone belongs to
  106062. * @param bone the bone that will be looking to the target
  106063. * @param target the target Vector3 to look at
  106064. * @param options optional settings:
  106065. * * maxYaw: the maximum angle the bone will yaw to
  106066. * * minYaw: the minimum angle the bone will yaw to
  106067. * * maxPitch: the maximum angle the bone will pitch to
  106068. * * minPitch: the minimum angle the bone will yaw to
  106069. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  106070. * * upAxis: the up axis of the coordinate system
  106071. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  106072. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  106073. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  106074. * * adjustYaw: used to make an adjustment to the yaw of the bone
  106075. * * adjustPitch: used to make an adjustment to the pitch of the bone
  106076. * * adjustRoll: used to make an adjustment to the roll of the bone
  106077. **/
  106078. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  106079. maxYaw?: number;
  106080. minYaw?: number;
  106081. maxPitch?: number;
  106082. minPitch?: number;
  106083. slerpAmount?: number;
  106084. upAxis?: Vector3;
  106085. upAxisSpace?: Space;
  106086. yawAxis?: Vector3;
  106087. pitchAxis?: Vector3;
  106088. adjustYaw?: number;
  106089. adjustPitch?: number;
  106090. adjustRoll?: number;
  106091. });
  106092. /**
  106093. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106094. */
  106095. update(): void;
  106096. private _getAngleDiff;
  106097. private _getAngleBetween;
  106098. private _isAngleBetween;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. /**
  106103. * Manage the gamepad inputs to control an arc rotate camera.
  106104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106105. */
  106106. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106107. /**
  106108. * Defines the camera the input is attached to.
  106109. */
  106110. camera: ArcRotateCamera;
  106111. /**
  106112. * Defines the gamepad the input is gathering event from.
  106113. */
  106114. gamepad: Nullable<Gamepad>;
  106115. /**
  106116. * Defines the gamepad rotation sensiblity.
  106117. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106118. */
  106119. gamepadRotationSensibility: number;
  106120. /**
  106121. * Defines the gamepad move sensiblity.
  106122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106123. */
  106124. gamepadMoveSensibility: number;
  106125. private _yAxisScale;
  106126. /**
  106127. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106128. */
  106129. invertYAxis: boolean;
  106130. private _onGamepadConnectedObserver;
  106131. private _onGamepadDisconnectedObserver;
  106132. /**
  106133. * Attach the input controls to a specific dom element to get the input from.
  106134. * @param element Defines the element the controls should be listened from
  106135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106136. */
  106137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106138. /**
  106139. * Detach the current controls from the specified dom element.
  106140. * @param element Defines the element to stop listening the inputs from
  106141. */
  106142. detachControl(element: Nullable<HTMLElement>): void;
  106143. /**
  106144. * Update the current camera state depending on the inputs that have been used this frame.
  106145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106146. */
  106147. checkInputs(): void;
  106148. /**
  106149. * Gets the class name of the current intput.
  106150. * @returns the class name
  106151. */
  106152. getClassName(): string;
  106153. /**
  106154. * Get the friendly name associated with the input class.
  106155. * @returns the input friendly name
  106156. */
  106157. getSimpleName(): string;
  106158. }
  106159. }
  106160. declare module BABYLON {
  106161. interface ArcRotateCameraInputsManager {
  106162. /**
  106163. * Add orientation input support to the input manager.
  106164. * @returns the current input manager
  106165. */
  106166. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106167. }
  106168. /**
  106169. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106171. */
  106172. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106173. /**
  106174. * Defines the camera the input is attached to.
  106175. */
  106176. camera: ArcRotateCamera;
  106177. /**
  106178. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106179. */
  106180. alphaCorrection: number;
  106181. /**
  106182. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106183. */
  106184. gammaCorrection: number;
  106185. private _alpha;
  106186. private _gamma;
  106187. private _dirty;
  106188. private _deviceOrientationHandler;
  106189. /**
  106190. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106191. */
  106192. constructor();
  106193. /**
  106194. * Attach the input controls to a specific dom element to get the input from.
  106195. * @param element Defines the element the controls should be listened from
  106196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106197. */
  106198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106199. /** @hidden */
  106200. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106201. /**
  106202. * Update the current camera state depending on the inputs that have been used this frame.
  106203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106204. */
  106205. checkInputs(): void;
  106206. /**
  106207. * Detach the current controls from the specified dom element.
  106208. * @param element Defines the element to stop listening the inputs from
  106209. */
  106210. detachControl(element: Nullable<HTMLElement>): void;
  106211. /**
  106212. * Gets the class name of the current intput.
  106213. * @returns the class name
  106214. */
  106215. getClassName(): string;
  106216. /**
  106217. * Get the friendly name associated with the input class.
  106218. * @returns the input friendly name
  106219. */
  106220. getSimpleName(): string;
  106221. }
  106222. }
  106223. declare module BABYLON {
  106224. /**
  106225. * Listen to mouse events to control the camera.
  106226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106227. */
  106228. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106229. /**
  106230. * Defines the camera the input is attached to.
  106231. */
  106232. camera: FlyCamera;
  106233. /**
  106234. * Defines if touch is enabled. (Default is true.)
  106235. */
  106236. touchEnabled: boolean;
  106237. /**
  106238. * Defines the buttons associated with the input to handle camera rotation.
  106239. */
  106240. buttons: number[];
  106241. /**
  106242. * Assign buttons for Yaw control.
  106243. */
  106244. buttonsYaw: number[];
  106245. /**
  106246. * Assign buttons for Pitch control.
  106247. */
  106248. buttonsPitch: number[];
  106249. /**
  106250. * Assign buttons for Roll control.
  106251. */
  106252. buttonsRoll: number[];
  106253. /**
  106254. * Detect if any button is being pressed while mouse is moved.
  106255. * -1 = Mouse locked.
  106256. * 0 = Left button.
  106257. * 1 = Middle Button.
  106258. * 2 = Right Button.
  106259. */
  106260. activeButton: number;
  106261. /**
  106262. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106263. * Higher values reduce its sensitivity.
  106264. */
  106265. angularSensibility: number;
  106266. private _mousemoveCallback;
  106267. private _observer;
  106268. private _rollObserver;
  106269. private previousPosition;
  106270. private noPreventDefault;
  106271. private element;
  106272. /**
  106273. * Listen to mouse events to control the camera.
  106274. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106276. */
  106277. constructor(touchEnabled?: boolean);
  106278. /**
  106279. * Attach the mouse control to the HTML DOM element.
  106280. * @param element Defines the element that listens to the input events.
  106281. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106282. */
  106283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106284. /**
  106285. * Detach the current controls from the specified dom element.
  106286. * @param element Defines the element to stop listening the inputs from
  106287. */
  106288. detachControl(element: Nullable<HTMLElement>): void;
  106289. /**
  106290. * Gets the class name of the current input.
  106291. * @returns the class name.
  106292. */
  106293. getClassName(): string;
  106294. /**
  106295. * Get the friendly name associated with the input class.
  106296. * @returns the input's friendly name.
  106297. */
  106298. getSimpleName(): string;
  106299. private _pointerInput;
  106300. private _onMouseMove;
  106301. /**
  106302. * Rotate camera by mouse offset.
  106303. */
  106304. private rotateCamera;
  106305. }
  106306. }
  106307. declare module BABYLON {
  106308. /**
  106309. * Default Inputs manager for the FlyCamera.
  106310. * It groups all the default supported inputs for ease of use.
  106311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106312. */
  106313. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106314. /**
  106315. * Instantiates a new FlyCameraInputsManager.
  106316. * @param camera Defines the camera the inputs belong to.
  106317. */
  106318. constructor(camera: FlyCamera);
  106319. /**
  106320. * Add keyboard input support to the input manager.
  106321. * @returns the new FlyCameraKeyboardMoveInput().
  106322. */
  106323. addKeyboard(): FlyCameraInputsManager;
  106324. /**
  106325. * Add mouse input support to the input manager.
  106326. * @param touchEnabled Enable touch screen support.
  106327. * @returns the new FlyCameraMouseInput().
  106328. */
  106329. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106330. }
  106331. }
  106332. declare module BABYLON {
  106333. /**
  106334. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106335. * such as in a 3D Space Shooter or a Flight Simulator.
  106336. */
  106337. export class FlyCamera extends TargetCamera {
  106338. /**
  106339. * Define the collision ellipsoid of the camera.
  106340. * This is helpful for simulating a camera body, like a player's body.
  106341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106342. */
  106343. ellipsoid: Vector3;
  106344. /**
  106345. * Define an offset for the position of the ellipsoid around the camera.
  106346. * This can be helpful if the camera is attached away from the player's body center,
  106347. * such as at its head.
  106348. */
  106349. ellipsoidOffset: Vector3;
  106350. /**
  106351. * Enable or disable collisions of the camera with the rest of the scene objects.
  106352. */
  106353. checkCollisions: boolean;
  106354. /**
  106355. * Enable or disable gravity on the camera.
  106356. */
  106357. applyGravity: boolean;
  106358. /**
  106359. * Define the current direction the camera is moving to.
  106360. */
  106361. cameraDirection: Vector3;
  106362. /**
  106363. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106364. * This overrides and empties cameraRotation.
  106365. */
  106366. rotationQuaternion: Quaternion;
  106367. /**
  106368. * Track Roll to maintain the wanted Rolling when looking around.
  106369. */
  106370. _trackRoll: number;
  106371. /**
  106372. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106373. */
  106374. rollCorrect: number;
  106375. /**
  106376. * Mimic a banked turn, Rolling the camera when Yawing.
  106377. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106378. */
  106379. bankedTurn: boolean;
  106380. /**
  106381. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106382. */
  106383. bankedTurnLimit: number;
  106384. /**
  106385. * Value of 0 disables the banked Roll.
  106386. * Value of 1 is equal to the Yaw angle in radians.
  106387. */
  106388. bankedTurnMultiplier: number;
  106389. /**
  106390. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106391. */
  106392. inputs: FlyCameraInputsManager;
  106393. /**
  106394. * Gets the input sensibility for mouse input.
  106395. * Higher values reduce sensitivity.
  106396. */
  106397. /**
  106398. * Sets the input sensibility for a mouse input.
  106399. * Higher values reduce sensitivity.
  106400. */
  106401. angularSensibility: number;
  106402. /**
  106403. * Get the keys for camera movement forward.
  106404. */
  106405. /**
  106406. * Set the keys for camera movement forward.
  106407. */
  106408. keysForward: number[];
  106409. /**
  106410. * Get the keys for camera movement backward.
  106411. */
  106412. keysBackward: number[];
  106413. /**
  106414. * Get the keys for camera movement up.
  106415. */
  106416. /**
  106417. * Set the keys for camera movement up.
  106418. */
  106419. keysUp: number[];
  106420. /**
  106421. * Get the keys for camera movement down.
  106422. */
  106423. /**
  106424. * Set the keys for camera movement down.
  106425. */
  106426. keysDown: number[];
  106427. /**
  106428. * Get the keys for camera movement left.
  106429. */
  106430. /**
  106431. * Set the keys for camera movement left.
  106432. */
  106433. keysLeft: number[];
  106434. /**
  106435. * Set the keys for camera movement right.
  106436. */
  106437. /**
  106438. * Set the keys for camera movement right.
  106439. */
  106440. keysRight: number[];
  106441. /**
  106442. * Event raised when the camera collides with a mesh in the scene.
  106443. */
  106444. onCollide: (collidedMesh: AbstractMesh) => void;
  106445. private _collider;
  106446. private _needMoveForGravity;
  106447. private _oldPosition;
  106448. private _diffPosition;
  106449. private _newPosition;
  106450. /** @hidden */
  106451. _localDirection: Vector3;
  106452. /** @hidden */
  106453. _transformedDirection: Vector3;
  106454. /**
  106455. * Instantiates a FlyCamera.
  106456. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106457. * such as in a 3D Space Shooter or a Flight Simulator.
  106458. * @param name Define the name of the camera in the scene.
  106459. * @param position Define the starting position of the camera in the scene.
  106460. * @param scene Define the scene the camera belongs to.
  106461. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106462. */
  106463. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106464. /**
  106465. * Attach a control to the HTML DOM element.
  106466. * @param element Defines the element that listens to the input events.
  106467. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106468. */
  106469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106470. /**
  106471. * Detach a control from the HTML DOM element.
  106472. * The camera will stop reacting to that input.
  106473. * @param element Defines the element that listens to the input events.
  106474. */
  106475. detachControl(element: HTMLElement): void;
  106476. private _collisionMask;
  106477. /**
  106478. * Get the mask that the camera ignores in collision events.
  106479. */
  106480. /**
  106481. * Set the mask that the camera ignores in collision events.
  106482. */
  106483. collisionMask: number;
  106484. /** @hidden */
  106485. _collideWithWorld(displacement: Vector3): void;
  106486. /** @hidden */
  106487. private _onCollisionPositionChange;
  106488. /** @hidden */
  106489. _checkInputs(): void;
  106490. /** @hidden */
  106491. _decideIfNeedsToMove(): boolean;
  106492. /** @hidden */
  106493. _updatePosition(): void;
  106494. /**
  106495. * Restore the Roll to its target value at the rate specified.
  106496. * @param rate - Higher means slower restoring.
  106497. * @hidden
  106498. */
  106499. restoreRoll(rate: number): void;
  106500. /**
  106501. * Destroy the camera and release the current resources held by it.
  106502. */
  106503. dispose(): void;
  106504. /**
  106505. * Get the current object class name.
  106506. * @returns the class name.
  106507. */
  106508. getClassName(): string;
  106509. }
  106510. }
  106511. declare module BABYLON {
  106512. /**
  106513. * Listen to keyboard events to control the camera.
  106514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106515. */
  106516. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106517. /**
  106518. * Defines the camera the input is attached to.
  106519. */
  106520. camera: FlyCamera;
  106521. /**
  106522. * The list of keyboard keys used to control the forward move of the camera.
  106523. */
  106524. keysForward: number[];
  106525. /**
  106526. * The list of keyboard keys used to control the backward move of the camera.
  106527. */
  106528. keysBackward: number[];
  106529. /**
  106530. * The list of keyboard keys used to control the forward move of the camera.
  106531. */
  106532. keysUp: number[];
  106533. /**
  106534. * The list of keyboard keys used to control the backward move of the camera.
  106535. */
  106536. keysDown: number[];
  106537. /**
  106538. * The list of keyboard keys used to control the right strafe move of the camera.
  106539. */
  106540. keysRight: number[];
  106541. /**
  106542. * The list of keyboard keys used to control the left strafe move of the camera.
  106543. */
  106544. keysLeft: number[];
  106545. private _keys;
  106546. private _onCanvasBlurObserver;
  106547. private _onKeyboardObserver;
  106548. private _engine;
  106549. private _scene;
  106550. /**
  106551. * Attach the input controls to a specific dom element to get the input from.
  106552. * @param element Defines the element the controls should be listened from
  106553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106554. */
  106555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106556. /**
  106557. * Detach the current controls from the specified dom element.
  106558. * @param element Defines the element to stop listening the inputs from
  106559. */
  106560. detachControl(element: Nullable<HTMLElement>): void;
  106561. /**
  106562. * Gets the class name of the current intput.
  106563. * @returns the class name
  106564. */
  106565. getClassName(): string;
  106566. /** @hidden */
  106567. _onLostFocus(e: FocusEvent): void;
  106568. /**
  106569. * Get the friendly name associated with the input class.
  106570. * @returns the input friendly name
  106571. */
  106572. getSimpleName(): string;
  106573. /**
  106574. * Update the current camera state depending on the inputs that have been used this frame.
  106575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106576. */
  106577. checkInputs(): void;
  106578. }
  106579. }
  106580. declare module BABYLON {
  106581. /**
  106582. * Manage the mouse wheel inputs to control a follow camera.
  106583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106584. */
  106585. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106586. /**
  106587. * Defines the camera the input is attached to.
  106588. */
  106589. camera: FollowCamera;
  106590. /**
  106591. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106592. */
  106593. axisControlRadius: boolean;
  106594. /**
  106595. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106596. */
  106597. axisControlHeight: boolean;
  106598. /**
  106599. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106600. */
  106601. axisControlRotation: boolean;
  106602. /**
  106603. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106604. * relation to mouseWheel events.
  106605. */
  106606. wheelPrecision: number;
  106607. /**
  106608. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106609. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106610. */
  106611. wheelDeltaPercentage: number;
  106612. private _wheel;
  106613. private _observer;
  106614. /**
  106615. * Attach the input controls to a specific dom element to get the input from.
  106616. * @param element Defines the element the controls should be listened from
  106617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106618. */
  106619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106620. /**
  106621. * Detach the current controls from the specified dom element.
  106622. * @param element Defines the element to stop listening the inputs from
  106623. */
  106624. detachControl(element: Nullable<HTMLElement>): void;
  106625. /**
  106626. * Gets the class name of the current intput.
  106627. * @returns the class name
  106628. */
  106629. getClassName(): string;
  106630. /**
  106631. * Get the friendly name associated with the input class.
  106632. * @returns the input friendly name
  106633. */
  106634. getSimpleName(): string;
  106635. }
  106636. }
  106637. declare module BABYLON {
  106638. /**
  106639. * Manage the pointers inputs to control an follow camera.
  106640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106641. */
  106642. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106643. /**
  106644. * Defines the camera the input is attached to.
  106645. */
  106646. camera: FollowCamera;
  106647. /**
  106648. * Gets the class name of the current input.
  106649. * @returns the class name
  106650. */
  106651. getClassName(): string;
  106652. /**
  106653. * Defines the pointer angular sensibility along the X axis or how fast is
  106654. * the camera rotating.
  106655. * A negative number will reverse the axis direction.
  106656. */
  106657. angularSensibilityX: number;
  106658. /**
  106659. * Defines the pointer angular sensibility along the Y axis or how fast is
  106660. * the camera rotating.
  106661. * A negative number will reverse the axis direction.
  106662. */
  106663. angularSensibilityY: number;
  106664. /**
  106665. * Defines the pointer pinch precision or how fast is the camera zooming.
  106666. * A negative number will reverse the axis direction.
  106667. */
  106668. pinchPrecision: number;
  106669. /**
  106670. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106671. * from 0.
  106672. * It defines the percentage of current camera.radius to use as delta when
  106673. * pinch zoom is used.
  106674. */
  106675. pinchDeltaPercentage: number;
  106676. /**
  106677. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106678. */
  106679. axisXControlRadius: boolean;
  106680. /**
  106681. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106682. */
  106683. axisXControlHeight: boolean;
  106684. /**
  106685. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106686. */
  106687. axisXControlRotation: boolean;
  106688. /**
  106689. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106690. */
  106691. axisYControlRadius: boolean;
  106692. /**
  106693. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106694. */
  106695. axisYControlHeight: boolean;
  106696. /**
  106697. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106698. */
  106699. axisYControlRotation: boolean;
  106700. /**
  106701. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106702. */
  106703. axisPinchControlRadius: boolean;
  106704. /**
  106705. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106706. */
  106707. axisPinchControlHeight: boolean;
  106708. /**
  106709. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106710. */
  106711. axisPinchControlRotation: boolean;
  106712. /**
  106713. * Log error messages if basic misconfiguration has occurred.
  106714. */
  106715. warningEnable: boolean;
  106716. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106717. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106718. private _warningCounter;
  106719. private _warning;
  106720. }
  106721. }
  106722. declare module BABYLON {
  106723. /**
  106724. * Default Inputs manager for the FollowCamera.
  106725. * It groups all the default supported inputs for ease of use.
  106726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106727. */
  106728. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106729. /**
  106730. * Instantiates a new FollowCameraInputsManager.
  106731. * @param camera Defines the camera the inputs belong to
  106732. */
  106733. constructor(camera: FollowCamera);
  106734. /**
  106735. * Add keyboard input support to the input manager.
  106736. * @returns the current input manager
  106737. */
  106738. addKeyboard(): FollowCameraInputsManager;
  106739. /**
  106740. * Add mouse wheel input support to the input manager.
  106741. * @returns the current input manager
  106742. */
  106743. addMouseWheel(): FollowCameraInputsManager;
  106744. /**
  106745. * Add pointers input support to the input manager.
  106746. * @returns the current input manager
  106747. */
  106748. addPointers(): FollowCameraInputsManager;
  106749. /**
  106750. * Add orientation input support to the input manager.
  106751. * @returns the current input manager
  106752. */
  106753. addVRDeviceOrientation(): FollowCameraInputsManager;
  106754. }
  106755. }
  106756. declare module BABYLON {
  106757. /**
  106758. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106759. * an arc rotate version arcFollowCamera are available.
  106760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106761. */
  106762. export class FollowCamera extends TargetCamera {
  106763. /**
  106764. * Distance the follow camera should follow an object at
  106765. */
  106766. radius: number;
  106767. /**
  106768. * Minimum allowed distance of the camera to the axis of rotation
  106769. * (The camera can not get closer).
  106770. * This can help limiting how the Camera is able to move in the scene.
  106771. */
  106772. lowerRadiusLimit: Nullable<number>;
  106773. /**
  106774. * Maximum allowed distance of the camera to the axis of rotation
  106775. * (The camera can not get further).
  106776. * This can help limiting how the Camera is able to move in the scene.
  106777. */
  106778. upperRadiusLimit: Nullable<number>;
  106779. /**
  106780. * Define a rotation offset between the camera and the object it follows
  106781. */
  106782. rotationOffset: number;
  106783. /**
  106784. * Minimum allowed angle to camera position relative to target object.
  106785. * This can help limiting how the Camera is able to move in the scene.
  106786. */
  106787. lowerRotationOffsetLimit: Nullable<number>;
  106788. /**
  106789. * Maximum allowed angle to camera position relative to target object.
  106790. * This can help limiting how the Camera is able to move in the scene.
  106791. */
  106792. upperRotationOffsetLimit: Nullable<number>;
  106793. /**
  106794. * Define a height offset between the camera and the object it follows.
  106795. * It can help following an object from the top (like a car chaing a plane)
  106796. */
  106797. heightOffset: number;
  106798. /**
  106799. * Minimum allowed height of camera position relative to target object.
  106800. * This can help limiting how the Camera is able to move in the scene.
  106801. */
  106802. lowerHeightOffsetLimit: Nullable<number>;
  106803. /**
  106804. * Maximum allowed height of camera position relative to target object.
  106805. * This can help limiting how the Camera is able to move in the scene.
  106806. */
  106807. upperHeightOffsetLimit: Nullable<number>;
  106808. /**
  106809. * Define how fast the camera can accelerate to follow it s target.
  106810. */
  106811. cameraAcceleration: number;
  106812. /**
  106813. * Define the speed limit of the camera following an object.
  106814. */
  106815. maxCameraSpeed: number;
  106816. /**
  106817. * Define the target of the camera.
  106818. */
  106819. lockedTarget: Nullable<AbstractMesh>;
  106820. /**
  106821. * Defines the input associated with the camera.
  106822. */
  106823. inputs: FollowCameraInputsManager;
  106824. /**
  106825. * Instantiates the follow camera.
  106826. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106827. * @param name Define the name of the camera in the scene
  106828. * @param position Define the position of the camera
  106829. * @param scene Define the scene the camera belong to
  106830. * @param lockedTarget Define the target of the camera
  106831. */
  106832. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106833. private _follow;
  106834. /**
  106835. * Attached controls to the current camera.
  106836. * @param element Defines the element the controls should be listened from
  106837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106838. */
  106839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106840. /**
  106841. * Detach the current controls from the camera.
  106842. * The camera will stop reacting to inputs.
  106843. * @param element Defines the element to stop listening the inputs from
  106844. */
  106845. detachControl(element: HTMLElement): void;
  106846. /** @hidden */
  106847. _checkInputs(): void;
  106848. private _checkLimits;
  106849. /**
  106850. * Gets the camera class name.
  106851. * @returns the class name
  106852. */
  106853. getClassName(): string;
  106854. }
  106855. /**
  106856. * Arc Rotate version of the follow camera.
  106857. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106858. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106859. */
  106860. export class ArcFollowCamera extends TargetCamera {
  106861. /** The longitudinal angle of the camera */
  106862. alpha: number;
  106863. /** The latitudinal angle of the camera */
  106864. beta: number;
  106865. /** The radius of the camera from its target */
  106866. radius: number;
  106867. /** Define the camera target (the messh it should follow) */
  106868. target: Nullable<AbstractMesh>;
  106869. private _cartesianCoordinates;
  106870. /**
  106871. * Instantiates a new ArcFollowCamera
  106872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106873. * @param name Define the name of the camera
  106874. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106875. * @param beta Define the rotation angle of the camera around the elevation axis
  106876. * @param radius Define the radius of the camera from its target point
  106877. * @param target Define the target of the camera
  106878. * @param scene Define the scene the camera belongs to
  106879. */
  106880. constructor(name: string,
  106881. /** The longitudinal angle of the camera */
  106882. alpha: number,
  106883. /** The latitudinal angle of the camera */
  106884. beta: number,
  106885. /** The radius of the camera from its target */
  106886. radius: number,
  106887. /** Define the camera target (the messh it should follow) */
  106888. target: Nullable<AbstractMesh>, scene: Scene);
  106889. private _follow;
  106890. /** @hidden */
  106891. _checkInputs(): void;
  106892. /**
  106893. * Returns the class name of the object.
  106894. * It is mostly used internally for serialization purposes.
  106895. */
  106896. getClassName(): string;
  106897. }
  106898. }
  106899. declare module BABYLON {
  106900. /**
  106901. * Manage the keyboard inputs to control the movement of a follow camera.
  106902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106903. */
  106904. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106905. /**
  106906. * Defines the camera the input is attached to.
  106907. */
  106908. camera: FollowCamera;
  106909. /**
  106910. * Defines the list of key codes associated with the up action (increase heightOffset)
  106911. */
  106912. keysHeightOffsetIncr: number[];
  106913. /**
  106914. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106915. */
  106916. keysHeightOffsetDecr: number[];
  106917. /**
  106918. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106919. */
  106920. keysHeightOffsetModifierAlt: boolean;
  106921. /**
  106922. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106923. */
  106924. keysHeightOffsetModifierCtrl: boolean;
  106925. /**
  106926. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106927. */
  106928. keysHeightOffsetModifierShift: boolean;
  106929. /**
  106930. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106931. */
  106932. keysRotationOffsetIncr: number[];
  106933. /**
  106934. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106935. */
  106936. keysRotationOffsetDecr: number[];
  106937. /**
  106938. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106939. */
  106940. keysRotationOffsetModifierAlt: boolean;
  106941. /**
  106942. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106943. */
  106944. keysRotationOffsetModifierCtrl: boolean;
  106945. /**
  106946. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106947. */
  106948. keysRotationOffsetModifierShift: boolean;
  106949. /**
  106950. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106951. */
  106952. keysRadiusIncr: number[];
  106953. /**
  106954. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106955. */
  106956. keysRadiusDecr: number[];
  106957. /**
  106958. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106959. */
  106960. keysRadiusModifierAlt: boolean;
  106961. /**
  106962. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106963. */
  106964. keysRadiusModifierCtrl: boolean;
  106965. /**
  106966. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106967. */
  106968. keysRadiusModifierShift: boolean;
  106969. /**
  106970. * Defines the rate of change of heightOffset.
  106971. */
  106972. heightSensibility: number;
  106973. /**
  106974. * Defines the rate of change of rotationOffset.
  106975. */
  106976. rotationSensibility: number;
  106977. /**
  106978. * Defines the rate of change of radius.
  106979. */
  106980. radiusSensibility: number;
  106981. private _keys;
  106982. private _ctrlPressed;
  106983. private _altPressed;
  106984. private _shiftPressed;
  106985. private _onCanvasBlurObserver;
  106986. private _onKeyboardObserver;
  106987. private _engine;
  106988. private _scene;
  106989. /**
  106990. * Attach the input controls to a specific dom element to get the input from.
  106991. * @param element Defines the element the controls should be listened from
  106992. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106993. */
  106994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106995. /**
  106996. * Detach the current controls from the specified dom element.
  106997. * @param element Defines the element to stop listening the inputs from
  106998. */
  106999. detachControl(element: Nullable<HTMLElement>): void;
  107000. /**
  107001. * Update the current camera state depending on the inputs that have been used this frame.
  107002. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107003. */
  107004. checkInputs(): void;
  107005. /**
  107006. * Gets the class name of the current input.
  107007. * @returns the class name
  107008. */
  107009. getClassName(): string;
  107010. /**
  107011. * Get the friendly name associated with the input class.
  107012. * @returns the input friendly name
  107013. */
  107014. getSimpleName(): string;
  107015. /**
  107016. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107017. * allow modification of the heightOffset value.
  107018. */
  107019. private _modifierHeightOffset;
  107020. /**
  107021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107022. * allow modification of the rotationOffset value.
  107023. */
  107024. private _modifierRotationOffset;
  107025. /**
  107026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107027. * allow modification of the radius value.
  107028. */
  107029. private _modifierRadius;
  107030. }
  107031. }
  107032. declare module BABYLON {
  107033. interface FreeCameraInputsManager {
  107034. /**
  107035. * @hidden
  107036. */
  107037. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  107038. /**
  107039. * Add orientation input support to the input manager.
  107040. * @returns the current input manager
  107041. */
  107042. addDeviceOrientation(): FreeCameraInputsManager;
  107043. }
  107044. /**
  107045. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  107046. * Screen rotation is taken into account.
  107047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107048. */
  107049. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  107050. private _camera;
  107051. private _screenOrientationAngle;
  107052. private _constantTranform;
  107053. private _screenQuaternion;
  107054. private _alpha;
  107055. private _beta;
  107056. private _gamma;
  107057. /**
  107058. * Can be used to detect if a device orientation sensor is availible on a device
  107059. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  107060. * @returns a promise that will resolve on orientation change
  107061. */
  107062. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  107063. /**
  107064. * @hidden
  107065. */
  107066. _onDeviceOrientationChangedObservable: Observable<void>;
  107067. /**
  107068. * Instantiates a new input
  107069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107070. */
  107071. constructor();
  107072. /**
  107073. * Define the camera controlled by the input.
  107074. */
  107075. camera: FreeCamera;
  107076. /**
  107077. * Attach the input controls to a specific dom element to get the input from.
  107078. * @param element Defines the element the controls should be listened from
  107079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107080. */
  107081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107082. private _orientationChanged;
  107083. private _deviceOrientation;
  107084. /**
  107085. * Detach the current controls from the specified dom element.
  107086. * @param element Defines the element to stop listening the inputs from
  107087. */
  107088. detachControl(element: Nullable<HTMLElement>): void;
  107089. /**
  107090. * Update the current camera state depending on the inputs that have been used this frame.
  107091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107092. */
  107093. checkInputs(): void;
  107094. /**
  107095. * Gets the class name of the current intput.
  107096. * @returns the class name
  107097. */
  107098. getClassName(): string;
  107099. /**
  107100. * Get the friendly name associated with the input class.
  107101. * @returns the input friendly name
  107102. */
  107103. getSimpleName(): string;
  107104. }
  107105. }
  107106. declare module BABYLON {
  107107. /**
  107108. * Manage the gamepad inputs to control a free camera.
  107109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107110. */
  107111. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107112. /**
  107113. * Define the camera the input is attached to.
  107114. */
  107115. camera: FreeCamera;
  107116. /**
  107117. * Define the Gamepad controlling the input
  107118. */
  107119. gamepad: Nullable<Gamepad>;
  107120. /**
  107121. * Defines the gamepad rotation sensiblity.
  107122. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107123. */
  107124. gamepadAngularSensibility: number;
  107125. /**
  107126. * Defines the gamepad move sensiblity.
  107127. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107128. */
  107129. gamepadMoveSensibility: number;
  107130. private _yAxisScale;
  107131. /**
  107132. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107133. */
  107134. invertYAxis: boolean;
  107135. private _onGamepadConnectedObserver;
  107136. private _onGamepadDisconnectedObserver;
  107137. private _cameraTransform;
  107138. private _deltaTransform;
  107139. private _vector3;
  107140. private _vector2;
  107141. /**
  107142. * Attach the input controls to a specific dom element to get the input from.
  107143. * @param element Defines the element the controls should be listened from
  107144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107145. */
  107146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107147. /**
  107148. * Detach the current controls from the specified dom element.
  107149. * @param element Defines the element to stop listening the inputs from
  107150. */
  107151. detachControl(element: Nullable<HTMLElement>): void;
  107152. /**
  107153. * Update the current camera state depending on the inputs that have been used this frame.
  107154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107155. */
  107156. checkInputs(): void;
  107157. /**
  107158. * Gets the class name of the current intput.
  107159. * @returns the class name
  107160. */
  107161. getClassName(): string;
  107162. /**
  107163. * Get the friendly name associated with the input class.
  107164. * @returns the input friendly name
  107165. */
  107166. getSimpleName(): string;
  107167. }
  107168. }
  107169. declare module BABYLON {
  107170. /**
  107171. * Defines the potential axis of a Joystick
  107172. */
  107173. export enum JoystickAxis {
  107174. /** X axis */
  107175. X = 0,
  107176. /** Y axis */
  107177. Y = 1,
  107178. /** Z axis */
  107179. Z = 2
  107180. }
  107181. /**
  107182. * Class used to define virtual joystick (used in touch mode)
  107183. */
  107184. export class VirtualJoystick {
  107185. /**
  107186. * Gets or sets a boolean indicating that left and right values must be inverted
  107187. */
  107188. reverseLeftRight: boolean;
  107189. /**
  107190. * Gets or sets a boolean indicating that up and down values must be inverted
  107191. */
  107192. reverseUpDown: boolean;
  107193. /**
  107194. * Gets the offset value for the position (ie. the change of the position value)
  107195. */
  107196. deltaPosition: Vector3;
  107197. /**
  107198. * Gets a boolean indicating if the virtual joystick was pressed
  107199. */
  107200. pressed: boolean;
  107201. /**
  107202. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107203. */
  107204. static Canvas: Nullable<HTMLCanvasElement>;
  107205. private static _globalJoystickIndex;
  107206. private static vjCanvasContext;
  107207. private static vjCanvasWidth;
  107208. private static vjCanvasHeight;
  107209. private static halfWidth;
  107210. private _action;
  107211. private _axisTargetedByLeftAndRight;
  107212. private _axisTargetedByUpAndDown;
  107213. private _joystickSensibility;
  107214. private _inversedSensibility;
  107215. private _joystickPointerID;
  107216. private _joystickColor;
  107217. private _joystickPointerPos;
  107218. private _joystickPreviousPointerPos;
  107219. private _joystickPointerStartPos;
  107220. private _deltaJoystickVector;
  107221. private _leftJoystick;
  107222. private _touches;
  107223. private _onPointerDownHandlerRef;
  107224. private _onPointerMoveHandlerRef;
  107225. private _onPointerUpHandlerRef;
  107226. private _onResize;
  107227. /**
  107228. * Creates a new virtual joystick
  107229. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107230. */
  107231. constructor(leftJoystick?: boolean);
  107232. /**
  107233. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107234. * @param newJoystickSensibility defines the new sensibility
  107235. */
  107236. setJoystickSensibility(newJoystickSensibility: number): void;
  107237. private _onPointerDown;
  107238. private _onPointerMove;
  107239. private _onPointerUp;
  107240. /**
  107241. * Change the color of the virtual joystick
  107242. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107243. */
  107244. setJoystickColor(newColor: string): void;
  107245. /**
  107246. * Defines a callback to call when the joystick is touched
  107247. * @param action defines the callback
  107248. */
  107249. setActionOnTouch(action: () => any): void;
  107250. /**
  107251. * Defines which axis you'd like to control for left & right
  107252. * @param axis defines the axis to use
  107253. */
  107254. setAxisForLeftRight(axis: JoystickAxis): void;
  107255. /**
  107256. * Defines which axis you'd like to control for up & down
  107257. * @param axis defines the axis to use
  107258. */
  107259. setAxisForUpDown(axis: JoystickAxis): void;
  107260. private _drawVirtualJoystick;
  107261. /**
  107262. * Release internal HTML canvas
  107263. */
  107264. releaseCanvas(): void;
  107265. }
  107266. }
  107267. declare module BABYLON {
  107268. interface FreeCameraInputsManager {
  107269. /**
  107270. * Add virtual joystick input support to the input manager.
  107271. * @returns the current input manager
  107272. */
  107273. addVirtualJoystick(): FreeCameraInputsManager;
  107274. }
  107275. /**
  107276. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107278. */
  107279. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107280. /**
  107281. * Defines the camera the input is attached to.
  107282. */
  107283. camera: FreeCamera;
  107284. private _leftjoystick;
  107285. private _rightjoystick;
  107286. /**
  107287. * Gets the left stick of the virtual joystick.
  107288. * @returns The virtual Joystick
  107289. */
  107290. getLeftJoystick(): VirtualJoystick;
  107291. /**
  107292. * Gets the right stick of the virtual joystick.
  107293. * @returns The virtual Joystick
  107294. */
  107295. getRightJoystick(): VirtualJoystick;
  107296. /**
  107297. * Update the current camera state depending on the inputs that have been used this frame.
  107298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107299. */
  107300. checkInputs(): void;
  107301. /**
  107302. * Attach the input controls to a specific dom element to get the input from.
  107303. * @param element Defines the element the controls should be listened from
  107304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107305. */
  107306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107307. /**
  107308. * Detach the current controls from the specified dom element.
  107309. * @param element Defines the element to stop listening the inputs from
  107310. */
  107311. detachControl(element: Nullable<HTMLElement>): void;
  107312. /**
  107313. * Gets the class name of the current intput.
  107314. * @returns the class name
  107315. */
  107316. getClassName(): string;
  107317. /**
  107318. * Get the friendly name associated with the input class.
  107319. * @returns the input friendly name
  107320. */
  107321. getSimpleName(): string;
  107322. }
  107323. }
  107324. declare module BABYLON {
  107325. /**
  107326. * This represents a FPS type of camera controlled by touch.
  107327. * This is like a universal camera minus the Gamepad controls.
  107328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107329. */
  107330. export class TouchCamera extends FreeCamera {
  107331. /**
  107332. * Defines the touch sensibility for rotation.
  107333. * The higher the faster.
  107334. */
  107335. touchAngularSensibility: number;
  107336. /**
  107337. * Defines the touch sensibility for move.
  107338. * The higher the faster.
  107339. */
  107340. touchMoveSensibility: number;
  107341. /**
  107342. * Instantiates a new touch camera.
  107343. * This represents a FPS type of camera controlled by touch.
  107344. * This is like a universal camera minus the Gamepad controls.
  107345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107346. * @param name Define the name of the camera in the scene
  107347. * @param position Define the start position of the camera in the scene
  107348. * @param scene Define the scene the camera belongs to
  107349. */
  107350. constructor(name: string, position: Vector3, scene: Scene);
  107351. /**
  107352. * Gets the current object class name.
  107353. * @return the class name
  107354. */
  107355. getClassName(): string;
  107356. /** @hidden */
  107357. _setupInputs(): void;
  107358. }
  107359. }
  107360. declare module BABYLON {
  107361. /**
  107362. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107363. * being tilted forward or back and left or right.
  107364. */
  107365. export class DeviceOrientationCamera extends FreeCamera {
  107366. private _initialQuaternion;
  107367. private _quaternionCache;
  107368. private _tmpDragQuaternion;
  107369. private _disablePointerInputWhenUsingDeviceOrientation;
  107370. /**
  107371. * Creates a new device orientation camera
  107372. * @param name The name of the camera
  107373. * @param position The start position camera
  107374. * @param scene The scene the camera belongs to
  107375. */
  107376. constructor(name: string, position: Vector3, scene: Scene);
  107377. /**
  107378. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107379. */
  107380. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107381. private _dragFactor;
  107382. /**
  107383. * Enabled turning on the y axis when the orientation sensor is active
  107384. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107385. */
  107386. enableHorizontalDragging(dragFactor?: number): void;
  107387. /**
  107388. * Gets the current instance class name ("DeviceOrientationCamera").
  107389. * This helps avoiding instanceof at run time.
  107390. * @returns the class name
  107391. */
  107392. getClassName(): string;
  107393. /**
  107394. * @hidden
  107395. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107396. */
  107397. _checkInputs(): void;
  107398. /**
  107399. * Reset the camera to its default orientation on the specified axis only.
  107400. * @param axis The axis to reset
  107401. */
  107402. resetToCurrentRotation(axis?: Axis): void;
  107403. }
  107404. }
  107405. declare module BABYLON {
  107406. /**
  107407. * Defines supported buttons for XBox360 compatible gamepads
  107408. */
  107409. export enum Xbox360Button {
  107410. /** A */
  107411. A = 0,
  107412. /** B */
  107413. B = 1,
  107414. /** X */
  107415. X = 2,
  107416. /** Y */
  107417. Y = 3,
  107418. /** Start */
  107419. Start = 4,
  107420. /** Back */
  107421. Back = 5,
  107422. /** Left button */
  107423. LB = 6,
  107424. /** Right button */
  107425. RB = 7,
  107426. /** Left stick */
  107427. LeftStick = 8,
  107428. /** Right stick */
  107429. RightStick = 9
  107430. }
  107431. /** Defines values for XBox360 DPad */
  107432. export enum Xbox360Dpad {
  107433. /** Up */
  107434. Up = 0,
  107435. /** Down */
  107436. Down = 1,
  107437. /** Left */
  107438. Left = 2,
  107439. /** Right */
  107440. Right = 3
  107441. }
  107442. /**
  107443. * Defines a XBox360 gamepad
  107444. */
  107445. export class Xbox360Pad extends Gamepad {
  107446. private _leftTrigger;
  107447. private _rightTrigger;
  107448. private _onlefttriggerchanged;
  107449. private _onrighttriggerchanged;
  107450. private _onbuttondown;
  107451. private _onbuttonup;
  107452. private _ondpaddown;
  107453. private _ondpadup;
  107454. /** Observable raised when a button is pressed */
  107455. onButtonDownObservable: Observable<Xbox360Button>;
  107456. /** Observable raised when a button is released */
  107457. onButtonUpObservable: Observable<Xbox360Button>;
  107458. /** Observable raised when a pad is pressed */
  107459. onPadDownObservable: Observable<Xbox360Dpad>;
  107460. /** Observable raised when a pad is released */
  107461. onPadUpObservable: Observable<Xbox360Dpad>;
  107462. private _buttonA;
  107463. private _buttonB;
  107464. private _buttonX;
  107465. private _buttonY;
  107466. private _buttonBack;
  107467. private _buttonStart;
  107468. private _buttonLB;
  107469. private _buttonRB;
  107470. private _buttonLeftStick;
  107471. private _buttonRightStick;
  107472. private _dPadUp;
  107473. private _dPadDown;
  107474. private _dPadLeft;
  107475. private _dPadRight;
  107476. private _isXboxOnePad;
  107477. /**
  107478. * Creates a new XBox360 gamepad object
  107479. * @param id defines the id of this gamepad
  107480. * @param index defines its index
  107481. * @param gamepad defines the internal HTML gamepad object
  107482. * @param xboxOne defines if it is a XBox One gamepad
  107483. */
  107484. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107485. /**
  107486. * Defines the callback to call when left trigger is pressed
  107487. * @param callback defines the callback to use
  107488. */
  107489. onlefttriggerchanged(callback: (value: number) => void): void;
  107490. /**
  107491. * Defines the callback to call when right trigger is pressed
  107492. * @param callback defines the callback to use
  107493. */
  107494. onrighttriggerchanged(callback: (value: number) => void): void;
  107495. /**
  107496. * Gets the left trigger value
  107497. */
  107498. /**
  107499. * Sets the left trigger value
  107500. */
  107501. leftTrigger: number;
  107502. /**
  107503. * Gets the right trigger value
  107504. */
  107505. /**
  107506. * Sets the right trigger value
  107507. */
  107508. rightTrigger: number;
  107509. /**
  107510. * Defines the callback to call when a button is pressed
  107511. * @param callback defines the callback to use
  107512. */
  107513. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107514. /**
  107515. * Defines the callback to call when a button is released
  107516. * @param callback defines the callback to use
  107517. */
  107518. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107519. /**
  107520. * Defines the callback to call when a pad is pressed
  107521. * @param callback defines the callback to use
  107522. */
  107523. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107524. /**
  107525. * Defines the callback to call when a pad is released
  107526. * @param callback defines the callback to use
  107527. */
  107528. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107529. private _setButtonValue;
  107530. private _setDPadValue;
  107531. /**
  107532. * Gets the value of the `A` button
  107533. */
  107534. /**
  107535. * Sets the value of the `A` button
  107536. */
  107537. buttonA: number;
  107538. /**
  107539. * Gets the value of the `B` button
  107540. */
  107541. /**
  107542. * Sets the value of the `B` button
  107543. */
  107544. buttonB: number;
  107545. /**
  107546. * Gets the value of the `X` button
  107547. */
  107548. /**
  107549. * Sets the value of the `X` button
  107550. */
  107551. buttonX: number;
  107552. /**
  107553. * Gets the value of the `Y` button
  107554. */
  107555. /**
  107556. * Sets the value of the `Y` button
  107557. */
  107558. buttonY: number;
  107559. /**
  107560. * Gets the value of the `Start` button
  107561. */
  107562. /**
  107563. * Sets the value of the `Start` button
  107564. */
  107565. buttonStart: number;
  107566. /**
  107567. * Gets the value of the `Back` button
  107568. */
  107569. /**
  107570. * Sets the value of the `Back` button
  107571. */
  107572. buttonBack: number;
  107573. /**
  107574. * Gets the value of the `Left` button
  107575. */
  107576. /**
  107577. * Sets the value of the `Left` button
  107578. */
  107579. buttonLB: number;
  107580. /**
  107581. * Gets the value of the `Right` button
  107582. */
  107583. /**
  107584. * Sets the value of the `Right` button
  107585. */
  107586. buttonRB: number;
  107587. /**
  107588. * Gets the value of the Left joystick
  107589. */
  107590. /**
  107591. * Sets the value of the Left joystick
  107592. */
  107593. buttonLeftStick: number;
  107594. /**
  107595. * Gets the value of the Right joystick
  107596. */
  107597. /**
  107598. * Sets the value of the Right joystick
  107599. */
  107600. buttonRightStick: number;
  107601. /**
  107602. * Gets the value of D-pad up
  107603. */
  107604. /**
  107605. * Sets the value of D-pad up
  107606. */
  107607. dPadUp: number;
  107608. /**
  107609. * Gets the value of D-pad down
  107610. */
  107611. /**
  107612. * Sets the value of D-pad down
  107613. */
  107614. dPadDown: number;
  107615. /**
  107616. * Gets the value of D-pad left
  107617. */
  107618. /**
  107619. * Sets the value of D-pad left
  107620. */
  107621. dPadLeft: number;
  107622. /**
  107623. * Gets the value of D-pad right
  107624. */
  107625. /**
  107626. * Sets the value of D-pad right
  107627. */
  107628. dPadRight: number;
  107629. /**
  107630. * Force the gamepad to synchronize with device values
  107631. */
  107632. update(): void;
  107633. /**
  107634. * Disposes the gamepad
  107635. */
  107636. dispose(): void;
  107637. }
  107638. }
  107639. declare module BABYLON {
  107640. /**
  107641. * Defines supported buttons for DualShock compatible gamepads
  107642. */
  107643. export enum DualShockButton {
  107644. /** Cross */
  107645. Cross = 0,
  107646. /** Circle */
  107647. Circle = 1,
  107648. /** Square */
  107649. Square = 2,
  107650. /** Triangle */
  107651. Triangle = 3,
  107652. /** Options */
  107653. Options = 4,
  107654. /** Share */
  107655. Share = 5,
  107656. /** L1 */
  107657. L1 = 6,
  107658. /** R1 */
  107659. R1 = 7,
  107660. /** Left stick */
  107661. LeftStick = 8,
  107662. /** Right stick */
  107663. RightStick = 9
  107664. }
  107665. /** Defines values for DualShock DPad */
  107666. export enum DualShockDpad {
  107667. /** Up */
  107668. Up = 0,
  107669. /** Down */
  107670. Down = 1,
  107671. /** Left */
  107672. Left = 2,
  107673. /** Right */
  107674. Right = 3
  107675. }
  107676. /**
  107677. * Defines a DualShock gamepad
  107678. */
  107679. export class DualShockPad extends Gamepad {
  107680. private _leftTrigger;
  107681. private _rightTrigger;
  107682. private _onlefttriggerchanged;
  107683. private _onrighttriggerchanged;
  107684. private _onbuttondown;
  107685. private _onbuttonup;
  107686. private _ondpaddown;
  107687. private _ondpadup;
  107688. /** Observable raised when a button is pressed */
  107689. onButtonDownObservable: Observable<DualShockButton>;
  107690. /** Observable raised when a button is released */
  107691. onButtonUpObservable: Observable<DualShockButton>;
  107692. /** Observable raised when a pad is pressed */
  107693. onPadDownObservable: Observable<DualShockDpad>;
  107694. /** Observable raised when a pad is released */
  107695. onPadUpObservable: Observable<DualShockDpad>;
  107696. private _buttonCross;
  107697. private _buttonCircle;
  107698. private _buttonSquare;
  107699. private _buttonTriangle;
  107700. private _buttonShare;
  107701. private _buttonOptions;
  107702. private _buttonL1;
  107703. private _buttonR1;
  107704. private _buttonLeftStick;
  107705. private _buttonRightStick;
  107706. private _dPadUp;
  107707. private _dPadDown;
  107708. private _dPadLeft;
  107709. private _dPadRight;
  107710. /**
  107711. * Creates a new DualShock gamepad object
  107712. * @param id defines the id of this gamepad
  107713. * @param index defines its index
  107714. * @param gamepad defines the internal HTML gamepad object
  107715. */
  107716. constructor(id: string, index: number, gamepad: any);
  107717. /**
  107718. * Defines the callback to call when left trigger is pressed
  107719. * @param callback defines the callback to use
  107720. */
  107721. onlefttriggerchanged(callback: (value: number) => void): void;
  107722. /**
  107723. * Defines the callback to call when right trigger is pressed
  107724. * @param callback defines the callback to use
  107725. */
  107726. onrighttriggerchanged(callback: (value: number) => void): void;
  107727. /**
  107728. * Gets the left trigger value
  107729. */
  107730. /**
  107731. * Sets the left trigger value
  107732. */
  107733. leftTrigger: number;
  107734. /**
  107735. * Gets the right trigger value
  107736. */
  107737. /**
  107738. * Sets the right trigger value
  107739. */
  107740. rightTrigger: number;
  107741. /**
  107742. * Defines the callback to call when a button is pressed
  107743. * @param callback defines the callback to use
  107744. */
  107745. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107746. /**
  107747. * Defines the callback to call when a button is released
  107748. * @param callback defines the callback to use
  107749. */
  107750. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107751. /**
  107752. * Defines the callback to call when a pad is pressed
  107753. * @param callback defines the callback to use
  107754. */
  107755. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107756. /**
  107757. * Defines the callback to call when a pad is released
  107758. * @param callback defines the callback to use
  107759. */
  107760. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107761. private _setButtonValue;
  107762. private _setDPadValue;
  107763. /**
  107764. * Gets the value of the `Cross` button
  107765. */
  107766. /**
  107767. * Sets the value of the `Cross` button
  107768. */
  107769. buttonCross: number;
  107770. /**
  107771. * Gets the value of the `Circle` button
  107772. */
  107773. /**
  107774. * Sets the value of the `Circle` button
  107775. */
  107776. buttonCircle: number;
  107777. /**
  107778. * Gets the value of the `Square` button
  107779. */
  107780. /**
  107781. * Sets the value of the `Square` button
  107782. */
  107783. buttonSquare: number;
  107784. /**
  107785. * Gets the value of the `Triangle` button
  107786. */
  107787. /**
  107788. * Sets the value of the `Triangle` button
  107789. */
  107790. buttonTriangle: number;
  107791. /**
  107792. * Gets the value of the `Options` button
  107793. */
  107794. /**
  107795. * Sets the value of the `Options` button
  107796. */
  107797. buttonOptions: number;
  107798. /**
  107799. * Gets the value of the `Share` button
  107800. */
  107801. /**
  107802. * Sets the value of the `Share` button
  107803. */
  107804. buttonShare: number;
  107805. /**
  107806. * Gets the value of the `L1` button
  107807. */
  107808. /**
  107809. * Sets the value of the `L1` button
  107810. */
  107811. buttonL1: number;
  107812. /**
  107813. * Gets the value of the `R1` button
  107814. */
  107815. /**
  107816. * Sets the value of the `R1` button
  107817. */
  107818. buttonR1: number;
  107819. /**
  107820. * Gets the value of the Left joystick
  107821. */
  107822. /**
  107823. * Sets the value of the Left joystick
  107824. */
  107825. buttonLeftStick: number;
  107826. /**
  107827. * Gets the value of the Right joystick
  107828. */
  107829. /**
  107830. * Sets the value of the Right joystick
  107831. */
  107832. buttonRightStick: number;
  107833. /**
  107834. * Gets the value of D-pad up
  107835. */
  107836. /**
  107837. * Sets the value of D-pad up
  107838. */
  107839. dPadUp: number;
  107840. /**
  107841. * Gets the value of D-pad down
  107842. */
  107843. /**
  107844. * Sets the value of D-pad down
  107845. */
  107846. dPadDown: number;
  107847. /**
  107848. * Gets the value of D-pad left
  107849. */
  107850. /**
  107851. * Sets the value of D-pad left
  107852. */
  107853. dPadLeft: number;
  107854. /**
  107855. * Gets the value of D-pad right
  107856. */
  107857. /**
  107858. * Sets the value of D-pad right
  107859. */
  107860. dPadRight: number;
  107861. /**
  107862. * Force the gamepad to synchronize with device values
  107863. */
  107864. update(): void;
  107865. /**
  107866. * Disposes the gamepad
  107867. */
  107868. dispose(): void;
  107869. }
  107870. }
  107871. declare module BABYLON {
  107872. /**
  107873. * Manager for handling gamepads
  107874. */
  107875. export class GamepadManager {
  107876. private _scene?;
  107877. private _babylonGamepads;
  107878. private _oneGamepadConnected;
  107879. /** @hidden */
  107880. _isMonitoring: boolean;
  107881. private _gamepadEventSupported;
  107882. private _gamepadSupport;
  107883. /**
  107884. * observable to be triggered when the gamepad controller has been connected
  107885. */
  107886. onGamepadConnectedObservable: Observable<Gamepad>;
  107887. /**
  107888. * observable to be triggered when the gamepad controller has been disconnected
  107889. */
  107890. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107891. private _onGamepadConnectedEvent;
  107892. private _onGamepadDisconnectedEvent;
  107893. /**
  107894. * Initializes the gamepad manager
  107895. * @param _scene BabylonJS scene
  107896. */
  107897. constructor(_scene?: Scene | undefined);
  107898. /**
  107899. * The gamepads in the game pad manager
  107900. */
  107901. readonly gamepads: Gamepad[];
  107902. /**
  107903. * Get the gamepad controllers based on type
  107904. * @param type The type of gamepad controller
  107905. * @returns Nullable gamepad
  107906. */
  107907. getGamepadByType(type?: number): Nullable<Gamepad>;
  107908. /**
  107909. * Disposes the gamepad manager
  107910. */
  107911. dispose(): void;
  107912. private _addNewGamepad;
  107913. private _startMonitoringGamepads;
  107914. private _stopMonitoringGamepads;
  107915. /** @hidden */
  107916. _checkGamepadsStatus(): void;
  107917. private _updateGamepadObjects;
  107918. }
  107919. }
  107920. declare module BABYLON {
  107921. interface Scene {
  107922. /** @hidden */
  107923. _gamepadManager: Nullable<GamepadManager>;
  107924. /**
  107925. * Gets the gamepad manager associated with the scene
  107926. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107927. */
  107928. gamepadManager: GamepadManager;
  107929. }
  107930. /**
  107931. * Interface representing a free camera inputs manager
  107932. */
  107933. interface FreeCameraInputsManager {
  107934. /**
  107935. * Adds gamepad input support to the FreeCameraInputsManager.
  107936. * @returns the FreeCameraInputsManager
  107937. */
  107938. addGamepad(): FreeCameraInputsManager;
  107939. }
  107940. /**
  107941. * Interface representing an arc rotate camera inputs manager
  107942. */
  107943. interface ArcRotateCameraInputsManager {
  107944. /**
  107945. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107946. * @returns the camera inputs manager
  107947. */
  107948. addGamepad(): ArcRotateCameraInputsManager;
  107949. }
  107950. /**
  107951. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107952. */
  107953. export class GamepadSystemSceneComponent implements ISceneComponent {
  107954. /**
  107955. * The component name helpfull to identify the component in the list of scene components.
  107956. */
  107957. readonly name: string;
  107958. /**
  107959. * The scene the component belongs to.
  107960. */
  107961. scene: Scene;
  107962. /**
  107963. * Creates a new instance of the component for the given scene
  107964. * @param scene Defines the scene to register the component in
  107965. */
  107966. constructor(scene: Scene);
  107967. /**
  107968. * Registers the component in a given scene
  107969. */
  107970. register(): void;
  107971. /**
  107972. * Rebuilds the elements related to this component in case of
  107973. * context lost for instance.
  107974. */
  107975. rebuild(): void;
  107976. /**
  107977. * Disposes the component and the associated ressources
  107978. */
  107979. dispose(): void;
  107980. private _beforeCameraUpdate;
  107981. }
  107982. }
  107983. declare module BABYLON {
  107984. /**
  107985. * 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,
  107986. * which still works and will still be found in many Playgrounds.
  107987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107988. */
  107989. export class UniversalCamera extends TouchCamera {
  107990. /**
  107991. * Defines the gamepad rotation sensiblity.
  107992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107993. */
  107994. gamepadAngularSensibility: number;
  107995. /**
  107996. * Defines the gamepad move sensiblity.
  107997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107998. */
  107999. gamepadMoveSensibility: number;
  108000. /**
  108001. * 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,
  108002. * which still works and will still be found in many Playgrounds.
  108003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108004. * @param name Define the name of the camera in the scene
  108005. * @param position Define the start position of the camera in the scene
  108006. * @param scene Define the scene the camera belongs to
  108007. */
  108008. constructor(name: string, position: Vector3, scene: Scene);
  108009. /**
  108010. * Gets the current object class name.
  108011. * @return the class name
  108012. */
  108013. getClassName(): string;
  108014. }
  108015. }
  108016. declare module BABYLON {
  108017. /**
  108018. * This represents a FPS type of camera. This is only here for back compat purpose.
  108019. * Please use the UniversalCamera instead as both are identical.
  108020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108021. */
  108022. export class GamepadCamera extends UniversalCamera {
  108023. /**
  108024. * Instantiates a new Gamepad Camera
  108025. * This represents a FPS type of camera. This is only here for back compat purpose.
  108026. * Please use the UniversalCamera instead as both are identical.
  108027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108028. * @param name Define the name of the camera in the scene
  108029. * @param position Define the start position of the camera in the scene
  108030. * @param scene Define the scene the camera belongs to
  108031. */
  108032. constructor(name: string, position: Vector3, scene: Scene);
  108033. /**
  108034. * Gets the current object class name.
  108035. * @return the class name
  108036. */
  108037. getClassName(): string;
  108038. }
  108039. }
  108040. declare module BABYLON {
  108041. /** @hidden */
  108042. export var passPixelShader: {
  108043. name: string;
  108044. shader: string;
  108045. };
  108046. }
  108047. declare module BABYLON {
  108048. /** @hidden */
  108049. export var passCubePixelShader: {
  108050. name: string;
  108051. shader: string;
  108052. };
  108053. }
  108054. declare module BABYLON {
  108055. /**
  108056. * PassPostProcess which produces an output the same as it's input
  108057. */
  108058. export class PassPostProcess extends PostProcess {
  108059. /**
  108060. * Creates the PassPostProcess
  108061. * @param name The name of the effect.
  108062. * @param options The required width/height ratio to downsize to before computing the render pass.
  108063. * @param camera The camera to apply the render pass to.
  108064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108065. * @param engine The engine which the post process will be applied. (default: current engine)
  108066. * @param reusable If the post process can be reused on the same frame. (default: false)
  108067. * @param textureType The type of texture to be used when performing the post processing.
  108068. * @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)
  108069. */
  108070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108071. }
  108072. /**
  108073. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  108074. */
  108075. export class PassCubePostProcess extends PostProcess {
  108076. private _face;
  108077. /**
  108078. * Gets or sets the cube face to display.
  108079. * * 0 is +X
  108080. * * 1 is -X
  108081. * * 2 is +Y
  108082. * * 3 is -Y
  108083. * * 4 is +Z
  108084. * * 5 is -Z
  108085. */
  108086. face: number;
  108087. /**
  108088. * Creates the PassCubePostProcess
  108089. * @param name The name of the effect.
  108090. * @param options The required width/height ratio to downsize to before computing the render pass.
  108091. * @param camera The camera to apply the render pass to.
  108092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108093. * @param engine The engine which the post process will be applied. (default: current engine)
  108094. * @param reusable If the post process can be reused on the same frame. (default: false)
  108095. * @param textureType The type of texture to be used when performing the post processing.
  108096. * @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)
  108097. */
  108098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108099. }
  108100. }
  108101. declare module BABYLON {
  108102. /** @hidden */
  108103. export var anaglyphPixelShader: {
  108104. name: string;
  108105. shader: string;
  108106. };
  108107. }
  108108. declare module BABYLON {
  108109. /**
  108110. * Postprocess used to generate anaglyphic rendering
  108111. */
  108112. export class AnaglyphPostProcess extends PostProcess {
  108113. private _passedProcess;
  108114. /**
  108115. * Creates a new AnaglyphPostProcess
  108116. * @param name defines postprocess name
  108117. * @param options defines creation options or target ratio scale
  108118. * @param rigCameras defines cameras using this postprocess
  108119. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108120. * @param engine defines hosting engine
  108121. * @param reusable defines if the postprocess will be reused multiple times per frame
  108122. */
  108123. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108124. }
  108125. }
  108126. declare module BABYLON {
  108127. /**
  108128. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108129. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108130. */
  108131. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108132. /**
  108133. * Creates a new AnaglyphArcRotateCamera
  108134. * @param name defines camera name
  108135. * @param alpha defines alpha angle (in radians)
  108136. * @param beta defines beta angle (in radians)
  108137. * @param radius defines radius
  108138. * @param target defines camera target
  108139. * @param interaxialDistance defines distance between each color axis
  108140. * @param scene defines the hosting scene
  108141. */
  108142. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108143. /**
  108144. * Gets camera class name
  108145. * @returns AnaglyphArcRotateCamera
  108146. */
  108147. getClassName(): string;
  108148. }
  108149. }
  108150. declare module BABYLON {
  108151. /**
  108152. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108154. */
  108155. export class AnaglyphFreeCamera extends FreeCamera {
  108156. /**
  108157. * Creates a new AnaglyphFreeCamera
  108158. * @param name defines camera name
  108159. * @param position defines initial position
  108160. * @param interaxialDistance defines distance between each color axis
  108161. * @param scene defines the hosting scene
  108162. */
  108163. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108164. /**
  108165. * Gets camera class name
  108166. * @returns AnaglyphFreeCamera
  108167. */
  108168. getClassName(): string;
  108169. }
  108170. }
  108171. declare module BABYLON {
  108172. /**
  108173. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108174. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108175. */
  108176. export class AnaglyphGamepadCamera extends GamepadCamera {
  108177. /**
  108178. * Creates a new AnaglyphGamepadCamera
  108179. * @param name defines camera name
  108180. * @param position defines initial position
  108181. * @param interaxialDistance defines distance between each color axis
  108182. * @param scene defines the hosting scene
  108183. */
  108184. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108185. /**
  108186. * Gets camera class name
  108187. * @returns AnaglyphGamepadCamera
  108188. */
  108189. getClassName(): string;
  108190. }
  108191. }
  108192. declare module BABYLON {
  108193. /**
  108194. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108196. */
  108197. export class AnaglyphUniversalCamera extends UniversalCamera {
  108198. /**
  108199. * Creates a new AnaglyphUniversalCamera
  108200. * @param name defines camera name
  108201. * @param position defines initial position
  108202. * @param interaxialDistance defines distance between each color axis
  108203. * @param scene defines the hosting scene
  108204. */
  108205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108206. /**
  108207. * Gets camera class name
  108208. * @returns AnaglyphUniversalCamera
  108209. */
  108210. getClassName(): string;
  108211. }
  108212. }
  108213. declare module BABYLON {
  108214. /** @hidden */
  108215. export var stereoscopicInterlacePixelShader: {
  108216. name: string;
  108217. shader: string;
  108218. };
  108219. }
  108220. declare module BABYLON {
  108221. /**
  108222. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108223. */
  108224. export class StereoscopicInterlacePostProcess extends PostProcess {
  108225. private _stepSize;
  108226. private _passedProcess;
  108227. /**
  108228. * Initializes a StereoscopicInterlacePostProcess
  108229. * @param name The name of the effect.
  108230. * @param rigCameras The rig cameras to be appled to the post process
  108231. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108233. * @param engine The engine which the post process will be applied. (default: current engine)
  108234. * @param reusable If the post process can be reused on the same frame. (default: false)
  108235. */
  108236. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108237. }
  108238. }
  108239. declare module BABYLON {
  108240. /**
  108241. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108242. * @see http://doc.babylonjs.com/features/cameras
  108243. */
  108244. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108245. /**
  108246. * Creates a new StereoscopicArcRotateCamera
  108247. * @param name defines camera name
  108248. * @param alpha defines alpha angle (in radians)
  108249. * @param beta defines beta angle (in radians)
  108250. * @param radius defines radius
  108251. * @param target defines camera target
  108252. * @param interaxialDistance defines distance between each color axis
  108253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108254. * @param scene defines the hosting scene
  108255. */
  108256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108257. /**
  108258. * Gets camera class name
  108259. * @returns StereoscopicArcRotateCamera
  108260. */
  108261. getClassName(): string;
  108262. }
  108263. }
  108264. declare module BABYLON {
  108265. /**
  108266. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108267. * @see http://doc.babylonjs.com/features/cameras
  108268. */
  108269. export class StereoscopicFreeCamera extends FreeCamera {
  108270. /**
  108271. * Creates a new StereoscopicFreeCamera
  108272. * @param name defines camera name
  108273. * @param position defines initial position
  108274. * @param interaxialDistance defines distance between each color axis
  108275. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108276. * @param scene defines the hosting scene
  108277. */
  108278. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108279. /**
  108280. * Gets camera class name
  108281. * @returns StereoscopicFreeCamera
  108282. */
  108283. getClassName(): string;
  108284. }
  108285. }
  108286. declare module BABYLON {
  108287. /**
  108288. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108289. * @see http://doc.babylonjs.com/features/cameras
  108290. */
  108291. export class StereoscopicGamepadCamera extends GamepadCamera {
  108292. /**
  108293. * Creates a new StereoscopicGamepadCamera
  108294. * @param name defines camera name
  108295. * @param position defines initial position
  108296. * @param interaxialDistance defines distance between each color axis
  108297. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108298. * @param scene defines the hosting scene
  108299. */
  108300. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108301. /**
  108302. * Gets camera class name
  108303. * @returns StereoscopicGamepadCamera
  108304. */
  108305. getClassName(): string;
  108306. }
  108307. }
  108308. declare module BABYLON {
  108309. /**
  108310. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108311. * @see http://doc.babylonjs.com/features/cameras
  108312. */
  108313. export class StereoscopicUniversalCamera extends UniversalCamera {
  108314. /**
  108315. * Creates a new StereoscopicUniversalCamera
  108316. * @param name defines camera name
  108317. * @param position defines initial position
  108318. * @param interaxialDistance defines distance between each color axis
  108319. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108320. * @param scene defines the hosting scene
  108321. */
  108322. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108323. /**
  108324. * Gets camera class name
  108325. * @returns StereoscopicUniversalCamera
  108326. */
  108327. getClassName(): string;
  108328. }
  108329. }
  108330. declare module BABYLON {
  108331. /**
  108332. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108333. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108334. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108335. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108336. */
  108337. export class VirtualJoysticksCamera extends FreeCamera {
  108338. /**
  108339. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108340. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108341. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108342. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108343. * @param name Define the name of the camera in the scene
  108344. * @param position Define the start position of the camera in the scene
  108345. * @param scene Define the scene the camera belongs to
  108346. */
  108347. constructor(name: string, position: Vector3, scene: Scene);
  108348. /**
  108349. * Gets the current object class name.
  108350. * @return the class name
  108351. */
  108352. getClassName(): string;
  108353. }
  108354. }
  108355. declare module BABYLON {
  108356. /**
  108357. * This represents all the required metrics to create a VR camera.
  108358. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108359. */
  108360. export class VRCameraMetrics {
  108361. /**
  108362. * Define the horizontal resolution off the screen.
  108363. */
  108364. hResolution: number;
  108365. /**
  108366. * Define the vertical resolution off the screen.
  108367. */
  108368. vResolution: number;
  108369. /**
  108370. * Define the horizontal screen size.
  108371. */
  108372. hScreenSize: number;
  108373. /**
  108374. * Define the vertical screen size.
  108375. */
  108376. vScreenSize: number;
  108377. /**
  108378. * Define the vertical screen center position.
  108379. */
  108380. vScreenCenter: number;
  108381. /**
  108382. * Define the distance of the eyes to the screen.
  108383. */
  108384. eyeToScreenDistance: number;
  108385. /**
  108386. * Define the distance between both lenses
  108387. */
  108388. lensSeparationDistance: number;
  108389. /**
  108390. * Define the distance between both viewer's eyes.
  108391. */
  108392. interpupillaryDistance: number;
  108393. /**
  108394. * Define the distortion factor of the VR postprocess.
  108395. * Please, touch with care.
  108396. */
  108397. distortionK: number[];
  108398. /**
  108399. * Define the chromatic aberration correction factors for the VR post process.
  108400. */
  108401. chromaAbCorrection: number[];
  108402. /**
  108403. * Define the scale factor of the post process.
  108404. * The smaller the better but the slower.
  108405. */
  108406. postProcessScaleFactor: number;
  108407. /**
  108408. * Define an offset for the lens center.
  108409. */
  108410. lensCenterOffset: number;
  108411. /**
  108412. * Define if the current vr camera should compensate the distortion of the lense or not.
  108413. */
  108414. compensateDistortion: boolean;
  108415. /**
  108416. * Defines if multiview should be enabled when rendering (Default: false)
  108417. */
  108418. multiviewEnabled: boolean;
  108419. /**
  108420. * Gets the rendering aspect ratio based on the provided resolutions.
  108421. */
  108422. readonly aspectRatio: number;
  108423. /**
  108424. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108425. */
  108426. readonly aspectRatioFov: number;
  108427. /**
  108428. * @hidden
  108429. */
  108430. readonly leftHMatrix: Matrix;
  108431. /**
  108432. * @hidden
  108433. */
  108434. readonly rightHMatrix: Matrix;
  108435. /**
  108436. * @hidden
  108437. */
  108438. readonly leftPreViewMatrix: Matrix;
  108439. /**
  108440. * @hidden
  108441. */
  108442. readonly rightPreViewMatrix: Matrix;
  108443. /**
  108444. * Get the default VRMetrics based on the most generic setup.
  108445. * @returns the default vr metrics
  108446. */
  108447. static GetDefault(): VRCameraMetrics;
  108448. }
  108449. }
  108450. declare module BABYLON {
  108451. /** @hidden */
  108452. export var vrDistortionCorrectionPixelShader: {
  108453. name: string;
  108454. shader: string;
  108455. };
  108456. }
  108457. declare module BABYLON {
  108458. /**
  108459. * VRDistortionCorrectionPostProcess used for mobile VR
  108460. */
  108461. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108462. private _isRightEye;
  108463. private _distortionFactors;
  108464. private _postProcessScaleFactor;
  108465. private _lensCenterOffset;
  108466. private _scaleIn;
  108467. private _scaleFactor;
  108468. private _lensCenter;
  108469. /**
  108470. * Initializes the VRDistortionCorrectionPostProcess
  108471. * @param name The name of the effect.
  108472. * @param camera The camera to apply the render pass to.
  108473. * @param isRightEye If this is for the right eye distortion
  108474. * @param vrMetrics All the required metrics for the VR camera
  108475. */
  108476. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108477. }
  108478. }
  108479. declare module BABYLON {
  108480. /**
  108481. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108482. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108483. */
  108484. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108485. /**
  108486. * Creates a new VRDeviceOrientationArcRotateCamera
  108487. * @param name defines camera name
  108488. * @param alpha defines the camera rotation along the logitudinal axis
  108489. * @param beta defines the camera rotation along the latitudinal axis
  108490. * @param radius defines the camera distance from its target
  108491. * @param target defines the camera target
  108492. * @param scene defines the scene the camera belongs to
  108493. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108494. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108495. */
  108496. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108497. /**
  108498. * Gets camera class name
  108499. * @returns VRDeviceOrientationArcRotateCamera
  108500. */
  108501. getClassName(): string;
  108502. }
  108503. }
  108504. declare module BABYLON {
  108505. /**
  108506. * Camera used to simulate VR rendering (based on FreeCamera)
  108507. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108508. */
  108509. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108510. /**
  108511. * Creates a new VRDeviceOrientationFreeCamera
  108512. * @param name defines camera name
  108513. * @param position defines the start position of the camera
  108514. * @param scene defines the scene the camera belongs to
  108515. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108516. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108517. */
  108518. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108519. /**
  108520. * Gets camera class name
  108521. * @returns VRDeviceOrientationFreeCamera
  108522. */
  108523. getClassName(): string;
  108524. }
  108525. }
  108526. declare module BABYLON {
  108527. /**
  108528. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108529. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108530. */
  108531. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108532. /**
  108533. * Creates a new VRDeviceOrientationGamepadCamera
  108534. * @param name defines camera name
  108535. * @param position defines the start position of the camera
  108536. * @param scene defines the scene the camera belongs to
  108537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108539. */
  108540. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108541. /**
  108542. * Gets camera class name
  108543. * @returns VRDeviceOrientationGamepadCamera
  108544. */
  108545. getClassName(): string;
  108546. }
  108547. }
  108548. declare module BABYLON {
  108549. /**
  108550. * Base class of materials working in push mode in babylon JS
  108551. * @hidden
  108552. */
  108553. export class PushMaterial extends Material {
  108554. protected _activeEffect: Effect;
  108555. protected _normalMatrix: Matrix;
  108556. /**
  108557. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108558. * This means that the material can keep using a previous shader while a new one is being compiled.
  108559. * This is mostly used when shader parallel compilation is supported (true by default)
  108560. */
  108561. allowShaderHotSwapping: boolean;
  108562. constructor(name: string, scene: Scene);
  108563. getEffect(): Effect;
  108564. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108565. /**
  108566. * Binds the given world matrix to the active effect
  108567. *
  108568. * @param world the matrix to bind
  108569. */
  108570. bindOnlyWorldMatrix(world: Matrix): void;
  108571. /**
  108572. * Binds the given normal matrix to the active effect
  108573. *
  108574. * @param normalMatrix the matrix to bind
  108575. */
  108576. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108577. bind(world: Matrix, mesh?: Mesh): void;
  108578. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108579. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108580. }
  108581. }
  108582. declare module BABYLON {
  108583. /**
  108584. * This groups all the flags used to control the materials channel.
  108585. */
  108586. export class MaterialFlags {
  108587. private static _DiffuseTextureEnabled;
  108588. /**
  108589. * Are diffuse textures enabled in the application.
  108590. */
  108591. static DiffuseTextureEnabled: boolean;
  108592. private static _AmbientTextureEnabled;
  108593. /**
  108594. * Are ambient textures enabled in the application.
  108595. */
  108596. static AmbientTextureEnabled: boolean;
  108597. private static _OpacityTextureEnabled;
  108598. /**
  108599. * Are opacity textures enabled in the application.
  108600. */
  108601. static OpacityTextureEnabled: boolean;
  108602. private static _ReflectionTextureEnabled;
  108603. /**
  108604. * Are reflection textures enabled in the application.
  108605. */
  108606. static ReflectionTextureEnabled: boolean;
  108607. private static _EmissiveTextureEnabled;
  108608. /**
  108609. * Are emissive textures enabled in the application.
  108610. */
  108611. static EmissiveTextureEnabled: boolean;
  108612. private static _SpecularTextureEnabled;
  108613. /**
  108614. * Are specular textures enabled in the application.
  108615. */
  108616. static SpecularTextureEnabled: boolean;
  108617. private static _BumpTextureEnabled;
  108618. /**
  108619. * Are bump textures enabled in the application.
  108620. */
  108621. static BumpTextureEnabled: boolean;
  108622. private static _LightmapTextureEnabled;
  108623. /**
  108624. * Are lightmap textures enabled in the application.
  108625. */
  108626. static LightmapTextureEnabled: boolean;
  108627. private static _RefractionTextureEnabled;
  108628. /**
  108629. * Are refraction textures enabled in the application.
  108630. */
  108631. static RefractionTextureEnabled: boolean;
  108632. private static _ColorGradingTextureEnabled;
  108633. /**
  108634. * Are color grading textures enabled in the application.
  108635. */
  108636. static ColorGradingTextureEnabled: boolean;
  108637. private static _FresnelEnabled;
  108638. /**
  108639. * Are fresnels enabled in the application.
  108640. */
  108641. static FresnelEnabled: boolean;
  108642. private static _ClearCoatTextureEnabled;
  108643. /**
  108644. * Are clear coat textures enabled in the application.
  108645. */
  108646. static ClearCoatTextureEnabled: boolean;
  108647. private static _ClearCoatBumpTextureEnabled;
  108648. /**
  108649. * Are clear coat bump textures enabled in the application.
  108650. */
  108651. static ClearCoatBumpTextureEnabled: boolean;
  108652. private static _ClearCoatTintTextureEnabled;
  108653. /**
  108654. * Are clear coat tint textures enabled in the application.
  108655. */
  108656. static ClearCoatTintTextureEnabled: boolean;
  108657. private static _SheenTextureEnabled;
  108658. /**
  108659. * Are sheen textures enabled in the application.
  108660. */
  108661. static SheenTextureEnabled: boolean;
  108662. private static _AnisotropicTextureEnabled;
  108663. /**
  108664. * Are anisotropic textures enabled in the application.
  108665. */
  108666. static AnisotropicTextureEnabled: boolean;
  108667. private static _ThicknessTextureEnabled;
  108668. /**
  108669. * Are thickness textures enabled in the application.
  108670. */
  108671. static ThicknessTextureEnabled: boolean;
  108672. }
  108673. }
  108674. declare module BABYLON {
  108675. /** @hidden */
  108676. export var defaultFragmentDeclaration: {
  108677. name: string;
  108678. shader: string;
  108679. };
  108680. }
  108681. declare module BABYLON {
  108682. /** @hidden */
  108683. export var defaultUboDeclaration: {
  108684. name: string;
  108685. shader: string;
  108686. };
  108687. }
  108688. declare module BABYLON {
  108689. /** @hidden */
  108690. export var lightFragmentDeclaration: {
  108691. name: string;
  108692. shader: string;
  108693. };
  108694. }
  108695. declare module BABYLON {
  108696. /** @hidden */
  108697. export var lightUboDeclaration: {
  108698. name: string;
  108699. shader: string;
  108700. };
  108701. }
  108702. declare module BABYLON {
  108703. /** @hidden */
  108704. export var lightsFragmentFunctions: {
  108705. name: string;
  108706. shader: string;
  108707. };
  108708. }
  108709. declare module BABYLON {
  108710. /** @hidden */
  108711. export var shadowsFragmentFunctions: {
  108712. name: string;
  108713. shader: string;
  108714. };
  108715. }
  108716. declare module BABYLON {
  108717. /** @hidden */
  108718. export var fresnelFunction: {
  108719. name: string;
  108720. shader: string;
  108721. };
  108722. }
  108723. declare module BABYLON {
  108724. /** @hidden */
  108725. export var reflectionFunction: {
  108726. name: string;
  108727. shader: string;
  108728. };
  108729. }
  108730. declare module BABYLON {
  108731. /** @hidden */
  108732. export var bumpFragmentFunctions: {
  108733. name: string;
  108734. shader: string;
  108735. };
  108736. }
  108737. declare module BABYLON {
  108738. /** @hidden */
  108739. export var logDepthDeclaration: {
  108740. name: string;
  108741. shader: string;
  108742. };
  108743. }
  108744. declare module BABYLON {
  108745. /** @hidden */
  108746. export var bumpFragment: {
  108747. name: string;
  108748. shader: string;
  108749. };
  108750. }
  108751. declare module BABYLON {
  108752. /** @hidden */
  108753. export var depthPrePass: {
  108754. name: string;
  108755. shader: string;
  108756. };
  108757. }
  108758. declare module BABYLON {
  108759. /** @hidden */
  108760. export var lightFragment: {
  108761. name: string;
  108762. shader: string;
  108763. };
  108764. }
  108765. declare module BABYLON {
  108766. /** @hidden */
  108767. export var logDepthFragment: {
  108768. name: string;
  108769. shader: string;
  108770. };
  108771. }
  108772. declare module BABYLON {
  108773. /** @hidden */
  108774. export var defaultPixelShader: {
  108775. name: string;
  108776. shader: string;
  108777. };
  108778. }
  108779. declare module BABYLON {
  108780. /** @hidden */
  108781. export var defaultVertexDeclaration: {
  108782. name: string;
  108783. shader: string;
  108784. };
  108785. }
  108786. declare module BABYLON {
  108787. /** @hidden */
  108788. export var bumpVertexDeclaration: {
  108789. name: string;
  108790. shader: string;
  108791. };
  108792. }
  108793. declare module BABYLON {
  108794. /** @hidden */
  108795. export var bumpVertex: {
  108796. name: string;
  108797. shader: string;
  108798. };
  108799. }
  108800. declare module BABYLON {
  108801. /** @hidden */
  108802. export var fogVertex: {
  108803. name: string;
  108804. shader: string;
  108805. };
  108806. }
  108807. declare module BABYLON {
  108808. /** @hidden */
  108809. export var shadowsVertex: {
  108810. name: string;
  108811. shader: string;
  108812. };
  108813. }
  108814. declare module BABYLON {
  108815. /** @hidden */
  108816. export var pointCloudVertex: {
  108817. name: string;
  108818. shader: string;
  108819. };
  108820. }
  108821. declare module BABYLON {
  108822. /** @hidden */
  108823. export var logDepthVertex: {
  108824. name: string;
  108825. shader: string;
  108826. };
  108827. }
  108828. declare module BABYLON {
  108829. /** @hidden */
  108830. export var defaultVertexShader: {
  108831. name: string;
  108832. shader: string;
  108833. };
  108834. }
  108835. declare module BABYLON {
  108836. /** @hidden */
  108837. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108838. MAINUV1: boolean;
  108839. MAINUV2: boolean;
  108840. DIFFUSE: boolean;
  108841. DIFFUSEDIRECTUV: number;
  108842. AMBIENT: boolean;
  108843. AMBIENTDIRECTUV: number;
  108844. OPACITY: boolean;
  108845. OPACITYDIRECTUV: number;
  108846. OPACITYRGB: boolean;
  108847. REFLECTION: boolean;
  108848. EMISSIVE: boolean;
  108849. EMISSIVEDIRECTUV: number;
  108850. SPECULAR: boolean;
  108851. SPECULARDIRECTUV: number;
  108852. BUMP: boolean;
  108853. BUMPDIRECTUV: number;
  108854. PARALLAX: boolean;
  108855. PARALLAXOCCLUSION: boolean;
  108856. SPECULAROVERALPHA: boolean;
  108857. CLIPPLANE: boolean;
  108858. CLIPPLANE2: boolean;
  108859. CLIPPLANE3: boolean;
  108860. CLIPPLANE4: boolean;
  108861. ALPHATEST: boolean;
  108862. DEPTHPREPASS: boolean;
  108863. ALPHAFROMDIFFUSE: boolean;
  108864. POINTSIZE: boolean;
  108865. FOG: boolean;
  108866. SPECULARTERM: boolean;
  108867. DIFFUSEFRESNEL: boolean;
  108868. OPACITYFRESNEL: boolean;
  108869. REFLECTIONFRESNEL: boolean;
  108870. REFRACTIONFRESNEL: boolean;
  108871. EMISSIVEFRESNEL: boolean;
  108872. FRESNEL: boolean;
  108873. NORMAL: boolean;
  108874. UV1: boolean;
  108875. UV2: boolean;
  108876. VERTEXCOLOR: boolean;
  108877. VERTEXALPHA: boolean;
  108878. NUM_BONE_INFLUENCERS: number;
  108879. BonesPerMesh: number;
  108880. BONETEXTURE: boolean;
  108881. INSTANCES: boolean;
  108882. GLOSSINESS: boolean;
  108883. ROUGHNESS: boolean;
  108884. EMISSIVEASILLUMINATION: boolean;
  108885. LINKEMISSIVEWITHDIFFUSE: boolean;
  108886. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108887. LIGHTMAP: boolean;
  108888. LIGHTMAPDIRECTUV: number;
  108889. OBJECTSPACE_NORMALMAP: boolean;
  108890. USELIGHTMAPASSHADOWMAP: boolean;
  108891. REFLECTIONMAP_3D: boolean;
  108892. REFLECTIONMAP_SPHERICAL: boolean;
  108893. REFLECTIONMAP_PLANAR: boolean;
  108894. REFLECTIONMAP_CUBIC: boolean;
  108895. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108896. REFLECTIONMAP_PROJECTION: boolean;
  108897. REFLECTIONMAP_SKYBOX: boolean;
  108898. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108899. REFLECTIONMAP_EXPLICIT: boolean;
  108900. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108901. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108902. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108903. INVERTCUBICMAP: boolean;
  108904. LOGARITHMICDEPTH: boolean;
  108905. REFRACTION: boolean;
  108906. REFRACTIONMAP_3D: boolean;
  108907. REFLECTIONOVERALPHA: boolean;
  108908. TWOSIDEDLIGHTING: boolean;
  108909. SHADOWFLOAT: boolean;
  108910. MORPHTARGETS: boolean;
  108911. MORPHTARGETS_NORMAL: boolean;
  108912. MORPHTARGETS_TANGENT: boolean;
  108913. MORPHTARGETS_UV: boolean;
  108914. NUM_MORPH_INFLUENCERS: number;
  108915. NONUNIFORMSCALING: boolean;
  108916. PREMULTIPLYALPHA: boolean;
  108917. IMAGEPROCESSING: boolean;
  108918. VIGNETTE: boolean;
  108919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108920. VIGNETTEBLENDMODEOPAQUE: boolean;
  108921. TONEMAPPING: boolean;
  108922. TONEMAPPING_ACES: boolean;
  108923. CONTRAST: boolean;
  108924. COLORCURVES: boolean;
  108925. COLORGRADING: boolean;
  108926. COLORGRADING3D: boolean;
  108927. SAMPLER3DGREENDEPTH: boolean;
  108928. SAMPLER3DBGRMAP: boolean;
  108929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108930. MULTIVIEW: boolean;
  108931. /**
  108932. * If the reflection texture on this material is in linear color space
  108933. * @hidden
  108934. */
  108935. IS_REFLECTION_LINEAR: boolean;
  108936. /**
  108937. * If the refraction texture on this material is in linear color space
  108938. * @hidden
  108939. */
  108940. IS_REFRACTION_LINEAR: boolean;
  108941. EXPOSURE: boolean;
  108942. constructor();
  108943. setReflectionMode(modeToEnable: string): void;
  108944. }
  108945. /**
  108946. * This is the default material used in Babylon. It is the best trade off between quality
  108947. * and performances.
  108948. * @see http://doc.babylonjs.com/babylon101/materials
  108949. */
  108950. export class StandardMaterial extends PushMaterial {
  108951. private _diffuseTexture;
  108952. /**
  108953. * The basic texture of the material as viewed under a light.
  108954. */
  108955. diffuseTexture: Nullable<BaseTexture>;
  108956. private _ambientTexture;
  108957. /**
  108958. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108959. */
  108960. ambientTexture: Nullable<BaseTexture>;
  108961. private _opacityTexture;
  108962. /**
  108963. * Define the transparency of the material from a texture.
  108964. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108965. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108966. */
  108967. opacityTexture: Nullable<BaseTexture>;
  108968. private _reflectionTexture;
  108969. /**
  108970. * Define the texture used to display the reflection.
  108971. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108972. */
  108973. reflectionTexture: Nullable<BaseTexture>;
  108974. private _emissiveTexture;
  108975. /**
  108976. * Define texture of the material as if self lit.
  108977. * This will be mixed in the final result even in the absence of light.
  108978. */
  108979. emissiveTexture: Nullable<BaseTexture>;
  108980. private _specularTexture;
  108981. /**
  108982. * Define how the color and intensity of the highlight given by the light in the material.
  108983. */
  108984. specularTexture: Nullable<BaseTexture>;
  108985. private _bumpTexture;
  108986. /**
  108987. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108988. * 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.
  108989. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108990. */
  108991. bumpTexture: Nullable<BaseTexture>;
  108992. private _lightmapTexture;
  108993. /**
  108994. * Complex lighting can be computationally expensive to compute at runtime.
  108995. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108996. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108997. */
  108998. lightmapTexture: Nullable<BaseTexture>;
  108999. private _refractionTexture;
  109000. /**
  109001. * Define the texture used to display the refraction.
  109002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109003. */
  109004. refractionTexture: Nullable<BaseTexture>;
  109005. /**
  109006. * The color of the material lit by the environmental background lighting.
  109007. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109008. */
  109009. ambientColor: Color3;
  109010. /**
  109011. * The basic color of the material as viewed under a light.
  109012. */
  109013. diffuseColor: Color3;
  109014. /**
  109015. * Define how the color and intensity of the highlight given by the light in the material.
  109016. */
  109017. specularColor: Color3;
  109018. /**
  109019. * Define the color of the material as if self lit.
  109020. * This will be mixed in the final result even in the absence of light.
  109021. */
  109022. emissiveColor: Color3;
  109023. /**
  109024. * Defines how sharp are the highlights in the material.
  109025. * The bigger the value the sharper giving a more glossy feeling to the result.
  109026. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109027. */
  109028. specularPower: number;
  109029. private _useAlphaFromDiffuseTexture;
  109030. /**
  109031. * Does the transparency come from the diffuse texture alpha channel.
  109032. */
  109033. useAlphaFromDiffuseTexture: boolean;
  109034. private _useEmissiveAsIllumination;
  109035. /**
  109036. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109037. */
  109038. useEmissiveAsIllumination: boolean;
  109039. private _linkEmissiveWithDiffuse;
  109040. /**
  109041. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109042. * the emissive level when the final color is close to one.
  109043. */
  109044. linkEmissiveWithDiffuse: boolean;
  109045. private _useSpecularOverAlpha;
  109046. /**
  109047. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109048. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109049. */
  109050. useSpecularOverAlpha: boolean;
  109051. private _useReflectionOverAlpha;
  109052. /**
  109053. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109054. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109055. */
  109056. useReflectionOverAlpha: boolean;
  109057. private _disableLighting;
  109058. /**
  109059. * Does lights from the scene impacts this material.
  109060. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109061. */
  109062. disableLighting: boolean;
  109063. private _useObjectSpaceNormalMap;
  109064. /**
  109065. * Allows using an object space normal map (instead of tangent space).
  109066. */
  109067. useObjectSpaceNormalMap: boolean;
  109068. private _useParallax;
  109069. /**
  109070. * Is parallax enabled or not.
  109071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109072. */
  109073. useParallax: boolean;
  109074. private _useParallaxOcclusion;
  109075. /**
  109076. * Is parallax occlusion enabled or not.
  109077. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109078. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109079. */
  109080. useParallaxOcclusion: boolean;
  109081. /**
  109082. * 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.
  109083. */
  109084. parallaxScaleBias: number;
  109085. private _roughness;
  109086. /**
  109087. * Helps to define how blurry the reflections should appears in the material.
  109088. */
  109089. roughness: number;
  109090. /**
  109091. * In case of refraction, define the value of the index of refraction.
  109092. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109093. */
  109094. indexOfRefraction: number;
  109095. /**
  109096. * Invert the refraction texture alongside the y axis.
  109097. * It can be useful with procedural textures or probe for instance.
  109098. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109099. */
  109100. invertRefractionY: boolean;
  109101. /**
  109102. * Defines the alpha limits in alpha test mode.
  109103. */
  109104. alphaCutOff: number;
  109105. private _useLightmapAsShadowmap;
  109106. /**
  109107. * In case of light mapping, define whether the map contains light or shadow informations.
  109108. */
  109109. useLightmapAsShadowmap: boolean;
  109110. private _diffuseFresnelParameters;
  109111. /**
  109112. * Define the diffuse fresnel parameters of the material.
  109113. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109114. */
  109115. diffuseFresnelParameters: FresnelParameters;
  109116. private _opacityFresnelParameters;
  109117. /**
  109118. * Define the opacity fresnel parameters of the material.
  109119. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109120. */
  109121. opacityFresnelParameters: FresnelParameters;
  109122. private _reflectionFresnelParameters;
  109123. /**
  109124. * Define the reflection fresnel parameters of the material.
  109125. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109126. */
  109127. reflectionFresnelParameters: FresnelParameters;
  109128. private _refractionFresnelParameters;
  109129. /**
  109130. * Define the refraction fresnel parameters of the material.
  109131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109132. */
  109133. refractionFresnelParameters: FresnelParameters;
  109134. private _emissiveFresnelParameters;
  109135. /**
  109136. * Define the emissive fresnel parameters of the material.
  109137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109138. */
  109139. emissiveFresnelParameters: FresnelParameters;
  109140. private _useReflectionFresnelFromSpecular;
  109141. /**
  109142. * If true automatically deducts the fresnels values from the material specularity.
  109143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109144. */
  109145. useReflectionFresnelFromSpecular: boolean;
  109146. private _useGlossinessFromSpecularMapAlpha;
  109147. /**
  109148. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109149. */
  109150. useGlossinessFromSpecularMapAlpha: boolean;
  109151. private _maxSimultaneousLights;
  109152. /**
  109153. * Defines the maximum number of lights that can be used in the material
  109154. */
  109155. maxSimultaneousLights: number;
  109156. private _invertNormalMapX;
  109157. /**
  109158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109159. */
  109160. invertNormalMapX: boolean;
  109161. private _invertNormalMapY;
  109162. /**
  109163. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109164. */
  109165. invertNormalMapY: boolean;
  109166. private _twoSidedLighting;
  109167. /**
  109168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109169. */
  109170. twoSidedLighting: boolean;
  109171. /**
  109172. * Default configuration related to image processing available in the standard Material.
  109173. */
  109174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109175. /**
  109176. * Gets the image processing configuration used either in this material.
  109177. */
  109178. /**
  109179. * Sets the Default image processing configuration used either in the this material.
  109180. *
  109181. * If sets to null, the scene one is in use.
  109182. */
  109183. imageProcessingConfiguration: ImageProcessingConfiguration;
  109184. /**
  109185. * Keep track of the image processing observer to allow dispose and replace.
  109186. */
  109187. private _imageProcessingObserver;
  109188. /**
  109189. * Attaches a new image processing configuration to the Standard Material.
  109190. * @param configuration
  109191. */
  109192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109193. /**
  109194. * Gets wether the color curves effect is enabled.
  109195. */
  109196. /**
  109197. * Sets wether the color curves effect is enabled.
  109198. */
  109199. cameraColorCurvesEnabled: boolean;
  109200. /**
  109201. * Gets wether the color grading effect is enabled.
  109202. */
  109203. /**
  109204. * Gets wether the color grading effect is enabled.
  109205. */
  109206. cameraColorGradingEnabled: boolean;
  109207. /**
  109208. * Gets wether tonemapping is enabled or not.
  109209. */
  109210. /**
  109211. * Sets wether tonemapping is enabled or not
  109212. */
  109213. cameraToneMappingEnabled: boolean;
  109214. /**
  109215. * The camera exposure used on this material.
  109216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109217. * This corresponds to a photographic exposure.
  109218. */
  109219. /**
  109220. * The camera exposure used on this material.
  109221. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109222. * This corresponds to a photographic exposure.
  109223. */
  109224. cameraExposure: number;
  109225. /**
  109226. * Gets The camera contrast used on this material.
  109227. */
  109228. /**
  109229. * Sets The camera contrast used on this material.
  109230. */
  109231. cameraContrast: number;
  109232. /**
  109233. * Gets the Color Grading 2D Lookup Texture.
  109234. */
  109235. /**
  109236. * Sets the Color Grading 2D Lookup Texture.
  109237. */
  109238. cameraColorGradingTexture: Nullable<BaseTexture>;
  109239. /**
  109240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109242. * 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;
  109243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109244. */
  109245. /**
  109246. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109247. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109248. * 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;
  109249. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109250. */
  109251. cameraColorCurves: Nullable<ColorCurves>;
  109252. /**
  109253. * Custom callback helping to override the default shader used in the material.
  109254. */
  109255. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109256. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109257. protected _worldViewProjectionMatrix: Matrix;
  109258. protected _globalAmbientColor: Color3;
  109259. protected _useLogarithmicDepth: boolean;
  109260. protected _rebuildInParallel: boolean;
  109261. /**
  109262. * Instantiates a new standard material.
  109263. * This is the default material used in Babylon. It is the best trade off between quality
  109264. * and performances.
  109265. * @see http://doc.babylonjs.com/babylon101/materials
  109266. * @param name Define the name of the material in the scene
  109267. * @param scene Define the scene the material belong to
  109268. */
  109269. constructor(name: string, scene: Scene);
  109270. /**
  109271. * Gets a boolean indicating that current material needs to register RTT
  109272. */
  109273. readonly hasRenderTargetTextures: boolean;
  109274. /**
  109275. * Gets the current class name of the material e.g. "StandardMaterial"
  109276. * Mainly use in serialization.
  109277. * @returns the class name
  109278. */
  109279. getClassName(): string;
  109280. /**
  109281. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109282. * You can try switching to logarithmic depth.
  109283. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109284. */
  109285. useLogarithmicDepth: boolean;
  109286. /**
  109287. * Specifies if the material will require alpha blending
  109288. * @returns a boolean specifying if alpha blending is needed
  109289. */
  109290. needAlphaBlending(): boolean;
  109291. /**
  109292. * Specifies if this material should be rendered in alpha test mode
  109293. * @returns a boolean specifying if an alpha test is needed.
  109294. */
  109295. needAlphaTesting(): boolean;
  109296. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109297. /**
  109298. * Get the texture used for alpha test purpose.
  109299. * @returns the diffuse texture in case of the standard material.
  109300. */
  109301. getAlphaTestTexture(): Nullable<BaseTexture>;
  109302. /**
  109303. * Get if the submesh is ready to be used and all its information available.
  109304. * Child classes can use it to update shaders
  109305. * @param mesh defines the mesh to check
  109306. * @param subMesh defines which submesh to check
  109307. * @param useInstances specifies that instances should be used
  109308. * @returns a boolean indicating that the submesh is ready or not
  109309. */
  109310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109311. /**
  109312. * Builds the material UBO layouts.
  109313. * Used internally during the effect preparation.
  109314. */
  109315. buildUniformLayout(): void;
  109316. /**
  109317. * Unbinds the material from the mesh
  109318. */
  109319. unbind(): void;
  109320. /**
  109321. * Binds the submesh to this material by preparing the effect and shader to draw
  109322. * @param world defines the world transformation matrix
  109323. * @param mesh defines the mesh containing the submesh
  109324. * @param subMesh defines the submesh to bind the material to
  109325. */
  109326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109327. /**
  109328. * Get the list of animatables in the material.
  109329. * @returns the list of animatables object used in the material
  109330. */
  109331. getAnimatables(): IAnimatable[];
  109332. /**
  109333. * Gets the active textures from the material
  109334. * @returns an array of textures
  109335. */
  109336. getActiveTextures(): BaseTexture[];
  109337. /**
  109338. * Specifies if the material uses a texture
  109339. * @param texture defines the texture to check against the material
  109340. * @returns a boolean specifying if the material uses the texture
  109341. */
  109342. hasTexture(texture: BaseTexture): boolean;
  109343. /**
  109344. * Disposes the material
  109345. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109346. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109347. */
  109348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109349. /**
  109350. * Makes a duplicate of the material, and gives it a new name
  109351. * @param name defines the new name for the duplicated material
  109352. * @returns the cloned material
  109353. */
  109354. clone(name: string): StandardMaterial;
  109355. /**
  109356. * Serializes this material in a JSON representation
  109357. * @returns the serialized material object
  109358. */
  109359. serialize(): any;
  109360. /**
  109361. * Creates a standard material from parsed material data
  109362. * @param source defines the JSON representation of the material
  109363. * @param scene defines the hosting scene
  109364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109365. * @returns a new standard material
  109366. */
  109367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109368. /**
  109369. * Are diffuse textures enabled in the application.
  109370. */
  109371. static DiffuseTextureEnabled: boolean;
  109372. /**
  109373. * Are ambient textures enabled in the application.
  109374. */
  109375. static AmbientTextureEnabled: boolean;
  109376. /**
  109377. * Are opacity textures enabled in the application.
  109378. */
  109379. static OpacityTextureEnabled: boolean;
  109380. /**
  109381. * Are reflection textures enabled in the application.
  109382. */
  109383. static ReflectionTextureEnabled: boolean;
  109384. /**
  109385. * Are emissive textures enabled in the application.
  109386. */
  109387. static EmissiveTextureEnabled: boolean;
  109388. /**
  109389. * Are specular textures enabled in the application.
  109390. */
  109391. static SpecularTextureEnabled: boolean;
  109392. /**
  109393. * Are bump textures enabled in the application.
  109394. */
  109395. static BumpTextureEnabled: boolean;
  109396. /**
  109397. * Are lightmap textures enabled in the application.
  109398. */
  109399. static LightmapTextureEnabled: boolean;
  109400. /**
  109401. * Are refraction textures enabled in the application.
  109402. */
  109403. static RefractionTextureEnabled: boolean;
  109404. /**
  109405. * Are color grading textures enabled in the application.
  109406. */
  109407. static ColorGradingTextureEnabled: boolean;
  109408. /**
  109409. * Are fresnels enabled in the application.
  109410. */
  109411. static FresnelEnabled: boolean;
  109412. }
  109413. }
  109414. declare module BABYLON {
  109415. /** @hidden */
  109416. export var imageProcessingPixelShader: {
  109417. name: string;
  109418. shader: string;
  109419. };
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * ImageProcessingPostProcess
  109424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109425. */
  109426. export class ImageProcessingPostProcess extends PostProcess {
  109427. /**
  109428. * Default configuration related to image processing available in the PBR Material.
  109429. */
  109430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109431. /**
  109432. * Gets the image processing configuration used either in this material.
  109433. */
  109434. /**
  109435. * Sets the Default image processing configuration used either in the this material.
  109436. *
  109437. * If sets to null, the scene one is in use.
  109438. */
  109439. imageProcessingConfiguration: ImageProcessingConfiguration;
  109440. /**
  109441. * Keep track of the image processing observer to allow dispose and replace.
  109442. */
  109443. private _imageProcessingObserver;
  109444. /**
  109445. * Attaches a new image processing configuration to the PBR Material.
  109446. * @param configuration
  109447. */
  109448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109449. /**
  109450. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109451. */
  109452. /**
  109453. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109454. */
  109455. colorCurves: Nullable<ColorCurves>;
  109456. /**
  109457. * Gets wether the color curves effect is enabled.
  109458. */
  109459. /**
  109460. * Sets wether the color curves effect is enabled.
  109461. */
  109462. colorCurvesEnabled: boolean;
  109463. /**
  109464. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109465. */
  109466. /**
  109467. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109468. */
  109469. colorGradingTexture: Nullable<BaseTexture>;
  109470. /**
  109471. * Gets wether the color grading effect is enabled.
  109472. */
  109473. /**
  109474. * Gets wether the color grading effect is enabled.
  109475. */
  109476. colorGradingEnabled: boolean;
  109477. /**
  109478. * Gets exposure used in the effect.
  109479. */
  109480. /**
  109481. * Sets exposure used in the effect.
  109482. */
  109483. exposure: number;
  109484. /**
  109485. * Gets wether tonemapping is enabled or not.
  109486. */
  109487. /**
  109488. * Sets wether tonemapping is enabled or not
  109489. */
  109490. toneMappingEnabled: boolean;
  109491. /**
  109492. * Gets the type of tone mapping effect.
  109493. */
  109494. /**
  109495. * Sets the type of tone mapping effect.
  109496. */
  109497. toneMappingType: number;
  109498. /**
  109499. * Gets contrast used in the effect.
  109500. */
  109501. /**
  109502. * Sets contrast used in the effect.
  109503. */
  109504. contrast: number;
  109505. /**
  109506. * Gets Vignette stretch size.
  109507. */
  109508. /**
  109509. * Sets Vignette stretch size.
  109510. */
  109511. vignetteStretch: number;
  109512. /**
  109513. * Gets Vignette centre X Offset.
  109514. */
  109515. /**
  109516. * Sets Vignette centre X Offset.
  109517. */
  109518. vignetteCentreX: number;
  109519. /**
  109520. * Gets Vignette centre Y Offset.
  109521. */
  109522. /**
  109523. * Sets Vignette centre Y Offset.
  109524. */
  109525. vignetteCentreY: number;
  109526. /**
  109527. * Gets Vignette weight or intensity of the vignette effect.
  109528. */
  109529. /**
  109530. * Sets Vignette weight or intensity of the vignette effect.
  109531. */
  109532. vignetteWeight: number;
  109533. /**
  109534. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109535. * if vignetteEnabled is set to true.
  109536. */
  109537. /**
  109538. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109539. * if vignetteEnabled is set to true.
  109540. */
  109541. vignetteColor: Color4;
  109542. /**
  109543. * Gets Camera field of view used by the Vignette effect.
  109544. */
  109545. /**
  109546. * Sets Camera field of view used by the Vignette effect.
  109547. */
  109548. vignetteCameraFov: number;
  109549. /**
  109550. * Gets the vignette blend mode allowing different kind of effect.
  109551. */
  109552. /**
  109553. * Sets the vignette blend mode allowing different kind of effect.
  109554. */
  109555. vignetteBlendMode: number;
  109556. /**
  109557. * Gets wether the vignette effect is enabled.
  109558. */
  109559. /**
  109560. * Sets wether the vignette effect is enabled.
  109561. */
  109562. vignetteEnabled: boolean;
  109563. private _fromLinearSpace;
  109564. /**
  109565. * Gets wether the input of the processing is in Gamma or Linear Space.
  109566. */
  109567. /**
  109568. * Sets wether the input of the processing is in Gamma or Linear Space.
  109569. */
  109570. fromLinearSpace: boolean;
  109571. /**
  109572. * Defines cache preventing GC.
  109573. */
  109574. private _defines;
  109575. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109576. /**
  109577. * "ImageProcessingPostProcess"
  109578. * @returns "ImageProcessingPostProcess"
  109579. */
  109580. getClassName(): string;
  109581. protected _updateParameters(): void;
  109582. dispose(camera?: Camera): void;
  109583. }
  109584. }
  109585. declare module BABYLON {
  109586. /**
  109587. * Class containing static functions to help procedurally build meshes
  109588. */
  109589. export class GroundBuilder {
  109590. /**
  109591. * Creates a ground mesh
  109592. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109593. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109595. * @param name defines the name of the mesh
  109596. * @param options defines the options used to create the mesh
  109597. * @param scene defines the hosting scene
  109598. * @returns the ground mesh
  109599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109600. */
  109601. static CreateGround(name: string, options: {
  109602. width?: number;
  109603. height?: number;
  109604. subdivisions?: number;
  109605. subdivisionsX?: number;
  109606. subdivisionsY?: number;
  109607. updatable?: boolean;
  109608. }, scene: any): Mesh;
  109609. /**
  109610. * Creates a tiled ground mesh
  109611. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109612. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109613. * * 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
  109614. * * 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
  109615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109616. * @param name defines the name of the mesh
  109617. * @param options defines the options used to create the mesh
  109618. * @param scene defines the hosting scene
  109619. * @returns the tiled ground mesh
  109620. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109621. */
  109622. static CreateTiledGround(name: string, options: {
  109623. xmin: number;
  109624. zmin: number;
  109625. xmax: number;
  109626. zmax: number;
  109627. subdivisions?: {
  109628. w: number;
  109629. h: number;
  109630. };
  109631. precision?: {
  109632. w: number;
  109633. h: number;
  109634. };
  109635. updatable?: boolean;
  109636. }, scene?: Nullable<Scene>): Mesh;
  109637. /**
  109638. * Creates a ground mesh from a height map
  109639. * * The parameter `url` sets the URL of the height map image resource.
  109640. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109641. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109642. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109643. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109644. * * 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.
  109645. * * 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).
  109646. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109648. * @param name defines the name of the mesh
  109649. * @param url defines the url to the height map
  109650. * @param options defines the options used to create the mesh
  109651. * @param scene defines the hosting scene
  109652. * @returns the ground mesh
  109653. * @see https://doc.babylonjs.com/babylon101/height_map
  109654. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109655. */
  109656. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109657. width?: number;
  109658. height?: number;
  109659. subdivisions?: number;
  109660. minHeight?: number;
  109661. maxHeight?: number;
  109662. colorFilter?: Color3;
  109663. alphaFilter?: number;
  109664. updatable?: boolean;
  109665. onReady?: (mesh: GroundMesh) => void;
  109666. }, scene?: Nullable<Scene>): GroundMesh;
  109667. }
  109668. }
  109669. declare module BABYLON {
  109670. /**
  109671. * Class containing static functions to help procedurally build meshes
  109672. */
  109673. export class TorusBuilder {
  109674. /**
  109675. * Creates a torus mesh
  109676. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109677. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109678. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109682. * @param name defines the name of the mesh
  109683. * @param options defines the options used to create the mesh
  109684. * @param scene defines the hosting scene
  109685. * @returns the torus mesh
  109686. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109687. */
  109688. static CreateTorus(name: string, options: {
  109689. diameter?: number;
  109690. thickness?: number;
  109691. tessellation?: number;
  109692. updatable?: boolean;
  109693. sideOrientation?: number;
  109694. frontUVs?: Vector4;
  109695. backUVs?: Vector4;
  109696. }, scene: any): Mesh;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /**
  109701. * Class containing static functions to help procedurally build meshes
  109702. */
  109703. export class CylinderBuilder {
  109704. /**
  109705. * Creates a cylinder or a cone mesh
  109706. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109707. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109708. * * 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.
  109709. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109710. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109711. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109712. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109713. * * 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).
  109714. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109715. * * 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).
  109716. * * 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
  109717. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109718. * * 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
  109719. * * 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.
  109720. * * If `enclose` is false, a ring surface is one element.
  109721. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109722. * * 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
  109723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109726. * @param name defines the name of the mesh
  109727. * @param options defines the options used to create the mesh
  109728. * @param scene defines the hosting scene
  109729. * @returns the cylinder mesh
  109730. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109731. */
  109732. static CreateCylinder(name: string, options: {
  109733. height?: number;
  109734. diameterTop?: number;
  109735. diameterBottom?: number;
  109736. diameter?: number;
  109737. tessellation?: number;
  109738. subdivisions?: number;
  109739. arc?: number;
  109740. faceColors?: Color4[];
  109741. faceUV?: Vector4[];
  109742. updatable?: boolean;
  109743. hasRings?: boolean;
  109744. enclose?: boolean;
  109745. cap?: number;
  109746. sideOrientation?: number;
  109747. frontUVs?: Vector4;
  109748. backUVs?: Vector4;
  109749. }, scene: any): Mesh;
  109750. }
  109751. }
  109752. declare module BABYLON {
  109753. /**
  109754. * Options to modify the vr teleportation behavior.
  109755. */
  109756. export interface VRTeleportationOptions {
  109757. /**
  109758. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109759. */
  109760. floorMeshName?: string;
  109761. /**
  109762. * A list of meshes to be used as the teleportation floor. (default: empty)
  109763. */
  109764. floorMeshes?: Mesh[];
  109765. }
  109766. /**
  109767. * Options to modify the vr experience helper's behavior.
  109768. */
  109769. export interface VRExperienceHelperOptions extends WebVROptions {
  109770. /**
  109771. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109772. */
  109773. createDeviceOrientationCamera?: boolean;
  109774. /**
  109775. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109776. */
  109777. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109778. /**
  109779. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109780. */
  109781. laserToggle?: boolean;
  109782. /**
  109783. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109784. */
  109785. floorMeshes?: Mesh[];
  109786. /**
  109787. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109788. */
  109789. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109790. }
  109791. /**
  109792. * Event containing information after VR has been entered
  109793. */
  109794. export class OnAfterEnteringVRObservableEvent {
  109795. /**
  109796. * If entering vr was successful
  109797. */
  109798. success: boolean;
  109799. }
  109800. /**
  109801. * Helps to quickly add VR support to an existing scene.
  109802. * See http://doc.babylonjs.com/how_to/webvr_helper
  109803. */
  109804. export class VRExperienceHelper {
  109805. /** Options to modify the vr experience helper's behavior. */
  109806. webVROptions: VRExperienceHelperOptions;
  109807. private _scene;
  109808. private _position;
  109809. private _btnVR;
  109810. private _btnVRDisplayed;
  109811. private _webVRsupported;
  109812. private _webVRready;
  109813. private _webVRrequesting;
  109814. private _webVRpresenting;
  109815. private _hasEnteredVR;
  109816. private _fullscreenVRpresenting;
  109817. private _inputElement;
  109818. private _webVRCamera;
  109819. private _vrDeviceOrientationCamera;
  109820. private _deviceOrientationCamera;
  109821. private _existingCamera;
  109822. private _onKeyDown;
  109823. private _onVrDisplayPresentChange;
  109824. private _onVRDisplayChanged;
  109825. private _onVRRequestPresentStart;
  109826. private _onVRRequestPresentComplete;
  109827. /**
  109828. * 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)
  109829. */
  109830. enableGazeEvenWhenNoPointerLock: boolean;
  109831. /**
  109832. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109833. */
  109834. exitVROnDoubleTap: boolean;
  109835. /**
  109836. * Observable raised right before entering VR.
  109837. */
  109838. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109839. /**
  109840. * Observable raised when entering VR has completed.
  109841. */
  109842. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109843. /**
  109844. * Observable raised when exiting VR.
  109845. */
  109846. onExitingVRObservable: Observable<VRExperienceHelper>;
  109847. /**
  109848. * Observable raised when controller mesh is loaded.
  109849. */
  109850. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109851. /** Return this.onEnteringVRObservable
  109852. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109853. */
  109854. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109855. /** Return this.onExitingVRObservable
  109856. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109857. */
  109858. readonly onExitingVR: Observable<VRExperienceHelper>;
  109859. /** Return this.onControllerMeshLoadedObservable
  109860. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109861. */
  109862. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109863. private _rayLength;
  109864. private _useCustomVRButton;
  109865. private _teleportationRequested;
  109866. private _teleportActive;
  109867. private _floorMeshName;
  109868. private _floorMeshesCollection;
  109869. private _rotationAllowed;
  109870. private _teleportBackwardsVector;
  109871. private _teleportationTarget;
  109872. private _isDefaultTeleportationTarget;
  109873. private _postProcessMove;
  109874. private _teleportationFillColor;
  109875. private _teleportationBorderColor;
  109876. private _rotationAngle;
  109877. private _haloCenter;
  109878. private _cameraGazer;
  109879. private _padSensibilityUp;
  109880. private _padSensibilityDown;
  109881. private _leftController;
  109882. private _rightController;
  109883. /**
  109884. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109885. */
  109886. onNewMeshSelected: Observable<AbstractMesh>;
  109887. /**
  109888. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109889. * This observable will provide the mesh and the controller used to select the mesh
  109890. */
  109891. onMeshSelectedWithController: Observable<{
  109892. mesh: AbstractMesh;
  109893. controller: WebVRController;
  109894. }>;
  109895. /**
  109896. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109897. */
  109898. onNewMeshPicked: Observable<PickingInfo>;
  109899. private _circleEase;
  109900. /**
  109901. * Observable raised before camera teleportation
  109902. */
  109903. onBeforeCameraTeleport: Observable<Vector3>;
  109904. /**
  109905. * Observable raised after camera teleportation
  109906. */
  109907. onAfterCameraTeleport: Observable<Vector3>;
  109908. /**
  109909. * Observable raised when current selected mesh gets unselected
  109910. */
  109911. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109912. private _raySelectionPredicate;
  109913. /**
  109914. * To be optionaly changed by user to define custom ray selection
  109915. */
  109916. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109917. /**
  109918. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109919. */
  109920. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109921. /**
  109922. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109923. */
  109924. teleportationEnabled: boolean;
  109925. private _defaultHeight;
  109926. private _teleportationInitialized;
  109927. private _interactionsEnabled;
  109928. private _interactionsRequested;
  109929. private _displayGaze;
  109930. private _displayLaserPointer;
  109931. /**
  109932. * The mesh used to display where the user is going to teleport.
  109933. */
  109934. /**
  109935. * Sets the mesh to be used to display where the user is going to teleport.
  109936. */
  109937. teleportationTarget: Mesh;
  109938. /**
  109939. * 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
  109940. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109941. * See http://doc.babylonjs.com/resources/baking_transformations
  109942. */
  109943. gazeTrackerMesh: Mesh;
  109944. /**
  109945. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109946. */
  109947. updateGazeTrackerScale: boolean;
  109948. /**
  109949. * If the gaze trackers color should be updated when selecting meshes
  109950. */
  109951. updateGazeTrackerColor: boolean;
  109952. /**
  109953. * If the controller laser color should be updated when selecting meshes
  109954. */
  109955. updateControllerLaserColor: boolean;
  109956. /**
  109957. * The gaze tracking mesh corresponding to the left controller
  109958. */
  109959. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109960. /**
  109961. * The gaze tracking mesh corresponding to the right controller
  109962. */
  109963. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109964. /**
  109965. * If the ray of the gaze should be displayed.
  109966. */
  109967. /**
  109968. * Sets if the ray of the gaze should be displayed.
  109969. */
  109970. displayGaze: boolean;
  109971. /**
  109972. * If the ray of the LaserPointer should be displayed.
  109973. */
  109974. /**
  109975. * Sets if the ray of the LaserPointer should be displayed.
  109976. */
  109977. displayLaserPointer: boolean;
  109978. /**
  109979. * The deviceOrientationCamera used as the camera when not in VR.
  109980. */
  109981. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109982. /**
  109983. * Based on the current WebVR support, returns the current VR camera used.
  109984. */
  109985. readonly currentVRCamera: Nullable<Camera>;
  109986. /**
  109987. * The webVRCamera which is used when in VR.
  109988. */
  109989. readonly webVRCamera: WebVRFreeCamera;
  109990. /**
  109991. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109992. */
  109993. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109994. /**
  109995. * The html button that is used to trigger entering into VR.
  109996. */
  109997. readonly vrButton: Nullable<HTMLButtonElement>;
  109998. private readonly _teleportationRequestInitiated;
  109999. /**
  110000. * Defines wether or not Pointer lock should be requested when switching to
  110001. * full screen.
  110002. */
  110003. requestPointerLockOnFullScreen: boolean;
  110004. /**
  110005. * Instantiates a VRExperienceHelper.
  110006. * Helps to quickly add VR support to an existing scene.
  110007. * @param scene The scene the VRExperienceHelper belongs to.
  110008. * @param webVROptions Options to modify the vr experience helper's behavior.
  110009. */
  110010. constructor(scene: Scene,
  110011. /** Options to modify the vr experience helper's behavior. */
  110012. webVROptions?: VRExperienceHelperOptions);
  110013. private _onDefaultMeshLoaded;
  110014. private _onResize;
  110015. private _onFullscreenChange;
  110016. /**
  110017. * Gets a value indicating if we are currently in VR mode.
  110018. */
  110019. readonly isInVRMode: boolean;
  110020. private onVrDisplayPresentChange;
  110021. private onVRDisplayChanged;
  110022. private moveButtonToBottomRight;
  110023. private displayVRButton;
  110024. private updateButtonVisibility;
  110025. private _cachedAngularSensibility;
  110026. /**
  110027. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  110028. * Otherwise, will use the fullscreen API.
  110029. */
  110030. enterVR(): void;
  110031. /**
  110032. * Attempt to exit VR, or fullscreen.
  110033. */
  110034. exitVR(): void;
  110035. /**
  110036. * The position of the vr experience helper.
  110037. */
  110038. /**
  110039. * Sets the position of the vr experience helper.
  110040. */
  110041. position: Vector3;
  110042. /**
  110043. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  110044. */
  110045. enableInteractions(): void;
  110046. private readonly _noControllerIsActive;
  110047. private beforeRender;
  110048. private _isTeleportationFloor;
  110049. /**
  110050. * Adds a floor mesh to be used for teleportation.
  110051. * @param floorMesh the mesh to be used for teleportation.
  110052. */
  110053. addFloorMesh(floorMesh: Mesh): void;
  110054. /**
  110055. * Removes a floor mesh from being used for teleportation.
  110056. * @param floorMesh the mesh to be removed.
  110057. */
  110058. removeFloorMesh(floorMesh: Mesh): void;
  110059. /**
  110060. * Enables interactions and teleportation using the VR controllers and gaze.
  110061. * @param vrTeleportationOptions options to modify teleportation behavior.
  110062. */
  110063. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  110064. private _onNewGamepadConnected;
  110065. private _tryEnableInteractionOnController;
  110066. private _onNewGamepadDisconnected;
  110067. private _enableInteractionOnController;
  110068. private _checkTeleportWithRay;
  110069. private _checkRotate;
  110070. private _checkTeleportBackwards;
  110071. private _enableTeleportationOnController;
  110072. private _createTeleportationCircles;
  110073. private _displayTeleportationTarget;
  110074. private _hideTeleportationTarget;
  110075. private _rotateCamera;
  110076. private _moveTeleportationSelectorTo;
  110077. private _workingVector;
  110078. private _workingQuaternion;
  110079. private _workingMatrix;
  110080. /**
  110081. * Teleports the users feet to the desired location
  110082. * @param location The location where the user's feet should be placed
  110083. */
  110084. teleportCamera(location: Vector3): void;
  110085. private _convertNormalToDirectionOfRay;
  110086. private _castRayAndSelectObject;
  110087. private _notifySelectedMeshUnselected;
  110088. /**
  110089. * Sets the color of the laser ray from the vr controllers.
  110090. * @param color new color for the ray.
  110091. */
  110092. changeLaserColor(color: Color3): void;
  110093. /**
  110094. * Sets the color of the ray from the vr headsets gaze.
  110095. * @param color new color for the ray.
  110096. */
  110097. changeGazeColor(color: Color3): void;
  110098. /**
  110099. * Exits VR and disposes of the vr experience helper
  110100. */
  110101. dispose(): void;
  110102. /**
  110103. * Gets the name of the VRExperienceHelper class
  110104. * @returns "VRExperienceHelper"
  110105. */
  110106. getClassName(): string;
  110107. }
  110108. }
  110109. declare module BABYLON {
  110110. /**
  110111. * States of the webXR experience
  110112. */
  110113. export enum WebXRState {
  110114. /**
  110115. * Transitioning to being in XR mode
  110116. */
  110117. ENTERING_XR = 0,
  110118. /**
  110119. * Transitioning to non XR mode
  110120. */
  110121. EXITING_XR = 1,
  110122. /**
  110123. * In XR mode and presenting
  110124. */
  110125. IN_XR = 2,
  110126. /**
  110127. * Not entered XR mode
  110128. */
  110129. NOT_IN_XR = 3
  110130. }
  110131. /**
  110132. * Abstraction of the XR render target
  110133. */
  110134. export interface WebXRRenderTarget extends IDisposable {
  110135. /**
  110136. * xrpresent context of the canvas which can be used to display/mirror xr content
  110137. */
  110138. canvasContext: WebGLRenderingContext;
  110139. /**
  110140. * xr layer for the canvas
  110141. */
  110142. xrLayer: Nullable<XRWebGLLayer>;
  110143. /**
  110144. * Initializes the xr layer for the session
  110145. * @param xrSession xr session
  110146. * @returns a promise that will resolve once the XR Layer has been created
  110147. */
  110148. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110149. }
  110150. }
  110151. declare module BABYLON {
  110152. /**
  110153. * COnfiguration object for WebXR output canvas
  110154. */
  110155. export class WebXRManagedOutputCanvasOptions {
  110156. /**
  110157. * Options for this XR Layer output
  110158. */
  110159. canvasOptions: XRWebGLLayerOptions;
  110160. /**
  110161. * CSS styling for a newly created canvas (if not provided)
  110162. */
  110163. newCanvasCssStyle?: string;
  110164. /**
  110165. * Get the default values of the configuration object
  110166. * @returns default values of this configuration object
  110167. */
  110168. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110169. }
  110170. /**
  110171. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110172. */
  110173. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110174. private configuration;
  110175. private _engine;
  110176. private _canvas;
  110177. /**
  110178. * xrpresent context of the canvas which can be used to display/mirror xr content
  110179. */
  110180. canvasContext: WebGLRenderingContext;
  110181. /**
  110182. * xr layer for the canvas
  110183. */
  110184. xrLayer: Nullable<XRWebGLLayer>;
  110185. /**
  110186. * Initializes the xr layer for the session
  110187. * @param xrSession xr session
  110188. * @returns a promise that will resolve once the XR Layer has been created
  110189. */
  110190. initializeXRLayerAsync(xrSession: any): any;
  110191. /**
  110192. * Initializes the canvas to be added/removed upon entering/exiting xr
  110193. * @param engine the Babylon engine
  110194. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110195. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110196. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110197. */
  110198. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110199. /**
  110200. * Disposes of the object
  110201. */
  110202. dispose(): void;
  110203. private _setManagedOutputCanvas;
  110204. private _addCanvas;
  110205. private _removeCanvas;
  110206. }
  110207. }
  110208. declare module BABYLON {
  110209. /**
  110210. * Manages an XRSession to work with Babylon's engine
  110211. * @see https://doc.babylonjs.com/how_to/webxr
  110212. */
  110213. export class WebXRSessionManager implements IDisposable {
  110214. private scene;
  110215. /**
  110216. * Fires every time a new xrFrame arrives which can be used to update the camera
  110217. */
  110218. onXRFrameObservable: Observable<any>;
  110219. /**
  110220. * Fires when the xr session is ended either by the device or manually done
  110221. */
  110222. onXRSessionEnded: Observable<any>;
  110223. /**
  110224. * Underlying xr session
  110225. */
  110226. session: XRSession;
  110227. /**
  110228. * Type of reference space used when creating the session
  110229. */
  110230. referenceSpace: XRReferenceSpace;
  110231. /**
  110232. * Current XR frame
  110233. */
  110234. currentFrame: Nullable<XRFrame>;
  110235. private _xrNavigator;
  110236. private baseLayer;
  110237. private _rttProvider;
  110238. private _sessionEnded;
  110239. /**
  110240. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110241. * @param scene The scene which the session should be created for
  110242. */
  110243. constructor(scene: Scene);
  110244. /**
  110245. * Initializes the manager
  110246. * After initialization enterXR can be called to start an XR session
  110247. * @returns Promise which resolves after it is initialized
  110248. */
  110249. initializeAsync(): Promise<void>;
  110250. /**
  110251. * Initializes an xr session
  110252. * @param xrSessionMode mode to initialize
  110253. * @param optionalFeatures defines optional values to pass to the session builder
  110254. * @returns a promise which will resolve once the session has been initialized
  110255. */
  110256. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  110257. /**
  110258. * Sets the reference space on the xr session
  110259. * @param referenceSpace space to set
  110260. * @returns a promise that will resolve once the reference space has been set
  110261. */
  110262. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110263. /**
  110264. * Updates the render state of the session
  110265. * @param state state to set
  110266. * @returns a promise that resolves once the render state has been updated
  110267. */
  110268. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110269. /**
  110270. * Starts rendering to the xr layer
  110271. * @returns a promise that will resolve once rendering has started
  110272. */
  110273. startRenderingToXRAsync(): Promise<void>;
  110274. /**
  110275. * Gets the correct render target texture to be rendered this frame for this eye
  110276. * @param eye the eye for which to get the render target
  110277. * @returns the render target for the specified eye
  110278. */
  110279. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110280. /**
  110281. * Stops the xrSession and restores the renderloop
  110282. * @returns Promise which resolves after it exits XR
  110283. */
  110284. exitXRAsync(): Promise<void>;
  110285. /**
  110286. * Checks if a session would be supported for the creation options specified
  110287. * @param sessionMode session mode to check if supported eg. immersive-vr
  110288. * @returns true if supported
  110289. */
  110290. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110291. /**
  110292. * Creates a WebXRRenderTarget object for the XR session
  110293. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110294. * @param options optional options to provide when creating a new render target
  110295. * @returns a WebXR render target to which the session can render
  110296. */
  110297. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110298. /**
  110299. * @hidden
  110300. * Converts the render layer of xrSession to a render target
  110301. * @param session session to create render target for
  110302. * @param scene scene the new render target should be created for
  110303. */
  110304. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110305. /**
  110306. * Disposes of the session manager
  110307. */
  110308. dispose(): void;
  110309. }
  110310. }
  110311. declare module BABYLON {
  110312. /**
  110313. * WebXR Camera which holds the views for the xrSession
  110314. * @see https://doc.babylonjs.com/how_to/webxr
  110315. */
  110316. export class WebXRCamera extends FreeCamera {
  110317. private static _TmpMatrix;
  110318. /**
  110319. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110320. * @param name the name of the camera
  110321. * @param scene the scene to add the camera to
  110322. */
  110323. constructor(name: string, scene: Scene);
  110324. private _updateNumberOfRigCameras;
  110325. /** @hidden */
  110326. _updateForDualEyeDebugging(): void;
  110327. /**
  110328. * Updates the cameras position from the current pose information of the XR session
  110329. * @param xrSessionManager the session containing pose information
  110330. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110331. */
  110332. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110333. }
  110334. }
  110335. declare module BABYLON {
  110336. /**
  110337. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110338. * @see https://doc.babylonjs.com/how_to/webxr
  110339. */
  110340. export class WebXRExperienceHelper implements IDisposable {
  110341. private scene;
  110342. /**
  110343. * 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
  110344. */
  110345. container: AbstractMesh;
  110346. /**
  110347. * Camera used to render xr content
  110348. */
  110349. camera: WebXRCamera;
  110350. /**
  110351. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110352. */
  110353. state: WebXRState;
  110354. private _setState;
  110355. private static _TmpVector;
  110356. /**
  110357. * Fires when the state of the experience helper has changed
  110358. */
  110359. onStateChangedObservable: Observable<WebXRState>;
  110360. /** Session manager used to keep track of xr session */
  110361. sessionManager: WebXRSessionManager;
  110362. private _nonVRCamera;
  110363. private _originalSceneAutoClear;
  110364. private _supported;
  110365. /**
  110366. * Creates the experience helper
  110367. * @param scene the scene to attach the experience helper to
  110368. * @returns a promise for the experience helper
  110369. */
  110370. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110371. /**
  110372. * Creates a WebXRExperienceHelper
  110373. * @param scene The scene the helper should be created in
  110374. */
  110375. private constructor();
  110376. /**
  110377. * Exits XR mode and returns the scene to its original state
  110378. * @returns promise that resolves after xr mode has exited
  110379. */
  110380. exitXRAsync(): Promise<void>;
  110381. /**
  110382. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110383. * @param sessionMode options for the XR session
  110384. * @param referenceSpaceType frame of reference of the XR session
  110385. * @param renderTarget the output canvas that will be used to enter XR mode
  110386. * @returns promise that resolves after xr mode has entered
  110387. */
  110388. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110389. /**
  110390. * Updates the global position of the camera by moving the camera's container
  110391. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110392. * @param position The desired global position of the camera
  110393. */
  110394. setPositionOfCameraUsingContainer(position: Vector3): void;
  110395. /**
  110396. * Rotates the xr camera by rotating the camera's container around the camera's position
  110397. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110398. * @param rotation the desired quaternion rotation to apply to the camera
  110399. */
  110400. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110401. /**
  110402. * Disposes of the experience helper
  110403. */
  110404. dispose(): void;
  110405. }
  110406. }
  110407. declare module BABYLON {
  110408. /**
  110409. * Button which can be used to enter a different mode of XR
  110410. */
  110411. export class WebXREnterExitUIButton {
  110412. /** button element */
  110413. element: HTMLElement;
  110414. /** XR initialization options for the button */
  110415. sessionMode: XRSessionMode;
  110416. /** Reference space type */
  110417. referenceSpaceType: XRReferenceSpaceType;
  110418. /**
  110419. * Creates a WebXREnterExitUIButton
  110420. * @param element button element
  110421. * @param sessionMode XR initialization session mode
  110422. * @param referenceSpaceType the type of reference space to be used
  110423. */
  110424. constructor(
  110425. /** button element */
  110426. element: HTMLElement,
  110427. /** XR initialization options for the button */
  110428. sessionMode: XRSessionMode,
  110429. /** Reference space type */
  110430. referenceSpaceType: XRReferenceSpaceType);
  110431. /**
  110432. * Overwritable function which can be used to update the button's visuals when the state changes
  110433. * @param activeButton the current active button in the UI
  110434. */
  110435. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110436. }
  110437. /**
  110438. * Options to create the webXR UI
  110439. */
  110440. export class WebXREnterExitUIOptions {
  110441. /**
  110442. * Context to enter xr with
  110443. */
  110444. renderTarget?: Nullable<WebXRRenderTarget>;
  110445. /**
  110446. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110447. */
  110448. customButtons?: Array<WebXREnterExitUIButton>;
  110449. }
  110450. /**
  110451. * UI to allow the user to enter/exit XR mode
  110452. */
  110453. export class WebXREnterExitUI implements IDisposable {
  110454. private scene;
  110455. private _overlay;
  110456. private _buttons;
  110457. private _activeButton;
  110458. /**
  110459. * Fired every time the active button is changed.
  110460. *
  110461. * When xr is entered via a button that launches xr that button will be the callback parameter
  110462. *
  110463. * When exiting xr the callback parameter will be null)
  110464. */
  110465. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110466. /**
  110467. * Creates UI to allow the user to enter/exit XR mode
  110468. * @param scene the scene to add the ui to
  110469. * @param helper the xr experience helper to enter/exit xr with
  110470. * @param options options to configure the UI
  110471. * @returns the created ui
  110472. */
  110473. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110474. private constructor();
  110475. private _updateButtons;
  110476. /**
  110477. * Disposes of the object
  110478. */
  110479. dispose(): void;
  110480. }
  110481. }
  110482. declare module BABYLON {
  110483. /**
  110484. * Represents an XR input
  110485. */
  110486. export class WebXRController {
  110487. private scene;
  110488. /** The underlying input source for the controller */
  110489. inputSource: XRInputSource;
  110490. private parentContainer;
  110491. /**
  110492. * 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
  110493. */
  110494. grip?: AbstractMesh;
  110495. /**
  110496. * Pointer which can be used to select objects or attach a visible laser to
  110497. */
  110498. pointer: AbstractMesh;
  110499. private _gamepadMode;
  110500. /**
  110501. * If available, this is the gamepad object related to this controller.
  110502. * Using this object it is possible to get click events and trackpad changes of the
  110503. * webxr controller that is currently being used.
  110504. */
  110505. gamepadController?: WebVRController;
  110506. /**
  110507. * Event that fires when the controller is removed/disposed
  110508. */
  110509. onDisposeObservable: Observable<{}>;
  110510. private _tmpMatrix;
  110511. private _tmpQuaternion;
  110512. private _tmpVector;
  110513. /**
  110514. * Creates the controller
  110515. * @see https://doc.babylonjs.com/how_to/webxr
  110516. * @param scene the scene which the controller should be associated to
  110517. * @param inputSource the underlying input source for the controller
  110518. * @param parentContainer parent that the controller meshes should be children of
  110519. */
  110520. constructor(scene: Scene,
  110521. /** The underlying input source for the controller */
  110522. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110523. /**
  110524. * Updates the controller pose based on the given XRFrame
  110525. * @param xrFrame xr frame to update the pose with
  110526. * @param referenceSpace reference space to use
  110527. */
  110528. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110529. /**
  110530. * Gets a world space ray coming from the controller
  110531. * @param result the resulting ray
  110532. */
  110533. getWorldPointerRayToRef(result: Ray): void;
  110534. /**
  110535. * Get the scene associated with this controller
  110536. * @returns the scene object
  110537. */
  110538. getScene(): Scene;
  110539. /**
  110540. * Disposes of the object
  110541. */
  110542. dispose(): void;
  110543. }
  110544. }
  110545. declare module BABYLON {
  110546. /**
  110547. * XR input used to track XR inputs such as controllers/rays
  110548. */
  110549. export class WebXRInput implements IDisposable {
  110550. /**
  110551. * Base experience the input listens to
  110552. */
  110553. baseExperience: WebXRExperienceHelper;
  110554. /**
  110555. * XR controllers being tracked
  110556. */
  110557. controllers: Array<WebXRController>;
  110558. private _frameObserver;
  110559. private _stateObserver;
  110560. /**
  110561. * Event when a controller has been connected/added
  110562. */
  110563. onControllerAddedObservable: Observable<WebXRController>;
  110564. /**
  110565. * Event when a controller has been removed/disconnected
  110566. */
  110567. onControllerRemovedObservable: Observable<WebXRController>;
  110568. /**
  110569. * Initializes the WebXRInput
  110570. * @param baseExperience experience helper which the input should be created for
  110571. */
  110572. constructor(
  110573. /**
  110574. * Base experience the input listens to
  110575. */
  110576. baseExperience: WebXRExperienceHelper);
  110577. private _onInputSourcesChange;
  110578. private _addAndRemoveControllers;
  110579. /**
  110580. * Disposes of the object
  110581. */
  110582. dispose(): void;
  110583. }
  110584. }
  110585. declare module BABYLON {
  110586. /**
  110587. * Enables teleportation
  110588. */
  110589. export class WebXRControllerTeleportation {
  110590. private _teleportationFillColor;
  110591. private _teleportationBorderColor;
  110592. private _tmpRay;
  110593. private _tmpVector;
  110594. /**
  110595. * Creates a WebXRControllerTeleportation
  110596. * @param input input manager to add teleportation to
  110597. * @param floorMeshes floormeshes which can be teleported to
  110598. */
  110599. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110600. }
  110601. }
  110602. declare module BABYLON {
  110603. /**
  110604. * Handles pointer input automatically for the pointer of XR controllers
  110605. */
  110606. export class WebXRControllerPointerSelection {
  110607. private static _idCounter;
  110608. private _tmpRay;
  110609. /**
  110610. * Creates a WebXRControllerPointerSelection
  110611. * @param input input manager to setup pointer selection
  110612. */
  110613. constructor(input: WebXRInput);
  110614. private _convertNormalToDirectionOfRay;
  110615. private _updatePointerDistance;
  110616. }
  110617. }
  110618. declare module BABYLON {
  110619. /**
  110620. * Class used to represent data loading progression
  110621. */
  110622. export class SceneLoaderProgressEvent {
  110623. /** defines if data length to load can be evaluated */
  110624. readonly lengthComputable: boolean;
  110625. /** defines the loaded data length */
  110626. readonly loaded: number;
  110627. /** defines the data length to load */
  110628. readonly total: number;
  110629. /**
  110630. * Create a new progress event
  110631. * @param lengthComputable defines if data length to load can be evaluated
  110632. * @param loaded defines the loaded data length
  110633. * @param total defines the data length to load
  110634. */
  110635. constructor(
  110636. /** defines if data length to load can be evaluated */
  110637. lengthComputable: boolean,
  110638. /** defines the loaded data length */
  110639. loaded: number,
  110640. /** defines the data length to load */
  110641. total: number);
  110642. /**
  110643. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110644. * @param event defines the source event
  110645. * @returns a new SceneLoaderProgressEvent
  110646. */
  110647. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110648. }
  110649. /**
  110650. * Interface used by SceneLoader plugins to define supported file extensions
  110651. */
  110652. export interface ISceneLoaderPluginExtensions {
  110653. /**
  110654. * Defines the list of supported extensions
  110655. */
  110656. [extension: string]: {
  110657. isBinary: boolean;
  110658. };
  110659. }
  110660. /**
  110661. * Interface used by SceneLoader plugin factory
  110662. */
  110663. export interface ISceneLoaderPluginFactory {
  110664. /**
  110665. * Defines the name of the factory
  110666. */
  110667. name: string;
  110668. /**
  110669. * Function called to create a new plugin
  110670. * @return the new plugin
  110671. */
  110672. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110673. /**
  110674. * The callback that returns true if the data can be directly loaded.
  110675. * @param data string containing the file data
  110676. * @returns if the data can be loaded directly
  110677. */
  110678. canDirectLoad?(data: string): boolean;
  110679. }
  110680. /**
  110681. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110682. */
  110683. export interface ISceneLoaderPluginBase {
  110684. /**
  110685. * The friendly name of this plugin.
  110686. */
  110687. name: string;
  110688. /**
  110689. * The file extensions supported by this plugin.
  110690. */
  110691. extensions: string | ISceneLoaderPluginExtensions;
  110692. /**
  110693. * The callback called when loading from a url.
  110694. * @param scene scene loading this url
  110695. * @param url url to load
  110696. * @param onSuccess callback called when the file successfully loads
  110697. * @param onProgress callback called while file is loading (if the server supports this mode)
  110698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110699. * @param onError callback called when the file fails to load
  110700. * @returns a file request object
  110701. */
  110702. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110703. /**
  110704. * The callback called when loading from a file object.
  110705. * @param scene scene loading this file
  110706. * @param file defines the file to load
  110707. * @param onSuccess defines the callback to call when data is loaded
  110708. * @param onProgress defines the callback to call during loading process
  110709. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110710. * @param onError defines the callback to call when an error occurs
  110711. * @returns a file request object
  110712. */
  110713. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110714. /**
  110715. * The callback that returns true if the data can be directly loaded.
  110716. * @param data string containing the file data
  110717. * @returns if the data can be loaded directly
  110718. */
  110719. canDirectLoad?(data: string): boolean;
  110720. /**
  110721. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110722. * @param scene scene loading this data
  110723. * @param data string containing the data
  110724. * @returns data to pass to the plugin
  110725. */
  110726. directLoad?(scene: Scene, data: string): any;
  110727. /**
  110728. * The callback that allows custom handling of the root url based on the response url.
  110729. * @param rootUrl the original root url
  110730. * @param responseURL the response url if available
  110731. * @returns the new root url
  110732. */
  110733. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110734. }
  110735. /**
  110736. * Interface used to define a SceneLoader plugin
  110737. */
  110738. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110739. /**
  110740. * Import meshes into a scene.
  110741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110742. * @param scene The scene to import into
  110743. * @param data The data to import
  110744. * @param rootUrl The root url for scene and resources
  110745. * @param meshes The meshes array to import into
  110746. * @param particleSystems The particle systems array to import into
  110747. * @param skeletons The skeletons array to import into
  110748. * @param onError The callback when import fails
  110749. * @returns True if successful or false otherwise
  110750. */
  110751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110752. /**
  110753. * Load into a scene.
  110754. * @param scene The scene to load into
  110755. * @param data The data to import
  110756. * @param rootUrl The root url for scene and resources
  110757. * @param onError The callback when import fails
  110758. * @returns True if successful or false otherwise
  110759. */
  110760. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110761. /**
  110762. * Load into an asset container.
  110763. * @param scene The scene to load into
  110764. * @param data The data to import
  110765. * @param rootUrl The root url for scene and resources
  110766. * @param onError The callback when import fails
  110767. * @returns The loaded asset container
  110768. */
  110769. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110770. }
  110771. /**
  110772. * Interface used to define an async SceneLoader plugin
  110773. */
  110774. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110775. /**
  110776. * Import meshes into a scene.
  110777. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110778. * @param scene The scene to import into
  110779. * @param data The data to import
  110780. * @param rootUrl The root url for scene and resources
  110781. * @param onProgress The callback when the load progresses
  110782. * @param fileName Defines the name of the file to load
  110783. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110784. */
  110785. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110786. meshes: AbstractMesh[];
  110787. particleSystems: IParticleSystem[];
  110788. skeletons: Skeleton[];
  110789. animationGroups: AnimationGroup[];
  110790. }>;
  110791. /**
  110792. * Load into a scene.
  110793. * @param scene The scene to load into
  110794. * @param data The data to import
  110795. * @param rootUrl The root url for scene and resources
  110796. * @param onProgress The callback when the load progresses
  110797. * @param fileName Defines the name of the file to load
  110798. * @returns Nothing
  110799. */
  110800. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110801. /**
  110802. * Load into an asset container.
  110803. * @param scene The scene to load into
  110804. * @param data The data to import
  110805. * @param rootUrl The root url for scene and resources
  110806. * @param onProgress The callback when the load progresses
  110807. * @param fileName Defines the name of the file to load
  110808. * @returns The loaded asset container
  110809. */
  110810. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110811. }
  110812. /**
  110813. * Class used to load scene from various file formats using registered plugins
  110814. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110815. */
  110816. export class SceneLoader {
  110817. /**
  110818. * No logging while loading
  110819. */
  110820. static readonly NO_LOGGING: number;
  110821. /**
  110822. * Minimal logging while loading
  110823. */
  110824. static readonly MINIMAL_LOGGING: number;
  110825. /**
  110826. * Summary logging while loading
  110827. */
  110828. static readonly SUMMARY_LOGGING: number;
  110829. /**
  110830. * Detailled logging while loading
  110831. */
  110832. static readonly DETAILED_LOGGING: number;
  110833. /**
  110834. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110835. */
  110836. static ForceFullSceneLoadingForIncremental: boolean;
  110837. /**
  110838. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110839. */
  110840. static ShowLoadingScreen: boolean;
  110841. /**
  110842. * Defines the current logging level (while loading the scene)
  110843. * @ignorenaming
  110844. */
  110845. static loggingLevel: number;
  110846. /**
  110847. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110848. */
  110849. static CleanBoneMatrixWeights: boolean;
  110850. /**
  110851. * Event raised when a plugin is used to load a scene
  110852. */
  110853. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110854. private static _registeredPlugins;
  110855. private static _getDefaultPlugin;
  110856. private static _getPluginForExtension;
  110857. private static _getPluginForDirectLoad;
  110858. private static _getPluginForFilename;
  110859. private static _getDirectLoad;
  110860. private static _loadData;
  110861. private static _getFileInfo;
  110862. /**
  110863. * Gets a plugin that can load the given extension
  110864. * @param extension defines the extension to load
  110865. * @returns a plugin or null if none works
  110866. */
  110867. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110868. /**
  110869. * Gets a boolean indicating that the given extension can be loaded
  110870. * @param extension defines the extension to load
  110871. * @returns true if the extension is supported
  110872. */
  110873. static IsPluginForExtensionAvailable(extension: string): boolean;
  110874. /**
  110875. * Adds a new plugin to the list of registered plugins
  110876. * @param plugin defines the plugin to add
  110877. */
  110878. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110879. /**
  110880. * Import meshes into a scene
  110881. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110882. * @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)
  110883. * @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)
  110884. * @param scene the instance of BABYLON.Scene to append to
  110885. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110886. * @param onProgress a callback with a progress event for each file being loaded
  110887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110888. * @param pluginExtension the extension used to determine the plugin
  110889. * @returns The loaded plugin
  110890. */
  110891. 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>;
  110892. /**
  110893. * Import meshes into a scene
  110894. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110895. * @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)
  110896. * @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)
  110897. * @param scene the instance of BABYLON.Scene to append to
  110898. * @param onProgress a callback with a progress event for each file being loaded
  110899. * @param pluginExtension the extension used to determine the plugin
  110900. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110901. */
  110902. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110903. meshes: AbstractMesh[];
  110904. particleSystems: IParticleSystem[];
  110905. skeletons: Skeleton[];
  110906. animationGroups: AnimationGroup[];
  110907. }>;
  110908. /**
  110909. * Load a scene
  110910. * @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)
  110911. * @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)
  110912. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110913. * @param onSuccess a callback with the scene when import succeeds
  110914. * @param onProgress a callback with a progress event for each file being loaded
  110915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110916. * @param pluginExtension the extension used to determine the plugin
  110917. * @returns The loaded plugin
  110918. */
  110919. 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>;
  110920. /**
  110921. * Load a scene
  110922. * @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)
  110923. * @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)
  110924. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110925. * @param onProgress a callback with a progress event for each file being loaded
  110926. * @param pluginExtension the extension used to determine the plugin
  110927. * @returns The loaded scene
  110928. */
  110929. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110930. /**
  110931. * Append a scene
  110932. * @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)
  110933. * @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)
  110934. * @param scene is the instance of BABYLON.Scene to append to
  110935. * @param onSuccess a callback with the scene when import succeeds
  110936. * @param onProgress a callback with a progress event for each file being loaded
  110937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110938. * @param pluginExtension the extension used to determine the plugin
  110939. * @returns The loaded plugin
  110940. */
  110941. 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>;
  110942. /**
  110943. * Append a scene
  110944. * @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)
  110945. * @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)
  110946. * @param scene is the instance of BABYLON.Scene to append to
  110947. * @param onProgress a callback with a progress event for each file being loaded
  110948. * @param pluginExtension the extension used to determine the plugin
  110949. * @returns The given scene
  110950. */
  110951. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110952. /**
  110953. * Load a scene into an asset container
  110954. * @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)
  110955. * @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)
  110956. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110957. * @param onSuccess a callback with the scene when import succeeds
  110958. * @param onProgress a callback with a progress event for each file being loaded
  110959. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110960. * @param pluginExtension the extension used to determine the plugin
  110961. * @returns The loaded plugin
  110962. */
  110963. 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>;
  110964. /**
  110965. * Load a scene into an asset container
  110966. * @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)
  110967. * @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)
  110968. * @param scene is the instance of Scene to append to
  110969. * @param onProgress a callback with a progress event for each file being loaded
  110970. * @param pluginExtension the extension used to determine the plugin
  110971. * @returns The loaded asset container
  110972. */
  110973. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110974. }
  110975. }
  110976. declare module BABYLON {
  110977. /**
  110978. * Generic Controller
  110979. */
  110980. export class GenericController extends WebVRController {
  110981. /**
  110982. * Base Url for the controller model.
  110983. */
  110984. static readonly MODEL_BASE_URL: string;
  110985. /**
  110986. * File name for the controller model.
  110987. */
  110988. static readonly MODEL_FILENAME: string;
  110989. /**
  110990. * Creates a new GenericController from a gamepad
  110991. * @param vrGamepad the gamepad that the controller should be created from
  110992. */
  110993. constructor(vrGamepad: any);
  110994. /**
  110995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110996. * @param scene scene in which to add meshes
  110997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110998. */
  110999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111000. /**
  111001. * Called once for each button that changed state since the last frame
  111002. * @param buttonIdx Which button index changed
  111003. * @param state New state of the button
  111004. * @param changes Which properties on the state changed since last frame
  111005. */
  111006. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111007. }
  111008. }
  111009. declare module BABYLON {
  111010. /**
  111011. * Defines the WindowsMotionController object that the state of the windows motion controller
  111012. */
  111013. export class WindowsMotionController extends WebVRController {
  111014. /**
  111015. * The base url used to load the left and right controller models
  111016. */
  111017. static MODEL_BASE_URL: string;
  111018. /**
  111019. * The name of the left controller model file
  111020. */
  111021. static MODEL_LEFT_FILENAME: string;
  111022. /**
  111023. * The name of the right controller model file
  111024. */
  111025. static MODEL_RIGHT_FILENAME: string;
  111026. /**
  111027. * The controller name prefix for this controller type
  111028. */
  111029. static readonly GAMEPAD_ID_PREFIX: string;
  111030. /**
  111031. * The controller id pattern for this controller type
  111032. */
  111033. private static readonly GAMEPAD_ID_PATTERN;
  111034. private _loadedMeshInfo;
  111035. private readonly _mapping;
  111036. /**
  111037. * Fired when the trackpad on this controller is clicked
  111038. */
  111039. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111040. /**
  111041. * Fired when the trackpad on this controller is modified
  111042. */
  111043. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111044. /**
  111045. * The current x and y values of this controller's trackpad
  111046. */
  111047. trackpad: StickValues;
  111048. /**
  111049. * Creates a new WindowsMotionController from a gamepad
  111050. * @param vrGamepad the gamepad that the controller should be created from
  111051. */
  111052. constructor(vrGamepad: any);
  111053. /**
  111054. * Fired when the trigger on this controller is modified
  111055. */
  111056. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111057. /**
  111058. * Fired when the menu button on this controller is modified
  111059. */
  111060. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111061. /**
  111062. * Fired when the grip button on this controller is modified
  111063. */
  111064. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111065. /**
  111066. * Fired when the thumbstick button on this controller is modified
  111067. */
  111068. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111069. /**
  111070. * Fired when the touchpad button on this controller is modified
  111071. */
  111072. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111073. /**
  111074. * Fired when the touchpad values on this controller are modified
  111075. */
  111076. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111077. private _updateTrackpad;
  111078. /**
  111079. * Called once per frame by the engine.
  111080. */
  111081. update(): void;
  111082. /**
  111083. * Called once for each button that changed state since the last frame
  111084. * @param buttonIdx Which button index changed
  111085. * @param state New state of the button
  111086. * @param changes Which properties on the state changed since last frame
  111087. */
  111088. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111089. /**
  111090. * Moves the buttons on the controller mesh based on their current state
  111091. * @param buttonName the name of the button to move
  111092. * @param buttonValue the value of the button which determines the buttons new position
  111093. */
  111094. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111095. /**
  111096. * Moves the axis on the controller mesh based on its current state
  111097. * @param axis the index of the axis
  111098. * @param axisValue the value of the axis which determines the meshes new position
  111099. * @hidden
  111100. */
  111101. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111102. /**
  111103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111104. * @param scene scene in which to add meshes
  111105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111106. */
  111107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111108. /**
  111109. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111110. * can be transformed by button presses and axes values, based on this._mapping.
  111111. *
  111112. * @param scene scene in which the meshes exist
  111113. * @param meshes list of meshes that make up the controller model to process
  111114. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111115. */
  111116. private processModel;
  111117. private createMeshInfo;
  111118. /**
  111119. * Gets the ray of the controller in the direction the controller is pointing
  111120. * @param length the length the resulting ray should be
  111121. * @returns a ray in the direction the controller is pointing
  111122. */
  111123. getForwardRay(length?: number): Ray;
  111124. /**
  111125. * Disposes of the controller
  111126. */
  111127. dispose(): void;
  111128. }
  111129. }
  111130. declare module BABYLON {
  111131. /**
  111132. * Oculus Touch Controller
  111133. */
  111134. export class OculusTouchController extends WebVRController {
  111135. /**
  111136. * Base Url for the controller model.
  111137. */
  111138. static MODEL_BASE_URL: string;
  111139. /**
  111140. * File name for the left controller model.
  111141. */
  111142. static MODEL_LEFT_FILENAME: string;
  111143. /**
  111144. * File name for the right controller model.
  111145. */
  111146. static MODEL_RIGHT_FILENAME: string;
  111147. /**
  111148. * Base Url for the Quest controller model.
  111149. */
  111150. static QUEST_MODEL_BASE_URL: string;
  111151. /**
  111152. * @hidden
  111153. * If the controllers are running on a device that needs the updated Quest controller models
  111154. */
  111155. static _IsQuest: boolean;
  111156. /**
  111157. * Fired when the secondary trigger on this controller is modified
  111158. */
  111159. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111160. /**
  111161. * Fired when the thumb rest on this controller is modified
  111162. */
  111163. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111164. /**
  111165. * Creates a new OculusTouchController from a gamepad
  111166. * @param vrGamepad the gamepad that the controller should be created from
  111167. */
  111168. constructor(vrGamepad: any);
  111169. /**
  111170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111171. * @param scene scene in which to add meshes
  111172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111173. */
  111174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111175. /**
  111176. * Fired when the A button on this controller is modified
  111177. */
  111178. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111179. /**
  111180. * Fired when the B button on this controller is modified
  111181. */
  111182. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111183. /**
  111184. * Fired when the X button on this controller is modified
  111185. */
  111186. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111187. /**
  111188. * Fired when the Y button on this controller is modified
  111189. */
  111190. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111191. /**
  111192. * Called once for each button that changed state since the last frame
  111193. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111194. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111195. * 2) secondary trigger (same)
  111196. * 3) A (right) X (left), touch, pressed = value
  111197. * 4) B / Y
  111198. * 5) thumb rest
  111199. * @param buttonIdx Which button index changed
  111200. * @param state New state of the button
  111201. * @param changes Which properties on the state changed since last frame
  111202. */
  111203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111204. }
  111205. }
  111206. declare module BABYLON {
  111207. /**
  111208. * Vive Controller
  111209. */
  111210. export class ViveController extends WebVRController {
  111211. /**
  111212. * Base Url for the controller model.
  111213. */
  111214. static MODEL_BASE_URL: string;
  111215. /**
  111216. * File name for the controller model.
  111217. */
  111218. static MODEL_FILENAME: string;
  111219. /**
  111220. * Creates a new ViveController from a gamepad
  111221. * @param vrGamepad the gamepad that the controller should be created from
  111222. */
  111223. constructor(vrGamepad: any);
  111224. /**
  111225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111226. * @param scene scene in which to add meshes
  111227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111228. */
  111229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111230. /**
  111231. * Fired when the left button on this controller is modified
  111232. */
  111233. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111234. /**
  111235. * Fired when the right button on this controller is modified
  111236. */
  111237. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111238. /**
  111239. * Fired when the menu button on this controller is modified
  111240. */
  111241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111242. /**
  111243. * Called once for each button that changed state since the last frame
  111244. * Vive mapping:
  111245. * 0: touchpad
  111246. * 1: trigger
  111247. * 2: left AND right buttons
  111248. * 3: menu button
  111249. * @param buttonIdx Which button index changed
  111250. * @param state New state of the button
  111251. * @param changes Which properties on the state changed since last frame
  111252. */
  111253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111254. }
  111255. }
  111256. declare module BABYLON {
  111257. /**
  111258. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111259. */
  111260. export class WebXRControllerModelLoader {
  111261. /**
  111262. * Creates the WebXRControllerModelLoader
  111263. * @param input xr input that creates the controllers
  111264. */
  111265. constructor(input: WebXRInput);
  111266. }
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * Options for the default xr helper
  111271. */
  111272. export class WebXRDefaultExperienceOptions {
  111273. /**
  111274. * Floor meshes that should be used for teleporting
  111275. */
  111276. floorMeshes: Array<AbstractMesh>;
  111277. /**
  111278. * Enable or disable default UI to enter XR
  111279. */
  111280. disableDefaultUI: boolean;
  111281. /**
  111282. * optional configuration for the output canvas
  111283. */
  111284. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111285. }
  111286. /**
  111287. * Default experience which provides a similar setup to the previous webVRExperience
  111288. */
  111289. export class WebXRDefaultExperience {
  111290. /**
  111291. * Base experience
  111292. */
  111293. baseExperience: WebXRExperienceHelper;
  111294. /**
  111295. * Input experience extension
  111296. */
  111297. input: WebXRInput;
  111298. /**
  111299. * Loads the controller models
  111300. */
  111301. controllerModelLoader: WebXRControllerModelLoader;
  111302. /**
  111303. * Enables laser pointer and selection
  111304. */
  111305. pointerSelection: WebXRControllerPointerSelection;
  111306. /**
  111307. * Enables teleportation
  111308. */
  111309. teleportation: WebXRControllerTeleportation;
  111310. /**
  111311. * Enables ui for enetering/exiting xr
  111312. */
  111313. enterExitUI: WebXREnterExitUI;
  111314. /**
  111315. * Default target xr should render to
  111316. */
  111317. renderTarget: WebXRRenderTarget;
  111318. /**
  111319. * Creates the default xr experience
  111320. * @param scene scene
  111321. * @param options options for basic configuration
  111322. * @returns resulting WebXRDefaultExperience
  111323. */
  111324. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111325. private constructor();
  111326. /**
  111327. * DIsposes of the experience helper
  111328. */
  111329. dispose(): void;
  111330. }
  111331. }
  111332. declare module BABYLON {
  111333. /**
  111334. * Contains an array of blocks representing the octree
  111335. */
  111336. export interface IOctreeContainer<T> {
  111337. /**
  111338. * Blocks within the octree
  111339. */
  111340. blocks: Array<OctreeBlock<T>>;
  111341. }
  111342. /**
  111343. * Class used to store a cell in an octree
  111344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111345. */
  111346. export class OctreeBlock<T> {
  111347. /**
  111348. * Gets the content of the current block
  111349. */
  111350. entries: T[];
  111351. /**
  111352. * Gets the list of block children
  111353. */
  111354. blocks: Array<OctreeBlock<T>>;
  111355. private _depth;
  111356. private _maxDepth;
  111357. private _capacity;
  111358. private _minPoint;
  111359. private _maxPoint;
  111360. private _boundingVectors;
  111361. private _creationFunc;
  111362. /**
  111363. * Creates a new block
  111364. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111365. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111366. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111367. * @param depth defines the current depth of this block in the octree
  111368. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111369. * @param creationFunc defines a callback to call when an element is added to the block
  111370. */
  111371. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111372. /**
  111373. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111374. */
  111375. readonly capacity: number;
  111376. /**
  111377. * Gets the minimum vector (in world space) of the block's bounding box
  111378. */
  111379. readonly minPoint: Vector3;
  111380. /**
  111381. * Gets the maximum vector (in world space) of the block's bounding box
  111382. */
  111383. readonly maxPoint: Vector3;
  111384. /**
  111385. * Add a new element to this block
  111386. * @param entry defines the element to add
  111387. */
  111388. addEntry(entry: T): void;
  111389. /**
  111390. * Remove an element from this block
  111391. * @param entry defines the element to remove
  111392. */
  111393. removeEntry(entry: T): void;
  111394. /**
  111395. * Add an array of elements to this block
  111396. * @param entries defines the array of elements to add
  111397. */
  111398. addEntries(entries: T[]): void;
  111399. /**
  111400. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111401. * @param frustumPlanes defines the frustum planes to test
  111402. * @param selection defines the array to store current content if selection is positive
  111403. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111404. */
  111405. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111406. /**
  111407. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111408. * @param sphereCenter defines the bounding sphere center
  111409. * @param sphereRadius defines the bounding sphere radius
  111410. * @param selection defines the array to store current content if selection is positive
  111411. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111412. */
  111413. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111414. /**
  111415. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111416. * @param ray defines the ray to test with
  111417. * @param selection defines the array to store current content if selection is positive
  111418. */
  111419. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111420. /**
  111421. * Subdivide the content into child blocks (this block will then be empty)
  111422. */
  111423. createInnerBlocks(): void;
  111424. /**
  111425. * @hidden
  111426. */
  111427. 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;
  111428. }
  111429. }
  111430. declare module BABYLON {
  111431. /**
  111432. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111434. */
  111435. export class Octree<T> {
  111436. /** 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.) */
  111437. maxDepth: number;
  111438. /**
  111439. * Blocks within the octree containing objects
  111440. */
  111441. blocks: Array<OctreeBlock<T>>;
  111442. /**
  111443. * Content stored in the octree
  111444. */
  111445. dynamicContent: T[];
  111446. private _maxBlockCapacity;
  111447. private _selectionContent;
  111448. private _creationFunc;
  111449. /**
  111450. * Creates a octree
  111451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111452. * @param creationFunc function to be used to instatiate the octree
  111453. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111454. * @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.)
  111455. */
  111456. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111457. /** 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.) */
  111458. maxDepth?: number);
  111459. /**
  111460. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111461. * @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);
  111462. * @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);
  111463. * @param entries meshes to be added to the octree blocks
  111464. */
  111465. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111466. /**
  111467. * Adds a mesh to the octree
  111468. * @param entry Mesh to add to the octree
  111469. */
  111470. addMesh(entry: T): void;
  111471. /**
  111472. * Remove an element from the octree
  111473. * @param entry defines the element to remove
  111474. */
  111475. removeMesh(entry: T): void;
  111476. /**
  111477. * Selects an array of meshes within the frustum
  111478. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111479. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111480. * @returns array of meshes within the frustum
  111481. */
  111482. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111483. /**
  111484. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111485. * @param sphereCenter defines the bounding sphere center
  111486. * @param sphereRadius defines the bounding sphere radius
  111487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111488. * @returns an array of objects that intersect the sphere
  111489. */
  111490. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111491. /**
  111492. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111493. * @param ray defines the ray to test with
  111494. * @returns array of intersected objects
  111495. */
  111496. intersectsRay(ray: Ray): SmartArray<T>;
  111497. /**
  111498. * Adds a mesh into the octree block if it intersects the block
  111499. */
  111500. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111501. /**
  111502. * Adds a submesh into the octree block if it intersects the block
  111503. */
  111504. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111505. }
  111506. }
  111507. declare module BABYLON {
  111508. interface Scene {
  111509. /**
  111510. * @hidden
  111511. * Backing Filed
  111512. */
  111513. _selectionOctree: Octree<AbstractMesh>;
  111514. /**
  111515. * Gets the octree used to boost mesh selection (picking)
  111516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111517. */
  111518. selectionOctree: Octree<AbstractMesh>;
  111519. /**
  111520. * Creates or updates the octree used to boost selection (picking)
  111521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111522. * @param maxCapacity defines the maximum capacity per leaf
  111523. * @param maxDepth defines the maximum depth of the octree
  111524. * @returns an octree of AbstractMesh
  111525. */
  111526. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111527. }
  111528. interface AbstractMesh {
  111529. /**
  111530. * @hidden
  111531. * Backing Field
  111532. */
  111533. _submeshesOctree: Octree<SubMesh>;
  111534. /**
  111535. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111536. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111537. * @param maxCapacity defines the maximum size of each block (64 by default)
  111538. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111539. * @returns the new octree
  111540. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111542. */
  111543. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111544. }
  111545. /**
  111546. * Defines the octree scene component responsible to manage any octrees
  111547. * in a given scene.
  111548. */
  111549. export class OctreeSceneComponent {
  111550. /**
  111551. * The component name help to identify the component in the list of scene components.
  111552. */
  111553. readonly name: string;
  111554. /**
  111555. * The scene the component belongs to.
  111556. */
  111557. scene: Scene;
  111558. /**
  111559. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111560. */
  111561. readonly checksIsEnabled: boolean;
  111562. /**
  111563. * Creates a new instance of the component for the given scene
  111564. * @param scene Defines the scene to register the component in
  111565. */
  111566. constructor(scene: Scene);
  111567. /**
  111568. * Registers the component in a given scene
  111569. */
  111570. register(): void;
  111571. /**
  111572. * Return the list of active meshes
  111573. * @returns the list of active meshes
  111574. */
  111575. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111576. /**
  111577. * Return the list of active sub meshes
  111578. * @param mesh The mesh to get the candidates sub meshes from
  111579. * @returns the list of active sub meshes
  111580. */
  111581. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111582. private _tempRay;
  111583. /**
  111584. * Return the list of sub meshes intersecting with a given local ray
  111585. * @param mesh defines the mesh to find the submesh for
  111586. * @param localRay defines the ray in local space
  111587. * @returns the list of intersecting sub meshes
  111588. */
  111589. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111590. /**
  111591. * Return the list of sub meshes colliding with a collider
  111592. * @param mesh defines the mesh to find the submesh for
  111593. * @param collider defines the collider to evaluate the collision against
  111594. * @returns the list of colliding sub meshes
  111595. */
  111596. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111597. /**
  111598. * Rebuilds the elements related to this component in case of
  111599. * context lost for instance.
  111600. */
  111601. rebuild(): void;
  111602. /**
  111603. * Disposes the component and the associated ressources.
  111604. */
  111605. dispose(): void;
  111606. }
  111607. }
  111608. declare module BABYLON {
  111609. /**
  111610. * Renders a layer on top of an existing scene
  111611. */
  111612. export class UtilityLayerRenderer implements IDisposable {
  111613. /** the original scene that will be rendered on top of */
  111614. originalScene: Scene;
  111615. private _pointerCaptures;
  111616. private _lastPointerEvents;
  111617. private static _DefaultUtilityLayer;
  111618. private static _DefaultKeepDepthUtilityLayer;
  111619. private _sharedGizmoLight;
  111620. private _renderCamera;
  111621. /**
  111622. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111623. * @returns the camera that is used when rendering the utility layer
  111624. */
  111625. getRenderCamera(): Nullable<Camera>;
  111626. /**
  111627. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111628. * @param cam the camera that should be used when rendering the utility layer
  111629. */
  111630. setRenderCamera(cam: Nullable<Camera>): void;
  111631. /**
  111632. * @hidden
  111633. * Light which used by gizmos to get light shading
  111634. */
  111635. _getSharedGizmoLight(): HemisphericLight;
  111636. /**
  111637. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111638. */
  111639. pickUtilitySceneFirst: boolean;
  111640. /**
  111641. * 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)
  111642. */
  111643. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111644. /**
  111645. * 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)
  111646. */
  111647. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111648. /**
  111649. * The scene that is rendered on top of the original scene
  111650. */
  111651. utilityLayerScene: Scene;
  111652. /**
  111653. * If the utility layer should automatically be rendered on top of existing scene
  111654. */
  111655. shouldRender: boolean;
  111656. /**
  111657. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111658. */
  111659. onlyCheckPointerDownEvents: boolean;
  111660. /**
  111661. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111662. */
  111663. processAllEvents: boolean;
  111664. /**
  111665. * Observable raised when the pointer move from the utility layer scene to the main scene
  111666. */
  111667. onPointerOutObservable: Observable<number>;
  111668. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111669. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111670. private _afterRenderObserver;
  111671. private _sceneDisposeObserver;
  111672. private _originalPointerObserver;
  111673. /**
  111674. * Instantiates a UtilityLayerRenderer
  111675. * @param originalScene the original scene that will be rendered on top of
  111676. * @param handleEvents boolean indicating if the utility layer should handle events
  111677. */
  111678. constructor(
  111679. /** the original scene that will be rendered on top of */
  111680. originalScene: Scene, handleEvents?: boolean);
  111681. private _notifyObservers;
  111682. /**
  111683. * Renders the utility layers scene on top of the original scene
  111684. */
  111685. render(): void;
  111686. /**
  111687. * Disposes of the renderer
  111688. */
  111689. dispose(): void;
  111690. private _updateCamera;
  111691. }
  111692. }
  111693. declare module BABYLON {
  111694. /**
  111695. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111696. */
  111697. export class Gizmo implements IDisposable {
  111698. /** The utility layer the gizmo will be added to */
  111699. gizmoLayer: UtilityLayerRenderer;
  111700. /**
  111701. * The root mesh of the gizmo
  111702. */
  111703. _rootMesh: Mesh;
  111704. private _attachedMesh;
  111705. /**
  111706. * Ratio for the scale of the gizmo (Default: 1)
  111707. */
  111708. scaleRatio: number;
  111709. /**
  111710. * If a custom mesh has been set (Default: false)
  111711. */
  111712. protected _customMeshSet: boolean;
  111713. /**
  111714. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111715. * * When set, interactions will be enabled
  111716. */
  111717. attachedMesh: Nullable<AbstractMesh>;
  111718. /**
  111719. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111720. * @param mesh The mesh to replace the default mesh of the gizmo
  111721. */
  111722. setCustomMesh(mesh: Mesh): void;
  111723. /**
  111724. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111725. */
  111726. updateGizmoRotationToMatchAttachedMesh: boolean;
  111727. /**
  111728. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111729. */
  111730. updateGizmoPositionToMatchAttachedMesh: boolean;
  111731. /**
  111732. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111733. */
  111734. updateScale: boolean;
  111735. protected _interactionsEnabled: boolean;
  111736. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111737. private _beforeRenderObserver;
  111738. private _tempVector;
  111739. /**
  111740. * Creates a gizmo
  111741. * @param gizmoLayer The utility layer the gizmo will be added to
  111742. */
  111743. constructor(
  111744. /** The utility layer the gizmo will be added to */
  111745. gizmoLayer?: UtilityLayerRenderer);
  111746. /**
  111747. * Updates the gizmo to match the attached mesh's position/rotation
  111748. */
  111749. protected _update(): void;
  111750. /**
  111751. * Disposes of the gizmo
  111752. */
  111753. dispose(): void;
  111754. }
  111755. }
  111756. declare module BABYLON {
  111757. /**
  111758. * Single plane drag gizmo
  111759. */
  111760. export class PlaneDragGizmo extends Gizmo {
  111761. /**
  111762. * Drag behavior responsible for the gizmos dragging interactions
  111763. */
  111764. dragBehavior: PointerDragBehavior;
  111765. private _pointerObserver;
  111766. /**
  111767. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111768. */
  111769. snapDistance: number;
  111770. /**
  111771. * Event that fires each time the gizmo snaps to a new location.
  111772. * * snapDistance is the the change in distance
  111773. */
  111774. onSnapObservable: Observable<{
  111775. snapDistance: number;
  111776. }>;
  111777. private _plane;
  111778. private _coloredMaterial;
  111779. private _hoverMaterial;
  111780. private _isEnabled;
  111781. private _parent;
  111782. /** @hidden */
  111783. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111784. /** @hidden */
  111785. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111786. /**
  111787. * Creates a PlaneDragGizmo
  111788. * @param gizmoLayer The utility layer the gizmo will be added to
  111789. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111790. * @param color The color of the gizmo
  111791. */
  111792. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111793. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111794. /**
  111795. * If the gizmo is enabled
  111796. */
  111797. isEnabled: boolean;
  111798. /**
  111799. * Disposes of the gizmo
  111800. */
  111801. dispose(): void;
  111802. }
  111803. }
  111804. declare module BABYLON {
  111805. /**
  111806. * Gizmo that enables dragging a mesh along 3 axis
  111807. */
  111808. export class PositionGizmo extends Gizmo {
  111809. /**
  111810. * Internal gizmo used for interactions on the x axis
  111811. */
  111812. xGizmo: AxisDragGizmo;
  111813. /**
  111814. * Internal gizmo used for interactions on the y axis
  111815. */
  111816. yGizmo: AxisDragGizmo;
  111817. /**
  111818. * Internal gizmo used for interactions on the z axis
  111819. */
  111820. zGizmo: AxisDragGizmo;
  111821. /**
  111822. * Internal gizmo used for interactions on the yz plane
  111823. */
  111824. xPlaneGizmo: PlaneDragGizmo;
  111825. /**
  111826. * Internal gizmo used for interactions on the xz plane
  111827. */
  111828. yPlaneGizmo: PlaneDragGizmo;
  111829. /**
  111830. * Internal gizmo used for interactions on the xy plane
  111831. */
  111832. zPlaneGizmo: PlaneDragGizmo;
  111833. /**
  111834. * private variables
  111835. */
  111836. private _meshAttached;
  111837. private _updateGizmoRotationToMatchAttachedMesh;
  111838. private _snapDistance;
  111839. private _scaleRatio;
  111840. /** Fires an event when any of it's sub gizmos are dragged */
  111841. onDragStartObservable: Observable<unknown>;
  111842. /** Fires an event when any of it's sub gizmos are released from dragging */
  111843. onDragEndObservable: Observable<unknown>;
  111844. /**
  111845. * If set to true, planar drag is enabled
  111846. */
  111847. private _planarGizmoEnabled;
  111848. attachedMesh: Nullable<AbstractMesh>;
  111849. /**
  111850. * Creates a PositionGizmo
  111851. * @param gizmoLayer The utility layer the gizmo will be added to
  111852. */
  111853. constructor(gizmoLayer?: UtilityLayerRenderer);
  111854. /**
  111855. * If the planar drag gizmo is enabled
  111856. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111857. */
  111858. planarGizmoEnabled: boolean;
  111859. updateGizmoRotationToMatchAttachedMesh: boolean;
  111860. /**
  111861. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111862. */
  111863. snapDistance: number;
  111864. /**
  111865. * Ratio for the scale of the gizmo (Default: 1)
  111866. */
  111867. scaleRatio: number;
  111868. /**
  111869. * Disposes of the gizmo
  111870. */
  111871. dispose(): void;
  111872. /**
  111873. * CustomMeshes are not supported by this gizmo
  111874. * @param mesh The mesh to replace the default mesh of the gizmo
  111875. */
  111876. setCustomMesh(mesh: Mesh): void;
  111877. }
  111878. }
  111879. declare module BABYLON {
  111880. /**
  111881. * Single axis drag gizmo
  111882. */
  111883. export class AxisDragGizmo extends Gizmo {
  111884. /**
  111885. * Drag behavior responsible for the gizmos dragging interactions
  111886. */
  111887. dragBehavior: PointerDragBehavior;
  111888. private _pointerObserver;
  111889. /**
  111890. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111891. */
  111892. snapDistance: number;
  111893. /**
  111894. * Event that fires each time the gizmo snaps to a new location.
  111895. * * snapDistance is the the change in distance
  111896. */
  111897. onSnapObservable: Observable<{
  111898. snapDistance: number;
  111899. }>;
  111900. private _isEnabled;
  111901. private _parent;
  111902. private _arrow;
  111903. private _coloredMaterial;
  111904. private _hoverMaterial;
  111905. /** @hidden */
  111906. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111907. /** @hidden */
  111908. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111909. /**
  111910. * Creates an AxisDragGizmo
  111911. * @param gizmoLayer The utility layer the gizmo will be added to
  111912. * @param dragAxis The axis which the gizmo will be able to drag on
  111913. * @param color The color of the gizmo
  111914. */
  111915. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111917. /**
  111918. * If the gizmo is enabled
  111919. */
  111920. isEnabled: boolean;
  111921. /**
  111922. * Disposes of the gizmo
  111923. */
  111924. dispose(): void;
  111925. }
  111926. }
  111927. declare module BABYLON.Debug {
  111928. /**
  111929. * The Axes viewer will show 3 axes in a specific point in space
  111930. */
  111931. export class AxesViewer {
  111932. private _xAxis;
  111933. private _yAxis;
  111934. private _zAxis;
  111935. private _scaleLinesFactor;
  111936. private _instanced;
  111937. /**
  111938. * Gets the hosting scene
  111939. */
  111940. scene: Scene;
  111941. /**
  111942. * Gets or sets a number used to scale line length
  111943. */
  111944. scaleLines: number;
  111945. /** Gets the node hierarchy used to render x-axis */
  111946. readonly xAxis: TransformNode;
  111947. /** Gets the node hierarchy used to render y-axis */
  111948. readonly yAxis: TransformNode;
  111949. /** Gets the node hierarchy used to render z-axis */
  111950. readonly zAxis: TransformNode;
  111951. /**
  111952. * Creates a new AxesViewer
  111953. * @param scene defines the hosting scene
  111954. * @param scaleLines defines a number used to scale line length (1 by default)
  111955. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111956. * @param xAxis defines the node hierarchy used to render the x-axis
  111957. * @param yAxis defines the node hierarchy used to render the y-axis
  111958. * @param zAxis defines the node hierarchy used to render the z-axis
  111959. */
  111960. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111961. /**
  111962. * Force the viewer to update
  111963. * @param position defines the position of the viewer
  111964. * @param xaxis defines the x axis of the viewer
  111965. * @param yaxis defines the y axis of the viewer
  111966. * @param zaxis defines the z axis of the viewer
  111967. */
  111968. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111969. /**
  111970. * Creates an instance of this axes viewer.
  111971. * @returns a new axes viewer with instanced meshes
  111972. */
  111973. createInstance(): AxesViewer;
  111974. /** Releases resources */
  111975. dispose(): void;
  111976. private static _SetRenderingGroupId;
  111977. }
  111978. }
  111979. declare module BABYLON.Debug {
  111980. /**
  111981. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111982. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111983. */
  111984. export class BoneAxesViewer extends AxesViewer {
  111985. /**
  111986. * Gets or sets the target mesh where to display the axes viewer
  111987. */
  111988. mesh: Nullable<Mesh>;
  111989. /**
  111990. * Gets or sets the target bone where to display the axes viewer
  111991. */
  111992. bone: Nullable<Bone>;
  111993. /** Gets current position */
  111994. pos: Vector3;
  111995. /** Gets direction of X axis */
  111996. xaxis: Vector3;
  111997. /** Gets direction of Y axis */
  111998. yaxis: Vector3;
  111999. /** Gets direction of Z axis */
  112000. zaxis: Vector3;
  112001. /**
  112002. * Creates a new BoneAxesViewer
  112003. * @param scene defines the hosting scene
  112004. * @param bone defines the target bone
  112005. * @param mesh defines the target mesh
  112006. * @param scaleLines defines a scaling factor for line length (1 by default)
  112007. */
  112008. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112009. /**
  112010. * Force the viewer to update
  112011. */
  112012. update(): void;
  112013. /** Releases resources */
  112014. dispose(): void;
  112015. }
  112016. }
  112017. declare module BABYLON {
  112018. /**
  112019. * Interface used to define scene explorer extensibility option
  112020. */
  112021. export interface IExplorerExtensibilityOption {
  112022. /**
  112023. * Define the option label
  112024. */
  112025. label: string;
  112026. /**
  112027. * Defines the action to execute on click
  112028. */
  112029. action: (entity: any) => void;
  112030. }
  112031. /**
  112032. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112033. */
  112034. export interface IExplorerExtensibilityGroup {
  112035. /**
  112036. * Defines a predicate to test if a given type mut be extended
  112037. */
  112038. predicate: (entity: any) => boolean;
  112039. /**
  112040. * Gets the list of options added to a type
  112041. */
  112042. entries: IExplorerExtensibilityOption[];
  112043. }
  112044. /**
  112045. * Interface used to define the options to use to create the Inspector
  112046. */
  112047. export interface IInspectorOptions {
  112048. /**
  112049. * Display in overlay mode (default: false)
  112050. */
  112051. overlay?: boolean;
  112052. /**
  112053. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112054. */
  112055. globalRoot?: HTMLElement;
  112056. /**
  112057. * Display the Scene explorer
  112058. */
  112059. showExplorer?: boolean;
  112060. /**
  112061. * Display the property inspector
  112062. */
  112063. showInspector?: boolean;
  112064. /**
  112065. * Display in embed mode (both panes on the right)
  112066. */
  112067. embedMode?: boolean;
  112068. /**
  112069. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112070. */
  112071. handleResize?: boolean;
  112072. /**
  112073. * Allow the panes to popup (default: true)
  112074. */
  112075. enablePopup?: boolean;
  112076. /**
  112077. * Allow the panes to be closed by users (default: true)
  112078. */
  112079. enableClose?: boolean;
  112080. /**
  112081. * Optional list of extensibility entries
  112082. */
  112083. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112084. /**
  112085. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112086. */
  112087. inspectorURL?: string;
  112088. }
  112089. interface Scene {
  112090. /**
  112091. * @hidden
  112092. * Backing field
  112093. */
  112094. _debugLayer: DebugLayer;
  112095. /**
  112096. * Gets the debug layer (aka Inspector) associated with the scene
  112097. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112098. */
  112099. debugLayer: DebugLayer;
  112100. }
  112101. /**
  112102. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112103. * what is happening in your scene
  112104. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112105. */
  112106. export class DebugLayer {
  112107. /**
  112108. * Define the url to get the inspector script from.
  112109. * By default it uses the babylonjs CDN.
  112110. * @ignoreNaming
  112111. */
  112112. static InspectorURL: string;
  112113. private _scene;
  112114. private BJSINSPECTOR;
  112115. private _onPropertyChangedObservable?;
  112116. /**
  112117. * Observable triggered when a property is changed through the inspector.
  112118. */
  112119. readonly onPropertyChangedObservable: any;
  112120. /**
  112121. * Instantiates a new debug layer.
  112122. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112123. * what is happening in your scene
  112124. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112125. * @param scene Defines the scene to inspect
  112126. */
  112127. constructor(scene: Scene);
  112128. /** Creates the inspector window. */
  112129. private _createInspector;
  112130. /**
  112131. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112132. * @param entity defines the entity to select
  112133. * @param lineContainerTitle defines the specific block to highlight
  112134. */
  112135. select(entity: any, lineContainerTitle?: string): void;
  112136. /** Get the inspector from bundle or global */
  112137. private _getGlobalInspector;
  112138. /**
  112139. * Get if the inspector is visible or not.
  112140. * @returns true if visible otherwise, false
  112141. */
  112142. isVisible(): boolean;
  112143. /**
  112144. * Hide the inspector and close its window.
  112145. */
  112146. hide(): void;
  112147. /**
  112148. * Launch the debugLayer.
  112149. * @param config Define the configuration of the inspector
  112150. * @return a promise fulfilled when the debug layer is visible
  112151. */
  112152. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112153. }
  112154. }
  112155. declare module BABYLON {
  112156. /**
  112157. * Class containing static functions to help procedurally build meshes
  112158. */
  112159. export class BoxBuilder {
  112160. /**
  112161. * Creates a box mesh
  112162. * * The parameter `size` sets the size (float) of each box side (default 1)
  112163. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112164. * * 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)
  112165. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112169. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112170. * @param name defines the name of the mesh
  112171. * @param options defines the options used to create the mesh
  112172. * @param scene defines the hosting scene
  112173. * @returns the box mesh
  112174. */
  112175. static CreateBox(name: string, options: {
  112176. size?: number;
  112177. width?: number;
  112178. height?: number;
  112179. depth?: number;
  112180. faceUV?: Vector4[];
  112181. faceColors?: Color4[];
  112182. sideOrientation?: number;
  112183. frontUVs?: Vector4;
  112184. backUVs?: Vector4;
  112185. wrap?: boolean;
  112186. topBaseAt?: number;
  112187. bottomBaseAt?: number;
  112188. updatable?: boolean;
  112189. }, scene?: Nullable<Scene>): Mesh;
  112190. }
  112191. }
  112192. declare module BABYLON {
  112193. /**
  112194. * Class containing static functions to help procedurally build meshes
  112195. */
  112196. export class SphereBuilder {
  112197. /**
  112198. * Creates a sphere mesh
  112199. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112200. * * 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`)
  112201. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112202. * * 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
  112203. * * 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)
  112204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112207. * @param name defines the name of the mesh
  112208. * @param options defines the options used to create the mesh
  112209. * @param scene defines the hosting scene
  112210. * @returns the sphere mesh
  112211. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112212. */
  112213. static CreateSphere(name: string, options: {
  112214. segments?: number;
  112215. diameter?: number;
  112216. diameterX?: number;
  112217. diameterY?: number;
  112218. diameterZ?: number;
  112219. arc?: number;
  112220. slice?: number;
  112221. sideOrientation?: number;
  112222. frontUVs?: Vector4;
  112223. backUVs?: Vector4;
  112224. updatable?: boolean;
  112225. }, scene?: Nullable<Scene>): Mesh;
  112226. }
  112227. }
  112228. declare module BABYLON.Debug {
  112229. /**
  112230. * Used to show the physics impostor around the specific mesh
  112231. */
  112232. export class PhysicsViewer {
  112233. /** @hidden */
  112234. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112235. /** @hidden */
  112236. protected _meshes: Array<Nullable<AbstractMesh>>;
  112237. /** @hidden */
  112238. protected _scene: Nullable<Scene>;
  112239. /** @hidden */
  112240. protected _numMeshes: number;
  112241. /** @hidden */
  112242. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112243. private _renderFunction;
  112244. private _utilityLayer;
  112245. private _debugBoxMesh;
  112246. private _debugSphereMesh;
  112247. private _debugCylinderMesh;
  112248. private _debugMaterial;
  112249. private _debugMeshMeshes;
  112250. /**
  112251. * Creates a new PhysicsViewer
  112252. * @param scene defines the hosting scene
  112253. */
  112254. constructor(scene: Scene);
  112255. /** @hidden */
  112256. protected _updateDebugMeshes(): void;
  112257. /**
  112258. * Renders a specified physic impostor
  112259. * @param impostor defines the impostor to render
  112260. * @param targetMesh defines the mesh represented by the impostor
  112261. * @returns the new debug mesh used to render the impostor
  112262. */
  112263. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112264. /**
  112265. * Hides a specified physic impostor
  112266. * @param impostor defines the impostor to hide
  112267. */
  112268. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112269. private _getDebugMaterial;
  112270. private _getDebugBoxMesh;
  112271. private _getDebugSphereMesh;
  112272. private _getDebugCylinderMesh;
  112273. private _getDebugMeshMesh;
  112274. private _getDebugMesh;
  112275. /** Releases all resources */
  112276. dispose(): void;
  112277. }
  112278. }
  112279. declare module BABYLON {
  112280. /**
  112281. * Class containing static functions to help procedurally build meshes
  112282. */
  112283. export class LinesBuilder {
  112284. /**
  112285. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112286. * * 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
  112287. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112288. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112289. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112290. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112291. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112292. * * 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
  112293. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112296. * @param name defines the name of the new line system
  112297. * @param options defines the options used to create the line system
  112298. * @param scene defines the hosting scene
  112299. * @returns a new line system mesh
  112300. */
  112301. static CreateLineSystem(name: string, options: {
  112302. lines: Vector3[][];
  112303. updatable?: boolean;
  112304. instance?: Nullable<LinesMesh>;
  112305. colors?: Nullable<Color4[][]>;
  112306. useVertexAlpha?: boolean;
  112307. }, scene: Nullable<Scene>): LinesMesh;
  112308. /**
  112309. * Creates a line mesh
  112310. * 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
  112311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112312. * * The parameter `points` is an array successive Vector3
  112313. * * 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
  112314. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112315. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112316. * * When updating an instance, remember that only point positions can change, not the number of points
  112317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112319. * @param name defines the name of the new line system
  112320. * @param options defines the options used to create the line system
  112321. * @param scene defines the hosting scene
  112322. * @returns a new line mesh
  112323. */
  112324. static CreateLines(name: string, options: {
  112325. points: Vector3[];
  112326. updatable?: boolean;
  112327. instance?: Nullable<LinesMesh>;
  112328. colors?: Color4[];
  112329. useVertexAlpha?: boolean;
  112330. }, scene?: Nullable<Scene>): LinesMesh;
  112331. /**
  112332. * Creates a dashed line mesh
  112333. * * 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
  112334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112335. * * The parameter `points` is an array successive Vector3
  112336. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112337. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112338. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112339. * * 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
  112340. * * When updating an instance, remember that only point positions can change, not the number of points
  112341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112342. * @param name defines the name of the mesh
  112343. * @param options defines the options used to create the mesh
  112344. * @param scene defines the hosting scene
  112345. * @returns the dashed line mesh
  112346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112347. */
  112348. static CreateDashedLines(name: string, options: {
  112349. points: Vector3[];
  112350. dashSize?: number;
  112351. gapSize?: number;
  112352. dashNb?: number;
  112353. updatable?: boolean;
  112354. instance?: LinesMesh;
  112355. }, scene?: Nullable<Scene>): LinesMesh;
  112356. }
  112357. }
  112358. declare module BABYLON {
  112359. /**
  112360. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112361. * in order to better appreciate the issue one might have.
  112362. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112363. */
  112364. export class RayHelper {
  112365. /**
  112366. * Defines the ray we are currently tryin to visualize.
  112367. */
  112368. ray: Nullable<Ray>;
  112369. private _renderPoints;
  112370. private _renderLine;
  112371. private _renderFunction;
  112372. private _scene;
  112373. private _updateToMeshFunction;
  112374. private _attachedToMesh;
  112375. private _meshSpaceDirection;
  112376. private _meshSpaceOrigin;
  112377. /**
  112378. * Helper function to create a colored helper in a scene in one line.
  112379. * @param ray Defines the ray we are currently tryin to visualize
  112380. * @param scene Defines the scene the ray is used in
  112381. * @param color Defines the color we want to see the ray in
  112382. * @returns The newly created ray helper.
  112383. */
  112384. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112385. /**
  112386. * Instantiate a new ray helper.
  112387. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112388. * in order to better appreciate the issue one might have.
  112389. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112390. * @param ray Defines the ray we are currently tryin to visualize
  112391. */
  112392. constructor(ray: Ray);
  112393. /**
  112394. * Shows the ray we are willing to debug.
  112395. * @param scene Defines the scene the ray needs to be rendered in
  112396. * @param color Defines the color the ray needs to be rendered in
  112397. */
  112398. show(scene: Scene, color?: Color3): void;
  112399. /**
  112400. * Hides the ray we are debugging.
  112401. */
  112402. hide(): void;
  112403. private _render;
  112404. /**
  112405. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112406. * @param mesh Defines the mesh we want the helper attached to
  112407. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112408. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112409. * @param length Defines the length of the ray
  112410. */
  112411. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112412. /**
  112413. * Detach the ray helper from the mesh it has previously been attached to.
  112414. */
  112415. detachFromMesh(): void;
  112416. private _updateToMesh;
  112417. /**
  112418. * Dispose the helper and release its associated resources.
  112419. */
  112420. dispose(): void;
  112421. }
  112422. }
  112423. declare module BABYLON.Debug {
  112424. /**
  112425. * Class used to render a debug view of a given skeleton
  112426. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112427. */
  112428. export class SkeletonViewer {
  112429. /** defines the skeleton to render */
  112430. skeleton: Skeleton;
  112431. /** defines the mesh attached to the skeleton */
  112432. mesh: AbstractMesh;
  112433. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112434. autoUpdateBonesMatrices: boolean;
  112435. /** defines the rendering group id to use with the viewer */
  112436. renderingGroupId: number;
  112437. /** Gets or sets the color used to render the skeleton */
  112438. color: Color3;
  112439. private _scene;
  112440. private _debugLines;
  112441. private _debugMesh;
  112442. private _isEnabled;
  112443. private _renderFunction;
  112444. private _utilityLayer;
  112445. /**
  112446. * Returns the mesh used to render the bones
  112447. */
  112448. readonly debugMesh: Nullable<LinesMesh>;
  112449. /**
  112450. * Creates a new SkeletonViewer
  112451. * @param skeleton defines the skeleton to render
  112452. * @param mesh defines the mesh attached to the skeleton
  112453. * @param scene defines the hosting scene
  112454. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112455. * @param renderingGroupId defines the rendering group id to use with the viewer
  112456. */
  112457. constructor(
  112458. /** defines the skeleton to render */
  112459. skeleton: Skeleton,
  112460. /** defines the mesh attached to the skeleton */
  112461. mesh: AbstractMesh, scene: Scene,
  112462. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112463. autoUpdateBonesMatrices?: boolean,
  112464. /** defines the rendering group id to use with the viewer */
  112465. renderingGroupId?: number);
  112466. /** Gets or sets a boolean indicating if the viewer is enabled */
  112467. isEnabled: boolean;
  112468. private _getBonePosition;
  112469. private _getLinesForBonesWithLength;
  112470. private _getLinesForBonesNoLength;
  112471. /** Update the viewer to sync with current skeleton state */
  112472. update(): void;
  112473. /** Release associated resources */
  112474. dispose(): void;
  112475. }
  112476. }
  112477. declare module BABYLON {
  112478. /**
  112479. * Options to create the null engine
  112480. */
  112481. export class NullEngineOptions {
  112482. /**
  112483. * Render width (Default: 512)
  112484. */
  112485. renderWidth: number;
  112486. /**
  112487. * Render height (Default: 256)
  112488. */
  112489. renderHeight: number;
  112490. /**
  112491. * Texture size (Default: 512)
  112492. */
  112493. textureSize: number;
  112494. /**
  112495. * If delta time between frames should be constant
  112496. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112497. */
  112498. deterministicLockstep: boolean;
  112499. /**
  112500. * Maximum about of steps between frames (Default: 4)
  112501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112502. */
  112503. lockstepMaxSteps: number;
  112504. }
  112505. /**
  112506. * The null engine class provides support for headless version of babylon.js.
  112507. * This can be used in server side scenario or for testing purposes
  112508. */
  112509. export class NullEngine extends Engine {
  112510. private _options;
  112511. /**
  112512. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112513. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112514. * @returns true if engine is in deterministic lock step mode
  112515. */
  112516. isDeterministicLockStep(): boolean;
  112517. /**
  112518. * Gets the max steps when engine is running in deterministic lock step
  112519. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112520. * @returns the max steps
  112521. */
  112522. getLockstepMaxSteps(): number;
  112523. /**
  112524. * Gets the current hardware scaling level.
  112525. * By default the hardware scaling level is computed from the window device ratio.
  112526. * 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.
  112527. * @returns a number indicating the current hardware scaling level
  112528. */
  112529. getHardwareScalingLevel(): number;
  112530. constructor(options?: NullEngineOptions);
  112531. /**
  112532. * Creates a vertex buffer
  112533. * @param vertices the data for the vertex buffer
  112534. * @returns the new WebGL static buffer
  112535. */
  112536. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112537. /**
  112538. * Creates a new index buffer
  112539. * @param indices defines the content of the index buffer
  112540. * @param updatable defines if the index buffer must be updatable
  112541. * @returns a new webGL buffer
  112542. */
  112543. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112544. /**
  112545. * Clear the current render buffer or the current render target (if any is set up)
  112546. * @param color defines the color to use
  112547. * @param backBuffer defines if the back buffer must be cleared
  112548. * @param depth defines if the depth buffer must be cleared
  112549. * @param stencil defines if the stencil buffer must be cleared
  112550. */
  112551. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112552. /**
  112553. * Gets the current render width
  112554. * @param useScreen defines if screen size must be used (or the current render target if any)
  112555. * @returns a number defining the current render width
  112556. */
  112557. getRenderWidth(useScreen?: boolean): number;
  112558. /**
  112559. * Gets the current render height
  112560. * @param useScreen defines if screen size must be used (or the current render target if any)
  112561. * @returns a number defining the current render height
  112562. */
  112563. getRenderHeight(useScreen?: boolean): number;
  112564. /**
  112565. * Set the WebGL's viewport
  112566. * @param viewport defines the viewport element to be used
  112567. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112568. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112569. */
  112570. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112571. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112572. /**
  112573. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112574. * @param pipelineContext defines the pipeline context to use
  112575. * @param uniformsNames defines the list of uniform names
  112576. * @returns an array of webGL uniform locations
  112577. */
  112578. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112579. /**
  112580. * Gets the lsit of active attributes for a given webGL program
  112581. * @param pipelineContext defines the pipeline context to use
  112582. * @param attributesNames defines the list of attribute names to get
  112583. * @returns an array of indices indicating the offset of each attribute
  112584. */
  112585. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112586. /**
  112587. * Binds an effect to the webGL context
  112588. * @param effect defines the effect to bind
  112589. */
  112590. bindSamplers(effect: Effect): void;
  112591. /**
  112592. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112593. * @param effect defines the effect to activate
  112594. */
  112595. enableEffect(effect: Effect): void;
  112596. /**
  112597. * Set various states to the webGL context
  112598. * @param culling defines backface culling state
  112599. * @param zOffset defines the value to apply to zOffset (0 by default)
  112600. * @param force defines if states must be applied even if cache is up to date
  112601. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112602. */
  112603. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112604. /**
  112605. * Set the value of an uniform to an array of int32
  112606. * @param uniform defines the webGL uniform location where to store the value
  112607. * @param array defines the array of int32 to store
  112608. */
  112609. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112610. /**
  112611. * Set the value of an uniform to an array of int32 (stored as vec2)
  112612. * @param uniform defines the webGL uniform location where to store the value
  112613. * @param array defines the array of int32 to store
  112614. */
  112615. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112616. /**
  112617. * Set the value of an uniform to an array of int32 (stored as vec3)
  112618. * @param uniform defines the webGL uniform location where to store the value
  112619. * @param array defines the array of int32 to store
  112620. */
  112621. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112622. /**
  112623. * Set the value of an uniform to an array of int32 (stored as vec4)
  112624. * @param uniform defines the webGL uniform location where to store the value
  112625. * @param array defines the array of int32 to store
  112626. */
  112627. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112628. /**
  112629. * Set the value of an uniform to an array of float32
  112630. * @param uniform defines the webGL uniform location where to store the value
  112631. * @param array defines the array of float32 to store
  112632. */
  112633. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112634. /**
  112635. * Set the value of an uniform to an array of float32 (stored as vec2)
  112636. * @param uniform defines the webGL uniform location where to store the value
  112637. * @param array defines the array of float32 to store
  112638. */
  112639. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112640. /**
  112641. * Set the value of an uniform to an array of float32 (stored as vec3)
  112642. * @param uniform defines the webGL uniform location where to store the value
  112643. * @param array defines the array of float32 to store
  112644. */
  112645. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112646. /**
  112647. * Set the value of an uniform to an array of float32 (stored as vec4)
  112648. * @param uniform defines the webGL uniform location where to store the value
  112649. * @param array defines the array of float32 to store
  112650. */
  112651. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112652. /**
  112653. * Set the value of an uniform to an array of number
  112654. * @param uniform defines the webGL uniform location where to store the value
  112655. * @param array defines the array of number to store
  112656. */
  112657. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112658. /**
  112659. * Set the value of an uniform to an array of number (stored as vec2)
  112660. * @param uniform defines the webGL uniform location where to store the value
  112661. * @param array defines the array of number to store
  112662. */
  112663. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112664. /**
  112665. * Set the value of an uniform to an array of number (stored as vec3)
  112666. * @param uniform defines the webGL uniform location where to store the value
  112667. * @param array defines the array of number to store
  112668. */
  112669. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112670. /**
  112671. * Set the value of an uniform to an array of number (stored as vec4)
  112672. * @param uniform defines the webGL uniform location where to store the value
  112673. * @param array defines the array of number to store
  112674. */
  112675. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112676. /**
  112677. * Set the value of an uniform to an array of float32 (stored as matrices)
  112678. * @param uniform defines the webGL uniform location where to store the value
  112679. * @param matrices defines the array of float32 to store
  112680. */
  112681. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112682. /**
  112683. * Set the value of an uniform to a matrix (3x3)
  112684. * @param uniform defines the webGL uniform location where to store the value
  112685. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112686. */
  112687. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112688. /**
  112689. * Set the value of an uniform to a matrix (2x2)
  112690. * @param uniform defines the webGL uniform location where to store the value
  112691. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112692. */
  112693. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112694. /**
  112695. * Set the value of an uniform to a number (float)
  112696. * @param uniform defines the webGL uniform location where to store the value
  112697. * @param value defines the float number to store
  112698. */
  112699. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112700. /**
  112701. * Set the value of an uniform to a vec2
  112702. * @param uniform defines the webGL uniform location where to store the value
  112703. * @param x defines the 1st component of the value
  112704. * @param y defines the 2nd component of the value
  112705. */
  112706. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112707. /**
  112708. * Set the value of an uniform to a vec3
  112709. * @param uniform defines the webGL uniform location where to store the value
  112710. * @param x defines the 1st component of the value
  112711. * @param y defines the 2nd component of the value
  112712. * @param z defines the 3rd component of the value
  112713. */
  112714. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112715. /**
  112716. * Set the value of an uniform to a boolean
  112717. * @param uniform defines the webGL uniform location where to store the value
  112718. * @param bool defines the boolean to store
  112719. */
  112720. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112721. /**
  112722. * Set the value of an uniform to a vec4
  112723. * @param uniform defines the webGL uniform location where to store the value
  112724. * @param x defines the 1st component of the value
  112725. * @param y defines the 2nd component of the value
  112726. * @param z defines the 3rd component of the value
  112727. * @param w defines the 4th component of the value
  112728. */
  112729. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112730. /**
  112731. * Sets the current alpha mode
  112732. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112733. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112735. */
  112736. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112737. /**
  112738. * Bind webGl buffers directly to the webGL context
  112739. * @param vertexBuffers defines the vertex buffer to bind
  112740. * @param indexBuffer defines the index buffer to bind
  112741. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112742. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112743. * @param effect defines the effect associated with the vertex buffer
  112744. */
  112745. bindBuffers(vertexBuffers: {
  112746. [key: string]: VertexBuffer;
  112747. }, indexBuffer: DataBuffer, effect: Effect): void;
  112748. /**
  112749. * Force the entire cache to be cleared
  112750. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112751. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112752. */
  112753. wipeCaches(bruteForce?: boolean): void;
  112754. /**
  112755. * Send a draw order
  112756. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112757. * @param indexStart defines the starting index
  112758. * @param indexCount defines the number of index to draw
  112759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112760. */
  112761. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112762. /**
  112763. * Draw a list of indexed primitives
  112764. * @param fillMode defines the primitive to use
  112765. * @param indexStart defines the starting index
  112766. * @param indexCount defines the number of index to draw
  112767. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112768. */
  112769. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112770. /**
  112771. * Draw a list of unindexed primitives
  112772. * @param fillMode defines the primitive to use
  112773. * @param verticesStart defines the index of first vertex to draw
  112774. * @param verticesCount defines the count of vertices to draw
  112775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112776. */
  112777. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112778. /** @hidden */
  112779. _createTexture(): WebGLTexture;
  112780. /** @hidden */
  112781. _releaseTexture(texture: InternalTexture): void;
  112782. /**
  112783. * Usually called from Texture.ts.
  112784. * Passed information to create a WebGLTexture
  112785. * @param urlArg defines a value which contains one of the following:
  112786. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112787. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112788. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112790. * @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)
  112791. * @param scene needed for loading to the correct scene
  112792. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112793. * @param onLoad optional callback to be called upon successful completion
  112794. * @param onError optional callback to be called upon failure
  112795. * @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
  112796. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112797. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112798. * @param forcedExtension defines the extension to use to pick the right loader
  112799. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112800. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112801. */
  112802. 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;
  112803. /**
  112804. * Creates a new render target texture
  112805. * @param size defines the size of the texture
  112806. * @param options defines the options used to create the texture
  112807. * @returns a new render target texture stored in an InternalTexture
  112808. */
  112809. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112810. /**
  112811. * Update the sampling mode of a given texture
  112812. * @param samplingMode defines the required sampling mode
  112813. * @param texture defines the texture to update
  112814. */
  112815. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112816. /**
  112817. * Binds the frame buffer to the specified texture.
  112818. * @param texture The texture to render to or null for the default canvas
  112819. * @param faceIndex The face of the texture to render to in case of cube texture
  112820. * @param requiredWidth The width of the target to render to
  112821. * @param requiredHeight The height of the target to render to
  112822. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112823. * @param depthStencilTexture The depth stencil texture to use to render
  112824. * @param lodLevel defines le lod level to bind to the frame buffer
  112825. */
  112826. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112827. /**
  112828. * Unbind the current render target texture from the webGL context
  112829. * @param texture defines the render target texture to unbind
  112830. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112831. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112832. */
  112833. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112834. /**
  112835. * Creates a dynamic vertex buffer
  112836. * @param vertices the data for the dynamic vertex buffer
  112837. * @returns the new WebGL dynamic buffer
  112838. */
  112839. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112840. /**
  112841. * Update the content of a dynamic texture
  112842. * @param texture defines the texture to update
  112843. * @param canvas defines the canvas containing the source
  112844. * @param invertY defines if data must be stored with Y axis inverted
  112845. * @param premulAlpha defines if alpha is stored as premultiplied
  112846. * @param format defines the format of the data
  112847. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112848. */
  112849. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112850. /**
  112851. * Gets a boolean indicating if all created effects are ready
  112852. * @returns true if all effects are ready
  112853. */
  112854. areAllEffectsReady(): boolean;
  112855. /**
  112856. * @hidden
  112857. * Get the current error code of the webGL context
  112858. * @returns the error code
  112859. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112860. */
  112861. getError(): number;
  112862. /** @hidden */
  112863. _getUnpackAlignement(): number;
  112864. /** @hidden */
  112865. _unpackFlipY(value: boolean): void;
  112866. /**
  112867. * Update a dynamic index buffer
  112868. * @param indexBuffer defines the target index buffer
  112869. * @param indices defines the data to update
  112870. * @param offset defines the offset in the target index buffer where update should start
  112871. */
  112872. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112873. /**
  112874. * Updates a dynamic vertex buffer.
  112875. * @param vertexBuffer the vertex buffer to update
  112876. * @param vertices the data used to update the vertex buffer
  112877. * @param byteOffset the byte offset of the data (optional)
  112878. * @param byteLength the byte length of the data (optional)
  112879. */
  112880. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112881. /** @hidden */
  112882. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112883. /** @hidden */
  112884. _bindTexture(channel: number, texture: InternalTexture): void;
  112885. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112886. /**
  112887. * 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
  112888. */
  112889. releaseEffects(): void;
  112890. displayLoadingUI(): void;
  112891. hideLoadingUI(): void;
  112892. /** @hidden */
  112893. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112894. /** @hidden */
  112895. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112896. /** @hidden */
  112897. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112898. /** @hidden */
  112899. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112900. }
  112901. }
  112902. declare module BABYLON {
  112903. /** @hidden */
  112904. export class _OcclusionDataStorage {
  112905. /** @hidden */
  112906. occlusionInternalRetryCounter: number;
  112907. /** @hidden */
  112908. isOcclusionQueryInProgress: boolean;
  112909. /** @hidden */
  112910. isOccluded: boolean;
  112911. /** @hidden */
  112912. occlusionRetryCount: number;
  112913. /** @hidden */
  112914. occlusionType: number;
  112915. /** @hidden */
  112916. occlusionQueryAlgorithmType: number;
  112917. }
  112918. interface Engine {
  112919. /**
  112920. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112921. * @return the new query
  112922. */
  112923. createQuery(): WebGLQuery;
  112924. /**
  112925. * Delete and release a webGL query
  112926. * @param query defines the query to delete
  112927. * @return the current engine
  112928. */
  112929. deleteQuery(query: WebGLQuery): Engine;
  112930. /**
  112931. * Check if a given query has resolved and got its value
  112932. * @param query defines the query to check
  112933. * @returns true if the query got its value
  112934. */
  112935. isQueryResultAvailable(query: WebGLQuery): boolean;
  112936. /**
  112937. * Gets the value of a given query
  112938. * @param query defines the query to check
  112939. * @returns the value of the query
  112940. */
  112941. getQueryResult(query: WebGLQuery): number;
  112942. /**
  112943. * Initiates an occlusion query
  112944. * @param algorithmType defines the algorithm to use
  112945. * @param query defines the query to use
  112946. * @returns the current engine
  112947. * @see http://doc.babylonjs.com/features/occlusionquery
  112948. */
  112949. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112950. /**
  112951. * Ends an occlusion query
  112952. * @see http://doc.babylonjs.com/features/occlusionquery
  112953. * @param algorithmType defines the algorithm to use
  112954. * @returns the current engine
  112955. */
  112956. endOcclusionQuery(algorithmType: number): Engine;
  112957. /**
  112958. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112959. * Please note that only one query can be issued at a time
  112960. * @returns a time token used to track the time span
  112961. */
  112962. startTimeQuery(): Nullable<_TimeToken>;
  112963. /**
  112964. * Ends a time query
  112965. * @param token defines the token used to measure the time span
  112966. * @returns the time spent (in ns)
  112967. */
  112968. endTimeQuery(token: _TimeToken): int;
  112969. /** @hidden */
  112970. _currentNonTimestampToken: Nullable<_TimeToken>;
  112971. /** @hidden */
  112972. _createTimeQuery(): WebGLQuery;
  112973. /** @hidden */
  112974. _deleteTimeQuery(query: WebGLQuery): void;
  112975. /** @hidden */
  112976. _getGlAlgorithmType(algorithmType: number): number;
  112977. /** @hidden */
  112978. _getTimeQueryResult(query: WebGLQuery): any;
  112979. /** @hidden */
  112980. _getTimeQueryAvailability(query: WebGLQuery): any;
  112981. }
  112982. interface AbstractMesh {
  112983. /**
  112984. * Backing filed
  112985. * @hidden
  112986. */
  112987. __occlusionDataStorage: _OcclusionDataStorage;
  112988. /**
  112989. * Access property
  112990. * @hidden
  112991. */
  112992. _occlusionDataStorage: _OcclusionDataStorage;
  112993. /**
  112994. * 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.
  112995. * The default value is -1 which means don't break the query and wait till the result
  112996. * @see http://doc.babylonjs.com/features/occlusionquery
  112997. */
  112998. occlusionRetryCount: number;
  112999. /**
  113000. * 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:
  113001. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113002. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113003. * * 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.
  113004. * @see http://doc.babylonjs.com/features/occlusionquery
  113005. */
  113006. occlusionType: number;
  113007. /**
  113008. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113009. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113010. * * 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.
  113011. * @see http://doc.babylonjs.com/features/occlusionquery
  113012. */
  113013. occlusionQueryAlgorithmType: number;
  113014. /**
  113015. * 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
  113016. * @see http://doc.babylonjs.com/features/occlusionquery
  113017. */
  113018. isOccluded: boolean;
  113019. /**
  113020. * Flag to check the progress status of the query
  113021. * @see http://doc.babylonjs.com/features/occlusionquery
  113022. */
  113023. isOcclusionQueryInProgress: boolean;
  113024. }
  113025. }
  113026. declare module BABYLON {
  113027. /** @hidden */
  113028. export var _forceTransformFeedbackToBundle: boolean;
  113029. interface Engine {
  113030. /**
  113031. * Creates a webGL transform feedback object
  113032. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113033. * @returns the webGL transform feedback object
  113034. */
  113035. createTransformFeedback(): WebGLTransformFeedback;
  113036. /**
  113037. * Delete a webGL transform feedback object
  113038. * @param value defines the webGL transform feedback object to delete
  113039. */
  113040. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113041. /**
  113042. * Bind a webGL transform feedback object to the webgl context
  113043. * @param value defines the webGL transform feedback object to bind
  113044. */
  113045. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113046. /**
  113047. * Begins a transform feedback operation
  113048. * @param usePoints defines if points or triangles must be used
  113049. */
  113050. beginTransformFeedback(usePoints: boolean): void;
  113051. /**
  113052. * Ends a transform feedback operation
  113053. */
  113054. endTransformFeedback(): void;
  113055. /**
  113056. * Specify the varyings to use with transform feedback
  113057. * @param program defines the associated webGL program
  113058. * @param value defines the list of strings representing the varying names
  113059. */
  113060. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113061. /**
  113062. * Bind a webGL buffer for a transform feedback operation
  113063. * @param value defines the webGL buffer to bind
  113064. */
  113065. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113066. }
  113067. }
  113068. declare module BABYLON {
  113069. /**
  113070. * Creation options of the multi render target texture.
  113071. */
  113072. export interface IMultiRenderTargetOptions {
  113073. /**
  113074. * Define if the texture needs to create mip maps after render.
  113075. */
  113076. generateMipMaps?: boolean;
  113077. /**
  113078. * Define the types of all the draw buffers we want to create
  113079. */
  113080. types?: number[];
  113081. /**
  113082. * Define the sampling modes of all the draw buffers we want to create
  113083. */
  113084. samplingModes?: number[];
  113085. /**
  113086. * Define if a depth buffer is required
  113087. */
  113088. generateDepthBuffer?: boolean;
  113089. /**
  113090. * Define if a stencil buffer is required
  113091. */
  113092. generateStencilBuffer?: boolean;
  113093. /**
  113094. * Define if a depth texture is required instead of a depth buffer
  113095. */
  113096. generateDepthTexture?: boolean;
  113097. /**
  113098. * Define the number of desired draw buffers
  113099. */
  113100. textureCount?: number;
  113101. /**
  113102. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113103. */
  113104. doNotChangeAspectRatio?: boolean;
  113105. /**
  113106. * Define the default type of the buffers we are creating
  113107. */
  113108. defaultType?: number;
  113109. }
  113110. /**
  113111. * A multi render target, like a render target provides the ability to render to a texture.
  113112. * Unlike the render target, it can render to several draw buffers in one draw.
  113113. * This is specially interesting in deferred rendering or for any effects requiring more than
  113114. * just one color from a single pass.
  113115. */
  113116. export class MultiRenderTarget extends RenderTargetTexture {
  113117. private _internalTextures;
  113118. private _textures;
  113119. private _multiRenderTargetOptions;
  113120. /**
  113121. * Get if draw buffers are currently supported by the used hardware and browser.
  113122. */
  113123. readonly isSupported: boolean;
  113124. /**
  113125. * Get the list of textures generated by the multi render target.
  113126. */
  113127. readonly textures: Texture[];
  113128. /**
  113129. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113130. */
  113131. readonly depthTexture: Texture;
  113132. /**
  113133. * Set the wrapping mode on U of all the textures we are rendering to.
  113134. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113135. */
  113136. wrapU: number;
  113137. /**
  113138. * Set the wrapping mode on V of all the textures we are rendering to.
  113139. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113140. */
  113141. wrapV: number;
  113142. /**
  113143. * Instantiate a new multi render target texture.
  113144. * A multi render target, like a render target provides the ability to render to a texture.
  113145. * Unlike the render target, it can render to several draw buffers in one draw.
  113146. * This is specially interesting in deferred rendering or for any effects requiring more than
  113147. * just one color from a single pass.
  113148. * @param name Define the name of the texture
  113149. * @param size Define the size of the buffers to render to
  113150. * @param count Define the number of target we are rendering into
  113151. * @param scene Define the scene the texture belongs to
  113152. * @param options Define the options used to create the multi render target
  113153. */
  113154. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113155. /** @hidden */
  113156. _rebuild(): void;
  113157. private _createInternalTextures;
  113158. private _createTextures;
  113159. /**
  113160. * Define the number of samples used if MSAA is enabled.
  113161. */
  113162. samples: number;
  113163. /**
  113164. * Resize all the textures in the multi render target.
  113165. * Be carrefull as it will recreate all the data in the new texture.
  113166. * @param size Define the new size
  113167. */
  113168. resize(size: any): void;
  113169. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113170. /**
  113171. * Dispose the render targets and their associated resources
  113172. */
  113173. dispose(): void;
  113174. /**
  113175. * Release all the underlying texture used as draw buffers.
  113176. */
  113177. releaseInternalTextures(): void;
  113178. }
  113179. }
  113180. declare module BABYLON {
  113181. interface ThinEngine {
  113182. /**
  113183. * Unbind a list of render target textures from the webGL context
  113184. * This is used only when drawBuffer extension or webGL2 are active
  113185. * @param textures defines the render target textures to unbind
  113186. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113187. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113188. */
  113189. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113190. /**
  113191. * Create a multi render target texture
  113192. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113193. * @param size defines the size of the texture
  113194. * @param options defines the creation options
  113195. * @returns the cube texture as an InternalTexture
  113196. */
  113197. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113198. /**
  113199. * Update the sample count for a given multiple render target texture
  113200. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113201. * @param textures defines the textures to update
  113202. * @param samples defines the sample count to set
  113203. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113204. */
  113205. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113206. }
  113207. }
  113208. declare module BABYLON {
  113209. /**
  113210. * Class used to define an additional view for the engine
  113211. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113212. */
  113213. export class EngineView {
  113214. /** Defines the canvas where to render the view */
  113215. target: HTMLCanvasElement;
  113216. /** Defines an optional camera used to render the view (will use active camera else) */
  113217. camera?: Camera;
  113218. }
  113219. interface Engine {
  113220. /**
  113221. * Gets or sets the HTML element to use for attaching events
  113222. */
  113223. inputElement: Nullable<HTMLElement>;
  113224. /**
  113225. * Gets the current engine view
  113226. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113227. */
  113228. activeView: Nullable<EngineView>;
  113229. /** Gets or sets the list of views */
  113230. views: EngineView[];
  113231. /**
  113232. * Register a new child canvas
  113233. * @param canvas defines the canvas to register
  113234. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113235. * @returns the associated view
  113236. */
  113237. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113238. /**
  113239. * Remove a registered child canvas
  113240. * @param canvas defines the canvas to remove
  113241. * @returns the current engine
  113242. */
  113243. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113244. }
  113245. }
  113246. declare module BABYLON {
  113247. /**
  113248. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113249. */
  113250. export interface CubeMapInfo {
  113251. /**
  113252. * The pixel array for the front face.
  113253. * This is stored in format, left to right, up to down format.
  113254. */
  113255. front: Nullable<ArrayBufferView>;
  113256. /**
  113257. * The pixel array for the back face.
  113258. * This is stored in format, left to right, up to down format.
  113259. */
  113260. back: Nullable<ArrayBufferView>;
  113261. /**
  113262. * The pixel array for the left face.
  113263. * This is stored in format, left to right, up to down format.
  113264. */
  113265. left: Nullable<ArrayBufferView>;
  113266. /**
  113267. * The pixel array for the right face.
  113268. * This is stored in format, left to right, up to down format.
  113269. */
  113270. right: Nullable<ArrayBufferView>;
  113271. /**
  113272. * The pixel array for the up face.
  113273. * This is stored in format, left to right, up to down format.
  113274. */
  113275. up: Nullable<ArrayBufferView>;
  113276. /**
  113277. * The pixel array for the down face.
  113278. * This is stored in format, left to right, up to down format.
  113279. */
  113280. down: Nullable<ArrayBufferView>;
  113281. /**
  113282. * The size of the cubemap stored.
  113283. *
  113284. * Each faces will be size * size pixels.
  113285. */
  113286. size: number;
  113287. /**
  113288. * The format of the texture.
  113289. *
  113290. * RGBA, RGB.
  113291. */
  113292. format: number;
  113293. /**
  113294. * The type of the texture data.
  113295. *
  113296. * UNSIGNED_INT, FLOAT.
  113297. */
  113298. type: number;
  113299. /**
  113300. * Specifies whether the texture is in gamma space.
  113301. */
  113302. gammaSpace: boolean;
  113303. }
  113304. /**
  113305. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113306. */
  113307. export class PanoramaToCubeMapTools {
  113308. private static FACE_FRONT;
  113309. private static FACE_BACK;
  113310. private static FACE_RIGHT;
  113311. private static FACE_LEFT;
  113312. private static FACE_DOWN;
  113313. private static FACE_UP;
  113314. /**
  113315. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113316. *
  113317. * @param float32Array The source data.
  113318. * @param inputWidth The width of the input panorama.
  113319. * @param inputHeight The height of the input panorama.
  113320. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113321. * @return The cubemap data
  113322. */
  113323. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113324. private static CreateCubemapTexture;
  113325. private static CalcProjectionSpherical;
  113326. }
  113327. }
  113328. declare module BABYLON {
  113329. /**
  113330. * Helper class dealing with the extraction of spherical polynomial dataArray
  113331. * from a cube map.
  113332. */
  113333. export class CubeMapToSphericalPolynomialTools {
  113334. private static FileFaces;
  113335. /**
  113336. * Converts a texture to the according Spherical Polynomial data.
  113337. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113338. *
  113339. * @param texture The texture to extract the information from.
  113340. * @return The Spherical Polynomial data.
  113341. */
  113342. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113343. /**
  113344. * Converts a cubemap to the according Spherical Polynomial data.
  113345. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113346. *
  113347. * @param cubeInfo The Cube map to extract the information from.
  113348. * @return The Spherical Polynomial data.
  113349. */
  113350. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113351. }
  113352. }
  113353. declare module BABYLON {
  113354. interface BaseTexture {
  113355. /**
  113356. * Get the polynomial representation of the texture data.
  113357. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113358. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113359. */
  113360. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113361. }
  113362. }
  113363. declare module BABYLON {
  113364. /** @hidden */
  113365. export var rgbdEncodePixelShader: {
  113366. name: string;
  113367. shader: string;
  113368. };
  113369. }
  113370. declare module BABYLON {
  113371. /** @hidden */
  113372. export var rgbdDecodePixelShader: {
  113373. name: string;
  113374. shader: string;
  113375. };
  113376. }
  113377. declare module BABYLON {
  113378. /**
  113379. * Raw texture data and descriptor sufficient for WebGL texture upload
  113380. */
  113381. export interface EnvironmentTextureInfo {
  113382. /**
  113383. * Version of the environment map
  113384. */
  113385. version: number;
  113386. /**
  113387. * Width of image
  113388. */
  113389. width: number;
  113390. /**
  113391. * Irradiance information stored in the file.
  113392. */
  113393. irradiance: any;
  113394. /**
  113395. * Specular information stored in the file.
  113396. */
  113397. specular: any;
  113398. }
  113399. /**
  113400. * Defines One Image in the file. It requires only the position in the file
  113401. * as well as the length.
  113402. */
  113403. interface BufferImageData {
  113404. /**
  113405. * Length of the image data.
  113406. */
  113407. length: number;
  113408. /**
  113409. * Position of the data from the null terminator delimiting the end of the JSON.
  113410. */
  113411. position: number;
  113412. }
  113413. /**
  113414. * Defines the specular data enclosed in the file.
  113415. * This corresponds to the version 1 of the data.
  113416. */
  113417. export interface EnvironmentTextureSpecularInfoV1 {
  113418. /**
  113419. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113420. */
  113421. specularDataPosition?: number;
  113422. /**
  113423. * This contains all the images data needed to reconstruct the cubemap.
  113424. */
  113425. mipmaps: Array<BufferImageData>;
  113426. /**
  113427. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113428. */
  113429. lodGenerationScale: number;
  113430. }
  113431. /**
  113432. * Sets of helpers addressing the serialization and deserialization of environment texture
  113433. * stored in a BabylonJS env file.
  113434. * Those files are usually stored as .env files.
  113435. */
  113436. export class EnvironmentTextureTools {
  113437. /**
  113438. * Magic number identifying the env file.
  113439. */
  113440. private static _MagicBytes;
  113441. /**
  113442. * Gets the environment info from an env file.
  113443. * @param data The array buffer containing the .env bytes.
  113444. * @returns the environment file info (the json header) if successfully parsed.
  113445. */
  113446. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113447. /**
  113448. * Creates an environment texture from a loaded cube texture.
  113449. * @param texture defines the cube texture to convert in env file
  113450. * @return a promise containing the environment data if succesfull.
  113451. */
  113452. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113453. /**
  113454. * Creates a JSON representation of the spherical data.
  113455. * @param texture defines the texture containing the polynomials
  113456. * @return the JSON representation of the spherical info
  113457. */
  113458. private static _CreateEnvTextureIrradiance;
  113459. /**
  113460. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113461. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113462. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113463. * @return the views described by info providing access to the underlying buffer
  113464. */
  113465. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113466. /**
  113467. * Uploads the texture info contained in the env file to the GPU.
  113468. * @param texture defines the internal texture to upload to
  113469. * @param arrayBuffer defines the buffer cotaining the data to load
  113470. * @param info defines the texture info retrieved through the GetEnvInfo method
  113471. * @returns a promise
  113472. */
  113473. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113474. private static _OnImageReadyAsync;
  113475. /**
  113476. * Uploads the levels of image data to the GPU.
  113477. * @param texture defines the internal texture to upload to
  113478. * @param imageData defines the array buffer views of image data [mipmap][face]
  113479. * @returns a promise
  113480. */
  113481. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113482. /**
  113483. * Uploads spherical polynomials information to the texture.
  113484. * @param texture defines the texture we are trying to upload the information to
  113485. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113486. */
  113487. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113488. /** @hidden */
  113489. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113490. }
  113491. }
  113492. declare module BABYLON {
  113493. /**
  113494. * Contains position and normal vectors for a vertex
  113495. */
  113496. export class PositionNormalVertex {
  113497. /** the position of the vertex (defaut: 0,0,0) */
  113498. position: Vector3;
  113499. /** the normal of the vertex (defaut: 0,1,0) */
  113500. normal: Vector3;
  113501. /**
  113502. * Creates a PositionNormalVertex
  113503. * @param position the position of the vertex (defaut: 0,0,0)
  113504. * @param normal the normal of the vertex (defaut: 0,1,0)
  113505. */
  113506. constructor(
  113507. /** the position of the vertex (defaut: 0,0,0) */
  113508. position?: Vector3,
  113509. /** the normal of the vertex (defaut: 0,1,0) */
  113510. normal?: Vector3);
  113511. /**
  113512. * Clones the PositionNormalVertex
  113513. * @returns the cloned PositionNormalVertex
  113514. */
  113515. clone(): PositionNormalVertex;
  113516. }
  113517. /**
  113518. * Contains position, normal and uv vectors for a vertex
  113519. */
  113520. export class PositionNormalTextureVertex {
  113521. /** the position of the vertex (defaut: 0,0,0) */
  113522. position: Vector3;
  113523. /** the normal of the vertex (defaut: 0,1,0) */
  113524. normal: Vector3;
  113525. /** the uv of the vertex (default: 0,0) */
  113526. uv: Vector2;
  113527. /**
  113528. * Creates a PositionNormalTextureVertex
  113529. * @param position the position of the vertex (defaut: 0,0,0)
  113530. * @param normal the normal of the vertex (defaut: 0,1,0)
  113531. * @param uv the uv of the vertex (default: 0,0)
  113532. */
  113533. constructor(
  113534. /** the position of the vertex (defaut: 0,0,0) */
  113535. position?: Vector3,
  113536. /** the normal of the vertex (defaut: 0,1,0) */
  113537. normal?: Vector3,
  113538. /** the uv of the vertex (default: 0,0) */
  113539. uv?: Vector2);
  113540. /**
  113541. * Clones the PositionNormalTextureVertex
  113542. * @returns the cloned PositionNormalTextureVertex
  113543. */
  113544. clone(): PositionNormalTextureVertex;
  113545. }
  113546. }
  113547. declare module BABYLON {
  113548. /** @hidden */
  113549. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113550. private _genericAttributeLocation;
  113551. private _varyingLocationCount;
  113552. private _varyingLocationMap;
  113553. private _replacements;
  113554. private _textureCount;
  113555. private _uniforms;
  113556. lineProcessor(line: string): string;
  113557. attributeProcessor(attribute: string): string;
  113558. varyingProcessor(varying: string, isFragment: boolean): string;
  113559. uniformProcessor(uniform: string): string;
  113560. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113561. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113562. }
  113563. }
  113564. declare module BABYLON {
  113565. /**
  113566. * Container for accessors for natively-stored mesh data buffers.
  113567. */
  113568. class NativeDataBuffer extends DataBuffer {
  113569. /**
  113570. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113571. */
  113572. nativeIndexBuffer?: any;
  113573. /**
  113574. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113575. */
  113576. nativeVertexBuffer?: any;
  113577. }
  113578. /** @hidden */
  113579. class NativeTexture extends InternalTexture {
  113580. getInternalTexture(): InternalTexture;
  113581. getViewCount(): number;
  113582. }
  113583. /** @hidden */
  113584. export class NativeEngine extends Engine {
  113585. private readonly _native;
  113586. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113587. private readonly INVALID_HANDLE;
  113588. getHardwareScalingLevel(): number;
  113589. constructor();
  113590. /**
  113591. * Can be used to override the current requestAnimationFrame requester.
  113592. * @hidden
  113593. */
  113594. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113595. /**
  113596. * Override default engine behavior.
  113597. * @param color
  113598. * @param backBuffer
  113599. * @param depth
  113600. * @param stencil
  113601. */
  113602. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113603. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113604. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113605. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113606. recordVertexArrayObject(vertexBuffers: {
  113607. [key: string]: VertexBuffer;
  113608. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113609. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113610. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113611. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113612. /**
  113613. * Draw a list of indexed primitives
  113614. * @param fillMode defines the primitive to use
  113615. * @param indexStart defines the starting index
  113616. * @param indexCount defines the number of index to draw
  113617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113618. */
  113619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113620. /**
  113621. * Draw a list of unindexed primitives
  113622. * @param fillMode defines the primitive to use
  113623. * @param verticesStart defines the index of first vertex to draw
  113624. * @param verticesCount defines the count of vertices to draw
  113625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113626. */
  113627. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113628. createPipelineContext(): IPipelineContext;
  113629. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113630. /** @hidden */
  113631. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113632. /** @hidden */
  113633. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113634. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113635. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113636. protected _setProgram(program: WebGLProgram): void;
  113637. _releaseEffect(effect: Effect): void;
  113638. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113639. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113640. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113641. bindSamplers(effect: Effect): void;
  113642. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113643. getRenderWidth(useScreen?: boolean): number;
  113644. getRenderHeight(useScreen?: boolean): number;
  113645. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113646. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113647. /**
  113648. * Set the z offset to apply to current rendering
  113649. * @param value defines the offset to apply
  113650. */
  113651. setZOffset(value: number): void;
  113652. /**
  113653. * Gets the current value of the zOffset
  113654. * @returns the current zOffset state
  113655. */
  113656. getZOffset(): number;
  113657. /**
  113658. * Enable or disable depth buffering
  113659. * @param enable defines the state to set
  113660. */
  113661. setDepthBuffer(enable: boolean): void;
  113662. /**
  113663. * Gets a boolean indicating if depth writing is enabled
  113664. * @returns the current depth writing state
  113665. */
  113666. getDepthWrite(): boolean;
  113667. /**
  113668. * Enable or disable depth writing
  113669. * @param enable defines the state to set
  113670. */
  113671. setDepthWrite(enable: boolean): void;
  113672. /**
  113673. * Enable or disable color writing
  113674. * @param enable defines the state to set
  113675. */
  113676. setColorWrite(enable: boolean): void;
  113677. /**
  113678. * Gets a boolean indicating if color writing is enabled
  113679. * @returns the current color writing state
  113680. */
  113681. getColorWrite(): boolean;
  113682. /**
  113683. * Sets alpha constants used by some alpha blending modes
  113684. * @param r defines the red component
  113685. * @param g defines the green component
  113686. * @param b defines the blue component
  113687. * @param a defines the alpha component
  113688. */
  113689. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113690. /**
  113691. * Sets the current alpha mode
  113692. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113693. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113694. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113695. */
  113696. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113697. /**
  113698. * Gets the current alpha mode
  113699. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113700. * @returns the current alpha mode
  113701. */
  113702. getAlphaMode(): number;
  113703. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113704. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113705. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113706. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113707. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113708. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113709. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113710. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113711. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113712. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113713. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113714. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113715. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113716. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113717. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113718. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113719. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113720. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113721. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113722. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113723. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113724. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113725. wipeCaches(bruteForce?: boolean): void;
  113726. _createTexture(): WebGLTexture;
  113727. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113728. /**
  113729. * Usually called from BABYLON.Texture.ts.
  113730. * Passed information to create a WebGLTexture
  113731. * @param urlArg defines a value which contains one of the following:
  113732. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113733. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113734. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113736. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113737. * @param scene needed for loading to the correct scene
  113738. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113739. * @param onLoad optional callback to be called upon successful completion
  113740. * @param onError optional callback to be called upon failure
  113741. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113742. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113743. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113744. * @param forcedExtension defines the extension to use to pick the right loader
  113745. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113746. */
  113747. 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;
  113748. /**
  113749. * Creates a cube texture
  113750. * @param rootUrl defines the url where the files to load is located
  113751. * @param scene defines the current scene
  113752. * @param files defines the list of files to load (1 per face)
  113753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113754. * @param onLoad defines an optional callback raised when the texture is loaded
  113755. * @param onError defines an optional callback raised if there is an issue to load the texture
  113756. * @param format defines the format of the data
  113757. * @param forcedExtension defines the extension to use to pick the right loader
  113758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113762. * @returns the cube texture as an InternalTexture
  113763. */
  113764. 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;
  113765. private _getSamplingFilter;
  113766. private static _GetNativeTextureFormat;
  113767. createRenderTargetTexture(size: number | {
  113768. width: number;
  113769. height: number;
  113770. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113771. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113772. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113773. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113774. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113775. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113776. /**
  113777. * Updates a dynamic vertex buffer.
  113778. * @param vertexBuffer the vertex buffer to update
  113779. * @param data the data used to update the vertex buffer
  113780. * @param byteOffset the byte offset of the data (optional)
  113781. * @param byteLength the byte length of the data (optional)
  113782. */
  113783. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113784. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113785. private _updateAnisotropicLevel;
  113786. private _getAddressMode;
  113787. /** @hidden */
  113788. _bindTexture(channel: number, texture: InternalTexture): void;
  113789. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113790. releaseEffects(): void;
  113791. /** @hidden */
  113792. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113793. /** @hidden */
  113794. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113795. /** @hidden */
  113796. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113797. /** @hidden */
  113798. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113799. }
  113800. }
  113801. declare module BABYLON {
  113802. /**
  113803. * Gather the list of clipboard event types as constants.
  113804. */
  113805. export class ClipboardEventTypes {
  113806. /**
  113807. * The clipboard event is fired when a copy command is active (pressed).
  113808. */
  113809. static readonly COPY: number;
  113810. /**
  113811. * The clipboard event is fired when a cut command is active (pressed).
  113812. */
  113813. static readonly CUT: number;
  113814. /**
  113815. * The clipboard event is fired when a paste command is active (pressed).
  113816. */
  113817. static readonly PASTE: number;
  113818. }
  113819. /**
  113820. * This class is used to store clipboard related info for the onClipboardObservable event.
  113821. */
  113822. export class ClipboardInfo {
  113823. /**
  113824. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113825. */
  113826. type: number;
  113827. /**
  113828. * Defines the related dom event
  113829. */
  113830. event: ClipboardEvent;
  113831. /**
  113832. *Creates an instance of ClipboardInfo.
  113833. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113834. * @param event Defines the related dom event
  113835. */
  113836. constructor(
  113837. /**
  113838. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113839. */
  113840. type: number,
  113841. /**
  113842. * Defines the related dom event
  113843. */
  113844. event: ClipboardEvent);
  113845. /**
  113846. * Get the clipboard event's type from the keycode.
  113847. * @param keyCode Defines the keyCode for the current keyboard event.
  113848. * @return {number}
  113849. */
  113850. static GetTypeFromCharacter(keyCode: number): number;
  113851. }
  113852. }
  113853. declare module BABYLON {
  113854. /**
  113855. * Google Daydream controller
  113856. */
  113857. export class DaydreamController extends WebVRController {
  113858. /**
  113859. * Base Url for the controller model.
  113860. */
  113861. static MODEL_BASE_URL: string;
  113862. /**
  113863. * File name for the controller model.
  113864. */
  113865. static MODEL_FILENAME: string;
  113866. /**
  113867. * Gamepad Id prefix used to identify Daydream Controller.
  113868. */
  113869. static readonly GAMEPAD_ID_PREFIX: string;
  113870. /**
  113871. * Creates a new DaydreamController from a gamepad
  113872. * @param vrGamepad the gamepad that the controller should be created from
  113873. */
  113874. constructor(vrGamepad: any);
  113875. /**
  113876. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113877. * @param scene scene in which to add meshes
  113878. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113879. */
  113880. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113881. /**
  113882. * Called once for each button that changed state since the last frame
  113883. * @param buttonIdx Which button index changed
  113884. * @param state New state of the button
  113885. * @param changes Which properties on the state changed since last frame
  113886. */
  113887. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113888. }
  113889. }
  113890. declare module BABYLON {
  113891. /**
  113892. * Gear VR Controller
  113893. */
  113894. export class GearVRController extends WebVRController {
  113895. /**
  113896. * Base Url for the controller model.
  113897. */
  113898. static MODEL_BASE_URL: string;
  113899. /**
  113900. * File name for the controller model.
  113901. */
  113902. static MODEL_FILENAME: string;
  113903. /**
  113904. * Gamepad Id prefix used to identify this controller.
  113905. */
  113906. static readonly GAMEPAD_ID_PREFIX: string;
  113907. private readonly _buttonIndexToObservableNameMap;
  113908. /**
  113909. * Creates a new GearVRController from a gamepad
  113910. * @param vrGamepad the gamepad that the controller should be created from
  113911. */
  113912. constructor(vrGamepad: any);
  113913. /**
  113914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113915. * @param scene scene in which to add meshes
  113916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113917. */
  113918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113919. /**
  113920. * Called once for each button that changed state since the last frame
  113921. * @param buttonIdx Which button index changed
  113922. * @param state New state of the button
  113923. * @param changes Which properties on the state changed since last frame
  113924. */
  113925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113926. }
  113927. }
  113928. declare module BABYLON {
  113929. /**
  113930. * Class containing static functions to help procedurally build meshes
  113931. */
  113932. export class PolyhedronBuilder {
  113933. /**
  113934. * Creates a polyhedron mesh
  113935. * * 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
  113936. * * The parameter `size` (positive float, default 1) sets the polygon size
  113937. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113938. * * 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`
  113939. * * 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
  113940. * * 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)`)
  113941. * * 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
  113942. * * 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
  113943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113946. * @param name defines the name of the mesh
  113947. * @param options defines the options used to create the mesh
  113948. * @param scene defines the hosting scene
  113949. * @returns the polyhedron mesh
  113950. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113951. */
  113952. static CreatePolyhedron(name: string, options: {
  113953. type?: number;
  113954. size?: number;
  113955. sizeX?: number;
  113956. sizeY?: number;
  113957. sizeZ?: number;
  113958. custom?: any;
  113959. faceUV?: Vector4[];
  113960. faceColors?: Color4[];
  113961. flat?: boolean;
  113962. updatable?: boolean;
  113963. sideOrientation?: number;
  113964. frontUVs?: Vector4;
  113965. backUVs?: Vector4;
  113966. }, scene?: Nullable<Scene>): Mesh;
  113967. }
  113968. }
  113969. declare module BABYLON {
  113970. /**
  113971. * Gizmo that enables scaling a mesh along 3 axis
  113972. */
  113973. export class ScaleGizmo extends Gizmo {
  113974. /**
  113975. * Internal gizmo used for interactions on the x axis
  113976. */
  113977. xGizmo: AxisScaleGizmo;
  113978. /**
  113979. * Internal gizmo used for interactions on the y axis
  113980. */
  113981. yGizmo: AxisScaleGizmo;
  113982. /**
  113983. * Internal gizmo used for interactions on the z axis
  113984. */
  113985. zGizmo: AxisScaleGizmo;
  113986. /**
  113987. * Internal gizmo used to scale all axis equally
  113988. */
  113989. uniformScaleGizmo: AxisScaleGizmo;
  113990. private _meshAttached;
  113991. private _updateGizmoRotationToMatchAttachedMesh;
  113992. private _snapDistance;
  113993. private _scaleRatio;
  113994. private _uniformScalingMesh;
  113995. private _octahedron;
  113996. /** Fires an event when any of it's sub gizmos are dragged */
  113997. onDragStartObservable: Observable<unknown>;
  113998. /** Fires an event when any of it's sub gizmos are released from dragging */
  113999. onDragEndObservable: Observable<unknown>;
  114000. attachedMesh: Nullable<AbstractMesh>;
  114001. /**
  114002. * Creates a ScaleGizmo
  114003. * @param gizmoLayer The utility layer the gizmo will be added to
  114004. */
  114005. constructor(gizmoLayer?: UtilityLayerRenderer);
  114006. updateGizmoRotationToMatchAttachedMesh: boolean;
  114007. /**
  114008. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114009. */
  114010. snapDistance: number;
  114011. /**
  114012. * Ratio for the scale of the gizmo (Default: 1)
  114013. */
  114014. scaleRatio: number;
  114015. /**
  114016. * Disposes of the gizmo
  114017. */
  114018. dispose(): void;
  114019. }
  114020. }
  114021. declare module BABYLON {
  114022. /**
  114023. * Single axis scale gizmo
  114024. */
  114025. export class AxisScaleGizmo extends Gizmo {
  114026. /**
  114027. * Drag behavior responsible for the gizmos dragging interactions
  114028. */
  114029. dragBehavior: PointerDragBehavior;
  114030. private _pointerObserver;
  114031. /**
  114032. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114033. */
  114034. snapDistance: number;
  114035. /**
  114036. * Event that fires each time the gizmo snaps to a new location.
  114037. * * snapDistance is the the change in distance
  114038. */
  114039. onSnapObservable: Observable<{
  114040. snapDistance: number;
  114041. }>;
  114042. /**
  114043. * If the scaling operation should be done on all axis (default: false)
  114044. */
  114045. uniformScaling: boolean;
  114046. private _isEnabled;
  114047. private _parent;
  114048. private _arrow;
  114049. private _coloredMaterial;
  114050. private _hoverMaterial;
  114051. /**
  114052. * Creates an AxisScaleGizmo
  114053. * @param gizmoLayer The utility layer the gizmo will be added to
  114054. * @param dragAxis The axis which the gizmo will be able to scale on
  114055. * @param color The color of the gizmo
  114056. */
  114057. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114058. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114059. /**
  114060. * If the gizmo is enabled
  114061. */
  114062. isEnabled: boolean;
  114063. /**
  114064. * Disposes of the gizmo
  114065. */
  114066. dispose(): void;
  114067. /**
  114068. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114069. * @param mesh The mesh to replace the default mesh of the gizmo
  114070. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114071. */
  114072. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * Bounding box gizmo
  114078. */
  114079. export class BoundingBoxGizmo extends Gizmo {
  114080. private _lineBoundingBox;
  114081. private _rotateSpheresParent;
  114082. private _scaleBoxesParent;
  114083. private _boundingDimensions;
  114084. private _renderObserver;
  114085. private _pointerObserver;
  114086. private _scaleDragSpeed;
  114087. private _tmpQuaternion;
  114088. private _tmpVector;
  114089. private _tmpRotationMatrix;
  114090. /**
  114091. * 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)
  114092. */
  114093. ignoreChildren: boolean;
  114094. /**
  114095. * 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)
  114096. */
  114097. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114098. /**
  114099. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114100. */
  114101. rotationSphereSize: number;
  114102. /**
  114103. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114104. */
  114105. scaleBoxSize: number;
  114106. /**
  114107. * 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)
  114108. */
  114109. fixedDragMeshScreenSize: boolean;
  114110. /**
  114111. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114112. */
  114113. fixedDragMeshScreenSizeDistanceFactor: number;
  114114. /**
  114115. * Fired when a rotation sphere or scale box is dragged
  114116. */
  114117. onDragStartObservable: Observable<{}>;
  114118. /**
  114119. * Fired when a scale box is dragged
  114120. */
  114121. onScaleBoxDragObservable: Observable<{}>;
  114122. /**
  114123. * Fired when a scale box drag is ended
  114124. */
  114125. onScaleBoxDragEndObservable: Observable<{}>;
  114126. /**
  114127. * Fired when a rotation sphere is dragged
  114128. */
  114129. onRotationSphereDragObservable: Observable<{}>;
  114130. /**
  114131. * Fired when a rotation sphere drag is ended
  114132. */
  114133. onRotationSphereDragEndObservable: Observable<{}>;
  114134. /**
  114135. * 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)
  114136. */
  114137. scalePivot: Nullable<Vector3>;
  114138. /**
  114139. * Mesh used as a pivot to rotate the attached mesh
  114140. */
  114141. private _anchorMesh;
  114142. private _existingMeshScale;
  114143. private _dragMesh;
  114144. private pointerDragBehavior;
  114145. private coloredMaterial;
  114146. private hoverColoredMaterial;
  114147. /**
  114148. * Sets the color of the bounding box gizmo
  114149. * @param color the color to set
  114150. */
  114151. setColor(color: Color3): void;
  114152. /**
  114153. * Creates an BoundingBoxGizmo
  114154. * @param gizmoLayer The utility layer the gizmo will be added to
  114155. * @param color The color of the gizmo
  114156. */
  114157. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114159. private _selectNode;
  114160. /**
  114161. * Updates the bounding box information for the Gizmo
  114162. */
  114163. updateBoundingBox(): void;
  114164. private _updateRotationSpheres;
  114165. private _updateScaleBoxes;
  114166. /**
  114167. * Enables rotation on the specified axis and disables rotation on the others
  114168. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114169. */
  114170. setEnabledRotationAxis(axis: string): void;
  114171. /**
  114172. * Enables/disables scaling
  114173. * @param enable if scaling should be enabled
  114174. */
  114175. setEnabledScaling(enable: boolean): void;
  114176. private _updateDummy;
  114177. /**
  114178. * Enables a pointer drag behavior on the bounding box of the gizmo
  114179. */
  114180. enableDragBehavior(): void;
  114181. /**
  114182. * Disposes of the gizmo
  114183. */
  114184. dispose(): void;
  114185. /**
  114186. * 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)
  114187. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114188. * @returns the bounding box mesh with the passed in mesh as a child
  114189. */
  114190. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114191. /**
  114192. * CustomMeshes are not supported by this gizmo
  114193. * @param mesh The mesh to replace the default mesh of the gizmo
  114194. */
  114195. setCustomMesh(mesh: Mesh): void;
  114196. }
  114197. }
  114198. declare module BABYLON {
  114199. /**
  114200. * Single plane rotation gizmo
  114201. */
  114202. export class PlaneRotationGizmo extends Gizmo {
  114203. /**
  114204. * Drag behavior responsible for the gizmos dragging interactions
  114205. */
  114206. dragBehavior: PointerDragBehavior;
  114207. private _pointerObserver;
  114208. /**
  114209. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114210. */
  114211. snapDistance: number;
  114212. /**
  114213. * Event that fires each time the gizmo snaps to a new location.
  114214. * * snapDistance is the the change in distance
  114215. */
  114216. onSnapObservable: Observable<{
  114217. snapDistance: number;
  114218. }>;
  114219. private _isEnabled;
  114220. private _parent;
  114221. /**
  114222. * Creates a PlaneRotationGizmo
  114223. * @param gizmoLayer The utility layer the gizmo will be added to
  114224. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114225. * @param color The color of the gizmo
  114226. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114227. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114228. */
  114229. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114230. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114231. /**
  114232. * If the gizmo is enabled
  114233. */
  114234. isEnabled: boolean;
  114235. /**
  114236. * Disposes of the gizmo
  114237. */
  114238. dispose(): void;
  114239. }
  114240. }
  114241. declare module BABYLON {
  114242. /**
  114243. * Gizmo that enables rotating a mesh along 3 axis
  114244. */
  114245. export class RotationGizmo extends Gizmo {
  114246. /**
  114247. * Internal gizmo used for interactions on the x axis
  114248. */
  114249. xGizmo: PlaneRotationGizmo;
  114250. /**
  114251. * Internal gizmo used for interactions on the y axis
  114252. */
  114253. yGizmo: PlaneRotationGizmo;
  114254. /**
  114255. * Internal gizmo used for interactions on the z axis
  114256. */
  114257. zGizmo: PlaneRotationGizmo;
  114258. /** Fires an event when any of it's sub gizmos are dragged */
  114259. onDragStartObservable: Observable<unknown>;
  114260. /** Fires an event when any of it's sub gizmos are released from dragging */
  114261. onDragEndObservable: Observable<unknown>;
  114262. private _meshAttached;
  114263. attachedMesh: Nullable<AbstractMesh>;
  114264. /**
  114265. * Creates a RotationGizmo
  114266. * @param gizmoLayer The utility layer the gizmo will be added to
  114267. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114268. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114269. */
  114270. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114271. updateGizmoRotationToMatchAttachedMesh: boolean;
  114272. /**
  114273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114274. */
  114275. snapDistance: number;
  114276. /**
  114277. * Ratio for the scale of the gizmo (Default: 1)
  114278. */
  114279. scaleRatio: number;
  114280. /**
  114281. * Disposes of the gizmo
  114282. */
  114283. dispose(): void;
  114284. /**
  114285. * CustomMeshes are not supported by this gizmo
  114286. * @param mesh The mesh to replace the default mesh of the gizmo
  114287. */
  114288. setCustomMesh(mesh: Mesh): void;
  114289. }
  114290. }
  114291. declare module BABYLON {
  114292. /**
  114293. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114294. */
  114295. export class GizmoManager implements IDisposable {
  114296. private scene;
  114297. /**
  114298. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114299. */
  114300. gizmos: {
  114301. positionGizmo: Nullable<PositionGizmo>;
  114302. rotationGizmo: Nullable<RotationGizmo>;
  114303. scaleGizmo: Nullable<ScaleGizmo>;
  114304. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114305. };
  114306. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114307. clearGizmoOnEmptyPointerEvent: boolean;
  114308. /** Fires an event when the manager is attached to a mesh */
  114309. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114310. private _gizmosEnabled;
  114311. private _pointerObserver;
  114312. private _attachedMesh;
  114313. private _boundingBoxColor;
  114314. private _defaultUtilityLayer;
  114315. private _defaultKeepDepthUtilityLayer;
  114316. /**
  114317. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114318. */
  114319. boundingBoxDragBehavior: SixDofDragBehavior;
  114320. /**
  114321. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114322. */
  114323. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114324. /**
  114325. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114326. */
  114327. usePointerToAttachGizmos: boolean;
  114328. /**
  114329. * Utility layer that the bounding box gizmo belongs to
  114330. */
  114331. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114332. /**
  114333. * Utility layer that all gizmos besides bounding box belong to
  114334. */
  114335. readonly utilityLayer: UtilityLayerRenderer;
  114336. /**
  114337. * Instatiates a gizmo manager
  114338. * @param scene the scene to overlay the gizmos on top of
  114339. */
  114340. constructor(scene: Scene);
  114341. /**
  114342. * Attaches a set of gizmos to the specified mesh
  114343. * @param mesh The mesh the gizmo's should be attached to
  114344. */
  114345. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114346. /**
  114347. * If the position gizmo is enabled
  114348. */
  114349. positionGizmoEnabled: boolean;
  114350. /**
  114351. * If the rotation gizmo is enabled
  114352. */
  114353. rotationGizmoEnabled: boolean;
  114354. /**
  114355. * If the scale gizmo is enabled
  114356. */
  114357. scaleGizmoEnabled: boolean;
  114358. /**
  114359. * If the boundingBox gizmo is enabled
  114360. */
  114361. boundingBoxGizmoEnabled: boolean;
  114362. /**
  114363. * Disposes of the gizmo manager
  114364. */
  114365. dispose(): void;
  114366. }
  114367. }
  114368. declare module BABYLON {
  114369. /**
  114370. * A directional light is defined by a direction (what a surprise!).
  114371. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114372. * 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.
  114373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114374. */
  114375. export class DirectionalLight extends ShadowLight {
  114376. private _shadowFrustumSize;
  114377. /**
  114378. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114379. */
  114380. /**
  114381. * Specifies a fix frustum size for the shadow generation.
  114382. */
  114383. shadowFrustumSize: number;
  114384. private _shadowOrthoScale;
  114385. /**
  114386. * Gets the shadow projection scale against the optimal computed one.
  114387. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114388. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114389. */
  114390. /**
  114391. * Sets the shadow projection scale against the optimal computed one.
  114392. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114393. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114394. */
  114395. shadowOrthoScale: number;
  114396. /**
  114397. * Automatically compute the projection matrix to best fit (including all the casters)
  114398. * on each frame.
  114399. */
  114400. autoUpdateExtends: boolean;
  114401. private _orthoLeft;
  114402. private _orthoRight;
  114403. private _orthoTop;
  114404. private _orthoBottom;
  114405. /**
  114406. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114407. * The directional light is emitted from everywhere in the given direction.
  114408. * It can cast shadows.
  114409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114410. * @param name The friendly name of the light
  114411. * @param direction The direction of the light
  114412. * @param scene The scene the light belongs to
  114413. */
  114414. constructor(name: string, direction: Vector3, scene: Scene);
  114415. /**
  114416. * Returns the string "DirectionalLight".
  114417. * @return The class name
  114418. */
  114419. getClassName(): string;
  114420. /**
  114421. * Returns the integer 1.
  114422. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114423. */
  114424. getTypeID(): number;
  114425. /**
  114426. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114427. * Returns the DirectionalLight Shadow projection matrix.
  114428. */
  114429. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114430. /**
  114431. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114432. * Returns the DirectionalLight Shadow projection matrix.
  114433. */
  114434. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114435. /**
  114436. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114437. * Returns the DirectionalLight Shadow projection matrix.
  114438. */
  114439. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114440. protected _buildUniformLayout(): void;
  114441. /**
  114442. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114443. * @param effect The effect to update
  114444. * @param lightIndex The index of the light in the effect to update
  114445. * @returns The directional light
  114446. */
  114447. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114448. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114449. /**
  114450. * Gets the minZ used for shadow according to both the scene and the light.
  114451. *
  114452. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114453. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114454. * @param activeCamera The camera we are returning the min for
  114455. * @returns the depth min z
  114456. */
  114457. getDepthMinZ(activeCamera: Camera): number;
  114458. /**
  114459. * Gets the maxZ used for shadow according to both the scene and the light.
  114460. *
  114461. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114462. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114463. * @param activeCamera The camera we are returning the max for
  114464. * @returns the depth max z
  114465. */
  114466. getDepthMaxZ(activeCamera: Camera): number;
  114467. /**
  114468. * Prepares the list of defines specific to the light type.
  114469. * @param defines the list of defines
  114470. * @param lightIndex defines the index of the light for the effect
  114471. */
  114472. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114473. }
  114474. }
  114475. declare module BABYLON {
  114476. /**
  114477. * Class containing static functions to help procedurally build meshes
  114478. */
  114479. export class HemisphereBuilder {
  114480. /**
  114481. * Creates a hemisphere mesh
  114482. * @param name defines the name of the mesh
  114483. * @param options defines the options used to create the mesh
  114484. * @param scene defines the hosting scene
  114485. * @returns the hemisphere mesh
  114486. */
  114487. static CreateHemisphere(name: string, options: {
  114488. segments?: number;
  114489. diameter?: number;
  114490. sideOrientation?: number;
  114491. }, scene: any): Mesh;
  114492. }
  114493. }
  114494. declare module BABYLON {
  114495. /**
  114496. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114497. * These values define a cone of light starting from the position, emitting toward the direction.
  114498. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114499. * and the exponent defines the speed of the decay of the light with distance (reach).
  114500. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114501. */
  114502. export class SpotLight extends ShadowLight {
  114503. private _angle;
  114504. private _innerAngle;
  114505. private _cosHalfAngle;
  114506. private _lightAngleScale;
  114507. private _lightAngleOffset;
  114508. /**
  114509. * Gets the cone angle of the spot light in Radians.
  114510. */
  114511. /**
  114512. * Sets the cone angle of the spot light in Radians.
  114513. */
  114514. angle: number;
  114515. /**
  114516. * Only used in gltf falloff mode, this defines the angle where
  114517. * the directional falloff will start before cutting at angle which could be seen
  114518. * as outer angle.
  114519. */
  114520. /**
  114521. * Only used in gltf falloff mode, this defines the angle where
  114522. * the directional falloff will start before cutting at angle which could be seen
  114523. * as outer angle.
  114524. */
  114525. innerAngle: number;
  114526. private _shadowAngleScale;
  114527. /**
  114528. * Allows scaling the angle of the light for shadow generation only.
  114529. */
  114530. /**
  114531. * Allows scaling the angle of the light for shadow generation only.
  114532. */
  114533. shadowAngleScale: number;
  114534. /**
  114535. * The light decay speed with the distance from the emission spot.
  114536. */
  114537. exponent: number;
  114538. private _projectionTextureMatrix;
  114539. /**
  114540. * Allows reading the projecton texture
  114541. */
  114542. readonly projectionTextureMatrix: Matrix;
  114543. protected _projectionTextureLightNear: number;
  114544. /**
  114545. * Gets the near clip of the Spotlight for texture projection.
  114546. */
  114547. /**
  114548. * Sets the near clip of the Spotlight for texture projection.
  114549. */
  114550. projectionTextureLightNear: number;
  114551. protected _projectionTextureLightFar: number;
  114552. /**
  114553. * Gets the far clip of the Spotlight for texture projection.
  114554. */
  114555. /**
  114556. * Sets the far clip of the Spotlight for texture projection.
  114557. */
  114558. projectionTextureLightFar: number;
  114559. protected _projectionTextureUpDirection: Vector3;
  114560. /**
  114561. * Gets the Up vector of the Spotlight for texture projection.
  114562. */
  114563. /**
  114564. * Sets the Up vector of the Spotlight for texture projection.
  114565. */
  114566. projectionTextureUpDirection: Vector3;
  114567. private _projectionTexture;
  114568. /**
  114569. * Gets the projection texture of the light.
  114570. */
  114571. /**
  114572. * Sets the projection texture of the light.
  114573. */
  114574. projectionTexture: Nullable<BaseTexture>;
  114575. private _projectionTextureViewLightDirty;
  114576. private _projectionTextureProjectionLightDirty;
  114577. private _projectionTextureDirty;
  114578. private _projectionTextureViewTargetVector;
  114579. private _projectionTextureViewLightMatrix;
  114580. private _projectionTextureProjectionLightMatrix;
  114581. private _projectionTextureScalingMatrix;
  114582. /**
  114583. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114584. * It can cast shadows.
  114585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114586. * @param name The light friendly name
  114587. * @param position The position of the spot light in the scene
  114588. * @param direction The direction of the light in the scene
  114589. * @param angle The cone angle of the light in Radians
  114590. * @param exponent The light decay speed with the distance from the emission spot
  114591. * @param scene The scene the lights belongs to
  114592. */
  114593. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114594. /**
  114595. * Returns the string "SpotLight".
  114596. * @returns the class name
  114597. */
  114598. getClassName(): string;
  114599. /**
  114600. * Returns the integer 2.
  114601. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114602. */
  114603. getTypeID(): number;
  114604. /**
  114605. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114606. */
  114607. protected _setDirection(value: Vector3): void;
  114608. /**
  114609. * Overrides the position setter to recompute the projection texture view light Matrix.
  114610. */
  114611. protected _setPosition(value: Vector3): void;
  114612. /**
  114613. * 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.
  114614. * Returns the SpotLight.
  114615. */
  114616. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114617. protected _computeProjectionTextureViewLightMatrix(): void;
  114618. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114619. /**
  114620. * Main function for light texture projection matrix computing.
  114621. */
  114622. protected _computeProjectionTextureMatrix(): void;
  114623. protected _buildUniformLayout(): void;
  114624. private _computeAngleValues;
  114625. /**
  114626. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114627. * @param effect The effect to update
  114628. * @param lightIndex The index of the light in the effect to update
  114629. * @returns The spot light
  114630. */
  114631. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114632. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114633. /**
  114634. * Disposes the light and the associated resources.
  114635. */
  114636. dispose(): void;
  114637. /**
  114638. * Prepares the list of defines specific to the light type.
  114639. * @param defines the list of defines
  114640. * @param lightIndex defines the index of the light for the effect
  114641. */
  114642. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114643. }
  114644. }
  114645. declare module BABYLON {
  114646. /**
  114647. * Gizmo that enables viewing a light
  114648. */
  114649. export class LightGizmo extends Gizmo {
  114650. private _lightMesh;
  114651. private _material;
  114652. private cachedPosition;
  114653. private cachedForward;
  114654. /**
  114655. * Creates a LightGizmo
  114656. * @param gizmoLayer The utility layer the gizmo will be added to
  114657. */
  114658. constructor(gizmoLayer?: UtilityLayerRenderer);
  114659. private _light;
  114660. /**
  114661. * The light that the gizmo is attached to
  114662. */
  114663. light: Nullable<Light>;
  114664. /**
  114665. * Gets the material used to render the light gizmo
  114666. */
  114667. readonly material: StandardMaterial;
  114668. /**
  114669. * @hidden
  114670. * Updates the gizmo to match the attached mesh's position/rotation
  114671. */
  114672. protected _update(): void;
  114673. private static _Scale;
  114674. /**
  114675. * Creates the lines for a light mesh
  114676. */
  114677. private static _createLightLines;
  114678. /**
  114679. * Disposes of the light gizmo
  114680. */
  114681. dispose(): void;
  114682. private static _CreateHemisphericLightMesh;
  114683. private static _CreatePointLightMesh;
  114684. private static _CreateSpotLightMesh;
  114685. private static _CreateDirectionalLightMesh;
  114686. }
  114687. }
  114688. declare module BABYLON {
  114689. /** @hidden */
  114690. export var backgroundFragmentDeclaration: {
  114691. name: string;
  114692. shader: string;
  114693. };
  114694. }
  114695. declare module BABYLON {
  114696. /** @hidden */
  114697. export var backgroundUboDeclaration: {
  114698. name: string;
  114699. shader: string;
  114700. };
  114701. }
  114702. declare module BABYLON {
  114703. /** @hidden */
  114704. export var backgroundPixelShader: {
  114705. name: string;
  114706. shader: string;
  114707. };
  114708. }
  114709. declare module BABYLON {
  114710. /** @hidden */
  114711. export var backgroundVertexDeclaration: {
  114712. name: string;
  114713. shader: string;
  114714. };
  114715. }
  114716. declare module BABYLON {
  114717. /** @hidden */
  114718. export var backgroundVertexShader: {
  114719. name: string;
  114720. shader: string;
  114721. };
  114722. }
  114723. declare module BABYLON {
  114724. /**
  114725. * Background material used to create an efficient environement around your scene.
  114726. */
  114727. export class BackgroundMaterial extends PushMaterial {
  114728. /**
  114729. * Standard reflectance value at parallel view angle.
  114730. */
  114731. static StandardReflectance0: number;
  114732. /**
  114733. * Standard reflectance value at grazing angle.
  114734. */
  114735. static StandardReflectance90: number;
  114736. protected _primaryColor: Color3;
  114737. /**
  114738. * Key light Color (multiply against the environement texture)
  114739. */
  114740. primaryColor: Color3;
  114741. protected __perceptualColor: Nullable<Color3>;
  114742. /**
  114743. * Experimental Internal Use Only.
  114744. *
  114745. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114746. * This acts as a helper to set the primary color to a more "human friendly" value.
  114747. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114748. * output color as close as possible from the chosen value.
  114749. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114750. * part of lighting setup.)
  114751. */
  114752. _perceptualColor: Nullable<Color3>;
  114753. protected _primaryColorShadowLevel: float;
  114754. /**
  114755. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114756. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114757. */
  114758. primaryColorShadowLevel: float;
  114759. protected _primaryColorHighlightLevel: float;
  114760. /**
  114761. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114762. * The primary color is used at the level chosen to define what the white area would look.
  114763. */
  114764. primaryColorHighlightLevel: float;
  114765. protected _reflectionTexture: Nullable<BaseTexture>;
  114766. /**
  114767. * Reflection Texture used in the material.
  114768. * Should be author in a specific way for the best result (refer to the documentation).
  114769. */
  114770. reflectionTexture: Nullable<BaseTexture>;
  114771. protected _reflectionBlur: float;
  114772. /**
  114773. * Reflection Texture level of blur.
  114774. *
  114775. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114776. * texture twice.
  114777. */
  114778. reflectionBlur: float;
  114779. protected _diffuseTexture: Nullable<BaseTexture>;
  114780. /**
  114781. * Diffuse Texture used in the material.
  114782. * Should be author in a specific way for the best result (refer to the documentation).
  114783. */
  114784. diffuseTexture: Nullable<BaseTexture>;
  114785. protected _shadowLights: Nullable<IShadowLight[]>;
  114786. /**
  114787. * Specify the list of lights casting shadow on the material.
  114788. * All scene shadow lights will be included if null.
  114789. */
  114790. shadowLights: Nullable<IShadowLight[]>;
  114791. protected _shadowLevel: float;
  114792. /**
  114793. * Helps adjusting the shadow to a softer level if required.
  114794. * 0 means black shadows and 1 means no shadows.
  114795. */
  114796. shadowLevel: float;
  114797. protected _sceneCenter: Vector3;
  114798. /**
  114799. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114800. * It is usually zero but might be interesting to modify according to your setup.
  114801. */
  114802. sceneCenter: Vector3;
  114803. protected _opacityFresnel: boolean;
  114804. /**
  114805. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114806. * This helps ensuring a nice transition when the camera goes under the ground.
  114807. */
  114808. opacityFresnel: boolean;
  114809. protected _reflectionFresnel: boolean;
  114810. /**
  114811. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114812. * This helps adding a mirror texture on the ground.
  114813. */
  114814. reflectionFresnel: boolean;
  114815. protected _reflectionFalloffDistance: number;
  114816. /**
  114817. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114818. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114819. */
  114820. reflectionFalloffDistance: number;
  114821. protected _reflectionAmount: number;
  114822. /**
  114823. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114824. */
  114825. reflectionAmount: number;
  114826. protected _reflectionReflectance0: number;
  114827. /**
  114828. * This specifies the weight of the reflection at grazing angle.
  114829. */
  114830. reflectionReflectance0: number;
  114831. protected _reflectionReflectance90: number;
  114832. /**
  114833. * This specifies the weight of the reflection at a perpendicular point of view.
  114834. */
  114835. reflectionReflectance90: number;
  114836. /**
  114837. * Sets the reflection reflectance fresnel values according to the default standard
  114838. * empirically know to work well :-)
  114839. */
  114840. reflectionStandardFresnelWeight: number;
  114841. protected _useRGBColor: boolean;
  114842. /**
  114843. * Helps to directly use the maps channels instead of their level.
  114844. */
  114845. useRGBColor: boolean;
  114846. protected _enableNoise: boolean;
  114847. /**
  114848. * This helps reducing the banding effect that could occur on the background.
  114849. */
  114850. enableNoise: boolean;
  114851. /**
  114852. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114853. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114854. * Recommended to be keep at 1.0 except for special cases.
  114855. */
  114856. fovMultiplier: number;
  114857. private _fovMultiplier;
  114858. /**
  114859. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114860. */
  114861. useEquirectangularFOV: boolean;
  114862. private _maxSimultaneousLights;
  114863. /**
  114864. * Number of Simultaneous lights allowed on the material.
  114865. */
  114866. maxSimultaneousLights: int;
  114867. /**
  114868. * Default configuration related to image processing available in the Background Material.
  114869. */
  114870. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114871. /**
  114872. * Keep track of the image processing observer to allow dispose and replace.
  114873. */
  114874. private _imageProcessingObserver;
  114875. /**
  114876. * Attaches a new image processing configuration to the PBR Material.
  114877. * @param configuration (if null the scene configuration will be use)
  114878. */
  114879. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114880. /**
  114881. * Gets the image processing configuration used either in this material.
  114882. */
  114883. /**
  114884. * Sets the Default image processing configuration used either in the this material.
  114885. *
  114886. * If sets to null, the scene one is in use.
  114887. */
  114888. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114889. /**
  114890. * Gets wether the color curves effect is enabled.
  114891. */
  114892. /**
  114893. * Sets wether the color curves effect is enabled.
  114894. */
  114895. cameraColorCurvesEnabled: boolean;
  114896. /**
  114897. * Gets wether the color grading effect is enabled.
  114898. */
  114899. /**
  114900. * Gets wether the color grading effect is enabled.
  114901. */
  114902. cameraColorGradingEnabled: boolean;
  114903. /**
  114904. * Gets wether tonemapping is enabled or not.
  114905. */
  114906. /**
  114907. * Sets wether tonemapping is enabled or not
  114908. */
  114909. cameraToneMappingEnabled: boolean;
  114910. /**
  114911. * The camera exposure used on this material.
  114912. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114913. * This corresponds to a photographic exposure.
  114914. */
  114915. /**
  114916. * The camera exposure used on this material.
  114917. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114918. * This corresponds to a photographic exposure.
  114919. */
  114920. cameraExposure: float;
  114921. /**
  114922. * Gets The camera contrast used on this material.
  114923. */
  114924. /**
  114925. * Sets The camera contrast used on this material.
  114926. */
  114927. cameraContrast: float;
  114928. /**
  114929. * Gets the Color Grading 2D Lookup Texture.
  114930. */
  114931. /**
  114932. * Sets the Color Grading 2D Lookup Texture.
  114933. */
  114934. cameraColorGradingTexture: Nullable<BaseTexture>;
  114935. /**
  114936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114938. * 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;
  114939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114940. */
  114941. /**
  114942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114944. * 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;
  114945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114946. */
  114947. cameraColorCurves: Nullable<ColorCurves>;
  114948. /**
  114949. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114950. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114951. */
  114952. switchToBGR: boolean;
  114953. private _renderTargets;
  114954. private _reflectionControls;
  114955. private _white;
  114956. private _primaryShadowColor;
  114957. private _primaryHighlightColor;
  114958. /**
  114959. * Instantiates a Background Material in the given scene
  114960. * @param name The friendly name of the material
  114961. * @param scene The scene to add the material to
  114962. */
  114963. constructor(name: string, scene: Scene);
  114964. /**
  114965. * Gets a boolean indicating that current material needs to register RTT
  114966. */
  114967. readonly hasRenderTargetTextures: boolean;
  114968. /**
  114969. * The entire material has been created in order to prevent overdraw.
  114970. * @returns false
  114971. */
  114972. needAlphaTesting(): boolean;
  114973. /**
  114974. * The entire material has been created in order to prevent overdraw.
  114975. * @returns true if blending is enable
  114976. */
  114977. needAlphaBlending(): boolean;
  114978. /**
  114979. * Checks wether the material is ready to be rendered for a given mesh.
  114980. * @param mesh The mesh to render
  114981. * @param subMesh The submesh to check against
  114982. * @param useInstances Specify wether or not the material is used with instances
  114983. * @returns true if all the dependencies are ready (Textures, Effects...)
  114984. */
  114985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114986. /**
  114987. * Compute the primary color according to the chosen perceptual color.
  114988. */
  114989. private _computePrimaryColorFromPerceptualColor;
  114990. /**
  114991. * Compute the highlights and shadow colors according to their chosen levels.
  114992. */
  114993. private _computePrimaryColors;
  114994. /**
  114995. * Build the uniform buffer used in the material.
  114996. */
  114997. buildUniformLayout(): void;
  114998. /**
  114999. * Unbind the material.
  115000. */
  115001. unbind(): void;
  115002. /**
  115003. * Bind only the world matrix to the material.
  115004. * @param world The world matrix to bind.
  115005. */
  115006. bindOnlyWorldMatrix(world: Matrix): void;
  115007. /**
  115008. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115009. * @param world The world matrix to bind.
  115010. * @param subMesh The submesh to bind for.
  115011. */
  115012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115013. /**
  115014. * Checks to see if a texture is used in the material.
  115015. * @param texture - Base texture to use.
  115016. * @returns - Boolean specifying if a texture is used in the material.
  115017. */
  115018. hasTexture(texture: BaseTexture): boolean;
  115019. /**
  115020. * Dispose the material.
  115021. * @param forceDisposeEffect Force disposal of the associated effect.
  115022. * @param forceDisposeTextures Force disposal of the associated textures.
  115023. */
  115024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115025. /**
  115026. * Clones the material.
  115027. * @param name The cloned name.
  115028. * @returns The cloned material.
  115029. */
  115030. clone(name: string): BackgroundMaterial;
  115031. /**
  115032. * Serializes the current material to its JSON representation.
  115033. * @returns The JSON representation.
  115034. */
  115035. serialize(): any;
  115036. /**
  115037. * Gets the class name of the material
  115038. * @returns "BackgroundMaterial"
  115039. */
  115040. getClassName(): string;
  115041. /**
  115042. * Parse a JSON input to create back a background material.
  115043. * @param source The JSON data to parse
  115044. * @param scene The scene to create the parsed material in
  115045. * @param rootUrl The root url of the assets the material depends upon
  115046. * @returns the instantiated BackgroundMaterial.
  115047. */
  115048. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115049. }
  115050. }
  115051. declare module BABYLON {
  115052. /**
  115053. * Represents the different options available during the creation of
  115054. * a Environment helper.
  115055. *
  115056. * This can control the default ground, skybox and image processing setup of your scene.
  115057. */
  115058. export interface IEnvironmentHelperOptions {
  115059. /**
  115060. * Specifies wether or not to create a ground.
  115061. * True by default.
  115062. */
  115063. createGround: boolean;
  115064. /**
  115065. * Specifies the ground size.
  115066. * 15 by default.
  115067. */
  115068. groundSize: number;
  115069. /**
  115070. * The texture used on the ground for the main color.
  115071. * Comes from the BabylonJS CDN by default.
  115072. *
  115073. * Remarks: Can be either a texture or a url.
  115074. */
  115075. groundTexture: string | BaseTexture;
  115076. /**
  115077. * The color mixed in the ground texture by default.
  115078. * BabylonJS clearColor by default.
  115079. */
  115080. groundColor: Color3;
  115081. /**
  115082. * Specifies the ground opacity.
  115083. * 1 by default.
  115084. */
  115085. groundOpacity: number;
  115086. /**
  115087. * Enables the ground to receive shadows.
  115088. * True by default.
  115089. */
  115090. enableGroundShadow: boolean;
  115091. /**
  115092. * Helps preventing the shadow to be fully black on the ground.
  115093. * 0.5 by default.
  115094. */
  115095. groundShadowLevel: number;
  115096. /**
  115097. * Creates a mirror texture attach to the ground.
  115098. * false by default.
  115099. */
  115100. enableGroundMirror: boolean;
  115101. /**
  115102. * Specifies the ground mirror size ratio.
  115103. * 0.3 by default as the default kernel is 64.
  115104. */
  115105. groundMirrorSizeRatio: number;
  115106. /**
  115107. * Specifies the ground mirror blur kernel size.
  115108. * 64 by default.
  115109. */
  115110. groundMirrorBlurKernel: number;
  115111. /**
  115112. * Specifies the ground mirror visibility amount.
  115113. * 1 by default
  115114. */
  115115. groundMirrorAmount: number;
  115116. /**
  115117. * Specifies the ground mirror reflectance weight.
  115118. * This uses the standard weight of the background material to setup the fresnel effect
  115119. * of the mirror.
  115120. * 1 by default.
  115121. */
  115122. groundMirrorFresnelWeight: number;
  115123. /**
  115124. * Specifies the ground mirror Falloff distance.
  115125. * This can helps reducing the size of the reflection.
  115126. * 0 by Default.
  115127. */
  115128. groundMirrorFallOffDistance: number;
  115129. /**
  115130. * Specifies the ground mirror texture type.
  115131. * Unsigned Int by Default.
  115132. */
  115133. groundMirrorTextureType: number;
  115134. /**
  115135. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115136. * the shown objects.
  115137. */
  115138. groundYBias: number;
  115139. /**
  115140. * Specifies wether or not to create a skybox.
  115141. * True by default.
  115142. */
  115143. createSkybox: boolean;
  115144. /**
  115145. * Specifies the skybox size.
  115146. * 20 by default.
  115147. */
  115148. skyboxSize: number;
  115149. /**
  115150. * The texture used on the skybox for the main color.
  115151. * Comes from the BabylonJS CDN by default.
  115152. *
  115153. * Remarks: Can be either a texture or a url.
  115154. */
  115155. skyboxTexture: string | BaseTexture;
  115156. /**
  115157. * The color mixed in the skybox texture by default.
  115158. * BabylonJS clearColor by default.
  115159. */
  115160. skyboxColor: Color3;
  115161. /**
  115162. * The background rotation around the Y axis of the scene.
  115163. * This helps aligning the key lights of your scene with the background.
  115164. * 0 by default.
  115165. */
  115166. backgroundYRotation: number;
  115167. /**
  115168. * Compute automatically the size of the elements to best fit with the scene.
  115169. */
  115170. sizeAuto: boolean;
  115171. /**
  115172. * Default position of the rootMesh if autoSize is not true.
  115173. */
  115174. rootPosition: Vector3;
  115175. /**
  115176. * Sets up the image processing in the scene.
  115177. * true by default.
  115178. */
  115179. setupImageProcessing: boolean;
  115180. /**
  115181. * The texture used as your environment texture in the scene.
  115182. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115183. *
  115184. * Remarks: Can be either a texture or a url.
  115185. */
  115186. environmentTexture: string | BaseTexture;
  115187. /**
  115188. * The value of the exposure to apply to the scene.
  115189. * 0.6 by default if setupImageProcessing is true.
  115190. */
  115191. cameraExposure: number;
  115192. /**
  115193. * The value of the contrast to apply to the scene.
  115194. * 1.6 by default if setupImageProcessing is true.
  115195. */
  115196. cameraContrast: number;
  115197. /**
  115198. * Specifies wether or not tonemapping should be enabled in the scene.
  115199. * true by default if setupImageProcessing is true.
  115200. */
  115201. toneMappingEnabled: boolean;
  115202. }
  115203. /**
  115204. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115205. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115206. * It also helps with the default setup of your imageProcessing configuration.
  115207. */
  115208. export class EnvironmentHelper {
  115209. /**
  115210. * Default ground texture URL.
  115211. */
  115212. private static _groundTextureCDNUrl;
  115213. /**
  115214. * Default skybox texture URL.
  115215. */
  115216. private static _skyboxTextureCDNUrl;
  115217. /**
  115218. * Default environment texture URL.
  115219. */
  115220. private static _environmentTextureCDNUrl;
  115221. /**
  115222. * Creates the default options for the helper.
  115223. */
  115224. private static _getDefaultOptions;
  115225. private _rootMesh;
  115226. /**
  115227. * Gets the root mesh created by the helper.
  115228. */
  115229. readonly rootMesh: Mesh;
  115230. private _skybox;
  115231. /**
  115232. * Gets the skybox created by the helper.
  115233. */
  115234. readonly skybox: Nullable<Mesh>;
  115235. private _skyboxTexture;
  115236. /**
  115237. * Gets the skybox texture created by the helper.
  115238. */
  115239. readonly skyboxTexture: Nullable<BaseTexture>;
  115240. private _skyboxMaterial;
  115241. /**
  115242. * Gets the skybox material created by the helper.
  115243. */
  115244. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115245. private _ground;
  115246. /**
  115247. * Gets the ground mesh created by the helper.
  115248. */
  115249. readonly ground: Nullable<Mesh>;
  115250. private _groundTexture;
  115251. /**
  115252. * Gets the ground texture created by the helper.
  115253. */
  115254. readonly groundTexture: Nullable<BaseTexture>;
  115255. private _groundMirror;
  115256. /**
  115257. * Gets the ground mirror created by the helper.
  115258. */
  115259. readonly groundMirror: Nullable<MirrorTexture>;
  115260. /**
  115261. * Gets the ground mirror render list to helps pushing the meshes
  115262. * you wish in the ground reflection.
  115263. */
  115264. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115265. private _groundMaterial;
  115266. /**
  115267. * Gets the ground material created by the helper.
  115268. */
  115269. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115270. /**
  115271. * Stores the creation options.
  115272. */
  115273. private readonly _scene;
  115274. private _options;
  115275. /**
  115276. * This observable will be notified with any error during the creation of the environment,
  115277. * mainly texture creation errors.
  115278. */
  115279. onErrorObservable: Observable<{
  115280. message?: string;
  115281. exception?: any;
  115282. }>;
  115283. /**
  115284. * constructor
  115285. * @param options Defines the options we want to customize the helper
  115286. * @param scene The scene to add the material to
  115287. */
  115288. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115289. /**
  115290. * Updates the background according to the new options
  115291. * @param options
  115292. */
  115293. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115294. /**
  115295. * Sets the primary color of all the available elements.
  115296. * @param color the main color to affect to the ground and the background
  115297. */
  115298. setMainColor(color: Color3): void;
  115299. /**
  115300. * Setup the image processing according to the specified options.
  115301. */
  115302. private _setupImageProcessing;
  115303. /**
  115304. * Setup the environment texture according to the specified options.
  115305. */
  115306. private _setupEnvironmentTexture;
  115307. /**
  115308. * Setup the background according to the specified options.
  115309. */
  115310. private _setupBackground;
  115311. /**
  115312. * Get the scene sizes according to the setup.
  115313. */
  115314. private _getSceneSize;
  115315. /**
  115316. * Setup the ground according to the specified options.
  115317. */
  115318. private _setupGround;
  115319. /**
  115320. * Setup the ground material according to the specified options.
  115321. */
  115322. private _setupGroundMaterial;
  115323. /**
  115324. * Setup the ground diffuse texture according to the specified options.
  115325. */
  115326. private _setupGroundDiffuseTexture;
  115327. /**
  115328. * Setup the ground mirror texture according to the specified options.
  115329. */
  115330. private _setupGroundMirrorTexture;
  115331. /**
  115332. * Setup the ground to receive the mirror texture.
  115333. */
  115334. private _setupMirrorInGroundMaterial;
  115335. /**
  115336. * Setup the skybox according to the specified options.
  115337. */
  115338. private _setupSkybox;
  115339. /**
  115340. * Setup the skybox material according to the specified options.
  115341. */
  115342. private _setupSkyboxMaterial;
  115343. /**
  115344. * Setup the skybox reflection texture according to the specified options.
  115345. */
  115346. private _setupSkyboxReflectionTexture;
  115347. private _errorHandler;
  115348. /**
  115349. * Dispose all the elements created by the Helper.
  115350. */
  115351. dispose(): void;
  115352. }
  115353. }
  115354. declare module BABYLON {
  115355. /**
  115356. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115357. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115358. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115359. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115360. */
  115361. export class PhotoDome extends TransformNode {
  115362. /**
  115363. * Define the image as a Monoscopic panoramic 360 image.
  115364. */
  115365. static readonly MODE_MONOSCOPIC: number;
  115366. /**
  115367. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115368. */
  115369. static readonly MODE_TOPBOTTOM: number;
  115370. /**
  115371. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115372. */
  115373. static readonly MODE_SIDEBYSIDE: number;
  115374. private _useDirectMapping;
  115375. /**
  115376. * The texture being displayed on the sphere
  115377. */
  115378. protected _photoTexture: Texture;
  115379. /**
  115380. * Gets or sets the texture being displayed on the sphere
  115381. */
  115382. photoTexture: Texture;
  115383. /**
  115384. * Observable raised when an error occured while loading the 360 image
  115385. */
  115386. onLoadErrorObservable: Observable<string>;
  115387. /**
  115388. * The skybox material
  115389. */
  115390. protected _material: BackgroundMaterial;
  115391. /**
  115392. * The surface used for the skybox
  115393. */
  115394. protected _mesh: Mesh;
  115395. /**
  115396. * Gets the mesh used for the skybox.
  115397. */
  115398. readonly mesh: Mesh;
  115399. /**
  115400. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115401. * Also see the options.resolution property.
  115402. */
  115403. fovMultiplier: number;
  115404. private _imageMode;
  115405. /**
  115406. * Gets or set the current video mode for the video. It can be:
  115407. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115408. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115409. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115410. */
  115411. imageMode: number;
  115412. /**
  115413. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115414. * @param name Element's name, child elements will append suffixes for their own names.
  115415. * @param urlsOfPhoto defines the url of the photo to display
  115416. * @param options defines an object containing optional or exposed sub element properties
  115417. * @param onError defines a callback called when an error occured while loading the texture
  115418. */
  115419. constructor(name: string, urlOfPhoto: string, options: {
  115420. resolution?: number;
  115421. size?: number;
  115422. useDirectMapping?: boolean;
  115423. faceForward?: boolean;
  115424. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115425. private _onBeforeCameraRenderObserver;
  115426. private _changeImageMode;
  115427. /**
  115428. * Releases resources associated with this node.
  115429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115431. */
  115432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115433. }
  115434. }
  115435. declare module BABYLON {
  115436. /**
  115437. * Class used to host RGBD texture specific utilities
  115438. */
  115439. export class RGBDTextureTools {
  115440. /**
  115441. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115442. * @param texture the texture to expand.
  115443. */
  115444. static ExpandRGBDTexture(texture: Texture): void;
  115445. }
  115446. }
  115447. declare module BABYLON {
  115448. /**
  115449. * Class used to host texture specific utilities
  115450. */
  115451. export class BRDFTextureTools {
  115452. /**
  115453. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115454. * @param scene defines the hosting scene
  115455. * @returns the environment BRDF texture
  115456. */
  115457. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115458. private static _environmentBRDFBase64Texture;
  115459. }
  115460. }
  115461. declare module BABYLON {
  115462. /**
  115463. * @hidden
  115464. */
  115465. export interface IMaterialClearCoatDefines {
  115466. CLEARCOAT: boolean;
  115467. CLEARCOAT_DEFAULTIOR: boolean;
  115468. CLEARCOAT_TEXTURE: boolean;
  115469. CLEARCOAT_TEXTUREDIRECTUV: number;
  115470. CLEARCOAT_BUMP: boolean;
  115471. CLEARCOAT_BUMPDIRECTUV: number;
  115472. CLEARCOAT_TINT: boolean;
  115473. CLEARCOAT_TINT_TEXTURE: boolean;
  115474. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115475. /** @hidden */
  115476. _areTexturesDirty: boolean;
  115477. }
  115478. /**
  115479. * Define the code related to the clear coat parameters of the pbr material.
  115480. */
  115481. export class PBRClearCoatConfiguration {
  115482. /**
  115483. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115484. * The default fits with a polyurethane material.
  115485. */
  115486. private static readonly _DefaultIndexOfRefraction;
  115487. private _isEnabled;
  115488. /**
  115489. * Defines if the clear coat is enabled in the material.
  115490. */
  115491. isEnabled: boolean;
  115492. /**
  115493. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115494. */
  115495. intensity: number;
  115496. /**
  115497. * Defines the clear coat layer roughness.
  115498. */
  115499. roughness: number;
  115500. private _indexOfRefraction;
  115501. /**
  115502. * Defines the index of refraction of the clear coat.
  115503. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115504. * The default fits with a polyurethane material.
  115505. * Changing the default value is more performance intensive.
  115506. */
  115507. indexOfRefraction: number;
  115508. private _texture;
  115509. /**
  115510. * Stores the clear coat values in a texture.
  115511. */
  115512. texture: Nullable<BaseTexture>;
  115513. private _bumpTexture;
  115514. /**
  115515. * Define the clear coat specific bump texture.
  115516. */
  115517. bumpTexture: Nullable<BaseTexture>;
  115518. private _isTintEnabled;
  115519. /**
  115520. * Defines if the clear coat tint is enabled in the material.
  115521. */
  115522. isTintEnabled: boolean;
  115523. /**
  115524. * Defines the clear coat tint of the material.
  115525. * This is only use if tint is enabled
  115526. */
  115527. tintColor: Color3;
  115528. /**
  115529. * Defines the distance at which the tint color should be found in the
  115530. * clear coat media.
  115531. * This is only use if tint is enabled
  115532. */
  115533. tintColorAtDistance: number;
  115534. /**
  115535. * Defines the clear coat layer thickness.
  115536. * This is only use if tint is enabled
  115537. */
  115538. tintThickness: number;
  115539. private _tintTexture;
  115540. /**
  115541. * Stores the clear tint values in a texture.
  115542. * rgb is tint
  115543. * a is a thickness factor
  115544. */
  115545. tintTexture: Nullable<BaseTexture>;
  115546. /** @hidden */
  115547. private _internalMarkAllSubMeshesAsTexturesDirty;
  115548. /** @hidden */
  115549. _markAllSubMeshesAsTexturesDirty(): void;
  115550. /**
  115551. * Instantiate a new istance of clear coat configuration.
  115552. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115553. */
  115554. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115555. /**
  115556. * Gets wehter the submesh is ready to be used or not.
  115557. * @param defines the list of "defines" to update.
  115558. * @param scene defines the scene the material belongs to.
  115559. * @param engine defines the engine the material belongs to.
  115560. * @param disableBumpMap defines wether the material disables bump or not.
  115561. * @returns - boolean indicating that the submesh is ready or not.
  115562. */
  115563. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115564. /**
  115565. * Checks to see if a texture is used in the material.
  115566. * @param defines the list of "defines" to update.
  115567. * @param scene defines the scene to the material belongs to.
  115568. */
  115569. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115570. /**
  115571. * Binds the material data.
  115572. * @param uniformBuffer defines the Uniform buffer to fill in.
  115573. * @param scene defines the scene the material belongs to.
  115574. * @param engine defines the engine the material belongs to.
  115575. * @param disableBumpMap defines wether the material disables bump or not.
  115576. * @param isFrozen defines wether the material is frozen or not.
  115577. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115578. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115579. */
  115580. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115581. /**
  115582. * Checks to see if a texture is used in the material.
  115583. * @param texture - Base texture to use.
  115584. * @returns - Boolean specifying if a texture is used in the material.
  115585. */
  115586. hasTexture(texture: BaseTexture): boolean;
  115587. /**
  115588. * Returns an array of the actively used textures.
  115589. * @param activeTextures Array of BaseTextures
  115590. */
  115591. getActiveTextures(activeTextures: BaseTexture[]): void;
  115592. /**
  115593. * Returns the animatable textures.
  115594. * @param animatables Array of animatable textures.
  115595. */
  115596. getAnimatables(animatables: IAnimatable[]): void;
  115597. /**
  115598. * Disposes the resources of the material.
  115599. * @param forceDisposeTextures - Forces the disposal of all textures.
  115600. */
  115601. dispose(forceDisposeTextures?: boolean): void;
  115602. /**
  115603. * Get the current class name of the texture useful for serialization or dynamic coding.
  115604. * @returns "PBRClearCoatConfiguration"
  115605. */
  115606. getClassName(): string;
  115607. /**
  115608. * Add fallbacks to the effect fallbacks list.
  115609. * @param defines defines the Base texture to use.
  115610. * @param fallbacks defines the current fallback list.
  115611. * @param currentRank defines the current fallback rank.
  115612. * @returns the new fallback rank.
  115613. */
  115614. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115615. /**
  115616. * Add the required uniforms to the current list.
  115617. * @param uniforms defines the current uniform list.
  115618. */
  115619. static AddUniforms(uniforms: string[]): void;
  115620. /**
  115621. * Add the required samplers to the current list.
  115622. * @param samplers defines the current sampler list.
  115623. */
  115624. static AddSamplers(samplers: string[]): void;
  115625. /**
  115626. * Add the required uniforms to the current buffer.
  115627. * @param uniformBuffer defines the current uniform buffer.
  115628. */
  115629. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115630. /**
  115631. * Makes a duplicate of the current configuration into another one.
  115632. * @param clearCoatConfiguration define the config where to copy the info
  115633. */
  115634. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115635. /**
  115636. * Serializes this clear coat configuration.
  115637. * @returns - An object with the serialized config.
  115638. */
  115639. serialize(): any;
  115640. /**
  115641. * Parses a anisotropy Configuration from a serialized object.
  115642. * @param source - Serialized object.
  115643. * @param scene Defines the scene we are parsing for
  115644. * @param rootUrl Defines the rootUrl to load from
  115645. */
  115646. parse(source: any, scene: Scene, rootUrl: string): void;
  115647. }
  115648. }
  115649. declare module BABYLON {
  115650. /**
  115651. * @hidden
  115652. */
  115653. export interface IMaterialAnisotropicDefines {
  115654. ANISOTROPIC: boolean;
  115655. ANISOTROPIC_TEXTURE: boolean;
  115656. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115657. MAINUV1: boolean;
  115658. _areTexturesDirty: boolean;
  115659. _needUVs: boolean;
  115660. }
  115661. /**
  115662. * Define the code related to the anisotropic parameters of the pbr material.
  115663. */
  115664. export class PBRAnisotropicConfiguration {
  115665. private _isEnabled;
  115666. /**
  115667. * Defines if the anisotropy is enabled in the material.
  115668. */
  115669. isEnabled: boolean;
  115670. /**
  115671. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115672. */
  115673. intensity: number;
  115674. /**
  115675. * Defines if the effect is along the tangents, bitangents or in between.
  115676. * By default, the effect is "strectching" the highlights along the tangents.
  115677. */
  115678. direction: Vector2;
  115679. private _texture;
  115680. /**
  115681. * Stores the anisotropy values in a texture.
  115682. * rg is direction (like normal from -1 to 1)
  115683. * b is a intensity
  115684. */
  115685. texture: Nullable<BaseTexture>;
  115686. /** @hidden */
  115687. private _internalMarkAllSubMeshesAsTexturesDirty;
  115688. /** @hidden */
  115689. _markAllSubMeshesAsTexturesDirty(): void;
  115690. /**
  115691. * Instantiate a new istance of anisotropy configuration.
  115692. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115693. */
  115694. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115695. /**
  115696. * Specifies that the submesh is ready to be used.
  115697. * @param defines the list of "defines" to update.
  115698. * @param scene defines the scene the material belongs to.
  115699. * @returns - boolean indicating that the submesh is ready or not.
  115700. */
  115701. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115702. /**
  115703. * Checks to see if a texture is used in the material.
  115704. * @param defines the list of "defines" to update.
  115705. * @param mesh the mesh we are preparing the defines for.
  115706. * @param scene defines the scene the material belongs to.
  115707. */
  115708. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115709. /**
  115710. * Binds the material data.
  115711. * @param uniformBuffer defines the Uniform buffer to fill in.
  115712. * @param scene defines the scene the material belongs to.
  115713. * @param isFrozen defines wether the material is frozen or not.
  115714. */
  115715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115716. /**
  115717. * Checks to see if a texture is used in the material.
  115718. * @param texture - Base texture to use.
  115719. * @returns - Boolean specifying if a texture is used in the material.
  115720. */
  115721. hasTexture(texture: BaseTexture): boolean;
  115722. /**
  115723. * Returns an array of the actively used textures.
  115724. * @param activeTextures Array of BaseTextures
  115725. */
  115726. getActiveTextures(activeTextures: BaseTexture[]): void;
  115727. /**
  115728. * Returns the animatable textures.
  115729. * @param animatables Array of animatable textures.
  115730. */
  115731. getAnimatables(animatables: IAnimatable[]): void;
  115732. /**
  115733. * Disposes the resources of the material.
  115734. * @param forceDisposeTextures - Forces the disposal of all textures.
  115735. */
  115736. dispose(forceDisposeTextures?: boolean): void;
  115737. /**
  115738. * Get the current class name of the texture useful for serialization or dynamic coding.
  115739. * @returns "PBRAnisotropicConfiguration"
  115740. */
  115741. getClassName(): string;
  115742. /**
  115743. * Add fallbacks to the effect fallbacks list.
  115744. * @param defines defines the Base texture to use.
  115745. * @param fallbacks defines the current fallback list.
  115746. * @param currentRank defines the current fallback rank.
  115747. * @returns the new fallback rank.
  115748. */
  115749. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115750. /**
  115751. * Add the required uniforms to the current list.
  115752. * @param uniforms defines the current uniform list.
  115753. */
  115754. static AddUniforms(uniforms: string[]): void;
  115755. /**
  115756. * Add the required uniforms to the current buffer.
  115757. * @param uniformBuffer defines the current uniform buffer.
  115758. */
  115759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115760. /**
  115761. * Add the required samplers to the current list.
  115762. * @param samplers defines the current sampler list.
  115763. */
  115764. static AddSamplers(samplers: string[]): void;
  115765. /**
  115766. * Makes a duplicate of the current configuration into another one.
  115767. * @param anisotropicConfiguration define the config where to copy the info
  115768. */
  115769. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115770. /**
  115771. * Serializes this anisotropy configuration.
  115772. * @returns - An object with the serialized config.
  115773. */
  115774. serialize(): any;
  115775. /**
  115776. * Parses a anisotropy Configuration from a serialized object.
  115777. * @param source - Serialized object.
  115778. * @param scene Defines the scene we are parsing for
  115779. * @param rootUrl Defines the rootUrl to load from
  115780. */
  115781. parse(source: any, scene: Scene, rootUrl: string): void;
  115782. }
  115783. }
  115784. declare module BABYLON {
  115785. /**
  115786. * @hidden
  115787. */
  115788. export interface IMaterialBRDFDefines {
  115789. BRDF_V_HEIGHT_CORRELATED: boolean;
  115790. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115791. SPHERICAL_HARMONICS: boolean;
  115792. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115793. /** @hidden */
  115794. _areMiscDirty: boolean;
  115795. }
  115796. /**
  115797. * Define the code related to the BRDF parameters of the pbr material.
  115798. */
  115799. export class PBRBRDFConfiguration {
  115800. /**
  115801. * Default value used for the energy conservation.
  115802. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115803. */
  115804. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115805. /**
  115806. * Default value used for the Smith Visibility Height Correlated mode.
  115807. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115808. */
  115809. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115810. /**
  115811. * Default value used for the IBL diffuse part.
  115812. * This can help switching back to the polynomials mode globally which is a tiny bit
  115813. * less GPU intensive at the drawback of a lower quality.
  115814. */
  115815. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115816. /**
  115817. * Default value used for activating energy conservation for the specular workflow.
  115818. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115819. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115820. */
  115821. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115822. private _useEnergyConservation;
  115823. /**
  115824. * Defines if the material uses energy conservation.
  115825. */
  115826. useEnergyConservation: boolean;
  115827. private _useSmithVisibilityHeightCorrelated;
  115828. /**
  115829. * LEGACY Mode set to false
  115830. * Defines if the material uses height smith correlated visibility term.
  115831. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115832. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115833. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115834. * Not relying on height correlated will also disable energy conservation.
  115835. */
  115836. useSmithVisibilityHeightCorrelated: boolean;
  115837. private _useSphericalHarmonics;
  115838. /**
  115839. * LEGACY Mode set to false
  115840. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115841. * diffuse part of the IBL.
  115842. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115843. * to the ground truth.
  115844. */
  115845. useSphericalHarmonics: boolean;
  115846. private _useSpecularGlossinessInputEnergyConservation;
  115847. /**
  115848. * Defines if the material uses energy conservation, when the specular workflow is active.
  115849. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115850. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115851. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115852. */
  115853. useSpecularGlossinessInputEnergyConservation: boolean;
  115854. /** @hidden */
  115855. private _internalMarkAllSubMeshesAsMiscDirty;
  115856. /** @hidden */
  115857. _markAllSubMeshesAsMiscDirty(): void;
  115858. /**
  115859. * Instantiate a new istance of clear coat configuration.
  115860. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115861. */
  115862. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115863. /**
  115864. * Checks to see if a texture is used in the material.
  115865. * @param defines the list of "defines" to update.
  115866. */
  115867. prepareDefines(defines: IMaterialBRDFDefines): void;
  115868. /**
  115869. * Get the current class name of the texture useful for serialization or dynamic coding.
  115870. * @returns "PBRClearCoatConfiguration"
  115871. */
  115872. getClassName(): string;
  115873. /**
  115874. * Makes a duplicate of the current configuration into another one.
  115875. * @param brdfConfiguration define the config where to copy the info
  115876. */
  115877. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115878. /**
  115879. * Serializes this BRDF configuration.
  115880. * @returns - An object with the serialized config.
  115881. */
  115882. serialize(): any;
  115883. /**
  115884. * Parses a anisotropy Configuration from a serialized object.
  115885. * @param source - Serialized object.
  115886. * @param scene Defines the scene we are parsing for
  115887. * @param rootUrl Defines the rootUrl to load from
  115888. */
  115889. parse(source: any, scene: Scene, rootUrl: string): void;
  115890. }
  115891. }
  115892. declare module BABYLON {
  115893. /**
  115894. * @hidden
  115895. */
  115896. export interface IMaterialSheenDefines {
  115897. SHEEN: boolean;
  115898. SHEEN_TEXTURE: boolean;
  115899. SHEEN_TEXTUREDIRECTUV: number;
  115900. SHEEN_LINKWITHALBEDO: boolean;
  115901. /** @hidden */
  115902. _areTexturesDirty: boolean;
  115903. }
  115904. /**
  115905. * Define the code related to the Sheen parameters of the pbr material.
  115906. */
  115907. export class PBRSheenConfiguration {
  115908. private _isEnabled;
  115909. /**
  115910. * Defines if the material uses sheen.
  115911. */
  115912. isEnabled: boolean;
  115913. private _linkSheenWithAlbedo;
  115914. /**
  115915. * Defines if the sheen is linked to the sheen color.
  115916. */
  115917. linkSheenWithAlbedo: boolean;
  115918. /**
  115919. * Defines the sheen intensity.
  115920. */
  115921. intensity: number;
  115922. /**
  115923. * Defines the sheen color.
  115924. */
  115925. color: Color3;
  115926. private _texture;
  115927. /**
  115928. * Stores the sheen tint values in a texture.
  115929. * rgb is tint
  115930. * a is a intensity
  115931. */
  115932. texture: Nullable<BaseTexture>;
  115933. /** @hidden */
  115934. private _internalMarkAllSubMeshesAsTexturesDirty;
  115935. /** @hidden */
  115936. _markAllSubMeshesAsTexturesDirty(): void;
  115937. /**
  115938. * Instantiate a new istance of clear coat configuration.
  115939. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115940. */
  115941. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115942. /**
  115943. * Specifies that the submesh is ready to be used.
  115944. * @param defines the list of "defines" to update.
  115945. * @param scene defines the scene the material belongs to.
  115946. * @returns - boolean indicating that the submesh is ready or not.
  115947. */
  115948. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115949. /**
  115950. * Checks to see if a texture is used in the material.
  115951. * @param defines the list of "defines" to update.
  115952. * @param scene defines the scene the material belongs to.
  115953. */
  115954. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115955. /**
  115956. * Binds the material data.
  115957. * @param uniformBuffer defines the Uniform buffer to fill in.
  115958. * @param scene defines the scene the material belongs to.
  115959. * @param isFrozen defines wether the material is frozen or not.
  115960. */
  115961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115962. /**
  115963. * Checks to see if a texture is used in the material.
  115964. * @param texture - Base texture to use.
  115965. * @returns - Boolean specifying if a texture is used in the material.
  115966. */
  115967. hasTexture(texture: BaseTexture): boolean;
  115968. /**
  115969. * Returns an array of the actively used textures.
  115970. * @param activeTextures Array of BaseTextures
  115971. */
  115972. getActiveTextures(activeTextures: BaseTexture[]): void;
  115973. /**
  115974. * Returns the animatable textures.
  115975. * @param animatables Array of animatable textures.
  115976. */
  115977. getAnimatables(animatables: IAnimatable[]): void;
  115978. /**
  115979. * Disposes the resources of the material.
  115980. * @param forceDisposeTextures - Forces the disposal of all textures.
  115981. */
  115982. dispose(forceDisposeTextures?: boolean): void;
  115983. /**
  115984. * Get the current class name of the texture useful for serialization or dynamic coding.
  115985. * @returns "PBRSheenConfiguration"
  115986. */
  115987. getClassName(): string;
  115988. /**
  115989. * Add fallbacks to the effect fallbacks list.
  115990. * @param defines defines the Base texture to use.
  115991. * @param fallbacks defines the current fallback list.
  115992. * @param currentRank defines the current fallback rank.
  115993. * @returns the new fallback rank.
  115994. */
  115995. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115996. /**
  115997. * Add the required uniforms to the current list.
  115998. * @param uniforms defines the current uniform list.
  115999. */
  116000. static AddUniforms(uniforms: string[]): void;
  116001. /**
  116002. * Add the required uniforms to the current buffer.
  116003. * @param uniformBuffer defines the current uniform buffer.
  116004. */
  116005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116006. /**
  116007. * Add the required samplers to the current list.
  116008. * @param samplers defines the current sampler list.
  116009. */
  116010. static AddSamplers(samplers: string[]): void;
  116011. /**
  116012. * Makes a duplicate of the current configuration into another one.
  116013. * @param sheenConfiguration define the config where to copy the info
  116014. */
  116015. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116016. /**
  116017. * Serializes this BRDF configuration.
  116018. * @returns - An object with the serialized config.
  116019. */
  116020. serialize(): any;
  116021. /**
  116022. * Parses a anisotropy Configuration from a serialized object.
  116023. * @param source - Serialized object.
  116024. * @param scene Defines the scene we are parsing for
  116025. * @param rootUrl Defines the rootUrl to load from
  116026. */
  116027. parse(source: any, scene: Scene, rootUrl: string): void;
  116028. }
  116029. }
  116030. declare module BABYLON {
  116031. /**
  116032. * @hidden
  116033. */
  116034. export interface IMaterialSubSurfaceDefines {
  116035. SUBSURFACE: boolean;
  116036. SS_REFRACTION: boolean;
  116037. SS_TRANSLUCENCY: boolean;
  116038. SS_SCATERRING: boolean;
  116039. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116040. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116041. SS_REFRACTIONMAP_3D: boolean;
  116042. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116043. SS_LODINREFRACTIONALPHA: boolean;
  116044. SS_GAMMAREFRACTION: boolean;
  116045. SS_RGBDREFRACTION: boolean;
  116046. SS_LINEARSPECULARREFRACTION: boolean;
  116047. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116048. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116049. /** @hidden */
  116050. _areTexturesDirty: boolean;
  116051. }
  116052. /**
  116053. * Define the code related to the sub surface parameters of the pbr material.
  116054. */
  116055. export class PBRSubSurfaceConfiguration {
  116056. private _isRefractionEnabled;
  116057. /**
  116058. * Defines if the refraction is enabled in the material.
  116059. */
  116060. isRefractionEnabled: boolean;
  116061. private _isTranslucencyEnabled;
  116062. /**
  116063. * Defines if the translucency is enabled in the material.
  116064. */
  116065. isTranslucencyEnabled: boolean;
  116066. private _isScatteringEnabled;
  116067. /**
  116068. * Defines the refraction intensity of the material.
  116069. * The refraction when enabled replaces the Diffuse part of the material.
  116070. * The intensity helps transitionning between diffuse and refraction.
  116071. */
  116072. refractionIntensity: number;
  116073. /**
  116074. * Defines the translucency intensity of the material.
  116075. * When translucency has been enabled, this defines how much of the "translucency"
  116076. * is addded to the diffuse part of the material.
  116077. */
  116078. translucencyIntensity: number;
  116079. /**
  116080. * Defines the scattering intensity of the material.
  116081. * When scattering has been enabled, this defines how much of the "scattered light"
  116082. * is addded to the diffuse part of the material.
  116083. */
  116084. scatteringIntensity: number;
  116085. private _thicknessTexture;
  116086. /**
  116087. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  116088. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  116089. * 0 would mean minimumThickness
  116090. * 1 would mean maximumThickness
  116091. * The other channels might be use as a mask to vary the different effects intensity.
  116092. */
  116093. thicknessTexture: Nullable<BaseTexture>;
  116094. private _refractionTexture;
  116095. /**
  116096. * Defines the texture to use for refraction.
  116097. */
  116098. refractionTexture: Nullable<BaseTexture>;
  116099. private _indexOfRefraction;
  116100. /**
  116101. * Defines the index of refraction used in the material.
  116102. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116103. */
  116104. indexOfRefraction: number;
  116105. private _invertRefractionY;
  116106. /**
  116107. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116108. */
  116109. invertRefractionY: boolean;
  116110. private _linkRefractionWithTransparency;
  116111. /**
  116112. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116113. * Materials half opaque for instance using refraction could benefit from this control.
  116114. */
  116115. linkRefractionWithTransparency: boolean;
  116116. /**
  116117. * Defines the minimum thickness stored in the thickness map.
  116118. * If no thickness map is defined, this value will be used to simulate thickness.
  116119. */
  116120. minimumThickness: number;
  116121. /**
  116122. * Defines the maximum thickness stored in the thickness map.
  116123. */
  116124. maximumThickness: number;
  116125. /**
  116126. * Defines the volume tint of the material.
  116127. * This is used for both translucency and scattering.
  116128. */
  116129. tintColor: Color3;
  116130. /**
  116131. * Defines the distance at which the tint color should be found in the media.
  116132. * This is used for refraction only.
  116133. */
  116134. tintColorAtDistance: number;
  116135. /**
  116136. * Defines how far each channel transmit through the media.
  116137. * It is defined as a color to simplify it selection.
  116138. */
  116139. diffusionDistance: Color3;
  116140. private _useMaskFromThicknessTexture;
  116141. /**
  116142. * Stores the intensity of the different subsurface effects in the thickness texture.
  116143. * * the green channel is the translucency intensity.
  116144. * * the blue channel is the scattering intensity.
  116145. * * the alpha channel is the refraction intensity.
  116146. */
  116147. useMaskFromThicknessTexture: boolean;
  116148. /** @hidden */
  116149. private _internalMarkAllSubMeshesAsTexturesDirty;
  116150. /** @hidden */
  116151. _markAllSubMeshesAsTexturesDirty(): void;
  116152. /**
  116153. * Instantiate a new istance of sub surface configuration.
  116154. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116155. */
  116156. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116157. /**
  116158. * Gets wehter the submesh is ready to be used or not.
  116159. * @param defines the list of "defines" to update.
  116160. * @param scene defines the scene the material belongs to.
  116161. * @returns - boolean indicating that the submesh is ready or not.
  116162. */
  116163. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116164. /**
  116165. * Checks to see if a texture is used in the material.
  116166. * @param defines the list of "defines" to update.
  116167. * @param scene defines the scene to the material belongs to.
  116168. */
  116169. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116170. /**
  116171. * Binds the material data.
  116172. * @param uniformBuffer defines the Uniform buffer to fill in.
  116173. * @param scene defines the scene the material belongs to.
  116174. * @param engine defines the engine the material belongs to.
  116175. * @param isFrozen defines wether the material is frozen or not.
  116176. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116177. */
  116178. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116179. /**
  116180. * Unbinds the material from the mesh.
  116181. * @param activeEffect defines the effect that should be unbound from.
  116182. * @returns true if unbound, otherwise false
  116183. */
  116184. unbind(activeEffect: Effect): boolean;
  116185. /**
  116186. * Returns the texture used for refraction or null if none is used.
  116187. * @param scene defines the scene the material belongs to.
  116188. * @returns - Refraction texture if present. If no refraction texture and refraction
  116189. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116190. */
  116191. private _getRefractionTexture;
  116192. /**
  116193. * Returns true if alpha blending should be disabled.
  116194. */
  116195. readonly disableAlphaBlending: boolean;
  116196. /**
  116197. * Fills the list of render target textures.
  116198. * @param renderTargets the list of render targets to update
  116199. */
  116200. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116201. /**
  116202. * Checks to see if a texture is used in the material.
  116203. * @param texture - Base texture to use.
  116204. * @returns - Boolean specifying if a texture is used in the material.
  116205. */
  116206. hasTexture(texture: BaseTexture): boolean;
  116207. /**
  116208. * Gets a boolean indicating that current material needs to register RTT
  116209. * @returns true if this uses a render target otherwise false.
  116210. */
  116211. hasRenderTargetTextures(): boolean;
  116212. /**
  116213. * Returns an array of the actively used textures.
  116214. * @param activeTextures Array of BaseTextures
  116215. */
  116216. getActiveTextures(activeTextures: BaseTexture[]): void;
  116217. /**
  116218. * Returns the animatable textures.
  116219. * @param animatables Array of animatable textures.
  116220. */
  116221. getAnimatables(animatables: IAnimatable[]): void;
  116222. /**
  116223. * Disposes the resources of the material.
  116224. * @param forceDisposeTextures - Forces the disposal of all textures.
  116225. */
  116226. dispose(forceDisposeTextures?: boolean): void;
  116227. /**
  116228. * Get the current class name of the texture useful for serialization or dynamic coding.
  116229. * @returns "PBRSubSurfaceConfiguration"
  116230. */
  116231. getClassName(): string;
  116232. /**
  116233. * Add fallbacks to the effect fallbacks list.
  116234. * @param defines defines the Base texture to use.
  116235. * @param fallbacks defines the current fallback list.
  116236. * @param currentRank defines the current fallback rank.
  116237. * @returns the new fallback rank.
  116238. */
  116239. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116240. /**
  116241. * Add the required uniforms to the current list.
  116242. * @param uniforms defines the current uniform list.
  116243. */
  116244. static AddUniforms(uniforms: string[]): void;
  116245. /**
  116246. * Add the required samplers to the current list.
  116247. * @param samplers defines the current sampler list.
  116248. */
  116249. static AddSamplers(samplers: string[]): void;
  116250. /**
  116251. * Add the required uniforms to the current buffer.
  116252. * @param uniformBuffer defines the current uniform buffer.
  116253. */
  116254. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116255. /**
  116256. * Makes a duplicate of the current configuration into another one.
  116257. * @param configuration define the config where to copy the info
  116258. */
  116259. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116260. /**
  116261. * Serializes this Sub Surface configuration.
  116262. * @returns - An object with the serialized config.
  116263. */
  116264. serialize(): any;
  116265. /**
  116266. * Parses a anisotropy Configuration from a serialized object.
  116267. * @param source - Serialized object.
  116268. * @param scene Defines the scene we are parsing for
  116269. * @param rootUrl Defines the rootUrl to load from
  116270. */
  116271. parse(source: any, scene: Scene, rootUrl: string): void;
  116272. }
  116273. }
  116274. declare module BABYLON {
  116275. /** @hidden */
  116276. export var pbrFragmentDeclaration: {
  116277. name: string;
  116278. shader: string;
  116279. };
  116280. }
  116281. declare module BABYLON {
  116282. /** @hidden */
  116283. export var pbrUboDeclaration: {
  116284. name: string;
  116285. shader: string;
  116286. };
  116287. }
  116288. declare module BABYLON {
  116289. /** @hidden */
  116290. export var pbrFragmentExtraDeclaration: {
  116291. name: string;
  116292. shader: string;
  116293. };
  116294. }
  116295. declare module BABYLON {
  116296. /** @hidden */
  116297. export var pbrFragmentSamplersDeclaration: {
  116298. name: string;
  116299. shader: string;
  116300. };
  116301. }
  116302. declare module BABYLON {
  116303. /** @hidden */
  116304. export var pbrHelperFunctions: {
  116305. name: string;
  116306. shader: string;
  116307. };
  116308. }
  116309. declare module BABYLON {
  116310. /** @hidden */
  116311. export var harmonicsFunctions: {
  116312. name: string;
  116313. shader: string;
  116314. };
  116315. }
  116316. declare module BABYLON {
  116317. /** @hidden */
  116318. export var pbrDirectLightingSetupFunctions: {
  116319. name: string;
  116320. shader: string;
  116321. };
  116322. }
  116323. declare module BABYLON {
  116324. /** @hidden */
  116325. export var pbrDirectLightingFalloffFunctions: {
  116326. name: string;
  116327. shader: string;
  116328. };
  116329. }
  116330. declare module BABYLON {
  116331. /** @hidden */
  116332. export var pbrBRDFFunctions: {
  116333. name: string;
  116334. shader: string;
  116335. };
  116336. }
  116337. declare module BABYLON {
  116338. /** @hidden */
  116339. export var pbrDirectLightingFunctions: {
  116340. name: string;
  116341. shader: string;
  116342. };
  116343. }
  116344. declare module BABYLON {
  116345. /** @hidden */
  116346. export var pbrIBLFunctions: {
  116347. name: string;
  116348. shader: string;
  116349. };
  116350. }
  116351. declare module BABYLON {
  116352. /** @hidden */
  116353. export var pbrDebug: {
  116354. name: string;
  116355. shader: string;
  116356. };
  116357. }
  116358. declare module BABYLON {
  116359. /** @hidden */
  116360. export var pbrPixelShader: {
  116361. name: string;
  116362. shader: string;
  116363. };
  116364. }
  116365. declare module BABYLON {
  116366. /** @hidden */
  116367. export var pbrVertexDeclaration: {
  116368. name: string;
  116369. shader: string;
  116370. };
  116371. }
  116372. declare module BABYLON {
  116373. /** @hidden */
  116374. export var pbrVertexShader: {
  116375. name: string;
  116376. shader: string;
  116377. };
  116378. }
  116379. declare module BABYLON {
  116380. /**
  116381. * Manages the defines for the PBR Material.
  116382. * @hidden
  116383. */
  116384. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116385. PBR: boolean;
  116386. MAINUV1: boolean;
  116387. MAINUV2: boolean;
  116388. UV1: boolean;
  116389. UV2: boolean;
  116390. ALBEDO: boolean;
  116391. ALBEDODIRECTUV: number;
  116392. VERTEXCOLOR: boolean;
  116393. AMBIENT: boolean;
  116394. AMBIENTDIRECTUV: number;
  116395. AMBIENTINGRAYSCALE: boolean;
  116396. OPACITY: boolean;
  116397. VERTEXALPHA: boolean;
  116398. OPACITYDIRECTUV: number;
  116399. OPACITYRGB: boolean;
  116400. ALPHATEST: boolean;
  116401. DEPTHPREPASS: boolean;
  116402. ALPHABLEND: boolean;
  116403. ALPHAFROMALBEDO: boolean;
  116404. ALPHATESTVALUE: string;
  116405. SPECULAROVERALPHA: boolean;
  116406. RADIANCEOVERALPHA: boolean;
  116407. ALPHAFRESNEL: boolean;
  116408. LINEARALPHAFRESNEL: boolean;
  116409. PREMULTIPLYALPHA: boolean;
  116410. EMISSIVE: boolean;
  116411. EMISSIVEDIRECTUV: number;
  116412. REFLECTIVITY: boolean;
  116413. REFLECTIVITYDIRECTUV: number;
  116414. SPECULARTERM: boolean;
  116415. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116416. MICROSURFACEAUTOMATIC: boolean;
  116417. LODBASEDMICROSFURACE: boolean;
  116418. MICROSURFACEMAP: boolean;
  116419. MICROSURFACEMAPDIRECTUV: number;
  116420. METALLICWORKFLOW: boolean;
  116421. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116422. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116423. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116424. AOSTOREINMETALMAPRED: boolean;
  116425. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116426. ENVIRONMENTBRDF: boolean;
  116427. ENVIRONMENTBRDF_RGBD: boolean;
  116428. NORMAL: boolean;
  116429. TANGENT: boolean;
  116430. BUMP: boolean;
  116431. BUMPDIRECTUV: number;
  116432. OBJECTSPACE_NORMALMAP: boolean;
  116433. PARALLAX: boolean;
  116434. PARALLAXOCCLUSION: boolean;
  116435. NORMALXYSCALE: boolean;
  116436. LIGHTMAP: boolean;
  116437. LIGHTMAPDIRECTUV: number;
  116438. USELIGHTMAPASSHADOWMAP: boolean;
  116439. GAMMALIGHTMAP: boolean;
  116440. RGBDLIGHTMAP: boolean;
  116441. REFLECTION: boolean;
  116442. REFLECTIONMAP_3D: boolean;
  116443. REFLECTIONMAP_SPHERICAL: boolean;
  116444. REFLECTIONMAP_PLANAR: boolean;
  116445. REFLECTIONMAP_CUBIC: boolean;
  116446. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116447. REFLECTIONMAP_PROJECTION: boolean;
  116448. REFLECTIONMAP_SKYBOX: boolean;
  116449. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116450. REFLECTIONMAP_EXPLICIT: boolean;
  116451. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116452. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116453. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116454. INVERTCUBICMAP: boolean;
  116455. USESPHERICALFROMREFLECTIONMAP: boolean;
  116456. USEIRRADIANCEMAP: boolean;
  116457. SPHERICAL_HARMONICS: boolean;
  116458. USESPHERICALINVERTEX: boolean;
  116459. REFLECTIONMAP_OPPOSITEZ: boolean;
  116460. LODINREFLECTIONALPHA: boolean;
  116461. GAMMAREFLECTION: boolean;
  116462. RGBDREFLECTION: boolean;
  116463. LINEARSPECULARREFLECTION: boolean;
  116464. RADIANCEOCCLUSION: boolean;
  116465. HORIZONOCCLUSION: boolean;
  116466. INSTANCES: boolean;
  116467. NUM_BONE_INFLUENCERS: number;
  116468. BonesPerMesh: number;
  116469. BONETEXTURE: boolean;
  116470. NONUNIFORMSCALING: boolean;
  116471. MORPHTARGETS: boolean;
  116472. MORPHTARGETS_NORMAL: boolean;
  116473. MORPHTARGETS_TANGENT: boolean;
  116474. MORPHTARGETS_UV: boolean;
  116475. NUM_MORPH_INFLUENCERS: number;
  116476. IMAGEPROCESSING: boolean;
  116477. VIGNETTE: boolean;
  116478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116479. VIGNETTEBLENDMODEOPAQUE: boolean;
  116480. TONEMAPPING: boolean;
  116481. TONEMAPPING_ACES: boolean;
  116482. CONTRAST: boolean;
  116483. COLORCURVES: boolean;
  116484. COLORGRADING: boolean;
  116485. COLORGRADING3D: boolean;
  116486. SAMPLER3DGREENDEPTH: boolean;
  116487. SAMPLER3DBGRMAP: boolean;
  116488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116489. EXPOSURE: boolean;
  116490. MULTIVIEW: boolean;
  116491. USEPHYSICALLIGHTFALLOFF: boolean;
  116492. USEGLTFLIGHTFALLOFF: boolean;
  116493. TWOSIDEDLIGHTING: boolean;
  116494. SHADOWFLOAT: boolean;
  116495. CLIPPLANE: boolean;
  116496. CLIPPLANE2: boolean;
  116497. CLIPPLANE3: boolean;
  116498. CLIPPLANE4: boolean;
  116499. POINTSIZE: boolean;
  116500. FOG: boolean;
  116501. LOGARITHMICDEPTH: boolean;
  116502. FORCENORMALFORWARD: boolean;
  116503. SPECULARAA: boolean;
  116504. CLEARCOAT: boolean;
  116505. CLEARCOAT_DEFAULTIOR: boolean;
  116506. CLEARCOAT_TEXTURE: boolean;
  116507. CLEARCOAT_TEXTUREDIRECTUV: number;
  116508. CLEARCOAT_BUMP: boolean;
  116509. CLEARCOAT_BUMPDIRECTUV: number;
  116510. CLEARCOAT_TINT: boolean;
  116511. CLEARCOAT_TINT_TEXTURE: boolean;
  116512. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116513. ANISOTROPIC: boolean;
  116514. ANISOTROPIC_TEXTURE: boolean;
  116515. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116516. BRDF_V_HEIGHT_CORRELATED: boolean;
  116517. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116518. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116519. SHEEN: boolean;
  116520. SHEEN_TEXTURE: boolean;
  116521. SHEEN_TEXTUREDIRECTUV: number;
  116522. SHEEN_LINKWITHALBEDO: boolean;
  116523. SUBSURFACE: boolean;
  116524. SS_REFRACTION: boolean;
  116525. SS_TRANSLUCENCY: boolean;
  116526. SS_SCATERRING: boolean;
  116527. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116528. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116529. SS_REFRACTIONMAP_3D: boolean;
  116530. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116531. SS_LODINREFRACTIONALPHA: boolean;
  116532. SS_GAMMAREFRACTION: boolean;
  116533. SS_RGBDREFRACTION: boolean;
  116534. SS_LINEARSPECULARREFRACTION: boolean;
  116535. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116536. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116537. UNLIT: boolean;
  116538. DEBUGMODE: number;
  116539. /**
  116540. * Initializes the PBR Material defines.
  116541. */
  116542. constructor();
  116543. /**
  116544. * Resets the PBR Material defines.
  116545. */
  116546. reset(): void;
  116547. }
  116548. /**
  116549. * The Physically based material base class of BJS.
  116550. *
  116551. * This offers the main features of a standard PBR material.
  116552. * For more information, please refer to the documentation :
  116553. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116554. */
  116555. export abstract class PBRBaseMaterial extends PushMaterial {
  116556. /**
  116557. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116558. */
  116559. static readonly PBRMATERIAL_OPAQUE: number;
  116560. /**
  116561. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116562. */
  116563. static readonly PBRMATERIAL_ALPHATEST: number;
  116564. /**
  116565. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116566. */
  116567. static readonly PBRMATERIAL_ALPHABLEND: number;
  116568. /**
  116569. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116570. * They are also discarded below the alpha cutoff threshold to improve performances.
  116571. */
  116572. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116573. /**
  116574. * Defines the default value of how much AO map is occluding the analytical lights
  116575. * (point spot...).
  116576. */
  116577. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116578. /**
  116579. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116580. */
  116581. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116582. /**
  116583. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116584. * to enhance interoperability with other engines.
  116585. */
  116586. static readonly LIGHTFALLOFF_GLTF: number;
  116587. /**
  116588. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116589. * to enhance interoperability with other materials.
  116590. */
  116591. static readonly LIGHTFALLOFF_STANDARD: number;
  116592. /**
  116593. * Intensity of the direct lights e.g. the four lights available in your scene.
  116594. * This impacts both the direct diffuse and specular highlights.
  116595. */
  116596. protected _directIntensity: number;
  116597. /**
  116598. * Intensity of the emissive part of the material.
  116599. * This helps controlling the emissive effect without modifying the emissive color.
  116600. */
  116601. protected _emissiveIntensity: number;
  116602. /**
  116603. * Intensity of the environment e.g. how much the environment will light the object
  116604. * either through harmonics for rough material or through the refelction for shiny ones.
  116605. */
  116606. protected _environmentIntensity: number;
  116607. /**
  116608. * This is a special control allowing the reduction of the specular highlights coming from the
  116609. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116610. */
  116611. protected _specularIntensity: number;
  116612. /**
  116613. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116614. */
  116615. private _lightingInfos;
  116616. /**
  116617. * Debug Control allowing disabling the bump map on this material.
  116618. */
  116619. protected _disableBumpMap: boolean;
  116620. /**
  116621. * AKA Diffuse Texture in standard nomenclature.
  116622. */
  116623. protected _albedoTexture: Nullable<BaseTexture>;
  116624. /**
  116625. * AKA Occlusion Texture in other nomenclature.
  116626. */
  116627. protected _ambientTexture: Nullable<BaseTexture>;
  116628. /**
  116629. * AKA Occlusion Texture Intensity in other nomenclature.
  116630. */
  116631. protected _ambientTextureStrength: number;
  116632. /**
  116633. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116634. * 1 means it completely occludes it
  116635. * 0 mean it has no impact
  116636. */
  116637. protected _ambientTextureImpactOnAnalyticalLights: number;
  116638. /**
  116639. * Stores the alpha values in a texture.
  116640. */
  116641. protected _opacityTexture: Nullable<BaseTexture>;
  116642. /**
  116643. * Stores the reflection values in a texture.
  116644. */
  116645. protected _reflectionTexture: Nullable<BaseTexture>;
  116646. /**
  116647. * Stores the emissive values in a texture.
  116648. */
  116649. protected _emissiveTexture: Nullable<BaseTexture>;
  116650. /**
  116651. * AKA Specular texture in other nomenclature.
  116652. */
  116653. protected _reflectivityTexture: Nullable<BaseTexture>;
  116654. /**
  116655. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116656. */
  116657. protected _metallicTexture: Nullable<BaseTexture>;
  116658. /**
  116659. * Specifies the metallic scalar of the metallic/roughness workflow.
  116660. * Can also be used to scale the metalness values of the metallic texture.
  116661. */
  116662. protected _metallic: Nullable<number>;
  116663. /**
  116664. * Specifies the roughness scalar of the metallic/roughness workflow.
  116665. * Can also be used to scale the roughness values of the metallic texture.
  116666. */
  116667. protected _roughness: Nullable<number>;
  116668. /**
  116669. * Specifies the an F0 factor to help configuring the material F0.
  116670. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116671. * to 0.5 the previously hard coded value stays the same.
  116672. * Can also be used to scale the F0 values of the metallic texture.
  116673. */
  116674. protected _metallicF0Factor: number;
  116675. /**
  116676. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116677. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116678. * your expectation as it multiplies with the texture data.
  116679. */
  116680. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116681. /**
  116682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116684. */
  116685. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116686. /**
  116687. * Stores surface normal data used to displace a mesh in a texture.
  116688. */
  116689. protected _bumpTexture: Nullable<BaseTexture>;
  116690. /**
  116691. * Stores the pre-calculated light information of a mesh in a texture.
  116692. */
  116693. protected _lightmapTexture: Nullable<BaseTexture>;
  116694. /**
  116695. * The color of a material in ambient lighting.
  116696. */
  116697. protected _ambientColor: Color3;
  116698. /**
  116699. * AKA Diffuse Color in other nomenclature.
  116700. */
  116701. protected _albedoColor: Color3;
  116702. /**
  116703. * AKA Specular Color in other nomenclature.
  116704. */
  116705. protected _reflectivityColor: Color3;
  116706. /**
  116707. * The color applied when light is reflected from a material.
  116708. */
  116709. protected _reflectionColor: Color3;
  116710. /**
  116711. * The color applied when light is emitted from a material.
  116712. */
  116713. protected _emissiveColor: Color3;
  116714. /**
  116715. * AKA Glossiness in other nomenclature.
  116716. */
  116717. protected _microSurface: number;
  116718. /**
  116719. * Specifies that the material will use the light map as a show map.
  116720. */
  116721. protected _useLightmapAsShadowmap: boolean;
  116722. /**
  116723. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116724. * makes the reflect vector face the model (under horizon).
  116725. */
  116726. protected _useHorizonOcclusion: boolean;
  116727. /**
  116728. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116729. * too much the area relying on ambient texture to define their ambient occlusion.
  116730. */
  116731. protected _useRadianceOcclusion: boolean;
  116732. /**
  116733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116734. */
  116735. protected _useAlphaFromAlbedoTexture: boolean;
  116736. /**
  116737. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116738. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116739. */
  116740. protected _useSpecularOverAlpha: boolean;
  116741. /**
  116742. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116743. */
  116744. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116745. /**
  116746. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116747. */
  116748. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116749. /**
  116750. * Specifies if the metallic texture contains the roughness information in its green channel.
  116751. */
  116752. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116753. /**
  116754. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116755. */
  116756. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116757. /**
  116758. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116759. */
  116760. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116761. /**
  116762. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116763. */
  116764. protected _useAmbientInGrayScale: boolean;
  116765. /**
  116766. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116767. * The material will try to infer what glossiness each pixel should be.
  116768. */
  116769. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116770. /**
  116771. * Defines the falloff type used in this material.
  116772. * It by default is Physical.
  116773. */
  116774. protected _lightFalloff: number;
  116775. /**
  116776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116778. */
  116779. protected _useRadianceOverAlpha: boolean;
  116780. /**
  116781. * Allows using an object space normal map (instead of tangent space).
  116782. */
  116783. protected _useObjectSpaceNormalMap: boolean;
  116784. /**
  116785. * Allows using the bump map in parallax mode.
  116786. */
  116787. protected _useParallax: boolean;
  116788. /**
  116789. * Allows using the bump map in parallax occlusion mode.
  116790. */
  116791. protected _useParallaxOcclusion: boolean;
  116792. /**
  116793. * Controls the scale bias of the parallax mode.
  116794. */
  116795. protected _parallaxScaleBias: number;
  116796. /**
  116797. * If sets to true, disables all the lights affecting the material.
  116798. */
  116799. protected _disableLighting: boolean;
  116800. /**
  116801. * Number of Simultaneous lights allowed on the material.
  116802. */
  116803. protected _maxSimultaneousLights: number;
  116804. /**
  116805. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116806. */
  116807. protected _invertNormalMapX: boolean;
  116808. /**
  116809. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116810. */
  116811. protected _invertNormalMapY: boolean;
  116812. /**
  116813. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116814. */
  116815. protected _twoSidedLighting: boolean;
  116816. /**
  116817. * Defines the alpha limits in alpha test mode.
  116818. */
  116819. protected _alphaCutOff: number;
  116820. /**
  116821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116822. */
  116823. protected _forceAlphaTest: boolean;
  116824. /**
  116825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116826. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116827. */
  116828. protected _useAlphaFresnel: boolean;
  116829. /**
  116830. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116831. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116832. */
  116833. protected _useLinearAlphaFresnel: boolean;
  116834. /**
  116835. * The transparency mode of the material.
  116836. */
  116837. protected _transparencyMode: Nullable<number>;
  116838. /**
  116839. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116840. * from cos thetav and roughness:
  116841. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116842. */
  116843. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116844. /**
  116845. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116846. */
  116847. protected _forceIrradianceInFragment: boolean;
  116848. /**
  116849. * Force normal to face away from face.
  116850. */
  116851. protected _forceNormalForward: boolean;
  116852. /**
  116853. * Enables specular anti aliasing in the PBR shader.
  116854. * It will both interacts on the Geometry for analytical and IBL lighting.
  116855. * It also prefilter the roughness map based on the bump values.
  116856. */
  116857. protected _enableSpecularAntiAliasing: boolean;
  116858. /**
  116859. * Default configuration related to image processing available in the PBR Material.
  116860. */
  116861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116862. /**
  116863. * Keep track of the image processing observer to allow dispose and replace.
  116864. */
  116865. private _imageProcessingObserver;
  116866. /**
  116867. * Attaches a new image processing configuration to the PBR Material.
  116868. * @param configuration
  116869. */
  116870. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116871. /**
  116872. * Stores the available render targets.
  116873. */
  116874. private _renderTargets;
  116875. /**
  116876. * Sets the global ambient color for the material used in lighting calculations.
  116877. */
  116878. private _globalAmbientColor;
  116879. /**
  116880. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116881. */
  116882. private _useLogarithmicDepth;
  116883. /**
  116884. * If set to true, no lighting calculations will be applied.
  116885. */
  116886. private _unlit;
  116887. private _debugMode;
  116888. /**
  116889. * @hidden
  116890. * This is reserved for the inspector.
  116891. * Defines the material debug mode.
  116892. * It helps seeing only some components of the material while troubleshooting.
  116893. */
  116894. debugMode: number;
  116895. /**
  116896. * @hidden
  116897. * This is reserved for the inspector.
  116898. * Specify from where on screen the debug mode should start.
  116899. * The value goes from -1 (full screen) to 1 (not visible)
  116900. * It helps with side by side comparison against the final render
  116901. * This defaults to -1
  116902. */
  116903. private debugLimit;
  116904. /**
  116905. * @hidden
  116906. * This is reserved for the inspector.
  116907. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116908. * You can use the factor to better multiply the final value.
  116909. */
  116910. private debugFactor;
  116911. /**
  116912. * Defines the clear coat layer parameters for the material.
  116913. */
  116914. readonly clearCoat: PBRClearCoatConfiguration;
  116915. /**
  116916. * Defines the anisotropic parameters for the material.
  116917. */
  116918. readonly anisotropy: PBRAnisotropicConfiguration;
  116919. /**
  116920. * Defines the BRDF parameters for the material.
  116921. */
  116922. readonly brdf: PBRBRDFConfiguration;
  116923. /**
  116924. * Defines the Sheen parameters for the material.
  116925. */
  116926. readonly sheen: PBRSheenConfiguration;
  116927. /**
  116928. * Defines the SubSurface parameters for the material.
  116929. */
  116930. readonly subSurface: PBRSubSurfaceConfiguration;
  116931. /**
  116932. * Custom callback helping to override the default shader used in the material.
  116933. */
  116934. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116935. protected _rebuildInParallel: boolean;
  116936. /**
  116937. * Instantiates a new PBRMaterial instance.
  116938. *
  116939. * @param name The material name
  116940. * @param scene The scene the material will be use in.
  116941. */
  116942. constructor(name: string, scene: Scene);
  116943. /**
  116944. * Gets a boolean indicating that current material needs to register RTT
  116945. */
  116946. readonly hasRenderTargetTextures: boolean;
  116947. /**
  116948. * Gets the name of the material class.
  116949. */
  116950. getClassName(): string;
  116951. /**
  116952. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116953. */
  116954. /**
  116955. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116956. */
  116957. useLogarithmicDepth: boolean;
  116958. /**
  116959. * Gets the current transparency mode.
  116960. */
  116961. /**
  116962. * Sets the transparency mode of the material.
  116963. *
  116964. * | Value | Type | Description |
  116965. * | ----- | ----------------------------------- | ----------- |
  116966. * | 0 | OPAQUE | |
  116967. * | 1 | ALPHATEST | |
  116968. * | 2 | ALPHABLEND | |
  116969. * | 3 | ALPHATESTANDBLEND | |
  116970. *
  116971. */
  116972. transparencyMode: Nullable<number>;
  116973. /**
  116974. * Returns true if alpha blending should be disabled.
  116975. */
  116976. private readonly _disableAlphaBlending;
  116977. /**
  116978. * Specifies whether or not this material should be rendered in alpha blend mode.
  116979. */
  116980. needAlphaBlending(): boolean;
  116981. /**
  116982. * Specifies if the mesh will require alpha blending.
  116983. * @param mesh - BJS mesh.
  116984. */
  116985. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116986. /**
  116987. * Specifies whether or not this material should be rendered in alpha test mode.
  116988. */
  116989. needAlphaTesting(): boolean;
  116990. /**
  116991. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116992. */
  116993. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116994. /**
  116995. * Gets the texture used for the alpha test.
  116996. */
  116997. getAlphaTestTexture(): Nullable<BaseTexture>;
  116998. /**
  116999. * Specifies that the submesh is ready to be used.
  117000. * @param mesh - BJS mesh.
  117001. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117002. * @param useInstances - Specifies that instances should be used.
  117003. * @returns - boolean indicating that the submesh is ready or not.
  117004. */
  117005. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117006. /**
  117007. * Specifies if the material uses metallic roughness workflow.
  117008. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117009. */
  117010. isMetallicWorkflow(): boolean;
  117011. private _prepareEffect;
  117012. private _prepareDefines;
  117013. /**
  117014. * Force shader compilation
  117015. */
  117016. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117017. /**
  117018. * Initializes the uniform buffer layout for the shader.
  117019. */
  117020. buildUniformLayout(): void;
  117021. /**
  117022. * Unbinds the material from the mesh
  117023. */
  117024. unbind(): void;
  117025. /**
  117026. * Binds the submesh data.
  117027. * @param world - The world matrix.
  117028. * @param mesh - The BJS mesh.
  117029. * @param subMesh - A submesh of the BJS mesh.
  117030. */
  117031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117032. /**
  117033. * Returns the animatable textures.
  117034. * @returns - Array of animatable textures.
  117035. */
  117036. getAnimatables(): IAnimatable[];
  117037. /**
  117038. * Returns the texture used for reflections.
  117039. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117040. */
  117041. private _getReflectionTexture;
  117042. /**
  117043. * Returns an array of the actively used textures.
  117044. * @returns - Array of BaseTextures
  117045. */
  117046. getActiveTextures(): BaseTexture[];
  117047. /**
  117048. * Checks to see if a texture is used in the material.
  117049. * @param texture - Base texture to use.
  117050. * @returns - Boolean specifying if a texture is used in the material.
  117051. */
  117052. hasTexture(texture: BaseTexture): boolean;
  117053. /**
  117054. * Disposes the resources of the material.
  117055. * @param forceDisposeEffect - Forces the disposal of effects.
  117056. * @param forceDisposeTextures - Forces the disposal of all textures.
  117057. */
  117058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117059. }
  117060. }
  117061. declare module BABYLON {
  117062. /**
  117063. * The Physically based material of BJS.
  117064. *
  117065. * This offers the main features of a standard PBR material.
  117066. * For more information, please refer to the documentation :
  117067. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117068. */
  117069. export class PBRMaterial extends PBRBaseMaterial {
  117070. /**
  117071. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117072. */
  117073. static readonly PBRMATERIAL_OPAQUE: number;
  117074. /**
  117075. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117076. */
  117077. static readonly PBRMATERIAL_ALPHATEST: number;
  117078. /**
  117079. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117080. */
  117081. static readonly PBRMATERIAL_ALPHABLEND: number;
  117082. /**
  117083. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117084. * They are also discarded below the alpha cutoff threshold to improve performances.
  117085. */
  117086. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117087. /**
  117088. * Defines the default value of how much AO map is occluding the analytical lights
  117089. * (point spot...).
  117090. */
  117091. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117092. /**
  117093. * Intensity of the direct lights e.g. the four lights available in your scene.
  117094. * This impacts both the direct diffuse and specular highlights.
  117095. */
  117096. directIntensity: number;
  117097. /**
  117098. * Intensity of the emissive part of the material.
  117099. * This helps controlling the emissive effect without modifying the emissive color.
  117100. */
  117101. emissiveIntensity: number;
  117102. /**
  117103. * Intensity of the environment e.g. how much the environment will light the object
  117104. * either through harmonics for rough material or through the refelction for shiny ones.
  117105. */
  117106. environmentIntensity: number;
  117107. /**
  117108. * This is a special control allowing the reduction of the specular highlights coming from the
  117109. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117110. */
  117111. specularIntensity: number;
  117112. /**
  117113. * Debug Control allowing disabling the bump map on this material.
  117114. */
  117115. disableBumpMap: boolean;
  117116. /**
  117117. * AKA Diffuse Texture in standard nomenclature.
  117118. */
  117119. albedoTexture: BaseTexture;
  117120. /**
  117121. * AKA Occlusion Texture in other nomenclature.
  117122. */
  117123. ambientTexture: BaseTexture;
  117124. /**
  117125. * AKA Occlusion Texture Intensity in other nomenclature.
  117126. */
  117127. ambientTextureStrength: number;
  117128. /**
  117129. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117130. * 1 means it completely occludes it
  117131. * 0 mean it has no impact
  117132. */
  117133. ambientTextureImpactOnAnalyticalLights: number;
  117134. /**
  117135. * Stores the alpha values in a texture.
  117136. */
  117137. opacityTexture: BaseTexture;
  117138. /**
  117139. * Stores the reflection values in a texture.
  117140. */
  117141. reflectionTexture: Nullable<BaseTexture>;
  117142. /**
  117143. * Stores the emissive values in a texture.
  117144. */
  117145. emissiveTexture: BaseTexture;
  117146. /**
  117147. * AKA Specular texture in other nomenclature.
  117148. */
  117149. reflectivityTexture: BaseTexture;
  117150. /**
  117151. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117152. */
  117153. metallicTexture: BaseTexture;
  117154. /**
  117155. * Specifies the metallic scalar of the metallic/roughness workflow.
  117156. * Can also be used to scale the metalness values of the metallic texture.
  117157. */
  117158. metallic: Nullable<number>;
  117159. /**
  117160. * Specifies the roughness scalar of the metallic/roughness workflow.
  117161. * Can also be used to scale the roughness values of the metallic texture.
  117162. */
  117163. roughness: Nullable<number>;
  117164. /**
  117165. * Specifies the an F0 factor to help configuring the material F0.
  117166. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117167. * to 0.5 the previously hard coded value stays the same.
  117168. * Can also be used to scale the F0 values of the metallic texture.
  117169. */
  117170. metallicF0Factor: number;
  117171. /**
  117172. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117173. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117174. * your expectation as it multiplies with the texture data.
  117175. */
  117176. useMetallicF0FactorFromMetallicTexture: boolean;
  117177. /**
  117178. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117179. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117180. */
  117181. microSurfaceTexture: BaseTexture;
  117182. /**
  117183. * Stores surface normal data used to displace a mesh in a texture.
  117184. */
  117185. bumpTexture: BaseTexture;
  117186. /**
  117187. * Stores the pre-calculated light information of a mesh in a texture.
  117188. */
  117189. lightmapTexture: BaseTexture;
  117190. /**
  117191. * Stores the refracted light information in a texture.
  117192. */
  117193. refractionTexture: Nullable<BaseTexture>;
  117194. /**
  117195. * The color of a material in ambient lighting.
  117196. */
  117197. ambientColor: Color3;
  117198. /**
  117199. * AKA Diffuse Color in other nomenclature.
  117200. */
  117201. albedoColor: Color3;
  117202. /**
  117203. * AKA Specular Color in other nomenclature.
  117204. */
  117205. reflectivityColor: Color3;
  117206. /**
  117207. * The color reflected from the material.
  117208. */
  117209. reflectionColor: Color3;
  117210. /**
  117211. * The color emitted from the material.
  117212. */
  117213. emissiveColor: Color3;
  117214. /**
  117215. * AKA Glossiness in other nomenclature.
  117216. */
  117217. microSurface: number;
  117218. /**
  117219. * source material index of refraction (IOR)' / 'destination material IOR.
  117220. */
  117221. indexOfRefraction: number;
  117222. /**
  117223. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117224. */
  117225. invertRefractionY: boolean;
  117226. /**
  117227. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117228. * Materials half opaque for instance using refraction could benefit from this control.
  117229. */
  117230. linkRefractionWithTransparency: boolean;
  117231. /**
  117232. * If true, the light map contains occlusion information instead of lighting info.
  117233. */
  117234. useLightmapAsShadowmap: boolean;
  117235. /**
  117236. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117237. */
  117238. useAlphaFromAlbedoTexture: boolean;
  117239. /**
  117240. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117241. */
  117242. forceAlphaTest: boolean;
  117243. /**
  117244. * Defines the alpha limits in alpha test mode.
  117245. */
  117246. alphaCutOff: number;
  117247. /**
  117248. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117249. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117250. */
  117251. useSpecularOverAlpha: boolean;
  117252. /**
  117253. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117254. */
  117255. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117256. /**
  117257. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117258. */
  117259. useRoughnessFromMetallicTextureAlpha: boolean;
  117260. /**
  117261. * Specifies if the metallic texture contains the roughness information in its green channel.
  117262. */
  117263. useRoughnessFromMetallicTextureGreen: boolean;
  117264. /**
  117265. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117266. */
  117267. useMetallnessFromMetallicTextureBlue: boolean;
  117268. /**
  117269. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117270. */
  117271. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117272. /**
  117273. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117274. */
  117275. useAmbientInGrayScale: boolean;
  117276. /**
  117277. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117278. * The material will try to infer what glossiness each pixel should be.
  117279. */
  117280. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117281. /**
  117282. * BJS is using an harcoded light falloff based on a manually sets up range.
  117283. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117284. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117285. */
  117286. /**
  117287. * BJS is using an harcoded light falloff based on a manually sets up range.
  117288. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117289. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117290. */
  117291. usePhysicalLightFalloff: boolean;
  117292. /**
  117293. * In order to support the falloff compatibility with gltf, a special mode has been added
  117294. * to reproduce the gltf light falloff.
  117295. */
  117296. /**
  117297. * In order to support the falloff compatibility with gltf, a special mode has been added
  117298. * to reproduce the gltf light falloff.
  117299. */
  117300. useGLTFLightFalloff: boolean;
  117301. /**
  117302. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117303. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117304. */
  117305. useRadianceOverAlpha: boolean;
  117306. /**
  117307. * Allows using an object space normal map (instead of tangent space).
  117308. */
  117309. useObjectSpaceNormalMap: boolean;
  117310. /**
  117311. * Allows using the bump map in parallax mode.
  117312. */
  117313. useParallax: boolean;
  117314. /**
  117315. * Allows using the bump map in parallax occlusion mode.
  117316. */
  117317. useParallaxOcclusion: boolean;
  117318. /**
  117319. * Controls the scale bias of the parallax mode.
  117320. */
  117321. parallaxScaleBias: number;
  117322. /**
  117323. * If sets to true, disables all the lights affecting the material.
  117324. */
  117325. disableLighting: boolean;
  117326. /**
  117327. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117328. */
  117329. forceIrradianceInFragment: boolean;
  117330. /**
  117331. * Number of Simultaneous lights allowed on the material.
  117332. */
  117333. maxSimultaneousLights: number;
  117334. /**
  117335. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117336. */
  117337. invertNormalMapX: boolean;
  117338. /**
  117339. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117340. */
  117341. invertNormalMapY: boolean;
  117342. /**
  117343. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117344. */
  117345. twoSidedLighting: boolean;
  117346. /**
  117347. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117348. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117349. */
  117350. useAlphaFresnel: boolean;
  117351. /**
  117352. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117353. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117354. */
  117355. useLinearAlphaFresnel: boolean;
  117356. /**
  117357. * Let user defines the brdf lookup texture used for IBL.
  117358. * A default 8bit version is embedded but you could point at :
  117359. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117360. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117361. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117362. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117363. */
  117364. environmentBRDFTexture: Nullable<BaseTexture>;
  117365. /**
  117366. * Force normal to face away from face.
  117367. */
  117368. forceNormalForward: boolean;
  117369. /**
  117370. * Enables specular anti aliasing in the PBR shader.
  117371. * It will both interacts on the Geometry for analytical and IBL lighting.
  117372. * It also prefilter the roughness map based on the bump values.
  117373. */
  117374. enableSpecularAntiAliasing: boolean;
  117375. /**
  117376. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117377. * makes the reflect vector face the model (under horizon).
  117378. */
  117379. useHorizonOcclusion: boolean;
  117380. /**
  117381. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117382. * too much the area relying on ambient texture to define their ambient occlusion.
  117383. */
  117384. useRadianceOcclusion: boolean;
  117385. /**
  117386. * If set to true, no lighting calculations will be applied.
  117387. */
  117388. unlit: boolean;
  117389. /**
  117390. * Gets the image processing configuration used either in this material.
  117391. */
  117392. /**
  117393. * Sets the Default image processing configuration used either in the this material.
  117394. *
  117395. * If sets to null, the scene one is in use.
  117396. */
  117397. imageProcessingConfiguration: ImageProcessingConfiguration;
  117398. /**
  117399. * Gets wether the color curves effect is enabled.
  117400. */
  117401. /**
  117402. * Sets wether the color curves effect is enabled.
  117403. */
  117404. cameraColorCurvesEnabled: boolean;
  117405. /**
  117406. * Gets wether the color grading effect is enabled.
  117407. */
  117408. /**
  117409. * Gets wether the color grading effect is enabled.
  117410. */
  117411. cameraColorGradingEnabled: boolean;
  117412. /**
  117413. * Gets wether tonemapping is enabled or not.
  117414. */
  117415. /**
  117416. * Sets wether tonemapping is enabled or not
  117417. */
  117418. cameraToneMappingEnabled: boolean;
  117419. /**
  117420. * The camera exposure used on this material.
  117421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117422. * This corresponds to a photographic exposure.
  117423. */
  117424. /**
  117425. * The camera exposure used on this material.
  117426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117427. * This corresponds to a photographic exposure.
  117428. */
  117429. cameraExposure: number;
  117430. /**
  117431. * Gets The camera contrast used on this material.
  117432. */
  117433. /**
  117434. * Sets The camera contrast used on this material.
  117435. */
  117436. cameraContrast: number;
  117437. /**
  117438. * Gets the Color Grading 2D Lookup Texture.
  117439. */
  117440. /**
  117441. * Sets the Color Grading 2D Lookup Texture.
  117442. */
  117443. cameraColorGradingTexture: Nullable<BaseTexture>;
  117444. /**
  117445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117447. * 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;
  117448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117449. */
  117450. /**
  117451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117453. * 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;
  117454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117455. */
  117456. cameraColorCurves: Nullable<ColorCurves>;
  117457. /**
  117458. * Instantiates a new PBRMaterial instance.
  117459. *
  117460. * @param name The material name
  117461. * @param scene The scene the material will be use in.
  117462. */
  117463. constructor(name: string, scene: Scene);
  117464. /**
  117465. * Returns the name of this material class.
  117466. */
  117467. getClassName(): string;
  117468. /**
  117469. * Makes a duplicate of the current material.
  117470. * @param name - name to use for the new material.
  117471. */
  117472. clone(name: string): PBRMaterial;
  117473. /**
  117474. * Serializes this PBR Material.
  117475. * @returns - An object with the serialized material.
  117476. */
  117477. serialize(): any;
  117478. /**
  117479. * Parses a PBR Material from a serialized object.
  117480. * @param source - Serialized object.
  117481. * @param scene - BJS scene instance.
  117482. * @param rootUrl - url for the scene object
  117483. * @returns - PBRMaterial
  117484. */
  117485. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117486. }
  117487. }
  117488. declare module BABYLON {
  117489. /**
  117490. * Direct draw surface info
  117491. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117492. */
  117493. export interface DDSInfo {
  117494. /**
  117495. * Width of the texture
  117496. */
  117497. width: number;
  117498. /**
  117499. * Width of the texture
  117500. */
  117501. height: number;
  117502. /**
  117503. * Number of Mipmaps for the texture
  117504. * @see https://en.wikipedia.org/wiki/Mipmap
  117505. */
  117506. mipmapCount: number;
  117507. /**
  117508. * If the textures format is a known fourCC format
  117509. * @see https://www.fourcc.org/
  117510. */
  117511. isFourCC: boolean;
  117512. /**
  117513. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117514. */
  117515. isRGB: boolean;
  117516. /**
  117517. * If the texture is a lumincance format
  117518. */
  117519. isLuminance: boolean;
  117520. /**
  117521. * If this is a cube texture
  117522. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117523. */
  117524. isCube: boolean;
  117525. /**
  117526. * If the texture is a compressed format eg. FOURCC_DXT1
  117527. */
  117528. isCompressed: boolean;
  117529. /**
  117530. * The dxgiFormat of the texture
  117531. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117532. */
  117533. dxgiFormat: number;
  117534. /**
  117535. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117536. */
  117537. textureType: number;
  117538. /**
  117539. * Sphericle polynomial created for the dds texture
  117540. */
  117541. sphericalPolynomial?: SphericalPolynomial;
  117542. }
  117543. /**
  117544. * Class used to provide DDS decompression tools
  117545. */
  117546. export class DDSTools {
  117547. /**
  117548. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117549. */
  117550. static StoreLODInAlphaChannel: boolean;
  117551. /**
  117552. * Gets DDS information from an array buffer
  117553. * @param arrayBuffer defines the array buffer to read data from
  117554. * @returns the DDS information
  117555. */
  117556. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117557. private static _FloatView;
  117558. private static _Int32View;
  117559. private static _ToHalfFloat;
  117560. private static _FromHalfFloat;
  117561. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117562. private static _GetHalfFloatRGBAArrayBuffer;
  117563. private static _GetFloatRGBAArrayBuffer;
  117564. private static _GetFloatAsUIntRGBAArrayBuffer;
  117565. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117566. private static _GetRGBAArrayBuffer;
  117567. private static _ExtractLongWordOrder;
  117568. private static _GetRGBArrayBuffer;
  117569. private static _GetLuminanceArrayBuffer;
  117570. /**
  117571. * Uploads DDS Levels to a Babylon Texture
  117572. * @hidden
  117573. */
  117574. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117575. }
  117576. interface ThinEngine {
  117577. /**
  117578. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117579. * @param rootUrl defines the url where the file to load is located
  117580. * @param scene defines the current scene
  117581. * @param lodScale defines scale to apply to the mip map selection
  117582. * @param lodOffset defines offset to apply to the mip map selection
  117583. * @param onLoad defines an optional callback raised when the texture is loaded
  117584. * @param onError defines an optional callback raised if there is an issue to load the texture
  117585. * @param format defines the format of the data
  117586. * @param forcedExtension defines the extension to use to pick the right loader
  117587. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117588. * @returns the cube texture as an InternalTexture
  117589. */
  117590. 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;
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /**
  117595. * Implementation of the DDS Texture Loader.
  117596. * @hidden
  117597. */
  117598. export class _DDSTextureLoader implements IInternalTextureLoader {
  117599. /**
  117600. * Defines wether the loader supports cascade loading the different faces.
  117601. */
  117602. readonly supportCascades: boolean;
  117603. /**
  117604. * This returns if the loader support the current file information.
  117605. * @param extension defines the file extension of the file being loaded
  117606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117607. * @param fallback defines the fallback internal texture if any
  117608. * @param isBase64 defines whether the texture is encoded as a base64
  117609. * @param isBuffer defines whether the texture data are stored as a buffer
  117610. * @returns true if the loader can load the specified file
  117611. */
  117612. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117613. /**
  117614. * Transform the url before loading if required.
  117615. * @param rootUrl the url of the texture
  117616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117617. * @returns the transformed texture
  117618. */
  117619. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117620. /**
  117621. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117622. * @param rootUrl the url of the texture
  117623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117624. * @returns the fallback texture
  117625. */
  117626. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117627. /**
  117628. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117629. * @param data contains the texture data
  117630. * @param texture defines the BabylonJS internal texture
  117631. * @param createPolynomials will be true if polynomials have been requested
  117632. * @param onLoad defines the callback to trigger once the texture is ready
  117633. * @param onError defines the callback to trigger in case of error
  117634. */
  117635. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117636. /**
  117637. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117638. * @param data contains the texture data
  117639. * @param texture defines the BabylonJS internal texture
  117640. * @param callback defines the method to call once ready to upload
  117641. */
  117642. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117643. }
  117644. }
  117645. declare module BABYLON {
  117646. /**
  117647. * Implementation of the ENV Texture Loader.
  117648. * @hidden
  117649. */
  117650. export class _ENVTextureLoader implements IInternalTextureLoader {
  117651. /**
  117652. * Defines wether the loader supports cascade loading the different faces.
  117653. */
  117654. readonly supportCascades: boolean;
  117655. /**
  117656. * This returns if the loader support the current file information.
  117657. * @param extension defines the file extension of the file being loaded
  117658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117659. * @param fallback defines the fallback internal texture if any
  117660. * @param isBase64 defines whether the texture is encoded as a base64
  117661. * @param isBuffer defines whether the texture data are stored as a buffer
  117662. * @returns true if the loader can load the specified file
  117663. */
  117664. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117665. /**
  117666. * Transform the url before loading if required.
  117667. * @param rootUrl the url of the texture
  117668. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117669. * @returns the transformed texture
  117670. */
  117671. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117672. /**
  117673. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117674. * @param rootUrl the url of the texture
  117675. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117676. * @returns the fallback texture
  117677. */
  117678. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117679. /**
  117680. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117681. * @param data contains the texture data
  117682. * @param texture defines the BabylonJS internal texture
  117683. * @param createPolynomials will be true if polynomials have been requested
  117684. * @param onLoad defines the callback to trigger once the texture is ready
  117685. * @param onError defines the callback to trigger in case of error
  117686. */
  117687. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117688. /**
  117689. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117690. * @param data contains the texture data
  117691. * @param texture defines the BabylonJS internal texture
  117692. * @param callback defines the method to call once ready to upload
  117693. */
  117694. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117695. }
  117696. }
  117697. declare module BABYLON {
  117698. /**
  117699. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117700. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117701. */
  117702. export class KhronosTextureContainer {
  117703. /** contents of the KTX container file */
  117704. arrayBuffer: any;
  117705. private static HEADER_LEN;
  117706. private static COMPRESSED_2D;
  117707. private static COMPRESSED_3D;
  117708. private static TEX_2D;
  117709. private static TEX_3D;
  117710. /**
  117711. * Gets the openGL type
  117712. */
  117713. glType: number;
  117714. /**
  117715. * Gets the openGL type size
  117716. */
  117717. glTypeSize: number;
  117718. /**
  117719. * Gets the openGL format
  117720. */
  117721. glFormat: number;
  117722. /**
  117723. * Gets the openGL internal format
  117724. */
  117725. glInternalFormat: number;
  117726. /**
  117727. * Gets the base internal format
  117728. */
  117729. glBaseInternalFormat: number;
  117730. /**
  117731. * Gets image width in pixel
  117732. */
  117733. pixelWidth: number;
  117734. /**
  117735. * Gets image height in pixel
  117736. */
  117737. pixelHeight: number;
  117738. /**
  117739. * Gets image depth in pixels
  117740. */
  117741. pixelDepth: number;
  117742. /**
  117743. * Gets the number of array elements
  117744. */
  117745. numberOfArrayElements: number;
  117746. /**
  117747. * Gets the number of faces
  117748. */
  117749. numberOfFaces: number;
  117750. /**
  117751. * Gets the number of mipmap levels
  117752. */
  117753. numberOfMipmapLevels: number;
  117754. /**
  117755. * Gets the bytes of key value data
  117756. */
  117757. bytesOfKeyValueData: number;
  117758. /**
  117759. * Gets the load type
  117760. */
  117761. loadType: number;
  117762. /**
  117763. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117764. */
  117765. isInvalid: boolean;
  117766. /**
  117767. * Creates a new KhronosTextureContainer
  117768. * @param arrayBuffer contents of the KTX container file
  117769. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117770. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117771. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117772. */
  117773. constructor(
  117774. /** contents of the KTX container file */
  117775. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117776. /**
  117777. * Uploads KTX content to a Babylon Texture.
  117778. * It is assumed that the texture has already been created & is currently bound
  117779. * @hidden
  117780. */
  117781. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117782. private _upload2DCompressedLevels;
  117783. }
  117784. }
  117785. declare module BABYLON {
  117786. /**
  117787. * Implementation of the KTX Texture Loader.
  117788. * @hidden
  117789. */
  117790. export class _KTXTextureLoader implements IInternalTextureLoader {
  117791. /**
  117792. * Defines wether the loader supports cascade loading the different faces.
  117793. */
  117794. readonly supportCascades: boolean;
  117795. /**
  117796. * This returns if the loader support the current file information.
  117797. * @param extension defines the file extension of the file being loaded
  117798. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117799. * @param fallback defines the fallback internal texture if any
  117800. * @param isBase64 defines whether the texture is encoded as a base64
  117801. * @param isBuffer defines whether the texture data are stored as a buffer
  117802. * @returns true if the loader can load the specified file
  117803. */
  117804. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117805. /**
  117806. * Transform the url before loading if required.
  117807. * @param rootUrl the url of the texture
  117808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117809. * @returns the transformed texture
  117810. */
  117811. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117812. /**
  117813. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117814. * @param rootUrl the url of the texture
  117815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117816. * @returns the fallback texture
  117817. */
  117818. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117819. /**
  117820. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117821. * @param data contains the texture data
  117822. * @param texture defines the BabylonJS internal texture
  117823. * @param createPolynomials will be true if polynomials have been requested
  117824. * @param onLoad defines the callback to trigger once the texture is ready
  117825. * @param onError defines the callback to trigger in case of error
  117826. */
  117827. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117828. /**
  117829. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117830. * @param data contains the texture data
  117831. * @param texture defines the BabylonJS internal texture
  117832. * @param callback defines the method to call once ready to upload
  117833. */
  117834. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117835. }
  117836. }
  117837. declare module BABYLON {
  117838. /** @hidden */
  117839. export var _forceSceneHelpersToBundle: boolean;
  117840. interface Scene {
  117841. /**
  117842. * Creates a default light for the scene.
  117843. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117844. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117845. */
  117846. createDefaultLight(replace?: boolean): void;
  117847. /**
  117848. * Creates a default camera for the scene.
  117849. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117850. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117851. * @param replace has default false, when true replaces the active camera in the scene
  117852. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117853. */
  117854. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117855. /**
  117856. * Creates a default camera and a default light.
  117857. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117858. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117859. * @param replace has the default false, when true replaces the active camera/light in the scene
  117860. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117861. */
  117862. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117863. /**
  117864. * Creates a new sky box
  117865. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117866. * @param environmentTexture defines the texture to use as environment texture
  117867. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117868. * @param scale defines the overall scale of the skybox
  117869. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117870. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117871. * @returns a new mesh holding the sky box
  117872. */
  117873. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117874. /**
  117875. * Creates a new environment
  117876. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117877. * @param options defines the options you can use to configure the environment
  117878. * @returns the new EnvironmentHelper
  117879. */
  117880. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117881. /**
  117882. * Creates a new VREXperienceHelper
  117883. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117884. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117885. * @returns a new VREXperienceHelper
  117886. */
  117887. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117888. /**
  117889. * Creates a new WebXRDefaultExperience
  117890. * @see http://doc.babylonjs.com/how_to/webxr
  117891. * @param options experience options
  117892. * @returns a promise for a new WebXRDefaultExperience
  117893. */
  117894. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117895. }
  117896. }
  117897. declare module BABYLON {
  117898. /**
  117899. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117900. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117901. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117902. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117903. */
  117904. export class VideoDome extends TransformNode {
  117905. /**
  117906. * Define the video source as a Monoscopic panoramic 360 video.
  117907. */
  117908. static readonly MODE_MONOSCOPIC: number;
  117909. /**
  117910. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117911. */
  117912. static readonly MODE_TOPBOTTOM: number;
  117913. /**
  117914. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117915. */
  117916. static readonly MODE_SIDEBYSIDE: number;
  117917. private _halfDome;
  117918. private _useDirectMapping;
  117919. /**
  117920. * The video texture being displayed on the sphere
  117921. */
  117922. protected _videoTexture: VideoTexture;
  117923. /**
  117924. * Gets the video texture being displayed on the sphere
  117925. */
  117926. readonly videoTexture: VideoTexture;
  117927. /**
  117928. * The skybox material
  117929. */
  117930. protected _material: BackgroundMaterial;
  117931. /**
  117932. * The surface used for the skybox
  117933. */
  117934. protected _mesh: Mesh;
  117935. /**
  117936. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117937. */
  117938. private _halfDomeMask;
  117939. /**
  117940. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117941. * Also see the options.resolution property.
  117942. */
  117943. fovMultiplier: number;
  117944. private _videoMode;
  117945. /**
  117946. * Gets or set the current video mode for the video. It can be:
  117947. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117948. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117949. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117950. */
  117951. videoMode: number;
  117952. /**
  117953. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117954. *
  117955. */
  117956. /**
  117957. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117958. */
  117959. halfDome: boolean;
  117960. /**
  117961. * Oberserver used in Stereoscopic VR Mode.
  117962. */
  117963. private _onBeforeCameraRenderObserver;
  117964. /**
  117965. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117966. * @param name Element's name, child elements will append suffixes for their own names.
  117967. * @param urlsOrVideo defines the url(s) or the video element to use
  117968. * @param options An object containing optional or exposed sub element properties
  117969. */
  117970. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117971. resolution?: number;
  117972. clickToPlay?: boolean;
  117973. autoPlay?: boolean;
  117974. loop?: boolean;
  117975. size?: number;
  117976. poster?: string;
  117977. faceForward?: boolean;
  117978. useDirectMapping?: boolean;
  117979. halfDomeMode?: boolean;
  117980. }, scene: Scene);
  117981. private _changeVideoMode;
  117982. /**
  117983. * Releases resources associated with this node.
  117984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117986. */
  117987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117988. }
  117989. }
  117990. declare module BABYLON {
  117991. /**
  117992. * This class can be used to get instrumentation data from a Babylon engine
  117993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117994. */
  117995. export class EngineInstrumentation implements IDisposable {
  117996. /**
  117997. * Define the instrumented engine.
  117998. */
  117999. engine: Engine;
  118000. private _captureGPUFrameTime;
  118001. private _gpuFrameTimeToken;
  118002. private _gpuFrameTime;
  118003. private _captureShaderCompilationTime;
  118004. private _shaderCompilationTime;
  118005. private _onBeginFrameObserver;
  118006. private _onEndFrameObserver;
  118007. private _onBeforeShaderCompilationObserver;
  118008. private _onAfterShaderCompilationObserver;
  118009. /**
  118010. * Gets the perf counter used for GPU frame time
  118011. */
  118012. readonly gpuFrameTimeCounter: PerfCounter;
  118013. /**
  118014. * Gets the GPU frame time capture status
  118015. */
  118016. /**
  118017. * Enable or disable the GPU frame time capture
  118018. */
  118019. captureGPUFrameTime: boolean;
  118020. /**
  118021. * Gets the perf counter used for shader compilation time
  118022. */
  118023. readonly shaderCompilationTimeCounter: PerfCounter;
  118024. /**
  118025. * Gets the shader compilation time capture status
  118026. */
  118027. /**
  118028. * Enable or disable the shader compilation time capture
  118029. */
  118030. captureShaderCompilationTime: boolean;
  118031. /**
  118032. * Instantiates a new engine instrumentation.
  118033. * This class can be used to get instrumentation data from a Babylon engine
  118034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118035. * @param engine Defines the engine to instrument
  118036. */
  118037. constructor(
  118038. /**
  118039. * Define the instrumented engine.
  118040. */
  118041. engine: Engine);
  118042. /**
  118043. * Dispose and release associated resources.
  118044. */
  118045. dispose(): void;
  118046. }
  118047. }
  118048. declare module BABYLON {
  118049. /**
  118050. * This class can be used to get instrumentation data from a Babylon engine
  118051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118052. */
  118053. export class SceneInstrumentation implements IDisposable {
  118054. /**
  118055. * Defines the scene to instrument
  118056. */
  118057. scene: Scene;
  118058. private _captureActiveMeshesEvaluationTime;
  118059. private _activeMeshesEvaluationTime;
  118060. private _captureRenderTargetsRenderTime;
  118061. private _renderTargetsRenderTime;
  118062. private _captureFrameTime;
  118063. private _frameTime;
  118064. private _captureRenderTime;
  118065. private _renderTime;
  118066. private _captureInterFrameTime;
  118067. private _interFrameTime;
  118068. private _captureParticlesRenderTime;
  118069. private _particlesRenderTime;
  118070. private _captureSpritesRenderTime;
  118071. private _spritesRenderTime;
  118072. private _capturePhysicsTime;
  118073. private _physicsTime;
  118074. private _captureAnimationsTime;
  118075. private _animationsTime;
  118076. private _captureCameraRenderTime;
  118077. private _cameraRenderTime;
  118078. private _onBeforeActiveMeshesEvaluationObserver;
  118079. private _onAfterActiveMeshesEvaluationObserver;
  118080. private _onBeforeRenderTargetsRenderObserver;
  118081. private _onAfterRenderTargetsRenderObserver;
  118082. private _onAfterRenderObserver;
  118083. private _onBeforeDrawPhaseObserver;
  118084. private _onAfterDrawPhaseObserver;
  118085. private _onBeforeAnimationsObserver;
  118086. private _onBeforeParticlesRenderingObserver;
  118087. private _onAfterParticlesRenderingObserver;
  118088. private _onBeforeSpritesRenderingObserver;
  118089. private _onAfterSpritesRenderingObserver;
  118090. private _onBeforePhysicsObserver;
  118091. private _onAfterPhysicsObserver;
  118092. private _onAfterAnimationsObserver;
  118093. private _onBeforeCameraRenderObserver;
  118094. private _onAfterCameraRenderObserver;
  118095. /**
  118096. * Gets the perf counter used for active meshes evaluation time
  118097. */
  118098. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118099. /**
  118100. * Gets the active meshes evaluation time capture status
  118101. */
  118102. /**
  118103. * Enable or disable the active meshes evaluation time capture
  118104. */
  118105. captureActiveMeshesEvaluationTime: boolean;
  118106. /**
  118107. * Gets the perf counter used for render targets render time
  118108. */
  118109. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118110. /**
  118111. * Gets the render targets render time capture status
  118112. */
  118113. /**
  118114. * Enable or disable the render targets render time capture
  118115. */
  118116. captureRenderTargetsRenderTime: boolean;
  118117. /**
  118118. * Gets the perf counter used for particles render time
  118119. */
  118120. readonly particlesRenderTimeCounter: PerfCounter;
  118121. /**
  118122. * Gets the particles render time capture status
  118123. */
  118124. /**
  118125. * Enable or disable the particles render time capture
  118126. */
  118127. captureParticlesRenderTime: boolean;
  118128. /**
  118129. * Gets the perf counter used for sprites render time
  118130. */
  118131. readonly spritesRenderTimeCounter: PerfCounter;
  118132. /**
  118133. * Gets the sprites render time capture status
  118134. */
  118135. /**
  118136. * Enable or disable the sprites render time capture
  118137. */
  118138. captureSpritesRenderTime: boolean;
  118139. /**
  118140. * Gets the perf counter used for physics time
  118141. */
  118142. readonly physicsTimeCounter: PerfCounter;
  118143. /**
  118144. * Gets the physics time capture status
  118145. */
  118146. /**
  118147. * Enable or disable the physics time capture
  118148. */
  118149. capturePhysicsTime: boolean;
  118150. /**
  118151. * Gets the perf counter used for animations time
  118152. */
  118153. readonly animationsTimeCounter: PerfCounter;
  118154. /**
  118155. * Gets the animations time capture status
  118156. */
  118157. /**
  118158. * Enable or disable the animations time capture
  118159. */
  118160. captureAnimationsTime: boolean;
  118161. /**
  118162. * Gets the perf counter used for frame time capture
  118163. */
  118164. readonly frameTimeCounter: PerfCounter;
  118165. /**
  118166. * Gets the frame time capture status
  118167. */
  118168. /**
  118169. * Enable or disable the frame time capture
  118170. */
  118171. captureFrameTime: boolean;
  118172. /**
  118173. * Gets the perf counter used for inter-frames time capture
  118174. */
  118175. readonly interFrameTimeCounter: PerfCounter;
  118176. /**
  118177. * Gets the inter-frames time capture status
  118178. */
  118179. /**
  118180. * Enable or disable the inter-frames time capture
  118181. */
  118182. captureInterFrameTime: boolean;
  118183. /**
  118184. * Gets the perf counter used for render time capture
  118185. */
  118186. readonly renderTimeCounter: PerfCounter;
  118187. /**
  118188. * Gets the render time capture status
  118189. */
  118190. /**
  118191. * Enable or disable the render time capture
  118192. */
  118193. captureRenderTime: boolean;
  118194. /**
  118195. * Gets the perf counter used for camera render time capture
  118196. */
  118197. readonly cameraRenderTimeCounter: PerfCounter;
  118198. /**
  118199. * Gets the camera render time capture status
  118200. */
  118201. /**
  118202. * Enable or disable the camera render time capture
  118203. */
  118204. captureCameraRenderTime: boolean;
  118205. /**
  118206. * Gets the perf counter used for draw calls
  118207. */
  118208. readonly drawCallsCounter: PerfCounter;
  118209. /**
  118210. * Instantiates a new scene instrumentation.
  118211. * This class can be used to get instrumentation data from a Babylon engine
  118212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118213. * @param scene Defines the scene to instrument
  118214. */
  118215. constructor(
  118216. /**
  118217. * Defines the scene to instrument
  118218. */
  118219. scene: Scene);
  118220. /**
  118221. * Dispose and release associated resources.
  118222. */
  118223. dispose(): void;
  118224. }
  118225. }
  118226. declare module BABYLON {
  118227. /** @hidden */
  118228. export var glowMapGenerationPixelShader: {
  118229. name: string;
  118230. shader: string;
  118231. };
  118232. }
  118233. declare module BABYLON {
  118234. /** @hidden */
  118235. export var glowMapGenerationVertexShader: {
  118236. name: string;
  118237. shader: string;
  118238. };
  118239. }
  118240. declare module BABYLON {
  118241. /**
  118242. * Effect layer options. This helps customizing the behaviour
  118243. * of the effect layer.
  118244. */
  118245. export interface IEffectLayerOptions {
  118246. /**
  118247. * Multiplication factor apply to the canvas size to compute the render target size
  118248. * used to generated the objects (the smaller the faster).
  118249. */
  118250. mainTextureRatio: number;
  118251. /**
  118252. * Enforces a fixed size texture to ensure effect stability across devices.
  118253. */
  118254. mainTextureFixedSize?: number;
  118255. /**
  118256. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118257. */
  118258. alphaBlendingMode: number;
  118259. /**
  118260. * The camera attached to the layer.
  118261. */
  118262. camera: Nullable<Camera>;
  118263. /**
  118264. * The rendering group to draw the layer in.
  118265. */
  118266. renderingGroupId: number;
  118267. }
  118268. /**
  118269. * The effect layer Helps adding post process effect blended with the main pass.
  118270. *
  118271. * This can be for instance use to generate glow or higlight effects on the scene.
  118272. *
  118273. * The effect layer class can not be used directly and is intented to inherited from to be
  118274. * customized per effects.
  118275. */
  118276. export abstract class EffectLayer {
  118277. private _vertexBuffers;
  118278. private _indexBuffer;
  118279. private _cachedDefines;
  118280. private _effectLayerMapGenerationEffect;
  118281. private _effectLayerOptions;
  118282. private _mergeEffect;
  118283. protected _scene: Scene;
  118284. protected _engine: Engine;
  118285. protected _maxSize: number;
  118286. protected _mainTextureDesiredSize: ISize;
  118287. protected _mainTexture: RenderTargetTexture;
  118288. protected _shouldRender: boolean;
  118289. protected _postProcesses: PostProcess[];
  118290. protected _textures: BaseTexture[];
  118291. protected _emissiveTextureAndColor: {
  118292. texture: Nullable<BaseTexture>;
  118293. color: Color4;
  118294. };
  118295. /**
  118296. * The name of the layer
  118297. */
  118298. name: string;
  118299. /**
  118300. * The clear color of the texture used to generate the glow map.
  118301. */
  118302. neutralColor: Color4;
  118303. /**
  118304. * Specifies wether the highlight layer is enabled or not.
  118305. */
  118306. isEnabled: boolean;
  118307. /**
  118308. * Gets the camera attached to the layer.
  118309. */
  118310. readonly camera: Nullable<Camera>;
  118311. /**
  118312. * Gets the rendering group id the layer should render in.
  118313. */
  118314. renderingGroupId: number;
  118315. /**
  118316. * An event triggered when the effect layer has been disposed.
  118317. */
  118318. onDisposeObservable: Observable<EffectLayer>;
  118319. /**
  118320. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118321. */
  118322. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118323. /**
  118324. * An event triggered when the generated texture is being merged in the scene.
  118325. */
  118326. onBeforeComposeObservable: Observable<EffectLayer>;
  118327. /**
  118328. * An event triggered when the mesh is rendered into the effect render target.
  118329. */
  118330. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118331. /**
  118332. * An event triggered after the mesh has been rendered into the effect render target.
  118333. */
  118334. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118335. /**
  118336. * An event triggered when the generated texture has been merged in the scene.
  118337. */
  118338. onAfterComposeObservable: Observable<EffectLayer>;
  118339. /**
  118340. * An event triggered when the efffect layer changes its size.
  118341. */
  118342. onSizeChangedObservable: Observable<EffectLayer>;
  118343. /** @hidden */
  118344. static _SceneComponentInitialization: (scene: Scene) => void;
  118345. /**
  118346. * Instantiates a new effect Layer and references it in the scene.
  118347. * @param name The name of the layer
  118348. * @param scene The scene to use the layer in
  118349. */
  118350. constructor(
  118351. /** The Friendly of the effect in the scene */
  118352. name: string, scene: Scene);
  118353. /**
  118354. * Get the effect name of the layer.
  118355. * @return The effect name
  118356. */
  118357. abstract getEffectName(): string;
  118358. /**
  118359. * Checks for the readiness of the element composing the layer.
  118360. * @param subMesh the mesh to check for
  118361. * @param useInstances specify wether or not to use instances to render the mesh
  118362. * @return true if ready otherwise, false
  118363. */
  118364. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118365. /**
  118366. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118367. * @returns true if the effect requires stencil during the main canvas render pass.
  118368. */
  118369. abstract needStencil(): boolean;
  118370. /**
  118371. * Create the merge effect. This is the shader use to blit the information back
  118372. * to the main canvas at the end of the scene rendering.
  118373. * @returns The effect containing the shader used to merge the effect on the main canvas
  118374. */
  118375. protected abstract _createMergeEffect(): Effect;
  118376. /**
  118377. * Creates the render target textures and post processes used in the effect layer.
  118378. */
  118379. protected abstract _createTextureAndPostProcesses(): void;
  118380. /**
  118381. * Implementation specific of rendering the generating effect on the main canvas.
  118382. * @param effect The effect used to render through
  118383. */
  118384. protected abstract _internalRender(effect: Effect): void;
  118385. /**
  118386. * Sets the required values for both the emissive texture and and the main color.
  118387. */
  118388. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118389. /**
  118390. * Free any resources and references associated to a mesh.
  118391. * Internal use
  118392. * @param mesh The mesh to free.
  118393. */
  118394. abstract _disposeMesh(mesh: Mesh): void;
  118395. /**
  118396. * Serializes this layer (Glow or Highlight for example)
  118397. * @returns a serialized layer object
  118398. */
  118399. abstract serialize?(): any;
  118400. /**
  118401. * Initializes the effect layer with the required options.
  118402. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118403. */
  118404. protected _init(options: Partial<IEffectLayerOptions>): void;
  118405. /**
  118406. * Generates the index buffer of the full screen quad blending to the main canvas.
  118407. */
  118408. private _generateIndexBuffer;
  118409. /**
  118410. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118411. */
  118412. private _generateVertexBuffer;
  118413. /**
  118414. * Sets the main texture desired size which is the closest power of two
  118415. * of the engine canvas size.
  118416. */
  118417. private _setMainTextureSize;
  118418. /**
  118419. * Creates the main texture for the effect layer.
  118420. */
  118421. protected _createMainTexture(): void;
  118422. /**
  118423. * Adds specific effects defines.
  118424. * @param defines The defines to add specifics to.
  118425. */
  118426. protected _addCustomEffectDefines(defines: string[]): void;
  118427. /**
  118428. * Checks for the readiness of the element composing the layer.
  118429. * @param subMesh the mesh to check for
  118430. * @param useInstances specify wether or not to use instances to render the mesh
  118431. * @param emissiveTexture the associated emissive texture used to generate the glow
  118432. * @return true if ready otherwise, false
  118433. */
  118434. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118435. /**
  118436. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118437. */
  118438. render(): void;
  118439. /**
  118440. * Determine if a given mesh will be used in the current effect.
  118441. * @param mesh mesh to test
  118442. * @returns true if the mesh will be used
  118443. */
  118444. hasMesh(mesh: AbstractMesh): boolean;
  118445. /**
  118446. * Returns true if the layer contains information to display, otherwise false.
  118447. * @returns true if the glow layer should be rendered
  118448. */
  118449. shouldRender(): boolean;
  118450. /**
  118451. * Returns true if the mesh should render, otherwise false.
  118452. * @param mesh The mesh to render
  118453. * @returns true if it should render otherwise false
  118454. */
  118455. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118456. /**
  118457. * Returns true if the mesh can be rendered, otherwise false.
  118458. * @param mesh The mesh to render
  118459. * @param material The material used on the mesh
  118460. * @returns true if it can be rendered otherwise false
  118461. */
  118462. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118463. /**
  118464. * Returns true if the mesh should render, otherwise false.
  118465. * @param mesh The mesh to render
  118466. * @returns true if it should render otherwise false
  118467. */
  118468. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118469. /**
  118470. * Renders the submesh passed in parameter to the generation map.
  118471. */
  118472. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118473. /**
  118474. * Defines wether the current material of the mesh should be use to render the effect.
  118475. * @param mesh defines the current mesh to render
  118476. */
  118477. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118478. /**
  118479. * Rebuild the required buffers.
  118480. * @hidden Internal use only.
  118481. */
  118482. _rebuild(): void;
  118483. /**
  118484. * Dispose only the render target textures and post process.
  118485. */
  118486. private _disposeTextureAndPostProcesses;
  118487. /**
  118488. * Dispose the highlight layer and free resources.
  118489. */
  118490. dispose(): void;
  118491. /**
  118492. * Gets the class name of the effect layer
  118493. * @returns the string with the class name of the effect layer
  118494. */
  118495. getClassName(): string;
  118496. /**
  118497. * Creates an effect layer from parsed effect layer data
  118498. * @param parsedEffectLayer defines effect layer data
  118499. * @param scene defines the current scene
  118500. * @param rootUrl defines the root URL containing the effect layer information
  118501. * @returns a parsed effect Layer
  118502. */
  118503. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118504. }
  118505. }
  118506. declare module BABYLON {
  118507. interface AbstractScene {
  118508. /**
  118509. * The list of effect layers (highlights/glow) added to the scene
  118510. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118511. * @see http://doc.babylonjs.com/how_to/glow_layer
  118512. */
  118513. effectLayers: Array<EffectLayer>;
  118514. /**
  118515. * Removes the given effect layer from this scene.
  118516. * @param toRemove defines the effect layer to remove
  118517. * @returns the index of the removed effect layer
  118518. */
  118519. removeEffectLayer(toRemove: EffectLayer): number;
  118520. /**
  118521. * Adds the given effect layer to this scene
  118522. * @param newEffectLayer defines the effect layer to add
  118523. */
  118524. addEffectLayer(newEffectLayer: EffectLayer): void;
  118525. }
  118526. /**
  118527. * Defines the layer scene component responsible to manage any effect layers
  118528. * in a given scene.
  118529. */
  118530. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118531. /**
  118532. * The component name helpfull to identify the component in the list of scene components.
  118533. */
  118534. readonly name: string;
  118535. /**
  118536. * The scene the component belongs to.
  118537. */
  118538. scene: Scene;
  118539. private _engine;
  118540. private _renderEffects;
  118541. private _needStencil;
  118542. private _previousStencilState;
  118543. /**
  118544. * Creates a new instance of the component for the given scene
  118545. * @param scene Defines the scene to register the component in
  118546. */
  118547. constructor(scene: Scene);
  118548. /**
  118549. * Registers the component in a given scene
  118550. */
  118551. register(): void;
  118552. /**
  118553. * Rebuilds the elements related to this component in case of
  118554. * context lost for instance.
  118555. */
  118556. rebuild(): void;
  118557. /**
  118558. * Serializes the component data to the specified json object
  118559. * @param serializationObject The object to serialize to
  118560. */
  118561. serialize(serializationObject: any): void;
  118562. /**
  118563. * Adds all the elements from the container to the scene
  118564. * @param container the container holding the elements
  118565. */
  118566. addFromContainer(container: AbstractScene): void;
  118567. /**
  118568. * Removes all the elements in the container from the scene
  118569. * @param container contains the elements to remove
  118570. * @param dispose if the removed element should be disposed (default: false)
  118571. */
  118572. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118573. /**
  118574. * Disposes the component and the associated ressources.
  118575. */
  118576. dispose(): void;
  118577. private _isReadyForMesh;
  118578. private _renderMainTexture;
  118579. private _setStencil;
  118580. private _setStencilBack;
  118581. private _draw;
  118582. private _drawCamera;
  118583. private _drawRenderingGroup;
  118584. }
  118585. }
  118586. declare module BABYLON {
  118587. /** @hidden */
  118588. export var glowMapMergePixelShader: {
  118589. name: string;
  118590. shader: string;
  118591. };
  118592. }
  118593. declare module BABYLON {
  118594. /** @hidden */
  118595. export var glowMapMergeVertexShader: {
  118596. name: string;
  118597. shader: string;
  118598. };
  118599. }
  118600. declare module BABYLON {
  118601. interface AbstractScene {
  118602. /**
  118603. * Return a the first highlight layer of the scene with a given name.
  118604. * @param name The name of the highlight layer to look for.
  118605. * @return The highlight layer if found otherwise null.
  118606. */
  118607. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118608. }
  118609. /**
  118610. * Glow layer options. This helps customizing the behaviour
  118611. * of the glow layer.
  118612. */
  118613. export interface IGlowLayerOptions {
  118614. /**
  118615. * Multiplication factor apply to the canvas size to compute the render target size
  118616. * used to generated the glowing objects (the smaller the faster).
  118617. */
  118618. mainTextureRatio: number;
  118619. /**
  118620. * Enforces a fixed size texture to ensure resize independant blur.
  118621. */
  118622. mainTextureFixedSize?: number;
  118623. /**
  118624. * How big is the kernel of the blur texture.
  118625. */
  118626. blurKernelSize: number;
  118627. /**
  118628. * The camera attached to the layer.
  118629. */
  118630. camera: Nullable<Camera>;
  118631. /**
  118632. * Enable MSAA by chosing the number of samples.
  118633. */
  118634. mainTextureSamples?: number;
  118635. /**
  118636. * The rendering group to draw the layer in.
  118637. */
  118638. renderingGroupId: number;
  118639. }
  118640. /**
  118641. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118642. *
  118643. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118644. *
  118645. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118646. */
  118647. export class GlowLayer extends EffectLayer {
  118648. /**
  118649. * Effect Name of the layer.
  118650. */
  118651. static readonly EffectName: string;
  118652. /**
  118653. * The default blur kernel size used for the glow.
  118654. */
  118655. static DefaultBlurKernelSize: number;
  118656. /**
  118657. * The default texture size ratio used for the glow.
  118658. */
  118659. static DefaultTextureRatio: number;
  118660. /**
  118661. * Sets the kernel size of the blur.
  118662. */
  118663. /**
  118664. * Gets the kernel size of the blur.
  118665. */
  118666. blurKernelSize: number;
  118667. /**
  118668. * Sets the glow intensity.
  118669. */
  118670. /**
  118671. * Gets the glow intensity.
  118672. */
  118673. intensity: number;
  118674. private _options;
  118675. private _intensity;
  118676. private _horizontalBlurPostprocess1;
  118677. private _verticalBlurPostprocess1;
  118678. private _horizontalBlurPostprocess2;
  118679. private _verticalBlurPostprocess2;
  118680. private _blurTexture1;
  118681. private _blurTexture2;
  118682. private _postProcesses1;
  118683. private _postProcesses2;
  118684. private _includedOnlyMeshes;
  118685. private _excludedMeshes;
  118686. private _meshesUsingTheirOwnMaterials;
  118687. /**
  118688. * Callback used to let the user override the color selection on a per mesh basis
  118689. */
  118690. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118691. /**
  118692. * Callback used to let the user override the texture selection on a per mesh basis
  118693. */
  118694. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118695. /**
  118696. * Instantiates a new glow Layer and references it to the scene.
  118697. * @param name The name of the layer
  118698. * @param scene The scene to use the layer in
  118699. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118700. */
  118701. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118702. /**
  118703. * Get the effect name of the layer.
  118704. * @return The effect name
  118705. */
  118706. getEffectName(): string;
  118707. /**
  118708. * Create the merge effect. This is the shader use to blit the information back
  118709. * to the main canvas at the end of the scene rendering.
  118710. */
  118711. protected _createMergeEffect(): Effect;
  118712. /**
  118713. * Creates the render target textures and post processes used in the glow layer.
  118714. */
  118715. protected _createTextureAndPostProcesses(): void;
  118716. /**
  118717. * Checks for the readiness of the element composing the layer.
  118718. * @param subMesh the mesh to check for
  118719. * @param useInstances specify wether or not to use instances to render the mesh
  118720. * @param emissiveTexture the associated emissive texture used to generate the glow
  118721. * @return true if ready otherwise, false
  118722. */
  118723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118724. /**
  118725. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118726. */
  118727. needStencil(): boolean;
  118728. /**
  118729. * Returns true if the mesh can be rendered, otherwise false.
  118730. * @param mesh The mesh to render
  118731. * @param material The material used on the mesh
  118732. * @returns true if it can be rendered otherwise false
  118733. */
  118734. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118735. /**
  118736. * Implementation specific of rendering the generating effect on the main canvas.
  118737. * @param effect The effect used to render through
  118738. */
  118739. protected _internalRender(effect: Effect): void;
  118740. /**
  118741. * Sets the required values for both the emissive texture and and the main color.
  118742. */
  118743. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118744. /**
  118745. * Returns true if the mesh should render, otherwise false.
  118746. * @param mesh The mesh to render
  118747. * @returns true if it should render otherwise false
  118748. */
  118749. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118750. /**
  118751. * Adds specific effects defines.
  118752. * @param defines The defines to add specifics to.
  118753. */
  118754. protected _addCustomEffectDefines(defines: string[]): void;
  118755. /**
  118756. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118757. * @param mesh The mesh to exclude from the glow layer
  118758. */
  118759. addExcludedMesh(mesh: Mesh): void;
  118760. /**
  118761. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118762. * @param mesh The mesh to remove
  118763. */
  118764. removeExcludedMesh(mesh: Mesh): void;
  118765. /**
  118766. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118767. * @param mesh The mesh to include in the glow layer
  118768. */
  118769. addIncludedOnlyMesh(mesh: Mesh): void;
  118770. /**
  118771. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118772. * @param mesh The mesh to remove
  118773. */
  118774. removeIncludedOnlyMesh(mesh: Mesh): void;
  118775. /**
  118776. * Determine if a given mesh will be used in the glow layer
  118777. * @param mesh The mesh to test
  118778. * @returns true if the mesh will be highlighted by the current glow layer
  118779. */
  118780. hasMesh(mesh: AbstractMesh): boolean;
  118781. /**
  118782. * Defines wether the current material of the mesh should be use to render the effect.
  118783. * @param mesh defines the current mesh to render
  118784. */
  118785. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118786. /**
  118787. * Add a mesh to be rendered through its own material and not with emissive only.
  118788. * @param mesh The mesh for which we need to use its material
  118789. */
  118790. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118791. /**
  118792. * Remove a mesh from being rendered through its own material and not with emissive only.
  118793. * @param mesh The mesh for which we need to not use its material
  118794. */
  118795. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118796. /**
  118797. * Free any resources and references associated to a mesh.
  118798. * Internal use
  118799. * @param mesh The mesh to free.
  118800. * @hidden
  118801. */
  118802. _disposeMesh(mesh: Mesh): void;
  118803. /**
  118804. * Gets the class name of the effect layer
  118805. * @returns the string with the class name of the effect layer
  118806. */
  118807. getClassName(): string;
  118808. /**
  118809. * Serializes this glow layer
  118810. * @returns a serialized glow layer object
  118811. */
  118812. serialize(): any;
  118813. /**
  118814. * Creates a Glow Layer from parsed glow layer data
  118815. * @param parsedGlowLayer defines glow layer data
  118816. * @param scene defines the current scene
  118817. * @param rootUrl defines the root URL containing the glow layer information
  118818. * @returns a parsed Glow Layer
  118819. */
  118820. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118821. }
  118822. }
  118823. declare module BABYLON {
  118824. /** @hidden */
  118825. export var glowBlurPostProcessPixelShader: {
  118826. name: string;
  118827. shader: string;
  118828. };
  118829. }
  118830. declare module BABYLON {
  118831. interface AbstractScene {
  118832. /**
  118833. * Return a the first highlight layer of the scene with a given name.
  118834. * @param name The name of the highlight layer to look for.
  118835. * @return The highlight layer if found otherwise null.
  118836. */
  118837. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118838. }
  118839. /**
  118840. * Highlight layer options. This helps customizing the behaviour
  118841. * of the highlight layer.
  118842. */
  118843. export interface IHighlightLayerOptions {
  118844. /**
  118845. * Multiplication factor apply to the canvas size to compute the render target size
  118846. * used to generated the glowing objects (the smaller the faster).
  118847. */
  118848. mainTextureRatio: number;
  118849. /**
  118850. * Enforces a fixed size texture to ensure resize independant blur.
  118851. */
  118852. mainTextureFixedSize?: number;
  118853. /**
  118854. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118855. * of the picture to blur (the smaller the faster).
  118856. */
  118857. blurTextureSizeRatio: number;
  118858. /**
  118859. * How big in texel of the blur texture is the vertical blur.
  118860. */
  118861. blurVerticalSize: number;
  118862. /**
  118863. * How big in texel of the blur texture is the horizontal blur.
  118864. */
  118865. blurHorizontalSize: number;
  118866. /**
  118867. * Alpha blending mode used to apply the blur. Default is combine.
  118868. */
  118869. alphaBlendingMode: number;
  118870. /**
  118871. * The camera attached to the layer.
  118872. */
  118873. camera: Nullable<Camera>;
  118874. /**
  118875. * Should we display highlight as a solid stroke?
  118876. */
  118877. isStroke?: boolean;
  118878. /**
  118879. * The rendering group to draw the layer in.
  118880. */
  118881. renderingGroupId: number;
  118882. }
  118883. /**
  118884. * The highlight layer Helps adding a glow effect around a mesh.
  118885. *
  118886. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118887. * glowy meshes to your scene.
  118888. *
  118889. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118890. */
  118891. export class HighlightLayer extends EffectLayer {
  118892. name: string;
  118893. /**
  118894. * Effect Name of the highlight layer.
  118895. */
  118896. static readonly EffectName: string;
  118897. /**
  118898. * The neutral color used during the preparation of the glow effect.
  118899. * This is black by default as the blend operation is a blend operation.
  118900. */
  118901. static NeutralColor: Color4;
  118902. /**
  118903. * Stencil value used for glowing meshes.
  118904. */
  118905. static GlowingMeshStencilReference: number;
  118906. /**
  118907. * Stencil value used for the other meshes in the scene.
  118908. */
  118909. static NormalMeshStencilReference: number;
  118910. /**
  118911. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118912. */
  118913. innerGlow: boolean;
  118914. /**
  118915. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118916. */
  118917. outerGlow: boolean;
  118918. /**
  118919. * Specifies the horizontal size of the blur.
  118920. */
  118921. /**
  118922. * Gets the horizontal size of the blur.
  118923. */
  118924. blurHorizontalSize: number;
  118925. /**
  118926. * Specifies the vertical size of the blur.
  118927. */
  118928. /**
  118929. * Gets the vertical size of the blur.
  118930. */
  118931. blurVerticalSize: number;
  118932. /**
  118933. * An event triggered when the highlight layer is being blurred.
  118934. */
  118935. onBeforeBlurObservable: Observable<HighlightLayer>;
  118936. /**
  118937. * An event triggered when the highlight layer has been blurred.
  118938. */
  118939. onAfterBlurObservable: Observable<HighlightLayer>;
  118940. private _instanceGlowingMeshStencilReference;
  118941. private _options;
  118942. private _downSamplePostprocess;
  118943. private _horizontalBlurPostprocess;
  118944. private _verticalBlurPostprocess;
  118945. private _blurTexture;
  118946. private _meshes;
  118947. private _excludedMeshes;
  118948. /**
  118949. * Instantiates a new highlight Layer and references it to the scene..
  118950. * @param name The name of the layer
  118951. * @param scene The scene to use the layer in
  118952. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118953. */
  118954. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118955. /**
  118956. * Get the effect name of the layer.
  118957. * @return The effect name
  118958. */
  118959. getEffectName(): string;
  118960. /**
  118961. * Create the merge effect. This is the shader use to blit the information back
  118962. * to the main canvas at the end of the scene rendering.
  118963. */
  118964. protected _createMergeEffect(): Effect;
  118965. /**
  118966. * Creates the render target textures and post processes used in the highlight layer.
  118967. */
  118968. protected _createTextureAndPostProcesses(): void;
  118969. /**
  118970. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118971. */
  118972. needStencil(): boolean;
  118973. /**
  118974. * Checks for the readiness of the element composing the layer.
  118975. * @param subMesh the mesh to check for
  118976. * @param useInstances specify wether or not to use instances to render the mesh
  118977. * @param emissiveTexture the associated emissive texture used to generate the glow
  118978. * @return true if ready otherwise, false
  118979. */
  118980. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118981. /**
  118982. * Implementation specific of rendering the generating effect on the main canvas.
  118983. * @param effect The effect used to render through
  118984. */
  118985. protected _internalRender(effect: Effect): void;
  118986. /**
  118987. * Returns true if the layer contains information to display, otherwise false.
  118988. */
  118989. shouldRender(): boolean;
  118990. /**
  118991. * Returns true if the mesh should render, otherwise false.
  118992. * @param mesh The mesh to render
  118993. * @returns true if it should render otherwise false
  118994. */
  118995. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118996. /**
  118997. * Sets the required values for both the emissive texture and and the main color.
  118998. */
  118999. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119000. /**
  119001. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119002. * @param mesh The mesh to exclude from the highlight layer
  119003. */
  119004. addExcludedMesh(mesh: Mesh): void;
  119005. /**
  119006. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119007. * @param mesh The mesh to highlight
  119008. */
  119009. removeExcludedMesh(mesh: Mesh): void;
  119010. /**
  119011. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119012. * @param mesh mesh to test
  119013. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119014. */
  119015. hasMesh(mesh: AbstractMesh): boolean;
  119016. /**
  119017. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119018. * @param mesh The mesh to highlight
  119019. * @param color The color of the highlight
  119020. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119021. */
  119022. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119023. /**
  119024. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119025. * @param mesh The mesh to highlight
  119026. */
  119027. removeMesh(mesh: Mesh): void;
  119028. /**
  119029. * Force the stencil to the normal expected value for none glowing parts
  119030. */
  119031. private _defaultStencilReference;
  119032. /**
  119033. * Free any resources and references associated to a mesh.
  119034. * Internal use
  119035. * @param mesh The mesh to free.
  119036. * @hidden
  119037. */
  119038. _disposeMesh(mesh: Mesh): void;
  119039. /**
  119040. * Dispose the highlight layer and free resources.
  119041. */
  119042. dispose(): void;
  119043. /**
  119044. * Gets the class name of the effect layer
  119045. * @returns the string with the class name of the effect layer
  119046. */
  119047. getClassName(): string;
  119048. /**
  119049. * Serializes this Highlight layer
  119050. * @returns a serialized Highlight layer object
  119051. */
  119052. serialize(): any;
  119053. /**
  119054. * Creates a Highlight layer from parsed Highlight layer data
  119055. * @param parsedHightlightLayer defines the Highlight layer data
  119056. * @param scene defines the current scene
  119057. * @param rootUrl defines the root URL containing the Highlight layer information
  119058. * @returns a parsed Highlight layer
  119059. */
  119060. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119061. }
  119062. }
  119063. declare module BABYLON {
  119064. interface AbstractScene {
  119065. /**
  119066. * The list of layers (background and foreground) of the scene
  119067. */
  119068. layers: Array<Layer>;
  119069. }
  119070. /**
  119071. * Defines the layer scene component responsible to manage any layers
  119072. * in a given scene.
  119073. */
  119074. export class LayerSceneComponent implements ISceneComponent {
  119075. /**
  119076. * The component name helpfull to identify the component in the list of scene components.
  119077. */
  119078. readonly name: string;
  119079. /**
  119080. * The scene the component belongs to.
  119081. */
  119082. scene: Scene;
  119083. private _engine;
  119084. /**
  119085. * Creates a new instance of the component for the given scene
  119086. * @param scene Defines the scene to register the component in
  119087. */
  119088. constructor(scene: Scene);
  119089. /**
  119090. * Registers the component in a given scene
  119091. */
  119092. register(): void;
  119093. /**
  119094. * Rebuilds the elements related to this component in case of
  119095. * context lost for instance.
  119096. */
  119097. rebuild(): void;
  119098. /**
  119099. * Disposes the component and the associated ressources.
  119100. */
  119101. dispose(): void;
  119102. private _draw;
  119103. private _drawCameraPredicate;
  119104. private _drawCameraBackground;
  119105. private _drawCameraForeground;
  119106. private _drawRenderTargetPredicate;
  119107. private _drawRenderTargetBackground;
  119108. private _drawRenderTargetForeground;
  119109. /**
  119110. * Adds all the elements from the container to the scene
  119111. * @param container the container holding the elements
  119112. */
  119113. addFromContainer(container: AbstractScene): void;
  119114. /**
  119115. * Removes all the elements in the container from the scene
  119116. * @param container contains the elements to remove
  119117. * @param dispose if the removed element should be disposed (default: false)
  119118. */
  119119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119120. }
  119121. }
  119122. declare module BABYLON {
  119123. /** @hidden */
  119124. export var layerPixelShader: {
  119125. name: string;
  119126. shader: string;
  119127. };
  119128. }
  119129. declare module BABYLON {
  119130. /** @hidden */
  119131. export var layerVertexShader: {
  119132. name: string;
  119133. shader: string;
  119134. };
  119135. }
  119136. declare module BABYLON {
  119137. /**
  119138. * This represents a full screen 2d layer.
  119139. * This can be useful to display a picture in the background of your scene for instance.
  119140. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119141. */
  119142. export class Layer {
  119143. /**
  119144. * Define the name of the layer.
  119145. */
  119146. name: string;
  119147. /**
  119148. * Define the texture the layer should display.
  119149. */
  119150. texture: Nullable<Texture>;
  119151. /**
  119152. * Is the layer in background or foreground.
  119153. */
  119154. isBackground: boolean;
  119155. /**
  119156. * Define the color of the layer (instead of texture).
  119157. */
  119158. color: Color4;
  119159. /**
  119160. * Define the scale of the layer in order to zoom in out of the texture.
  119161. */
  119162. scale: Vector2;
  119163. /**
  119164. * Define an offset for the layer in order to shift the texture.
  119165. */
  119166. offset: Vector2;
  119167. /**
  119168. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119169. */
  119170. alphaBlendingMode: number;
  119171. /**
  119172. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119173. * Alpha test will not mix with the background color in case of transparency.
  119174. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119175. */
  119176. alphaTest: boolean;
  119177. /**
  119178. * Define a mask to restrict the layer to only some of the scene cameras.
  119179. */
  119180. layerMask: number;
  119181. /**
  119182. * Define the list of render target the layer is visible into.
  119183. */
  119184. renderTargetTextures: RenderTargetTexture[];
  119185. /**
  119186. * Define if the layer is only used in renderTarget or if it also
  119187. * renders in the main frame buffer of the canvas.
  119188. */
  119189. renderOnlyInRenderTargetTextures: boolean;
  119190. private _scene;
  119191. private _vertexBuffers;
  119192. private _indexBuffer;
  119193. private _effect;
  119194. private _alphaTestEffect;
  119195. /**
  119196. * An event triggered when the layer is disposed.
  119197. */
  119198. onDisposeObservable: Observable<Layer>;
  119199. private _onDisposeObserver;
  119200. /**
  119201. * Back compatibility with callback before the onDisposeObservable existed.
  119202. * The set callback will be triggered when the layer has been disposed.
  119203. */
  119204. onDispose: () => void;
  119205. /**
  119206. * An event triggered before rendering the scene
  119207. */
  119208. onBeforeRenderObservable: Observable<Layer>;
  119209. private _onBeforeRenderObserver;
  119210. /**
  119211. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119212. * The set callback will be triggered just before rendering the layer.
  119213. */
  119214. onBeforeRender: () => void;
  119215. /**
  119216. * An event triggered after rendering the scene
  119217. */
  119218. onAfterRenderObservable: Observable<Layer>;
  119219. private _onAfterRenderObserver;
  119220. /**
  119221. * Back compatibility with callback before the onAfterRenderObservable existed.
  119222. * The set callback will be triggered just after rendering the layer.
  119223. */
  119224. onAfterRender: () => void;
  119225. /**
  119226. * Instantiates a new layer.
  119227. * This represents a full screen 2d layer.
  119228. * This can be useful to display a picture in the background of your scene for instance.
  119229. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119230. * @param name Define the name of the layer in the scene
  119231. * @param imgUrl Define the url of the texture to display in the layer
  119232. * @param scene Define the scene the layer belongs to
  119233. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119234. * @param color Defines a color for the layer
  119235. */
  119236. constructor(
  119237. /**
  119238. * Define the name of the layer.
  119239. */
  119240. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119241. private _createIndexBuffer;
  119242. /** @hidden */
  119243. _rebuild(): void;
  119244. /**
  119245. * Renders the layer in the scene.
  119246. */
  119247. render(): void;
  119248. /**
  119249. * Disposes and releases the associated ressources.
  119250. */
  119251. dispose(): void;
  119252. }
  119253. }
  119254. declare module BABYLON {
  119255. /** @hidden */
  119256. export var lensFlarePixelShader: {
  119257. name: string;
  119258. shader: string;
  119259. };
  119260. }
  119261. declare module BABYLON {
  119262. /** @hidden */
  119263. export var lensFlareVertexShader: {
  119264. name: string;
  119265. shader: string;
  119266. };
  119267. }
  119268. declare module BABYLON {
  119269. /**
  119270. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119271. * It is usually composed of several `lensFlare`.
  119272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119273. */
  119274. export class LensFlareSystem {
  119275. /**
  119276. * Define the name of the lens flare system
  119277. */
  119278. name: string;
  119279. /**
  119280. * List of lens flares used in this system.
  119281. */
  119282. lensFlares: LensFlare[];
  119283. /**
  119284. * Define a limit from the border the lens flare can be visible.
  119285. */
  119286. borderLimit: number;
  119287. /**
  119288. * Define a viewport border we do not want to see the lens flare in.
  119289. */
  119290. viewportBorder: number;
  119291. /**
  119292. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119293. */
  119294. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119295. /**
  119296. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119297. */
  119298. layerMask: number;
  119299. /**
  119300. * Define the id of the lens flare system in the scene.
  119301. * (equal to name by default)
  119302. */
  119303. id: string;
  119304. private _scene;
  119305. private _emitter;
  119306. private _vertexBuffers;
  119307. private _indexBuffer;
  119308. private _effect;
  119309. private _positionX;
  119310. private _positionY;
  119311. private _isEnabled;
  119312. /** @hidden */
  119313. static _SceneComponentInitialization: (scene: Scene) => void;
  119314. /**
  119315. * Instantiates a lens flare system.
  119316. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119317. * It is usually composed of several `lensFlare`.
  119318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119319. * @param name Define the name of the lens flare system in the scene
  119320. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119321. * @param scene Define the scene the lens flare system belongs to
  119322. */
  119323. constructor(
  119324. /**
  119325. * Define the name of the lens flare system
  119326. */
  119327. name: string, emitter: any, scene: Scene);
  119328. /**
  119329. * Define if the lens flare system is enabled.
  119330. */
  119331. isEnabled: boolean;
  119332. /**
  119333. * Get the scene the effects belongs to.
  119334. * @returns the scene holding the lens flare system
  119335. */
  119336. getScene(): Scene;
  119337. /**
  119338. * Get the emitter of the lens flare system.
  119339. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119340. * @returns the emitter of the lens flare system
  119341. */
  119342. getEmitter(): any;
  119343. /**
  119344. * Set the emitter of the lens flare system.
  119345. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119346. * @param newEmitter Define the new emitter of the system
  119347. */
  119348. setEmitter(newEmitter: any): void;
  119349. /**
  119350. * Get the lens flare system emitter position.
  119351. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119352. * @returns the position
  119353. */
  119354. getEmitterPosition(): Vector3;
  119355. /**
  119356. * @hidden
  119357. */
  119358. computeEffectivePosition(globalViewport: Viewport): boolean;
  119359. /** @hidden */
  119360. _isVisible(): boolean;
  119361. /**
  119362. * @hidden
  119363. */
  119364. render(): boolean;
  119365. /**
  119366. * Dispose and release the lens flare with its associated resources.
  119367. */
  119368. dispose(): void;
  119369. /**
  119370. * Parse a lens flare system from a JSON repressentation
  119371. * @param parsedLensFlareSystem Define the JSON to parse
  119372. * @param scene Define the scene the parsed system should be instantiated in
  119373. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119374. * @returns the parsed system
  119375. */
  119376. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119377. /**
  119378. * Serialize the current Lens Flare System into a JSON representation.
  119379. * @returns the serialized JSON
  119380. */
  119381. serialize(): any;
  119382. }
  119383. }
  119384. declare module BABYLON {
  119385. /**
  119386. * This represents one of the lens effect in a `lensFlareSystem`.
  119387. * It controls one of the indiviual texture used in the effect.
  119388. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119389. */
  119390. export class LensFlare {
  119391. /**
  119392. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119393. */
  119394. size: number;
  119395. /**
  119396. * 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.
  119397. */
  119398. position: number;
  119399. /**
  119400. * Define the lens color.
  119401. */
  119402. color: Color3;
  119403. /**
  119404. * Define the lens texture.
  119405. */
  119406. texture: Nullable<Texture>;
  119407. /**
  119408. * Define the alpha mode to render this particular lens.
  119409. */
  119410. alphaMode: number;
  119411. private _system;
  119412. /**
  119413. * Creates a new Lens Flare.
  119414. * This represents one of the lens effect in a `lensFlareSystem`.
  119415. * It controls one of the indiviual texture used in the effect.
  119416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119417. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119418. * @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.
  119419. * @param color Define the lens color
  119420. * @param imgUrl Define the lens texture url
  119421. * @param system Define the `lensFlareSystem` this flare is part of
  119422. * @returns The newly created Lens Flare
  119423. */
  119424. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119425. /**
  119426. * Instantiates a new Lens Flare.
  119427. * This represents one of the lens effect in a `lensFlareSystem`.
  119428. * It controls one of the indiviual texture used in the effect.
  119429. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119430. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119431. * @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.
  119432. * @param color Define the lens color
  119433. * @param imgUrl Define the lens texture url
  119434. * @param system Define the `lensFlareSystem` this flare is part of
  119435. */
  119436. constructor(
  119437. /**
  119438. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119439. */
  119440. size: number,
  119441. /**
  119442. * 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.
  119443. */
  119444. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119445. /**
  119446. * Dispose and release the lens flare with its associated resources.
  119447. */
  119448. dispose(): void;
  119449. }
  119450. }
  119451. declare module BABYLON {
  119452. interface AbstractScene {
  119453. /**
  119454. * The list of lens flare system added to the scene
  119455. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119456. */
  119457. lensFlareSystems: Array<LensFlareSystem>;
  119458. /**
  119459. * Removes the given lens flare system from this scene.
  119460. * @param toRemove The lens flare system to remove
  119461. * @returns The index of the removed lens flare system
  119462. */
  119463. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119464. /**
  119465. * Adds the given lens flare system to this scene
  119466. * @param newLensFlareSystem The lens flare system to add
  119467. */
  119468. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119469. /**
  119470. * Gets a lens flare system using its name
  119471. * @param name defines the name to look for
  119472. * @returns the lens flare system or null if not found
  119473. */
  119474. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119475. /**
  119476. * Gets a lens flare system using its id
  119477. * @param id defines the id to look for
  119478. * @returns the lens flare system or null if not found
  119479. */
  119480. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119481. }
  119482. /**
  119483. * Defines the lens flare scene component responsible to manage any lens flares
  119484. * in a given scene.
  119485. */
  119486. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119487. /**
  119488. * The component name helpfull to identify the component in the list of scene components.
  119489. */
  119490. readonly name: string;
  119491. /**
  119492. * The scene the component belongs to.
  119493. */
  119494. scene: Scene;
  119495. /**
  119496. * Creates a new instance of the component for the given scene
  119497. * @param scene Defines the scene to register the component in
  119498. */
  119499. constructor(scene: Scene);
  119500. /**
  119501. * Registers the component in a given scene
  119502. */
  119503. register(): void;
  119504. /**
  119505. * Rebuilds the elements related to this component in case of
  119506. * context lost for instance.
  119507. */
  119508. rebuild(): void;
  119509. /**
  119510. * Adds all the elements from the container to the scene
  119511. * @param container the container holding the elements
  119512. */
  119513. addFromContainer(container: AbstractScene): void;
  119514. /**
  119515. * Removes all the elements in the container from the scene
  119516. * @param container contains the elements to remove
  119517. * @param dispose if the removed element should be disposed (default: false)
  119518. */
  119519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119520. /**
  119521. * Serializes the component data to the specified json object
  119522. * @param serializationObject The object to serialize to
  119523. */
  119524. serialize(serializationObject: any): void;
  119525. /**
  119526. * Disposes the component and the associated ressources.
  119527. */
  119528. dispose(): void;
  119529. private _draw;
  119530. }
  119531. }
  119532. declare module BABYLON {
  119533. /**
  119534. * Defines the shadow generator component responsible to manage any shadow generators
  119535. * in a given scene.
  119536. */
  119537. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119538. /**
  119539. * The component name helpfull to identify the component in the list of scene components.
  119540. */
  119541. readonly name: string;
  119542. /**
  119543. * The scene the component belongs to.
  119544. */
  119545. scene: Scene;
  119546. /**
  119547. * Creates a new instance of the component for the given scene
  119548. * @param scene Defines the scene to register the component in
  119549. */
  119550. constructor(scene: Scene);
  119551. /**
  119552. * Registers the component in a given scene
  119553. */
  119554. register(): void;
  119555. /**
  119556. * Rebuilds the elements related to this component in case of
  119557. * context lost for instance.
  119558. */
  119559. rebuild(): void;
  119560. /**
  119561. * Serializes the component data to the specified json object
  119562. * @param serializationObject The object to serialize to
  119563. */
  119564. serialize(serializationObject: any): void;
  119565. /**
  119566. * Adds all the elements from the container to the scene
  119567. * @param container the container holding the elements
  119568. */
  119569. addFromContainer(container: AbstractScene): void;
  119570. /**
  119571. * Removes all the elements in the container from the scene
  119572. * @param container contains the elements to remove
  119573. * @param dispose if the removed element should be disposed (default: false)
  119574. */
  119575. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119576. /**
  119577. * Rebuilds the elements related to this component in case of
  119578. * context lost for instance.
  119579. */
  119580. dispose(): void;
  119581. private _gatherRenderTargets;
  119582. }
  119583. }
  119584. declare module BABYLON {
  119585. /**
  119586. * A point light is a light defined by an unique point in world space.
  119587. * The light is emitted in every direction from this point.
  119588. * A good example of a point light is a standard light bulb.
  119589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119590. */
  119591. export class PointLight extends ShadowLight {
  119592. private _shadowAngle;
  119593. /**
  119594. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119595. * This specifies what angle the shadow will use to be created.
  119596. *
  119597. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119598. */
  119599. /**
  119600. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119601. * This specifies what angle the shadow will use to be created.
  119602. *
  119603. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119604. */
  119605. shadowAngle: number;
  119606. /**
  119607. * Gets the direction if it has been set.
  119608. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119609. */
  119610. /**
  119611. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119612. */
  119613. direction: Vector3;
  119614. /**
  119615. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119616. * A PointLight emits the light in every direction.
  119617. * It can cast shadows.
  119618. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119619. * ```javascript
  119620. * var pointLight = new PointLight("pl", camera.position, scene);
  119621. * ```
  119622. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119623. * @param name The light friendly name
  119624. * @param position The position of the point light in the scene
  119625. * @param scene The scene the lights belongs to
  119626. */
  119627. constructor(name: string, position: Vector3, scene: Scene);
  119628. /**
  119629. * Returns the string "PointLight"
  119630. * @returns the class name
  119631. */
  119632. getClassName(): string;
  119633. /**
  119634. * Returns the integer 0.
  119635. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119636. */
  119637. getTypeID(): number;
  119638. /**
  119639. * Specifies wether or not the shadowmap should be a cube texture.
  119640. * @returns true if the shadowmap needs to be a cube texture.
  119641. */
  119642. needCube(): boolean;
  119643. /**
  119644. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119645. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119646. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119647. */
  119648. getShadowDirection(faceIndex?: number): Vector3;
  119649. /**
  119650. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119651. * - fov = PI / 2
  119652. * - aspect ratio : 1.0
  119653. * - z-near and far equal to the active camera minZ and maxZ.
  119654. * Returns the PointLight.
  119655. */
  119656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119657. protected _buildUniformLayout(): void;
  119658. /**
  119659. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119660. * @param effect The effect to update
  119661. * @param lightIndex The index of the light in the effect to update
  119662. * @returns The point light
  119663. */
  119664. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119665. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119666. /**
  119667. * Prepares the list of defines specific to the light type.
  119668. * @param defines the list of defines
  119669. * @param lightIndex defines the index of the light for the effect
  119670. */
  119671. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119672. }
  119673. }
  119674. declare module BABYLON {
  119675. /**
  119676. * Header information of HDR texture files.
  119677. */
  119678. export interface HDRInfo {
  119679. /**
  119680. * The height of the texture in pixels.
  119681. */
  119682. height: number;
  119683. /**
  119684. * The width of the texture in pixels.
  119685. */
  119686. width: number;
  119687. /**
  119688. * The index of the beginning of the data in the binary file.
  119689. */
  119690. dataPosition: number;
  119691. }
  119692. /**
  119693. * This groups tools to convert HDR texture to native colors array.
  119694. */
  119695. export class HDRTools {
  119696. private static Ldexp;
  119697. private static Rgbe2float;
  119698. private static readStringLine;
  119699. /**
  119700. * Reads header information from an RGBE texture stored in a native array.
  119701. * More information on this format are available here:
  119702. * https://en.wikipedia.org/wiki/RGBE_image_format
  119703. *
  119704. * @param uint8array The binary file stored in native array.
  119705. * @return The header information.
  119706. */
  119707. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119708. /**
  119709. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119710. * This RGBE texture needs to store the information as a panorama.
  119711. *
  119712. * More information on this format are available here:
  119713. * https://en.wikipedia.org/wiki/RGBE_image_format
  119714. *
  119715. * @param buffer The binary file stored in an array buffer.
  119716. * @param size The expected size of the extracted cubemap.
  119717. * @return The Cube Map information.
  119718. */
  119719. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119720. /**
  119721. * Returns the pixels data extracted from an RGBE texture.
  119722. * This pixels will be stored left to right up to down in the R G B order in one array.
  119723. *
  119724. * More information on this format are available here:
  119725. * https://en.wikipedia.org/wiki/RGBE_image_format
  119726. *
  119727. * @param uint8array The binary file stored in an array buffer.
  119728. * @param hdrInfo The header information of the file.
  119729. * @return The pixels data in RGB right to left up to down order.
  119730. */
  119731. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119732. private static RGBE_ReadPixels_RLE;
  119733. }
  119734. }
  119735. declare module BABYLON {
  119736. /**
  119737. * This represents a texture coming from an HDR input.
  119738. *
  119739. * The only supported format is currently panorama picture stored in RGBE format.
  119740. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119741. */
  119742. export class HDRCubeTexture extends BaseTexture {
  119743. private static _facesMapping;
  119744. private _generateHarmonics;
  119745. private _noMipmap;
  119746. private _textureMatrix;
  119747. private _size;
  119748. private _onLoad;
  119749. private _onError;
  119750. /**
  119751. * The texture URL.
  119752. */
  119753. url: string;
  119754. /**
  119755. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119756. */
  119757. coordinatesMode: number;
  119758. protected _isBlocking: boolean;
  119759. /**
  119760. * Sets wether or not the texture is blocking during loading.
  119761. */
  119762. /**
  119763. * Gets wether or not the texture is blocking during loading.
  119764. */
  119765. isBlocking: boolean;
  119766. protected _rotationY: number;
  119767. /**
  119768. * Sets texture matrix rotation angle around Y axis in radians.
  119769. */
  119770. /**
  119771. * Gets texture matrix rotation angle around Y axis radians.
  119772. */
  119773. rotationY: number;
  119774. /**
  119775. * Gets or sets the center of the bounding box associated with the cube texture
  119776. * It must define where the camera used to render the texture was set
  119777. */
  119778. boundingBoxPosition: Vector3;
  119779. private _boundingBoxSize;
  119780. /**
  119781. * Gets or sets the size of the bounding box associated with the cube texture
  119782. * When defined, the cubemap will switch to local mode
  119783. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119784. * @example https://www.babylonjs-playground.com/#RNASML
  119785. */
  119786. boundingBoxSize: Vector3;
  119787. /**
  119788. * Instantiates an HDRTexture from the following parameters.
  119789. *
  119790. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119791. * @param scene The scene the texture will be used in
  119792. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119793. * @param noMipmap Forces to not generate the mipmap if true
  119794. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119795. * @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)
  119796. * @param reserved Reserved flag for internal use.
  119797. */
  119798. 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>);
  119799. /**
  119800. * Get the current class name of the texture useful for serialization or dynamic coding.
  119801. * @returns "HDRCubeTexture"
  119802. */
  119803. getClassName(): string;
  119804. /**
  119805. * Occurs when the file is raw .hdr file.
  119806. */
  119807. private loadTexture;
  119808. clone(): HDRCubeTexture;
  119809. delayLoad(): void;
  119810. /**
  119811. * Get the texture reflection matrix used to rotate/transform the reflection.
  119812. * @returns the reflection matrix
  119813. */
  119814. getReflectionTextureMatrix(): Matrix;
  119815. /**
  119816. * Set the texture reflection matrix used to rotate/transform the reflection.
  119817. * @param value Define the reflection matrix to set
  119818. */
  119819. setReflectionTextureMatrix(value: Matrix): void;
  119820. /**
  119821. * Parses a JSON representation of an HDR Texture in order to create the texture
  119822. * @param parsedTexture Define the JSON representation
  119823. * @param scene Define the scene the texture should be created in
  119824. * @param rootUrl Define the root url in case we need to load relative dependencies
  119825. * @returns the newly created texture after parsing
  119826. */
  119827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119828. serialize(): any;
  119829. }
  119830. }
  119831. declare module BABYLON {
  119832. /**
  119833. * Class used to control physics engine
  119834. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119835. */
  119836. export class PhysicsEngine implements IPhysicsEngine {
  119837. private _physicsPlugin;
  119838. /**
  119839. * Global value used to control the smallest number supported by the simulation
  119840. */
  119841. static Epsilon: number;
  119842. private _impostors;
  119843. private _joints;
  119844. /**
  119845. * Gets the gravity vector used by the simulation
  119846. */
  119847. gravity: Vector3;
  119848. /**
  119849. * Factory used to create the default physics plugin.
  119850. * @returns The default physics plugin
  119851. */
  119852. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119853. /**
  119854. * Creates a new Physics Engine
  119855. * @param gravity defines the gravity vector used by the simulation
  119856. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119857. */
  119858. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119859. /**
  119860. * Sets the gravity vector used by the simulation
  119861. * @param gravity defines the gravity vector to use
  119862. */
  119863. setGravity(gravity: Vector3): void;
  119864. /**
  119865. * Set the time step of the physics engine.
  119866. * Default is 1/60.
  119867. * To slow it down, enter 1/600 for example.
  119868. * To speed it up, 1/30
  119869. * @param newTimeStep defines the new timestep to apply to this world.
  119870. */
  119871. setTimeStep(newTimeStep?: number): void;
  119872. /**
  119873. * Get the time step of the physics engine.
  119874. * @returns the current time step
  119875. */
  119876. getTimeStep(): number;
  119877. /**
  119878. * Release all resources
  119879. */
  119880. dispose(): void;
  119881. /**
  119882. * Gets the name of the current physics plugin
  119883. * @returns the name of the plugin
  119884. */
  119885. getPhysicsPluginName(): string;
  119886. /**
  119887. * Adding a new impostor for the impostor tracking.
  119888. * This will be done by the impostor itself.
  119889. * @param impostor the impostor to add
  119890. */
  119891. addImpostor(impostor: PhysicsImpostor): void;
  119892. /**
  119893. * Remove an impostor from the engine.
  119894. * This impostor and its mesh will not longer be updated by the physics engine.
  119895. * @param impostor the impostor to remove
  119896. */
  119897. removeImpostor(impostor: PhysicsImpostor): void;
  119898. /**
  119899. * Add a joint to the physics engine
  119900. * @param mainImpostor defines the main impostor to which the joint is added.
  119901. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119902. * @param joint defines the joint that will connect both impostors.
  119903. */
  119904. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119905. /**
  119906. * Removes a joint from the simulation
  119907. * @param mainImpostor defines the impostor used with the joint
  119908. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119909. * @param joint defines the joint to remove
  119910. */
  119911. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119912. /**
  119913. * Called by the scene. No need to call it.
  119914. * @param delta defines the timespam between frames
  119915. */
  119916. _step(delta: number): void;
  119917. /**
  119918. * Gets the current plugin used to run the simulation
  119919. * @returns current plugin
  119920. */
  119921. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119922. /**
  119923. * Gets the list of physic impostors
  119924. * @returns an array of PhysicsImpostor
  119925. */
  119926. getImpostors(): Array<PhysicsImpostor>;
  119927. /**
  119928. * Gets the impostor for a physics enabled object
  119929. * @param object defines the object impersonated by the impostor
  119930. * @returns the PhysicsImpostor or null if not found
  119931. */
  119932. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119933. /**
  119934. * Gets the impostor for a physics body object
  119935. * @param body defines physics body used by the impostor
  119936. * @returns the PhysicsImpostor or null if not found
  119937. */
  119938. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119939. /**
  119940. * Does a raycast in the physics world
  119941. * @param from when should the ray start?
  119942. * @param to when should the ray end?
  119943. * @returns PhysicsRaycastResult
  119944. */
  119945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119946. }
  119947. }
  119948. declare module BABYLON {
  119949. /** @hidden */
  119950. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119951. private _useDeltaForWorldStep;
  119952. world: any;
  119953. name: string;
  119954. private _physicsMaterials;
  119955. private _fixedTimeStep;
  119956. private _cannonRaycastResult;
  119957. private _raycastResult;
  119958. private _physicsBodysToRemoveAfterStep;
  119959. BJSCANNON: any;
  119960. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119961. setGravity(gravity: Vector3): void;
  119962. setTimeStep(timeStep: number): void;
  119963. getTimeStep(): number;
  119964. executeStep(delta: number): void;
  119965. private _removeMarkedPhysicsBodiesFromWorld;
  119966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119967. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119968. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119969. private _processChildMeshes;
  119970. removePhysicsBody(impostor: PhysicsImpostor): void;
  119971. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119972. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119973. private _addMaterial;
  119974. private _checkWithEpsilon;
  119975. private _createShape;
  119976. private _createHeightmap;
  119977. private _minus90X;
  119978. private _plus90X;
  119979. private _tmpPosition;
  119980. private _tmpDeltaPosition;
  119981. private _tmpUnityRotation;
  119982. private _updatePhysicsBodyTransformation;
  119983. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119984. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119985. isSupported(): boolean;
  119986. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119987. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119989. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119990. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119991. getBodyMass(impostor: PhysicsImpostor): number;
  119992. getBodyFriction(impostor: PhysicsImpostor): number;
  119993. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119994. getBodyRestitution(impostor: PhysicsImpostor): number;
  119995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119996. sleepBody(impostor: PhysicsImpostor): void;
  119997. wakeUpBody(impostor: PhysicsImpostor): void;
  119998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119999. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120001. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120002. getRadius(impostor: PhysicsImpostor): number;
  120003. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120004. dispose(): void;
  120005. private _extendNamespace;
  120006. /**
  120007. * Does a raycast in the physics world
  120008. * @param from when should the ray start?
  120009. * @param to when should the ray end?
  120010. * @returns PhysicsRaycastResult
  120011. */
  120012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120013. }
  120014. }
  120015. declare module BABYLON {
  120016. /** @hidden */
  120017. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120018. world: any;
  120019. name: string;
  120020. BJSOIMO: any;
  120021. private _raycastResult;
  120022. constructor(iterations?: number, oimoInjection?: any);
  120023. setGravity(gravity: Vector3): void;
  120024. setTimeStep(timeStep: number): void;
  120025. getTimeStep(): number;
  120026. private _tmpImpostorsArray;
  120027. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120028. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120029. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120030. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120031. private _tmpPositionVector;
  120032. removePhysicsBody(impostor: PhysicsImpostor): void;
  120033. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120034. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120035. isSupported(): boolean;
  120036. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120037. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120038. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120039. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120040. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120041. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120042. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120043. getBodyMass(impostor: PhysicsImpostor): number;
  120044. getBodyFriction(impostor: PhysicsImpostor): number;
  120045. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120046. getBodyRestitution(impostor: PhysicsImpostor): number;
  120047. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120048. sleepBody(impostor: PhysicsImpostor): void;
  120049. wakeUpBody(impostor: PhysicsImpostor): void;
  120050. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120051. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120052. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120053. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120054. getRadius(impostor: PhysicsImpostor): number;
  120055. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120056. dispose(): void;
  120057. /**
  120058. * Does a raycast in the physics world
  120059. * @param from when should the ray start?
  120060. * @param to when should the ray end?
  120061. * @returns PhysicsRaycastResult
  120062. */
  120063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120064. }
  120065. }
  120066. declare module BABYLON {
  120067. /**
  120068. * Class containing static functions to help procedurally build meshes
  120069. */
  120070. export class RibbonBuilder {
  120071. /**
  120072. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120073. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120074. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120075. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120076. * * 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
  120077. * * 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
  120078. * * 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
  120079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120082. * * 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
  120083. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120084. * * 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
  120085. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120087. * @param name defines the name of the mesh
  120088. * @param options defines the options used to create the mesh
  120089. * @param scene defines the hosting scene
  120090. * @returns the ribbon mesh
  120091. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120092. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120093. */
  120094. static CreateRibbon(name: string, options: {
  120095. pathArray: Vector3[][];
  120096. closeArray?: boolean;
  120097. closePath?: boolean;
  120098. offset?: number;
  120099. updatable?: boolean;
  120100. sideOrientation?: number;
  120101. frontUVs?: Vector4;
  120102. backUVs?: Vector4;
  120103. instance?: Mesh;
  120104. invertUV?: boolean;
  120105. uvs?: Vector2[];
  120106. colors?: Color4[];
  120107. }, scene?: Nullable<Scene>): Mesh;
  120108. }
  120109. }
  120110. declare module BABYLON {
  120111. /**
  120112. * Class containing static functions to help procedurally build meshes
  120113. */
  120114. export class ShapeBuilder {
  120115. /**
  120116. * 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.
  120117. * * 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.
  120118. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120119. * * 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.
  120120. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120121. * * 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
  120122. * * 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
  120123. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120128. * @param name defines the name of the mesh
  120129. * @param options defines the options used to create the mesh
  120130. * @param scene defines the hosting scene
  120131. * @returns the extruded shape mesh
  120132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120134. */
  120135. static ExtrudeShape(name: string, options: {
  120136. shape: Vector3[];
  120137. path: Vector3[];
  120138. scale?: number;
  120139. rotation?: number;
  120140. cap?: number;
  120141. updatable?: boolean;
  120142. sideOrientation?: number;
  120143. frontUVs?: Vector4;
  120144. backUVs?: Vector4;
  120145. instance?: Mesh;
  120146. invertUV?: boolean;
  120147. }, scene?: Nullable<Scene>): Mesh;
  120148. /**
  120149. * Creates an custom extruded shape mesh.
  120150. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120151. * * 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.
  120152. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120153. * * 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
  120154. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120155. * * 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
  120156. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120157. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120158. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120159. * * 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
  120160. * * 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
  120161. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120166. * @param name defines the name of the mesh
  120167. * @param options defines the options used to create the mesh
  120168. * @param scene defines the hosting scene
  120169. * @returns the custom extruded shape mesh
  120170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120173. */
  120174. static ExtrudeShapeCustom(name: string, options: {
  120175. shape: Vector3[];
  120176. path: Vector3[];
  120177. scaleFunction?: any;
  120178. rotationFunction?: any;
  120179. ribbonCloseArray?: boolean;
  120180. ribbonClosePath?: boolean;
  120181. cap?: number;
  120182. updatable?: boolean;
  120183. sideOrientation?: number;
  120184. frontUVs?: Vector4;
  120185. backUVs?: Vector4;
  120186. instance?: Mesh;
  120187. invertUV?: boolean;
  120188. }, scene?: Nullable<Scene>): Mesh;
  120189. private static _ExtrudeShapeGeneric;
  120190. }
  120191. }
  120192. declare module BABYLON {
  120193. /**
  120194. * AmmoJS Physics plugin
  120195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120196. * @see https://github.com/kripken/ammo.js/
  120197. */
  120198. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120199. private _useDeltaForWorldStep;
  120200. /**
  120201. * Reference to the Ammo library
  120202. */
  120203. bjsAMMO: any;
  120204. /**
  120205. * Created ammoJS world which physics bodies are added to
  120206. */
  120207. world: any;
  120208. /**
  120209. * Name of the plugin
  120210. */
  120211. name: string;
  120212. private _timeStep;
  120213. private _fixedTimeStep;
  120214. private _maxSteps;
  120215. private _tmpQuaternion;
  120216. private _tmpAmmoTransform;
  120217. private _tmpAmmoQuaternion;
  120218. private _tmpAmmoConcreteContactResultCallback;
  120219. private _collisionConfiguration;
  120220. private _dispatcher;
  120221. private _overlappingPairCache;
  120222. private _solver;
  120223. private _softBodySolver;
  120224. private _tmpAmmoVectorA;
  120225. private _tmpAmmoVectorB;
  120226. private _tmpAmmoVectorC;
  120227. private _tmpAmmoVectorD;
  120228. private _tmpContactCallbackResult;
  120229. private _tmpAmmoVectorRCA;
  120230. private _tmpAmmoVectorRCB;
  120231. private _raycastResult;
  120232. private static readonly DISABLE_COLLISION_FLAG;
  120233. private static readonly KINEMATIC_FLAG;
  120234. private static readonly DISABLE_DEACTIVATION_FLAG;
  120235. /**
  120236. * Initializes the ammoJS plugin
  120237. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120238. * @param ammoInjection can be used to inject your own ammo reference
  120239. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120240. */
  120241. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120242. /**
  120243. * Sets the gravity of the physics world (m/(s^2))
  120244. * @param gravity Gravity to set
  120245. */
  120246. setGravity(gravity: Vector3): void;
  120247. /**
  120248. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120249. * @param timeStep timestep to use in seconds
  120250. */
  120251. setTimeStep(timeStep: number): void;
  120252. /**
  120253. * 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)
  120254. * @param fixedTimeStep fixedTimeStep to use in seconds
  120255. */
  120256. setFixedTimeStep(fixedTimeStep: number): void;
  120257. /**
  120258. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120259. * @param maxSteps the maximum number of steps by the physics engine per frame
  120260. */
  120261. setMaxSteps(maxSteps: number): void;
  120262. /**
  120263. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120264. * @returns the current timestep in seconds
  120265. */
  120266. getTimeStep(): number;
  120267. private _isImpostorInContact;
  120268. private _isImpostorPairInContact;
  120269. private _stepSimulation;
  120270. /**
  120271. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120272. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120273. * After the step the babylon meshes are set to the position of the physics imposters
  120274. * @param delta amount of time to step forward
  120275. * @param impostors array of imposters to update before/after the step
  120276. */
  120277. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120278. /**
  120279. * Update babylon mesh to match physics world object
  120280. * @param impostor imposter to match
  120281. */
  120282. private _afterSoftStep;
  120283. /**
  120284. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120285. * @param impostor imposter to match
  120286. */
  120287. private _ropeStep;
  120288. /**
  120289. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120290. * @param impostor imposter to match
  120291. */
  120292. private _softbodyOrClothStep;
  120293. private _tmpVector;
  120294. private _tmpMatrix;
  120295. /**
  120296. * Applies an impulse on the imposter
  120297. * @param impostor imposter to apply impulse to
  120298. * @param force amount of force to be applied to the imposter
  120299. * @param contactPoint the location to apply the impulse on the imposter
  120300. */
  120301. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120302. /**
  120303. * Applies a force on the imposter
  120304. * @param impostor imposter to apply force
  120305. * @param force amount of force to be applied to the imposter
  120306. * @param contactPoint the location to apply the force on the imposter
  120307. */
  120308. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120309. /**
  120310. * Creates a physics body using the plugin
  120311. * @param impostor the imposter to create the physics body on
  120312. */
  120313. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120314. /**
  120315. * Removes the physics body from the imposter and disposes of the body's memory
  120316. * @param impostor imposter to remove the physics body from
  120317. */
  120318. removePhysicsBody(impostor: PhysicsImpostor): void;
  120319. /**
  120320. * Generates a joint
  120321. * @param impostorJoint the imposter joint to create the joint with
  120322. */
  120323. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120324. /**
  120325. * Removes a joint
  120326. * @param impostorJoint the imposter joint to remove the joint from
  120327. */
  120328. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120329. private _addMeshVerts;
  120330. /**
  120331. * Initialise the soft body vertices to match its object's (mesh) vertices
  120332. * Softbody vertices (nodes) are in world space and to match this
  120333. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120334. * @param impostor to create the softbody for
  120335. */
  120336. private _softVertexData;
  120337. /**
  120338. * Create an impostor's soft body
  120339. * @param impostor to create the softbody for
  120340. */
  120341. private _createSoftbody;
  120342. /**
  120343. * Create cloth for an impostor
  120344. * @param impostor to create the softbody for
  120345. */
  120346. private _createCloth;
  120347. /**
  120348. * Create rope for an impostor
  120349. * @param impostor to create the softbody for
  120350. */
  120351. private _createRope;
  120352. private _addHullVerts;
  120353. private _createShape;
  120354. /**
  120355. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120356. * @param impostor imposter containing the physics body and babylon object
  120357. */
  120358. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120359. /**
  120360. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120361. * @param impostor imposter containing the physics body and babylon object
  120362. * @param newPosition new position
  120363. * @param newRotation new rotation
  120364. */
  120365. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120366. /**
  120367. * If this plugin is supported
  120368. * @returns true if its supported
  120369. */
  120370. isSupported(): boolean;
  120371. /**
  120372. * Sets the linear velocity of the physics body
  120373. * @param impostor imposter to set the velocity on
  120374. * @param velocity velocity to set
  120375. */
  120376. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120377. /**
  120378. * Sets the angular velocity of the physics body
  120379. * @param impostor imposter to set the velocity on
  120380. * @param velocity velocity to set
  120381. */
  120382. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120383. /**
  120384. * gets the linear velocity
  120385. * @param impostor imposter to get linear velocity from
  120386. * @returns linear velocity
  120387. */
  120388. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120389. /**
  120390. * gets the angular velocity
  120391. * @param impostor imposter to get angular velocity from
  120392. * @returns angular velocity
  120393. */
  120394. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120395. /**
  120396. * Sets the mass of physics body
  120397. * @param impostor imposter to set the mass on
  120398. * @param mass mass to set
  120399. */
  120400. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120401. /**
  120402. * Gets the mass of the physics body
  120403. * @param impostor imposter to get the mass from
  120404. * @returns mass
  120405. */
  120406. getBodyMass(impostor: PhysicsImpostor): number;
  120407. /**
  120408. * Gets friction of the impostor
  120409. * @param impostor impostor to get friction from
  120410. * @returns friction value
  120411. */
  120412. getBodyFriction(impostor: PhysicsImpostor): number;
  120413. /**
  120414. * Sets friction of the impostor
  120415. * @param impostor impostor to set friction on
  120416. * @param friction friction value
  120417. */
  120418. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120419. /**
  120420. * Gets restitution of the impostor
  120421. * @param impostor impostor to get restitution from
  120422. * @returns restitution value
  120423. */
  120424. getBodyRestitution(impostor: PhysicsImpostor): number;
  120425. /**
  120426. * Sets resitution of the impostor
  120427. * @param impostor impostor to set resitution on
  120428. * @param restitution resitution value
  120429. */
  120430. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120431. /**
  120432. * Gets pressure inside the impostor
  120433. * @param impostor impostor to get pressure from
  120434. * @returns pressure value
  120435. */
  120436. getBodyPressure(impostor: PhysicsImpostor): number;
  120437. /**
  120438. * Sets pressure inside a soft body impostor
  120439. * Cloth and rope must remain 0 pressure
  120440. * @param impostor impostor to set pressure on
  120441. * @param pressure pressure value
  120442. */
  120443. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120444. /**
  120445. * Gets stiffness of the impostor
  120446. * @param impostor impostor to get stiffness from
  120447. * @returns pressure value
  120448. */
  120449. getBodyStiffness(impostor: PhysicsImpostor): number;
  120450. /**
  120451. * Sets stiffness of the impostor
  120452. * @param impostor impostor to set stiffness on
  120453. * @param stiffness stiffness value from 0 to 1
  120454. */
  120455. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120456. /**
  120457. * Gets velocityIterations of the impostor
  120458. * @param impostor impostor to get velocity iterations from
  120459. * @returns velocityIterations value
  120460. */
  120461. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120462. /**
  120463. * Sets velocityIterations of the impostor
  120464. * @param impostor impostor to set velocity iterations on
  120465. * @param velocityIterations velocityIterations value
  120466. */
  120467. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120468. /**
  120469. * Gets positionIterations of the impostor
  120470. * @param impostor impostor to get position iterations from
  120471. * @returns positionIterations value
  120472. */
  120473. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120474. /**
  120475. * Sets positionIterations of the impostor
  120476. * @param impostor impostor to set position on
  120477. * @param positionIterations positionIterations value
  120478. */
  120479. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120480. /**
  120481. * Append an anchor to a cloth object
  120482. * @param impostor is the cloth impostor to add anchor to
  120483. * @param otherImpostor is the rigid impostor to anchor to
  120484. * @param width ratio across width from 0 to 1
  120485. * @param height ratio up height from 0 to 1
  120486. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120487. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120488. */
  120489. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120490. /**
  120491. * Append an hook to a rope object
  120492. * @param impostor is the rope impostor to add hook to
  120493. * @param otherImpostor is the rigid impostor to hook to
  120494. * @param length ratio along the rope from 0 to 1
  120495. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120496. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120497. */
  120498. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120499. /**
  120500. * Sleeps the physics body and stops it from being active
  120501. * @param impostor impostor to sleep
  120502. */
  120503. sleepBody(impostor: PhysicsImpostor): void;
  120504. /**
  120505. * Activates the physics body
  120506. * @param impostor impostor to activate
  120507. */
  120508. wakeUpBody(impostor: PhysicsImpostor): void;
  120509. /**
  120510. * Updates the distance parameters of the joint
  120511. * @param joint joint to update
  120512. * @param maxDistance maximum distance of the joint
  120513. * @param minDistance minimum distance of the joint
  120514. */
  120515. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120516. /**
  120517. * Sets a motor on the joint
  120518. * @param joint joint to set motor on
  120519. * @param speed speed of the motor
  120520. * @param maxForce maximum force of the motor
  120521. * @param motorIndex index of the motor
  120522. */
  120523. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120524. /**
  120525. * Sets the motors limit
  120526. * @param joint joint to set limit on
  120527. * @param upperLimit upper limit
  120528. * @param lowerLimit lower limit
  120529. */
  120530. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120531. /**
  120532. * Syncs the position and rotation of a mesh with the impostor
  120533. * @param mesh mesh to sync
  120534. * @param impostor impostor to update the mesh with
  120535. */
  120536. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120537. /**
  120538. * Gets the radius of the impostor
  120539. * @param impostor impostor to get radius from
  120540. * @returns the radius
  120541. */
  120542. getRadius(impostor: PhysicsImpostor): number;
  120543. /**
  120544. * Gets the box size of the impostor
  120545. * @param impostor impostor to get box size from
  120546. * @param result the resulting box size
  120547. */
  120548. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120549. /**
  120550. * Disposes of the impostor
  120551. */
  120552. dispose(): void;
  120553. /**
  120554. * Does a raycast in the physics world
  120555. * @param from when should the ray start?
  120556. * @param to when should the ray end?
  120557. * @returns PhysicsRaycastResult
  120558. */
  120559. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120560. }
  120561. }
  120562. declare module BABYLON {
  120563. interface AbstractScene {
  120564. /**
  120565. * The list of reflection probes added to the scene
  120566. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120567. */
  120568. reflectionProbes: Array<ReflectionProbe>;
  120569. /**
  120570. * Removes the given reflection probe from this scene.
  120571. * @param toRemove The reflection probe to remove
  120572. * @returns The index of the removed reflection probe
  120573. */
  120574. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120575. /**
  120576. * Adds the given reflection probe to this scene.
  120577. * @param newReflectionProbe The reflection probe to add
  120578. */
  120579. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120580. }
  120581. /**
  120582. * Class used to generate realtime reflection / refraction cube textures
  120583. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120584. */
  120585. export class ReflectionProbe {
  120586. /** defines the name of the probe */
  120587. name: string;
  120588. private _scene;
  120589. private _renderTargetTexture;
  120590. private _projectionMatrix;
  120591. private _viewMatrix;
  120592. private _target;
  120593. private _add;
  120594. private _attachedMesh;
  120595. private _invertYAxis;
  120596. /** Gets or sets probe position (center of the cube map) */
  120597. position: Vector3;
  120598. /**
  120599. * Creates a new reflection probe
  120600. * @param name defines the name of the probe
  120601. * @param size defines the texture resolution (for each face)
  120602. * @param scene defines the hosting scene
  120603. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120604. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120605. */
  120606. constructor(
  120607. /** defines the name of the probe */
  120608. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120609. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120610. samples: number;
  120611. /** Gets or sets the refresh rate to use (on every frame by default) */
  120612. refreshRate: number;
  120613. /**
  120614. * Gets the hosting scene
  120615. * @returns a Scene
  120616. */
  120617. getScene(): Scene;
  120618. /** Gets the internal CubeTexture used to render to */
  120619. readonly cubeTexture: RenderTargetTexture;
  120620. /** Gets the list of meshes to render */
  120621. readonly renderList: Nullable<AbstractMesh[]>;
  120622. /**
  120623. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120624. * @param mesh defines the mesh to attach to
  120625. */
  120626. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120627. /**
  120628. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120629. * @param renderingGroupId The rendering group id corresponding to its index
  120630. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120631. */
  120632. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120633. /**
  120634. * Clean all associated resources
  120635. */
  120636. dispose(): void;
  120637. /**
  120638. * Converts the reflection probe information to a readable string for debug purpose.
  120639. * @param fullDetails Supports for multiple levels of logging within scene loading
  120640. * @returns the human readable reflection probe info
  120641. */
  120642. toString(fullDetails?: boolean): string;
  120643. /**
  120644. * Get the class name of the relfection probe.
  120645. * @returns "ReflectionProbe"
  120646. */
  120647. getClassName(): string;
  120648. /**
  120649. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120650. * @returns The JSON representation of the texture
  120651. */
  120652. serialize(): any;
  120653. /**
  120654. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120655. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120656. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120657. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120658. * @returns The parsed reflection probe if successful
  120659. */
  120660. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120661. }
  120662. }
  120663. declare module BABYLON {
  120664. /** @hidden */
  120665. export var _BabylonLoaderRegistered: boolean;
  120666. /**
  120667. * Helps setting up some configuration for the babylon file loader.
  120668. */
  120669. export class BabylonFileLoaderConfiguration {
  120670. /**
  120671. * The loader does not allow injecting custom physix engine into the plugins.
  120672. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120673. * So you could set this variable to your engine import to make it work.
  120674. */
  120675. static LoaderInjectedPhysicsEngine: any;
  120676. }
  120677. }
  120678. declare module BABYLON {
  120679. /**
  120680. * The Physically based simple base material of BJS.
  120681. *
  120682. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120683. * It is used as the base class for both the specGloss and metalRough conventions.
  120684. */
  120685. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120686. /**
  120687. * Number of Simultaneous lights allowed on the material.
  120688. */
  120689. maxSimultaneousLights: number;
  120690. /**
  120691. * If sets to true, disables all the lights affecting the material.
  120692. */
  120693. disableLighting: boolean;
  120694. /**
  120695. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120696. */
  120697. environmentTexture: BaseTexture;
  120698. /**
  120699. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120700. */
  120701. invertNormalMapX: boolean;
  120702. /**
  120703. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120704. */
  120705. invertNormalMapY: boolean;
  120706. /**
  120707. * Normal map used in the model.
  120708. */
  120709. normalTexture: BaseTexture;
  120710. /**
  120711. * Emissivie color used to self-illuminate the model.
  120712. */
  120713. emissiveColor: Color3;
  120714. /**
  120715. * Emissivie texture used to self-illuminate the model.
  120716. */
  120717. emissiveTexture: BaseTexture;
  120718. /**
  120719. * Occlusion Channel Strenght.
  120720. */
  120721. occlusionStrength: number;
  120722. /**
  120723. * Occlusion Texture of the material (adding extra occlusion effects).
  120724. */
  120725. occlusionTexture: BaseTexture;
  120726. /**
  120727. * Defines the alpha limits in alpha test mode.
  120728. */
  120729. alphaCutOff: number;
  120730. /**
  120731. * Gets the current double sided mode.
  120732. */
  120733. /**
  120734. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120735. */
  120736. doubleSided: boolean;
  120737. /**
  120738. * Stores the pre-calculated light information of a mesh in a texture.
  120739. */
  120740. lightmapTexture: BaseTexture;
  120741. /**
  120742. * If true, the light map contains occlusion information instead of lighting info.
  120743. */
  120744. useLightmapAsShadowmap: boolean;
  120745. /**
  120746. * Instantiates a new PBRMaterial instance.
  120747. *
  120748. * @param name The material name
  120749. * @param scene The scene the material will be use in.
  120750. */
  120751. constructor(name: string, scene: Scene);
  120752. getClassName(): string;
  120753. }
  120754. }
  120755. declare module BABYLON {
  120756. /**
  120757. * The PBR material of BJS following the metal roughness convention.
  120758. *
  120759. * This fits to the PBR convention in the GLTF definition:
  120760. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120761. */
  120762. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120763. /**
  120764. * The base color has two different interpretations depending on the value of metalness.
  120765. * When the material is a metal, the base color is the specific measured reflectance value
  120766. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120767. * of the material.
  120768. */
  120769. baseColor: Color3;
  120770. /**
  120771. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120772. * well as opacity information in the alpha channel.
  120773. */
  120774. baseTexture: BaseTexture;
  120775. /**
  120776. * Specifies the metallic scalar value of the material.
  120777. * Can also be used to scale the metalness values of the metallic texture.
  120778. */
  120779. metallic: number;
  120780. /**
  120781. * Specifies the roughness scalar value of the material.
  120782. * Can also be used to scale the roughness values of the metallic texture.
  120783. */
  120784. roughness: number;
  120785. /**
  120786. * Texture containing both the metallic value in the B channel and the
  120787. * roughness value in the G channel to keep better precision.
  120788. */
  120789. metallicRoughnessTexture: BaseTexture;
  120790. /**
  120791. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120792. *
  120793. * @param name The material name
  120794. * @param scene The scene the material will be use in.
  120795. */
  120796. constructor(name: string, scene: Scene);
  120797. /**
  120798. * Return the currrent class name of the material.
  120799. */
  120800. getClassName(): string;
  120801. /**
  120802. * Makes a duplicate of the current material.
  120803. * @param name - name to use for the new material.
  120804. */
  120805. clone(name: string): PBRMetallicRoughnessMaterial;
  120806. /**
  120807. * Serialize the material to a parsable JSON object.
  120808. */
  120809. serialize(): any;
  120810. /**
  120811. * Parses a JSON object correponding to the serialize function.
  120812. */
  120813. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120814. }
  120815. }
  120816. declare module BABYLON {
  120817. /**
  120818. * The PBR material of BJS following the specular glossiness convention.
  120819. *
  120820. * This fits to the PBR convention in the GLTF definition:
  120821. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120822. */
  120823. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120824. /**
  120825. * Specifies the diffuse color of the material.
  120826. */
  120827. diffuseColor: Color3;
  120828. /**
  120829. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120830. * channel.
  120831. */
  120832. diffuseTexture: BaseTexture;
  120833. /**
  120834. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120835. */
  120836. specularColor: Color3;
  120837. /**
  120838. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120839. */
  120840. glossiness: number;
  120841. /**
  120842. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120843. */
  120844. specularGlossinessTexture: BaseTexture;
  120845. /**
  120846. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120847. *
  120848. * @param name The material name
  120849. * @param scene The scene the material will be use in.
  120850. */
  120851. constructor(name: string, scene: Scene);
  120852. /**
  120853. * Return the currrent class name of the material.
  120854. */
  120855. getClassName(): string;
  120856. /**
  120857. * Makes a duplicate of the current material.
  120858. * @param name - name to use for the new material.
  120859. */
  120860. clone(name: string): PBRSpecularGlossinessMaterial;
  120861. /**
  120862. * Serialize the material to a parsable JSON object.
  120863. */
  120864. serialize(): any;
  120865. /**
  120866. * Parses a JSON object correponding to the serialize function.
  120867. */
  120868. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120869. }
  120870. }
  120871. declare module BABYLON {
  120872. /**
  120873. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120874. * It can help converting any input color in a desired output one. This can then be used to create effects
  120875. * from sepia, black and white to sixties or futuristic rendering...
  120876. *
  120877. * The only supported format is currently 3dl.
  120878. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120879. */
  120880. export class ColorGradingTexture extends BaseTexture {
  120881. /**
  120882. * The current texture matrix. (will always be identity in color grading texture)
  120883. */
  120884. private _textureMatrix;
  120885. /**
  120886. * The texture URL.
  120887. */
  120888. url: string;
  120889. /**
  120890. * Empty line regex stored for GC.
  120891. */
  120892. private static _noneEmptyLineRegex;
  120893. private _engine;
  120894. /**
  120895. * Instantiates a ColorGradingTexture from the following parameters.
  120896. *
  120897. * @param url The location of the color gradind data (currently only supporting 3dl)
  120898. * @param scene The scene the texture will be used in
  120899. */
  120900. constructor(url: string, scene: Scene);
  120901. /**
  120902. * Returns the texture matrix used in most of the material.
  120903. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120904. */
  120905. getTextureMatrix(): Matrix;
  120906. /**
  120907. * Occurs when the file being loaded is a .3dl LUT file.
  120908. */
  120909. private load3dlTexture;
  120910. /**
  120911. * Starts the loading process of the texture.
  120912. */
  120913. private loadTexture;
  120914. /**
  120915. * Clones the color gradind texture.
  120916. */
  120917. clone(): ColorGradingTexture;
  120918. /**
  120919. * Called during delayed load for textures.
  120920. */
  120921. delayLoad(): void;
  120922. /**
  120923. * Parses a color grading texture serialized by Babylon.
  120924. * @param parsedTexture The texture information being parsedTexture
  120925. * @param scene The scene to load the texture in
  120926. * @param rootUrl The root url of the data assets to load
  120927. * @return A color gradind texture
  120928. */
  120929. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120930. /**
  120931. * Serializes the LUT texture to json format.
  120932. */
  120933. serialize(): any;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. /**
  120938. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120939. */
  120940. export class EquiRectangularCubeTexture extends BaseTexture {
  120941. /** The six faces of the cube. */
  120942. private static _FacesMapping;
  120943. private _noMipmap;
  120944. private _onLoad;
  120945. private _onError;
  120946. /** The size of the cubemap. */
  120947. private _size;
  120948. /** The buffer of the image. */
  120949. private _buffer;
  120950. /** The width of the input image. */
  120951. private _width;
  120952. /** The height of the input image. */
  120953. private _height;
  120954. /** The URL to the image. */
  120955. url: string;
  120956. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120957. coordinatesMode: number;
  120958. /**
  120959. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120960. * @param url The location of the image
  120961. * @param scene The scene the texture will be used in
  120962. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120963. * @param noMipmap Forces to not generate the mipmap if true
  120964. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120965. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120966. * @param onLoad — defines a callback called when texture is loaded
  120967. * @param onError — defines a callback called if there is an error
  120968. */
  120969. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120970. /**
  120971. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120972. */
  120973. private loadImage;
  120974. /**
  120975. * Convert the image buffer into a cubemap and create a CubeTexture.
  120976. */
  120977. private loadTexture;
  120978. /**
  120979. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120980. * @param buffer The ArrayBuffer that should be converted.
  120981. * @returns The buffer as Float32Array.
  120982. */
  120983. private getFloat32ArrayFromArrayBuffer;
  120984. /**
  120985. * Get the current class name of the texture useful for serialization or dynamic coding.
  120986. * @returns "EquiRectangularCubeTexture"
  120987. */
  120988. getClassName(): string;
  120989. /**
  120990. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120991. * @returns A clone of the current EquiRectangularCubeTexture.
  120992. */
  120993. clone(): EquiRectangularCubeTexture;
  120994. }
  120995. }
  120996. declare module BABYLON {
  120997. /**
  120998. * Based on jsTGALoader - Javascript loader for TGA file
  120999. * By Vincent Thibault
  121000. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121001. */
  121002. export class TGATools {
  121003. private static _TYPE_INDEXED;
  121004. private static _TYPE_RGB;
  121005. private static _TYPE_GREY;
  121006. private static _TYPE_RLE_INDEXED;
  121007. private static _TYPE_RLE_RGB;
  121008. private static _TYPE_RLE_GREY;
  121009. private static _ORIGIN_MASK;
  121010. private static _ORIGIN_SHIFT;
  121011. private static _ORIGIN_BL;
  121012. private static _ORIGIN_BR;
  121013. private static _ORIGIN_UL;
  121014. private static _ORIGIN_UR;
  121015. /**
  121016. * Gets the header of a TGA file
  121017. * @param data defines the TGA data
  121018. * @returns the header
  121019. */
  121020. static GetTGAHeader(data: Uint8Array): any;
  121021. /**
  121022. * Uploads TGA content to a Babylon Texture
  121023. * @hidden
  121024. */
  121025. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121026. /** @hidden */
  121027. 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;
  121028. /** @hidden */
  121029. 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;
  121030. /** @hidden */
  121031. 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;
  121032. /** @hidden */
  121033. 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;
  121034. /** @hidden */
  121035. 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;
  121036. /** @hidden */
  121037. 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;
  121038. }
  121039. }
  121040. declare module BABYLON {
  121041. /**
  121042. * Implementation of the TGA Texture Loader.
  121043. * @hidden
  121044. */
  121045. export class _TGATextureLoader implements IInternalTextureLoader {
  121046. /**
  121047. * Defines wether the loader supports cascade loading the different faces.
  121048. */
  121049. readonly supportCascades: boolean;
  121050. /**
  121051. * This returns if the loader support the current file information.
  121052. * @param extension defines the file extension of the file being loaded
  121053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121054. * @param fallback defines the fallback internal texture if any
  121055. * @param isBase64 defines whether the texture is encoded as a base64
  121056. * @param isBuffer defines whether the texture data are stored as a buffer
  121057. * @returns true if the loader can load the specified file
  121058. */
  121059. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121060. /**
  121061. * Transform the url before loading if required.
  121062. * @param rootUrl the url of the texture
  121063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121064. * @returns the transformed texture
  121065. */
  121066. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121067. /**
  121068. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121069. * @param rootUrl the url of the texture
  121070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121071. * @returns the fallback texture
  121072. */
  121073. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121074. /**
  121075. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121076. * @param data contains the texture data
  121077. * @param texture defines the BabylonJS internal texture
  121078. * @param createPolynomials will be true if polynomials have been requested
  121079. * @param onLoad defines the callback to trigger once the texture is ready
  121080. * @param onError defines the callback to trigger in case of error
  121081. */
  121082. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121083. /**
  121084. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121085. * @param data contains the texture data
  121086. * @param texture defines the BabylonJS internal texture
  121087. * @param callback defines the method to call once ready to upload
  121088. */
  121089. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121090. }
  121091. }
  121092. declare module BABYLON {
  121093. /**
  121094. * Info about the .basis files
  121095. */
  121096. class BasisFileInfo {
  121097. /**
  121098. * If the file has alpha
  121099. */
  121100. hasAlpha: boolean;
  121101. /**
  121102. * Info about each image of the basis file
  121103. */
  121104. images: Array<{
  121105. levels: Array<{
  121106. width: number;
  121107. height: number;
  121108. transcodedPixels: ArrayBufferView;
  121109. }>;
  121110. }>;
  121111. }
  121112. /**
  121113. * Result of transcoding a basis file
  121114. */
  121115. class TranscodeResult {
  121116. /**
  121117. * Info about the .basis file
  121118. */
  121119. fileInfo: BasisFileInfo;
  121120. /**
  121121. * Format to use when loading the file
  121122. */
  121123. format: number;
  121124. }
  121125. /**
  121126. * Configuration options for the Basis transcoder
  121127. */
  121128. export class BasisTranscodeConfiguration {
  121129. /**
  121130. * Supported compression formats used to determine the supported output format of the transcoder
  121131. */
  121132. supportedCompressionFormats?: {
  121133. /**
  121134. * etc1 compression format
  121135. */
  121136. etc1?: boolean;
  121137. /**
  121138. * s3tc compression format
  121139. */
  121140. s3tc?: boolean;
  121141. /**
  121142. * pvrtc compression format
  121143. */
  121144. pvrtc?: boolean;
  121145. /**
  121146. * etc2 compression format
  121147. */
  121148. etc2?: boolean;
  121149. };
  121150. /**
  121151. * If mipmap levels should be loaded for transcoded images (Default: true)
  121152. */
  121153. loadMipmapLevels?: boolean;
  121154. /**
  121155. * Index of a single image to load (Default: all images)
  121156. */
  121157. loadSingleImage?: number;
  121158. }
  121159. /**
  121160. * Used to load .Basis files
  121161. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121162. */
  121163. export class BasisTools {
  121164. private static _IgnoreSupportedFormats;
  121165. /**
  121166. * URL to use when loading the basis transcoder
  121167. */
  121168. static JSModuleURL: string;
  121169. /**
  121170. * URL to use when loading the wasm module for the transcoder
  121171. */
  121172. static WasmModuleURL: string;
  121173. /**
  121174. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121175. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121176. * @returns internal format corresponding to the Basis format
  121177. */
  121178. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121179. private static _WorkerPromise;
  121180. private static _Worker;
  121181. private static _actionId;
  121182. private static _CreateWorkerAsync;
  121183. /**
  121184. * Transcodes a loaded image file to compressed pixel data
  121185. * @param imageData image data to transcode
  121186. * @param config configuration options for the transcoding
  121187. * @returns a promise resulting in the transcoded image
  121188. */
  121189. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121190. /**
  121191. * Loads a texture from the transcode result
  121192. * @param texture texture load to
  121193. * @param transcodeResult the result of transcoding the basis file to load from
  121194. */
  121195. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121196. }
  121197. }
  121198. declare module BABYLON {
  121199. /**
  121200. * Loader for .basis file format
  121201. */
  121202. export class _BasisTextureLoader implements IInternalTextureLoader {
  121203. /**
  121204. * Defines whether the loader supports cascade loading the different faces.
  121205. */
  121206. readonly supportCascades: boolean;
  121207. /**
  121208. * This returns if the loader support the current file information.
  121209. * @param extension defines the file extension of the file being loaded
  121210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121211. * @param fallback defines the fallback internal texture if any
  121212. * @param isBase64 defines whether the texture is encoded as a base64
  121213. * @param isBuffer defines whether the texture data are stored as a buffer
  121214. * @returns true if the loader can load the specified file
  121215. */
  121216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121217. /**
  121218. * Transform the url before loading if required.
  121219. * @param rootUrl the url of the texture
  121220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121221. * @returns the transformed texture
  121222. */
  121223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121224. /**
  121225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121226. * @param rootUrl the url of the texture
  121227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121228. * @returns the fallback texture
  121229. */
  121230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121231. /**
  121232. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121233. * @param data contains the texture data
  121234. * @param texture defines the BabylonJS internal texture
  121235. * @param createPolynomials will be true if polynomials have been requested
  121236. * @param onLoad defines the callback to trigger once the texture is ready
  121237. * @param onError defines the callback to trigger in case of error
  121238. */
  121239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121240. /**
  121241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121242. * @param data contains the texture data
  121243. * @param texture defines the BabylonJS internal texture
  121244. * @param callback defines the method to call once ready to upload
  121245. */
  121246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121247. }
  121248. }
  121249. declare module BABYLON {
  121250. /**
  121251. * 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.
  121252. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121253. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121254. */
  121255. export class CustomProceduralTexture extends ProceduralTexture {
  121256. private _animate;
  121257. private _time;
  121258. private _config;
  121259. private _texturePath;
  121260. /**
  121261. * Instantiates a new Custom Procedural Texture.
  121262. * 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.
  121263. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121265. * @param name Define the name of the texture
  121266. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121267. * @param size Define the size of the texture to create
  121268. * @param scene Define the scene the texture belongs to
  121269. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121270. * @param generateMipMaps Define if the texture should creates mip maps or not
  121271. */
  121272. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121273. private _loadJson;
  121274. /**
  121275. * Is the texture ready to be used ? (rendered at least once)
  121276. * @returns true if ready, otherwise, false.
  121277. */
  121278. isReady(): boolean;
  121279. /**
  121280. * Render the texture to its associated render target.
  121281. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121282. */
  121283. render(useCameraPostProcess?: boolean): void;
  121284. /**
  121285. * Update the list of dependant textures samplers in the shader.
  121286. */
  121287. updateTextures(): void;
  121288. /**
  121289. * Update the uniform values of the procedural texture in the shader.
  121290. */
  121291. updateShaderUniforms(): void;
  121292. /**
  121293. * Define if the texture animates or not.
  121294. */
  121295. animate: boolean;
  121296. }
  121297. }
  121298. declare module BABYLON {
  121299. /** @hidden */
  121300. export var noisePixelShader: {
  121301. name: string;
  121302. shader: string;
  121303. };
  121304. }
  121305. declare module BABYLON {
  121306. /**
  121307. * Class used to generate noise procedural textures
  121308. */
  121309. export class NoiseProceduralTexture extends ProceduralTexture {
  121310. private _time;
  121311. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121312. brightness: number;
  121313. /** Defines the number of octaves to process */
  121314. octaves: number;
  121315. /** Defines the level of persistence (0.8 by default) */
  121316. persistence: number;
  121317. /** Gets or sets animation speed factor (default is 1) */
  121318. animationSpeedFactor: number;
  121319. /**
  121320. * Creates a new NoiseProceduralTexture
  121321. * @param name defines the name fo the texture
  121322. * @param size defines the size of the texture (default is 256)
  121323. * @param scene defines the hosting scene
  121324. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121325. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121326. */
  121327. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121328. private _updateShaderUniforms;
  121329. protected _getDefines(): string;
  121330. /** Generate the current state of the procedural texture */
  121331. render(useCameraPostProcess?: boolean): void;
  121332. /**
  121333. * Serializes this noise procedural texture
  121334. * @returns a serialized noise procedural texture object
  121335. */
  121336. serialize(): any;
  121337. /**
  121338. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121339. * @param parsedTexture defines parsed texture data
  121340. * @param scene defines the current scene
  121341. * @param rootUrl defines the root URL containing noise procedural texture information
  121342. * @returns a parsed NoiseProceduralTexture
  121343. */
  121344. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121345. }
  121346. }
  121347. declare module BABYLON {
  121348. /**
  121349. * Raw cube texture where the raw buffers are passed in
  121350. */
  121351. export class RawCubeTexture extends CubeTexture {
  121352. /**
  121353. * Creates a cube texture where the raw buffers are passed in.
  121354. * @param scene defines the scene the texture is attached to
  121355. * @param data defines the array of data to use to create each face
  121356. * @param size defines the size of the textures
  121357. * @param format defines the format of the data
  121358. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121359. * @param generateMipMaps defines if the engine should generate the mip levels
  121360. * @param invertY defines if data must be stored with Y axis inverted
  121361. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121362. * @param compression defines the compression used (null by default)
  121363. */
  121364. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121365. /**
  121366. * Updates the raw cube texture.
  121367. * @param data defines the data to store
  121368. * @param format defines the data format
  121369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121370. * @param invertY defines if data must be stored with Y axis inverted
  121371. * @param compression defines the compression used (null by default)
  121372. * @param level defines which level of the texture to update
  121373. */
  121374. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121375. /**
  121376. * Updates a raw cube texture with RGBD encoded data.
  121377. * @param data defines the array of data [mipmap][face] to use to create each face
  121378. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121379. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121380. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121381. * @returns a promsie that resolves when the operation is complete
  121382. */
  121383. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121384. /**
  121385. * Clones the raw cube texture.
  121386. * @return a new cube texture
  121387. */
  121388. clone(): CubeTexture;
  121389. /** @hidden */
  121390. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121391. }
  121392. }
  121393. declare module BABYLON {
  121394. /**
  121395. * Class used to store 3D textures containing user data
  121396. */
  121397. export class RawTexture3D extends Texture {
  121398. /** Gets or sets the texture format to use */
  121399. format: number;
  121400. private _engine;
  121401. /**
  121402. * Create a new RawTexture3D
  121403. * @param data defines the data of the texture
  121404. * @param width defines the width of the texture
  121405. * @param height defines the height of the texture
  121406. * @param depth defines the depth of the texture
  121407. * @param format defines the texture format to use
  121408. * @param scene defines the hosting scene
  121409. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121410. * @param invertY defines if texture must be stored with Y axis inverted
  121411. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121412. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121413. */
  121414. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121415. /** Gets or sets the texture format to use */
  121416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121417. /**
  121418. * Update the texture with new data
  121419. * @param data defines the data to store in the texture
  121420. */
  121421. update(data: ArrayBufferView): void;
  121422. }
  121423. }
  121424. declare module BABYLON {
  121425. /**
  121426. * Class used to store 2D array textures containing user data
  121427. */
  121428. export class RawTexture2DArray extends Texture {
  121429. /** Gets or sets the texture format to use */
  121430. format: number;
  121431. private _engine;
  121432. /**
  121433. * Create a new RawTexture2DArray
  121434. * @param data defines the data of the texture
  121435. * @param width defines the width of the texture
  121436. * @param height defines the height of the texture
  121437. * @param depth defines the number of layers of the texture
  121438. * @param format defines the texture format to use
  121439. * @param scene defines the hosting scene
  121440. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121441. * @param invertY defines if texture must be stored with Y axis inverted
  121442. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121443. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121444. */
  121445. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121446. /** Gets or sets the texture format to use */
  121447. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121448. /**
  121449. * Update the texture with new data
  121450. * @param data defines the data to store in the texture
  121451. */
  121452. update(data: ArrayBufferView): void;
  121453. }
  121454. }
  121455. declare module BABYLON {
  121456. /**
  121457. * Creates a refraction texture used by refraction channel of the standard material.
  121458. * It is like a mirror but to see through a material.
  121459. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121460. */
  121461. export class RefractionTexture extends RenderTargetTexture {
  121462. /**
  121463. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121464. * 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.
  121465. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121466. */
  121467. refractionPlane: Plane;
  121468. /**
  121469. * Define how deep under the surface we should see.
  121470. */
  121471. depth: number;
  121472. /**
  121473. * Creates a refraction texture used by refraction channel of the standard material.
  121474. * It is like a mirror but to see through a material.
  121475. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121476. * @param name Define the texture name
  121477. * @param size Define the size of the underlying texture
  121478. * @param scene Define the scene the refraction belongs to
  121479. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121480. */
  121481. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121482. /**
  121483. * Clone the refraction texture.
  121484. * @returns the cloned texture
  121485. */
  121486. clone(): RefractionTexture;
  121487. /**
  121488. * Serialize the texture to a JSON representation you could use in Parse later on
  121489. * @returns the serialized JSON representation
  121490. */
  121491. serialize(): any;
  121492. }
  121493. }
  121494. declare module BABYLON {
  121495. /**
  121496. * Defines the options related to the creation of an HtmlElementTexture
  121497. */
  121498. export interface IHtmlElementTextureOptions {
  121499. /**
  121500. * Defines wether mip maps should be created or not.
  121501. */
  121502. generateMipMaps?: boolean;
  121503. /**
  121504. * Defines the sampling mode of the texture.
  121505. */
  121506. samplingMode?: number;
  121507. /**
  121508. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121509. */
  121510. engine: Nullable<ThinEngine>;
  121511. /**
  121512. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121513. */
  121514. scene: Nullable<Scene>;
  121515. }
  121516. /**
  121517. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121518. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121519. * is automatically managed.
  121520. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121521. * in your application.
  121522. *
  121523. * As the update is not automatic, you need to call them manually.
  121524. */
  121525. export class HtmlElementTexture extends BaseTexture {
  121526. /**
  121527. * The texture URL.
  121528. */
  121529. element: HTMLVideoElement | HTMLCanvasElement;
  121530. private static readonly DefaultOptions;
  121531. private _textureMatrix;
  121532. private _engine;
  121533. private _isVideo;
  121534. private _generateMipMaps;
  121535. private _samplingMode;
  121536. /**
  121537. * Instantiates a HtmlElementTexture from the following parameters.
  121538. *
  121539. * @param name Defines the name of the texture
  121540. * @param element Defines the video or canvas the texture is filled with
  121541. * @param options Defines the other none mandatory texture creation options
  121542. */
  121543. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121544. private _createInternalTexture;
  121545. /**
  121546. * Returns the texture matrix used in most of the material.
  121547. */
  121548. getTextureMatrix(): Matrix;
  121549. /**
  121550. * Updates the content of the texture.
  121551. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121552. */
  121553. update(invertY?: Nullable<boolean>): void;
  121554. }
  121555. }
  121556. declare module BABYLON {
  121557. /**
  121558. * Enum used to define the target of a block
  121559. */
  121560. export enum NodeMaterialBlockTargets {
  121561. /** Vertex shader */
  121562. Vertex = 1,
  121563. /** Fragment shader */
  121564. Fragment = 2,
  121565. /** Neutral */
  121566. Neutral = 4,
  121567. /** Vertex and Fragment */
  121568. VertexAndFragment = 3
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Defines the kind of connection point for node based material
  121574. */
  121575. export enum NodeMaterialBlockConnectionPointTypes {
  121576. /** Float */
  121577. Float = 1,
  121578. /** Int */
  121579. Int = 2,
  121580. /** Vector2 */
  121581. Vector2 = 4,
  121582. /** Vector3 */
  121583. Vector3 = 8,
  121584. /** Vector4 */
  121585. Vector4 = 16,
  121586. /** Color3 */
  121587. Color3 = 32,
  121588. /** Color4 */
  121589. Color4 = 64,
  121590. /** Matrix */
  121591. Matrix = 128,
  121592. /** Detect type based on connection */
  121593. AutoDetect = 1024,
  121594. /** Output type that will be defined by input type */
  121595. BasedOnInput = 2048
  121596. }
  121597. }
  121598. declare module BABYLON {
  121599. /**
  121600. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121601. */
  121602. export enum NodeMaterialBlockConnectionPointMode {
  121603. /** Value is an uniform */
  121604. Uniform = 0,
  121605. /** Value is a mesh attribute */
  121606. Attribute = 1,
  121607. /** Value is a varying between vertex and fragment shaders */
  121608. Varying = 2,
  121609. /** Mode is undefined */
  121610. Undefined = 3
  121611. }
  121612. }
  121613. declare module BABYLON {
  121614. /**
  121615. * Enum used to define system values e.g. values automatically provided by the system
  121616. */
  121617. export enum NodeMaterialSystemValues {
  121618. /** World */
  121619. World = 1,
  121620. /** View */
  121621. View = 2,
  121622. /** Projection */
  121623. Projection = 3,
  121624. /** ViewProjection */
  121625. ViewProjection = 4,
  121626. /** WorldView */
  121627. WorldView = 5,
  121628. /** WorldViewProjection */
  121629. WorldViewProjection = 6,
  121630. /** CameraPosition */
  121631. CameraPosition = 7,
  121632. /** Fog Color */
  121633. FogColor = 8,
  121634. /** Delta time */
  121635. DeltaTime = 9
  121636. }
  121637. }
  121638. declare module BABYLON {
  121639. /**
  121640. * Root class for all node material optimizers
  121641. */
  121642. export class NodeMaterialOptimizer {
  121643. /**
  121644. * Function used to optimize a NodeMaterial graph
  121645. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121646. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121647. */
  121648. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121649. }
  121650. }
  121651. declare module BABYLON {
  121652. /**
  121653. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121654. */
  121655. export class TransformBlock extends NodeMaterialBlock {
  121656. /**
  121657. * Defines the value to use to complement W value to transform it to a Vector4
  121658. */
  121659. complementW: number;
  121660. /**
  121661. * Defines the value to use to complement z value to transform it to a Vector4
  121662. */
  121663. complementZ: number;
  121664. /**
  121665. * Creates a new TransformBlock
  121666. * @param name defines the block name
  121667. */
  121668. constructor(name: string);
  121669. /**
  121670. * Gets the current class name
  121671. * @returns the class name
  121672. */
  121673. getClassName(): string;
  121674. /**
  121675. * Gets the vector input
  121676. */
  121677. readonly vector: NodeMaterialConnectionPoint;
  121678. /**
  121679. * Gets the output component
  121680. */
  121681. readonly output: NodeMaterialConnectionPoint;
  121682. /**
  121683. * Gets the matrix transform input
  121684. */
  121685. readonly transform: NodeMaterialConnectionPoint;
  121686. protected _buildBlock(state: NodeMaterialBuildState): this;
  121687. serialize(): any;
  121688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121689. protected _dumpPropertiesCode(): string;
  121690. }
  121691. }
  121692. declare module BABYLON {
  121693. /**
  121694. * Block used to output the vertex position
  121695. */
  121696. export class VertexOutputBlock extends NodeMaterialBlock {
  121697. /**
  121698. * Creates a new VertexOutputBlock
  121699. * @param name defines the block name
  121700. */
  121701. constructor(name: string);
  121702. /**
  121703. * Gets the current class name
  121704. * @returns the class name
  121705. */
  121706. getClassName(): string;
  121707. /**
  121708. * Gets the vector input component
  121709. */
  121710. readonly vector: NodeMaterialConnectionPoint;
  121711. protected _buildBlock(state: NodeMaterialBuildState): this;
  121712. }
  121713. }
  121714. declare module BABYLON {
  121715. /**
  121716. * Block used to output the final color
  121717. */
  121718. export class FragmentOutputBlock extends NodeMaterialBlock {
  121719. /**
  121720. * Create a new FragmentOutputBlock
  121721. * @param name defines the block name
  121722. */
  121723. constructor(name: string);
  121724. /**
  121725. * Gets the current class name
  121726. * @returns the class name
  121727. */
  121728. getClassName(): string;
  121729. /**
  121730. * Gets the rgba input component
  121731. */
  121732. readonly rgba: NodeMaterialConnectionPoint;
  121733. /**
  121734. * Gets the rgb input component
  121735. */
  121736. readonly rgb: NodeMaterialConnectionPoint;
  121737. /**
  121738. * Gets the a input component
  121739. */
  121740. readonly a: NodeMaterialConnectionPoint;
  121741. protected _buildBlock(state: NodeMaterialBuildState): this;
  121742. }
  121743. }
  121744. declare module BABYLON {
  121745. /**
  121746. * Block used to read a reflection texture from a sampler
  121747. */
  121748. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121749. private _define3DName;
  121750. private _defineCubicName;
  121751. private _defineExplicitName;
  121752. private _defineProjectionName;
  121753. private _defineLocalCubicName;
  121754. private _defineSphericalName;
  121755. private _definePlanarName;
  121756. private _defineEquirectangularName;
  121757. private _defineMirroredEquirectangularFixedName;
  121758. private _defineEquirectangularFixedName;
  121759. private _defineSkyboxName;
  121760. private _cubeSamplerName;
  121761. private _2DSamplerName;
  121762. private _positionUVWName;
  121763. private _directionWName;
  121764. private _reflectionCoordsName;
  121765. private _reflection2DCoordsName;
  121766. private _reflectionColorName;
  121767. private _reflectionMatrixName;
  121768. /**
  121769. * Gets or sets the texture associated with the node
  121770. */
  121771. texture: Nullable<BaseTexture>;
  121772. /**
  121773. * Create a new TextureBlock
  121774. * @param name defines the block name
  121775. */
  121776. constructor(name: string);
  121777. /**
  121778. * Gets the current class name
  121779. * @returns the class name
  121780. */
  121781. getClassName(): string;
  121782. /**
  121783. * Gets the world position input component
  121784. */
  121785. readonly position: NodeMaterialConnectionPoint;
  121786. /**
  121787. * Gets the world position input component
  121788. */
  121789. readonly worldPosition: NodeMaterialConnectionPoint;
  121790. /**
  121791. * Gets the world normal input component
  121792. */
  121793. readonly worldNormal: NodeMaterialConnectionPoint;
  121794. /**
  121795. * Gets the world input component
  121796. */
  121797. readonly world: NodeMaterialConnectionPoint;
  121798. /**
  121799. * Gets the camera (or eye) position component
  121800. */
  121801. readonly cameraPosition: NodeMaterialConnectionPoint;
  121802. /**
  121803. * Gets the view input component
  121804. */
  121805. readonly view: NodeMaterialConnectionPoint;
  121806. /**
  121807. * Gets the rgb output component
  121808. */
  121809. readonly rgb: NodeMaterialConnectionPoint;
  121810. /**
  121811. * Gets the r output component
  121812. */
  121813. readonly r: NodeMaterialConnectionPoint;
  121814. /**
  121815. * Gets the g output component
  121816. */
  121817. readonly g: NodeMaterialConnectionPoint;
  121818. /**
  121819. * Gets the b output component
  121820. */
  121821. readonly b: NodeMaterialConnectionPoint;
  121822. autoConfigure(material: NodeMaterial): void;
  121823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121824. isReady(): boolean;
  121825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121826. private _injectVertexCode;
  121827. private _writeOutput;
  121828. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121829. protected _dumpPropertiesCode(): string;
  121830. serialize(): any;
  121831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121832. }
  121833. }
  121834. declare module BABYLON {
  121835. /**
  121836. * Interface used to configure the node material editor
  121837. */
  121838. export interface INodeMaterialEditorOptions {
  121839. /** Define the URl to load node editor script */
  121840. editorURL?: string;
  121841. }
  121842. /** @hidden */
  121843. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121844. /** BONES */
  121845. NUM_BONE_INFLUENCERS: number;
  121846. BonesPerMesh: number;
  121847. BONETEXTURE: boolean;
  121848. /** MORPH TARGETS */
  121849. MORPHTARGETS: boolean;
  121850. MORPHTARGETS_NORMAL: boolean;
  121851. MORPHTARGETS_TANGENT: boolean;
  121852. MORPHTARGETS_UV: boolean;
  121853. NUM_MORPH_INFLUENCERS: number;
  121854. /** IMAGE PROCESSING */
  121855. IMAGEPROCESSING: boolean;
  121856. VIGNETTE: boolean;
  121857. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121858. VIGNETTEBLENDMODEOPAQUE: boolean;
  121859. TONEMAPPING: boolean;
  121860. TONEMAPPING_ACES: boolean;
  121861. CONTRAST: boolean;
  121862. EXPOSURE: boolean;
  121863. COLORCURVES: boolean;
  121864. COLORGRADING: boolean;
  121865. COLORGRADING3D: boolean;
  121866. SAMPLER3DGREENDEPTH: boolean;
  121867. SAMPLER3DBGRMAP: boolean;
  121868. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121869. /** MISC. */
  121870. BUMPDIRECTUV: number;
  121871. constructor();
  121872. setValue(name: string, value: boolean): void;
  121873. }
  121874. /**
  121875. * Class used to configure NodeMaterial
  121876. */
  121877. export interface INodeMaterialOptions {
  121878. /**
  121879. * Defines if blocks should emit comments
  121880. */
  121881. emitComments: boolean;
  121882. }
  121883. /**
  121884. * Class used to create a node based material built by assembling shader blocks
  121885. */
  121886. export class NodeMaterial extends PushMaterial {
  121887. private static _BuildIdGenerator;
  121888. private _options;
  121889. private _vertexCompilationState;
  121890. private _fragmentCompilationState;
  121891. private _sharedData;
  121892. private _buildId;
  121893. private _buildWasSuccessful;
  121894. private _cachedWorldViewMatrix;
  121895. private _cachedWorldViewProjectionMatrix;
  121896. private _optimizers;
  121897. private _animationFrame;
  121898. /** Define the URl to load node editor script */
  121899. static EditorURL: string;
  121900. private BJSNODEMATERIALEDITOR;
  121901. /** Get the inspector from bundle or global */
  121902. private _getGlobalNodeMaterialEditor;
  121903. /**
  121904. * 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)
  121905. */
  121906. ignoreAlpha: boolean;
  121907. /**
  121908. * Defines the maximum number of lights that can be used in the material
  121909. */
  121910. maxSimultaneousLights: number;
  121911. /**
  121912. * Observable raised when the material is built
  121913. */
  121914. onBuildObservable: Observable<NodeMaterial>;
  121915. /**
  121916. * Gets or sets the root nodes of the material vertex shader
  121917. */
  121918. _vertexOutputNodes: NodeMaterialBlock[];
  121919. /**
  121920. * Gets or sets the root nodes of the material fragment (pixel) shader
  121921. */
  121922. _fragmentOutputNodes: NodeMaterialBlock[];
  121923. /** Gets or sets options to control the node material overall behavior */
  121924. options: INodeMaterialOptions;
  121925. /**
  121926. * Default configuration related to image processing available in the standard Material.
  121927. */
  121928. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121929. /**
  121930. * Gets the image processing configuration used either in this material.
  121931. */
  121932. /**
  121933. * Sets the Default image processing configuration used either in the this material.
  121934. *
  121935. * If sets to null, the scene one is in use.
  121936. */
  121937. imageProcessingConfiguration: ImageProcessingConfiguration;
  121938. /**
  121939. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121940. */
  121941. attachedBlocks: NodeMaterialBlock[];
  121942. /**
  121943. * Create a new node based material
  121944. * @param name defines the material name
  121945. * @param scene defines the hosting scene
  121946. * @param options defines creation option
  121947. */
  121948. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121949. /**
  121950. * Gets the current class name of the material e.g. "NodeMaterial"
  121951. * @returns the class name
  121952. */
  121953. getClassName(): string;
  121954. /**
  121955. * Keep track of the image processing observer to allow dispose and replace.
  121956. */
  121957. private _imageProcessingObserver;
  121958. /**
  121959. * Attaches a new image processing configuration to the Standard Material.
  121960. * @param configuration
  121961. */
  121962. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121963. /**
  121964. * Get a block by its name
  121965. * @param name defines the name of the block to retrieve
  121966. * @returns the required block or null if not found
  121967. */
  121968. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121969. /**
  121970. * Get a block by its name
  121971. * @param predicate defines the predicate used to find the good candidate
  121972. * @returns the required block or null if not found
  121973. */
  121974. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121975. /**
  121976. * Get an input block by its name
  121977. * @param predicate defines the predicate used to find the good candidate
  121978. * @returns the required input block or null if not found
  121979. */
  121980. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121981. /**
  121982. * Gets the list of input blocks attached to this material
  121983. * @returns an array of InputBlocks
  121984. */
  121985. getInputBlocks(): InputBlock[];
  121986. /**
  121987. * Adds a new optimizer to the list of optimizers
  121988. * @param optimizer defines the optimizers to add
  121989. * @returns the current material
  121990. */
  121991. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121992. /**
  121993. * Remove an optimizer from the list of optimizers
  121994. * @param optimizer defines the optimizers to remove
  121995. * @returns the current material
  121996. */
  121997. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121998. /**
  121999. * Add a new block to the list of output nodes
  122000. * @param node defines the node to add
  122001. * @returns the current material
  122002. */
  122003. addOutputNode(node: NodeMaterialBlock): this;
  122004. /**
  122005. * Remove a block from the list of root nodes
  122006. * @param node defines the node to remove
  122007. * @returns the current material
  122008. */
  122009. removeOutputNode(node: NodeMaterialBlock): this;
  122010. private _addVertexOutputNode;
  122011. private _removeVertexOutputNode;
  122012. private _addFragmentOutputNode;
  122013. private _removeFragmentOutputNode;
  122014. /**
  122015. * Specifies if the material will require alpha blending
  122016. * @returns a boolean specifying if alpha blending is needed
  122017. */
  122018. needAlphaBlending(): boolean;
  122019. /**
  122020. * Specifies if this material should be rendered in alpha test mode
  122021. * @returns a boolean specifying if an alpha test is needed.
  122022. */
  122023. needAlphaTesting(): boolean;
  122024. private _initializeBlock;
  122025. private _resetDualBlocks;
  122026. /**
  122027. * Build the material and generates the inner effect
  122028. * @param verbose defines if the build should log activity
  122029. */
  122030. build(verbose?: boolean): void;
  122031. /**
  122032. * Runs an otpimization phase to try to improve the shader code
  122033. */
  122034. optimize(): void;
  122035. private _prepareDefinesForAttributes;
  122036. /**
  122037. * Get if the submesh is ready to be used and all its information available.
  122038. * Child classes can use it to update shaders
  122039. * @param mesh defines the mesh to check
  122040. * @param subMesh defines which submesh to check
  122041. * @param useInstances specifies that instances should be used
  122042. * @returns a boolean indicating that the submesh is ready or not
  122043. */
  122044. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122045. /**
  122046. * Get a string representing the shaders built by the current node graph
  122047. */
  122048. readonly compiledShaders: string;
  122049. /**
  122050. * Binds the world matrix to the material
  122051. * @param world defines the world transformation matrix
  122052. */
  122053. bindOnlyWorldMatrix(world: Matrix): void;
  122054. /**
  122055. * Binds the submesh to this material by preparing the effect and shader to draw
  122056. * @param world defines the world transformation matrix
  122057. * @param mesh defines the mesh containing the submesh
  122058. * @param subMesh defines the submesh to bind the material to
  122059. */
  122060. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122061. /**
  122062. * Gets the active textures from the material
  122063. * @returns an array of textures
  122064. */
  122065. getActiveTextures(): BaseTexture[];
  122066. /**
  122067. * Gets the list of texture blocks
  122068. * @returns an array of texture blocks
  122069. */
  122070. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  122071. /**
  122072. * Specifies if the material uses a texture
  122073. * @param texture defines the texture to check against the material
  122074. * @returns a boolean specifying if the material uses the texture
  122075. */
  122076. hasTexture(texture: BaseTexture): boolean;
  122077. /**
  122078. * Disposes the material
  122079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  122080. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  122081. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  122082. */
  122083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  122084. /** Creates the node editor window. */
  122085. private _createNodeEditor;
  122086. /**
  122087. * Launch the node material editor
  122088. * @param config Define the configuration of the editor
  122089. * @return a promise fulfilled when the node editor is visible
  122090. */
  122091. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122092. /**
  122093. * Clear the current material
  122094. */
  122095. clear(): void;
  122096. /**
  122097. * Clear the current material and set it to a default state
  122098. */
  122099. setToDefault(): void;
  122100. /**
  122101. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122102. * @param url defines the url to load from
  122103. * @returns a promise that will fullfil when the material is fully loaded
  122104. */
  122105. loadAsync(url: string): Promise<void>;
  122106. private _gatherBlocks;
  122107. /**
  122108. * Generate a string containing the code declaration required to create an equivalent of this material
  122109. * @returns a string
  122110. */
  122111. generateCode(): string;
  122112. /**
  122113. * Serializes this material in a JSON representation
  122114. * @returns the serialized material object
  122115. */
  122116. serialize(): any;
  122117. private _restoreConnections;
  122118. /**
  122119. * Clear the current graph and load a new one from a serialization object
  122120. * @param source defines the JSON representation of the material
  122121. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122122. */
  122123. loadFromSerialization(source: any, rootUrl?: string): void;
  122124. /**
  122125. * Creates a node material from parsed material data
  122126. * @param source defines the JSON representation of the material
  122127. * @param scene defines the hosting scene
  122128. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122129. * @returns a new node material
  122130. */
  122131. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122132. /**
  122133. * Creates a new node material set to default basic configuration
  122134. * @param name defines the name of the material
  122135. * @param scene defines the hosting scene
  122136. * @returns a new NodeMaterial
  122137. */
  122138. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /**
  122143. * Block used to read a texture from a sampler
  122144. */
  122145. export class TextureBlock extends NodeMaterialBlock {
  122146. private _defineName;
  122147. private _linearDefineName;
  122148. private _samplerName;
  122149. private _transformedUVName;
  122150. private _textureTransformName;
  122151. private _textureInfoName;
  122152. private _mainUVName;
  122153. private _mainUVDefineName;
  122154. /**
  122155. * Gets or sets the texture associated with the node
  122156. */
  122157. texture: Nullable<Texture>;
  122158. /**
  122159. * Create a new TextureBlock
  122160. * @param name defines the block name
  122161. */
  122162. constructor(name: string);
  122163. /**
  122164. * Gets the current class name
  122165. * @returns the class name
  122166. */
  122167. getClassName(): string;
  122168. /**
  122169. * Gets the uv input component
  122170. */
  122171. readonly uv: NodeMaterialConnectionPoint;
  122172. /**
  122173. * Gets the rgba output component
  122174. */
  122175. readonly rgba: NodeMaterialConnectionPoint;
  122176. /**
  122177. * Gets the rgb output component
  122178. */
  122179. readonly rgb: NodeMaterialConnectionPoint;
  122180. /**
  122181. * Gets the r output component
  122182. */
  122183. readonly r: NodeMaterialConnectionPoint;
  122184. /**
  122185. * Gets the g output component
  122186. */
  122187. readonly g: NodeMaterialConnectionPoint;
  122188. /**
  122189. * Gets the b output component
  122190. */
  122191. readonly b: NodeMaterialConnectionPoint;
  122192. /**
  122193. * Gets the a output component
  122194. */
  122195. readonly a: NodeMaterialConnectionPoint;
  122196. readonly target: NodeMaterialBlockTargets;
  122197. autoConfigure(material: NodeMaterial): void;
  122198. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122200. isReady(): boolean;
  122201. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122202. private readonly _isMixed;
  122203. private _injectVertexCode;
  122204. private _writeOutput;
  122205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122206. protected _dumpPropertiesCode(): string;
  122207. serialize(): any;
  122208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122209. }
  122210. }
  122211. declare module BABYLON {
  122212. /**
  122213. * Class used to store shared data between 2 NodeMaterialBuildState
  122214. */
  122215. export class NodeMaterialBuildStateSharedData {
  122216. /**
  122217. * Gets the list of emitted varyings
  122218. */
  122219. temps: string[];
  122220. /**
  122221. * Gets the list of emitted varyings
  122222. */
  122223. varyings: string[];
  122224. /**
  122225. * Gets the varying declaration string
  122226. */
  122227. varyingDeclaration: string;
  122228. /**
  122229. * Input blocks
  122230. */
  122231. inputBlocks: InputBlock[];
  122232. /**
  122233. * Input blocks
  122234. */
  122235. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122236. /**
  122237. * Bindable blocks (Blocks that need to set data to the effect)
  122238. */
  122239. bindableBlocks: NodeMaterialBlock[];
  122240. /**
  122241. * List of blocks that can provide a compilation fallback
  122242. */
  122243. blocksWithFallbacks: NodeMaterialBlock[];
  122244. /**
  122245. * List of blocks that can provide a define update
  122246. */
  122247. blocksWithDefines: NodeMaterialBlock[];
  122248. /**
  122249. * List of blocks that can provide a repeatable content
  122250. */
  122251. repeatableContentBlocks: NodeMaterialBlock[];
  122252. /**
  122253. * List of blocks that can provide a dynamic list of uniforms
  122254. */
  122255. dynamicUniformBlocks: NodeMaterialBlock[];
  122256. /**
  122257. * List of blocks that can block the isReady function for the material
  122258. */
  122259. blockingBlocks: NodeMaterialBlock[];
  122260. /**
  122261. * Gets the list of animated inputs
  122262. */
  122263. animatedInputs: InputBlock[];
  122264. /**
  122265. * Build Id used to avoid multiple recompilations
  122266. */
  122267. buildId: number;
  122268. /** List of emitted variables */
  122269. variableNames: {
  122270. [key: string]: number;
  122271. };
  122272. /** List of emitted defines */
  122273. defineNames: {
  122274. [key: string]: number;
  122275. };
  122276. /** Should emit comments? */
  122277. emitComments: boolean;
  122278. /** Emit build activity */
  122279. verbose: boolean;
  122280. /** Gets or sets the hosting scene */
  122281. scene: Scene;
  122282. /**
  122283. * Gets the compilation hints emitted at compilation time
  122284. */
  122285. hints: {
  122286. needWorldViewMatrix: boolean;
  122287. needWorldViewProjectionMatrix: boolean;
  122288. needAlphaBlending: boolean;
  122289. needAlphaTesting: boolean;
  122290. };
  122291. /**
  122292. * List of compilation checks
  122293. */
  122294. checks: {
  122295. emitVertex: boolean;
  122296. emitFragment: boolean;
  122297. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122298. };
  122299. /** Creates a new shared data */
  122300. constructor();
  122301. /**
  122302. * Emits console errors and exceptions if there is a failing check
  122303. */
  122304. emitErrors(): void;
  122305. }
  122306. }
  122307. declare module BABYLON {
  122308. /**
  122309. * Class used to store node based material build state
  122310. */
  122311. export class NodeMaterialBuildState {
  122312. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122313. supportUniformBuffers: boolean;
  122314. /**
  122315. * Gets the list of emitted attributes
  122316. */
  122317. attributes: string[];
  122318. /**
  122319. * Gets the list of emitted uniforms
  122320. */
  122321. uniforms: string[];
  122322. /**
  122323. * Gets the list of emitted constants
  122324. */
  122325. constants: string[];
  122326. /**
  122327. * Gets the list of emitted samplers
  122328. */
  122329. samplers: string[];
  122330. /**
  122331. * Gets the list of emitted functions
  122332. */
  122333. functions: {
  122334. [key: string]: string;
  122335. };
  122336. /**
  122337. * Gets the list of emitted extensions
  122338. */
  122339. extensions: {
  122340. [key: string]: string;
  122341. };
  122342. /**
  122343. * Gets the target of the compilation state
  122344. */
  122345. target: NodeMaterialBlockTargets;
  122346. /**
  122347. * Gets the list of emitted counters
  122348. */
  122349. counters: {
  122350. [key: string]: number;
  122351. };
  122352. /**
  122353. * Shared data between multiple NodeMaterialBuildState instances
  122354. */
  122355. sharedData: NodeMaterialBuildStateSharedData;
  122356. /** @hidden */
  122357. _vertexState: NodeMaterialBuildState;
  122358. /** @hidden */
  122359. _attributeDeclaration: string;
  122360. /** @hidden */
  122361. _uniformDeclaration: string;
  122362. /** @hidden */
  122363. _constantDeclaration: string;
  122364. /** @hidden */
  122365. _samplerDeclaration: string;
  122366. /** @hidden */
  122367. _varyingTransfer: string;
  122368. private _repeatableContentAnchorIndex;
  122369. /** @hidden */
  122370. _builtCompilationString: string;
  122371. /**
  122372. * Gets the emitted compilation strings
  122373. */
  122374. compilationString: string;
  122375. /**
  122376. * Finalize the compilation strings
  122377. * @param state defines the current compilation state
  122378. */
  122379. finalize(state: NodeMaterialBuildState): void;
  122380. /** @hidden */
  122381. readonly _repeatableContentAnchor: string;
  122382. /** @hidden */
  122383. _getFreeVariableName(prefix: string): string;
  122384. /** @hidden */
  122385. _getFreeDefineName(prefix: string): string;
  122386. /** @hidden */
  122387. _excludeVariableName(name: string): void;
  122388. /** @hidden */
  122389. _emit2DSampler(name: string): void;
  122390. /** @hidden */
  122391. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122392. /** @hidden */
  122393. _emitExtension(name: string, extension: string): void;
  122394. /** @hidden */
  122395. _emitFunction(name: string, code: string, comments: string): void;
  122396. /** @hidden */
  122397. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122398. replaceStrings?: {
  122399. search: RegExp;
  122400. replace: string;
  122401. }[];
  122402. repeatKey?: string;
  122403. }): string;
  122404. /** @hidden */
  122405. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122406. repeatKey?: string;
  122407. removeAttributes?: boolean;
  122408. removeUniforms?: boolean;
  122409. removeVaryings?: boolean;
  122410. removeIfDef?: boolean;
  122411. replaceStrings?: {
  122412. search: RegExp;
  122413. replace: string;
  122414. }[];
  122415. }, storeKey?: string): void;
  122416. /** @hidden */
  122417. _registerTempVariable(name: string): boolean;
  122418. /** @hidden */
  122419. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122420. /** @hidden */
  122421. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122422. /** @hidden */
  122423. _emitFloat(value: number): string;
  122424. }
  122425. }
  122426. declare module BABYLON {
  122427. /**
  122428. * Defines a block that can be used inside a node based material
  122429. */
  122430. export class NodeMaterialBlock {
  122431. private _buildId;
  122432. private _buildTarget;
  122433. private _target;
  122434. private _isFinalMerger;
  122435. private _isInput;
  122436. protected _isUnique: boolean;
  122437. /** @hidden */
  122438. _codeVariableName: string;
  122439. /** @hidden */
  122440. _inputs: NodeMaterialConnectionPoint[];
  122441. /** @hidden */
  122442. _outputs: NodeMaterialConnectionPoint[];
  122443. /** @hidden */
  122444. _preparationId: number;
  122445. /**
  122446. * Gets or sets the name of the block
  122447. */
  122448. name: string;
  122449. /**
  122450. * Gets or sets the unique id of the node
  122451. */
  122452. uniqueId: number;
  122453. /**
  122454. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122455. */
  122456. readonly isUnique: boolean;
  122457. /**
  122458. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122459. */
  122460. readonly isFinalMerger: boolean;
  122461. /**
  122462. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122463. */
  122464. readonly isInput: boolean;
  122465. /**
  122466. * Gets or sets the build Id
  122467. */
  122468. buildId: number;
  122469. /**
  122470. * Gets or sets the target of the block
  122471. */
  122472. target: NodeMaterialBlockTargets;
  122473. /**
  122474. * Gets the list of input points
  122475. */
  122476. readonly inputs: NodeMaterialConnectionPoint[];
  122477. /** Gets the list of output points */
  122478. readonly outputs: NodeMaterialConnectionPoint[];
  122479. /**
  122480. * Find an input by its name
  122481. * @param name defines the name of the input to look for
  122482. * @returns the input or null if not found
  122483. */
  122484. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122485. /**
  122486. * Find an output by its name
  122487. * @param name defines the name of the outputto look for
  122488. * @returns the output or null if not found
  122489. */
  122490. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122491. /**
  122492. * Creates a new NodeMaterialBlock
  122493. * @param name defines the block name
  122494. * @param target defines the target of that block (Vertex by default)
  122495. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122496. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122497. */
  122498. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122499. /**
  122500. * Initialize the block and prepare the context for build
  122501. * @param state defines the state that will be used for the build
  122502. */
  122503. initialize(state: NodeMaterialBuildState): void;
  122504. /**
  122505. * Bind data to effect. Will only be called for blocks with isBindable === true
  122506. * @param effect defines the effect to bind data to
  122507. * @param nodeMaterial defines the hosting NodeMaterial
  122508. * @param mesh defines the mesh that will be rendered
  122509. */
  122510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122511. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122512. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122513. protected _writeFloat(value: number): string;
  122514. /**
  122515. * Gets the current class name e.g. "NodeMaterialBlock"
  122516. * @returns the class name
  122517. */
  122518. getClassName(): string;
  122519. /**
  122520. * Register a new input. Must be called inside a block constructor
  122521. * @param name defines the connection point name
  122522. * @param type defines the connection point type
  122523. * @param isOptional defines a boolean indicating that this input can be omitted
  122524. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122525. * @returns the current block
  122526. */
  122527. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122528. /**
  122529. * Register a new output. Must be called inside a block constructor
  122530. * @param name defines the connection point name
  122531. * @param type defines the connection point type
  122532. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122533. * @returns the current block
  122534. */
  122535. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122536. /**
  122537. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122538. * @param forOutput defines an optional connection point to check compatibility with
  122539. * @returns the first available input or null
  122540. */
  122541. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122542. /**
  122543. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122544. * @param forBlock defines an optional block to check compatibility with
  122545. * @returns the first available input or null
  122546. */
  122547. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122548. /**
  122549. * Gets the sibling of the given output
  122550. * @param current defines the current output
  122551. * @returns the next output in the list or null
  122552. */
  122553. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122554. /**
  122555. * Connect current block with another block
  122556. * @param other defines the block to connect with
  122557. * @param options define the various options to help pick the right connections
  122558. * @returns the current block
  122559. */
  122560. connectTo(other: NodeMaterialBlock, options?: {
  122561. input?: string;
  122562. output?: string;
  122563. outputSwizzle?: string;
  122564. }): this | undefined;
  122565. protected _buildBlock(state: NodeMaterialBuildState): void;
  122566. /**
  122567. * Add uniforms, samplers and uniform buffers at compilation time
  122568. * @param state defines the state to update
  122569. * @param nodeMaterial defines the node material requesting the update
  122570. * @param defines defines the material defines to update
  122571. * @param uniformBuffers defines the list of uniform buffer names
  122572. */
  122573. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122574. /**
  122575. * Add potential fallbacks if shader compilation fails
  122576. * @param mesh defines the mesh to be rendered
  122577. * @param fallbacks defines the current prioritized list of fallbacks
  122578. */
  122579. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122580. /**
  122581. * Initialize defines for shader compilation
  122582. * @param mesh defines the mesh to be rendered
  122583. * @param nodeMaterial defines the node material requesting the update
  122584. * @param defines defines the material defines to update
  122585. * @param useInstances specifies that instances should be used
  122586. */
  122587. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122588. /**
  122589. * Update defines for shader compilation
  122590. * @param mesh defines the mesh to be rendered
  122591. * @param nodeMaterial defines the node material requesting the update
  122592. * @param defines defines the material defines to update
  122593. * @param useInstances specifies that instances should be used
  122594. */
  122595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122596. /**
  122597. * Lets the block try to connect some inputs automatically
  122598. * @param material defines the hosting NodeMaterial
  122599. */
  122600. autoConfigure(material: NodeMaterial): void;
  122601. /**
  122602. * Function called when a block is declared as repeatable content generator
  122603. * @param vertexShaderState defines the current compilation state for the vertex shader
  122604. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122605. * @param mesh defines the mesh to be rendered
  122606. * @param defines defines the material defines to update
  122607. */
  122608. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122609. /**
  122610. * Checks if the block is ready
  122611. * @param mesh defines the mesh to be rendered
  122612. * @param nodeMaterial defines the node material requesting the update
  122613. * @param defines defines the material defines to update
  122614. * @param useInstances specifies that instances should be used
  122615. * @returns true if the block is ready
  122616. */
  122617. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122618. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122619. private _processBuild;
  122620. /**
  122621. * Compile the current node and generate the shader code
  122622. * @param state defines the current compilation state (uniforms, samplers, current string)
  122623. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122624. * @returns true if already built
  122625. */
  122626. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122627. protected _inputRename(name: string): string;
  122628. protected _outputRename(name: string): string;
  122629. protected _dumpPropertiesCode(): string;
  122630. /** @hidden */
  122631. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122632. /** @hidden */
  122633. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122634. /**
  122635. * Clone the current block to a new identical block
  122636. * @param scene defines the hosting scene
  122637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122638. * @returns a copy of the current block
  122639. */
  122640. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122641. /**
  122642. * Serializes this block in a JSON representation
  122643. * @returns the serialized block object
  122644. */
  122645. serialize(): any;
  122646. /** @hidden */
  122647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122648. /**
  122649. * Release resources
  122650. */
  122651. dispose(): void;
  122652. }
  122653. }
  122654. declare module BABYLON {
  122655. /**
  122656. * Enum defining the type of animations supported by InputBlock
  122657. */
  122658. export enum AnimatedInputBlockTypes {
  122659. /** No animation */
  122660. None = 0,
  122661. /** Time based animation. Will only work for floats */
  122662. Time = 1
  122663. }
  122664. }
  122665. declare module BABYLON {
  122666. /**
  122667. * Block used to expose an input value
  122668. */
  122669. export class InputBlock extends NodeMaterialBlock {
  122670. private _mode;
  122671. private _associatedVariableName;
  122672. private _storedValue;
  122673. private _valueCallback;
  122674. private _type;
  122675. private _animationType;
  122676. /** Gets or set a value used to limit the range of float values */
  122677. min: number;
  122678. /** Gets or set a value used to limit the range of float values */
  122679. max: number;
  122680. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122681. matrixMode: number;
  122682. /** @hidden */
  122683. _systemValue: Nullable<NodeMaterialSystemValues>;
  122684. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122685. visibleInInspector: boolean;
  122686. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122687. isConstant: boolean;
  122688. /**
  122689. * Gets or sets the connection point type (default is float)
  122690. */
  122691. readonly type: NodeMaterialBlockConnectionPointTypes;
  122692. /**
  122693. * Creates a new InputBlock
  122694. * @param name defines the block name
  122695. * @param target defines the target of that block (Vertex by default)
  122696. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122697. */
  122698. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122699. /**
  122700. * Gets the output component
  122701. */
  122702. readonly output: NodeMaterialConnectionPoint;
  122703. /**
  122704. * Set the source of this connection point to a vertex attribute
  122705. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122706. * @returns the current connection point
  122707. */
  122708. setAsAttribute(attributeName?: string): InputBlock;
  122709. /**
  122710. * Set the source of this connection point to a system value
  122711. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122712. * @returns the current connection point
  122713. */
  122714. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122715. /**
  122716. * Gets or sets the value of that point.
  122717. * Please note that this value will be ignored if valueCallback is defined
  122718. */
  122719. value: any;
  122720. /**
  122721. * Gets or sets a callback used to get the value of that point.
  122722. * Please note that setting this value will force the connection point to ignore the value property
  122723. */
  122724. valueCallback: () => any;
  122725. /**
  122726. * Gets or sets the associated variable name in the shader
  122727. */
  122728. associatedVariableName: string;
  122729. /** Gets or sets the type of animation applied to the input */
  122730. animationType: AnimatedInputBlockTypes;
  122731. /**
  122732. * Gets a boolean indicating that this connection point not defined yet
  122733. */
  122734. readonly isUndefined: boolean;
  122735. /**
  122736. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122737. * In this case the connection point name must be the name of the uniform to use.
  122738. * Can only be set on inputs
  122739. */
  122740. isUniform: boolean;
  122741. /**
  122742. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122743. * In this case the connection point name must be the name of the attribute to use
  122744. * Can only be set on inputs
  122745. */
  122746. isAttribute: boolean;
  122747. /**
  122748. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122749. * Can only be set on exit points
  122750. */
  122751. isVarying: boolean;
  122752. /**
  122753. * Gets a boolean indicating that the current connection point is a system value
  122754. */
  122755. readonly isSystemValue: boolean;
  122756. /**
  122757. * Gets or sets the current well known value or null if not defined as a system value
  122758. */
  122759. systemValue: Nullable<NodeMaterialSystemValues>;
  122760. /**
  122761. * Gets the current class name
  122762. * @returns the class name
  122763. */
  122764. getClassName(): string;
  122765. /**
  122766. * Animate the input if animationType !== None
  122767. * @param scene defines the rendering scene
  122768. */
  122769. animate(scene: Scene): void;
  122770. private _emitDefine;
  122771. initialize(state: NodeMaterialBuildState): void;
  122772. /**
  122773. * Set the input block to its default value (based on its type)
  122774. */
  122775. setDefaultValue(): void;
  122776. private _emitConstant;
  122777. private _emit;
  122778. /** @hidden */
  122779. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122780. /** @hidden */
  122781. _transmit(effect: Effect, scene: Scene): void;
  122782. protected _buildBlock(state: NodeMaterialBuildState): void;
  122783. protected _dumpPropertiesCode(): string;
  122784. serialize(): any;
  122785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122786. }
  122787. }
  122788. declare module BABYLON {
  122789. /**
  122790. * Enum used to define the compatibility state between two connection points
  122791. */
  122792. export enum NodeMaterialConnectionPointCompatibilityStates {
  122793. /** Points are compatibles */
  122794. Compatible = 0,
  122795. /** Points are incompatible because of their types */
  122796. TypeIncompatible = 1,
  122797. /** Points are incompatible because of their targets (vertex vs fragment) */
  122798. TargetIncompatible = 2
  122799. }
  122800. /**
  122801. * Defines a connection point for a block
  122802. */
  122803. export class NodeMaterialConnectionPoint {
  122804. /** @hidden */
  122805. _ownerBlock: NodeMaterialBlock;
  122806. /** @hidden */
  122807. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122808. private _endpoints;
  122809. private _associatedVariableName;
  122810. /** @hidden */
  122811. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122812. /** @hidden */
  122813. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122814. private _type;
  122815. /** @hidden */
  122816. _enforceAssociatedVariableName: boolean;
  122817. /**
  122818. * Gets or sets the additional types supported by this connection point
  122819. */
  122820. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122821. /**
  122822. * Gets or sets the additional types excluded by this connection point
  122823. */
  122824. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122825. /**
  122826. * Observable triggered when this point is connected
  122827. */
  122828. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122829. /**
  122830. * Gets or sets the associated variable name in the shader
  122831. */
  122832. associatedVariableName: string;
  122833. /**
  122834. * Gets or sets the connection point type (default is float)
  122835. */
  122836. type: NodeMaterialBlockConnectionPointTypes;
  122837. /**
  122838. * Gets or sets the connection point name
  122839. */
  122840. name: string;
  122841. /**
  122842. * Gets or sets a boolean indicating that this connection point can be omitted
  122843. */
  122844. isOptional: boolean;
  122845. /**
  122846. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122847. */
  122848. define: string;
  122849. /** @hidden */
  122850. _prioritizeVertex: boolean;
  122851. private _target;
  122852. /** Gets or sets the target of that connection point */
  122853. target: NodeMaterialBlockTargets;
  122854. /**
  122855. * Gets a boolean indicating that the current point is connected
  122856. */
  122857. readonly isConnected: boolean;
  122858. /**
  122859. * Gets a boolean indicating that the current point is connected to an input block
  122860. */
  122861. readonly isConnectedToInputBlock: boolean;
  122862. /**
  122863. * Gets a the connected input block (if any)
  122864. */
  122865. readonly connectInputBlock: Nullable<InputBlock>;
  122866. /** Get the other side of the connection (if any) */
  122867. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122868. /** Get the block that owns this connection point */
  122869. readonly ownerBlock: NodeMaterialBlock;
  122870. /** Get the block connected on the other side of this connection (if any) */
  122871. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122872. /** Get the block connected on the endpoints of this connection (if any) */
  122873. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122874. /** Gets the list of connected endpoints */
  122875. readonly endpoints: NodeMaterialConnectionPoint[];
  122876. /** Gets a boolean indicating if that output point is connected to at least one input */
  122877. readonly hasEndpoints: boolean;
  122878. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122879. readonly isConnectedInVertexShader: boolean;
  122880. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122881. readonly isConnectedInFragmentShader: boolean;
  122882. /**
  122883. * Creates a new connection point
  122884. * @param name defines the connection point name
  122885. * @param ownerBlock defines the block hosting this connection point
  122886. */
  122887. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122888. /**
  122889. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122890. * @returns the class name
  122891. */
  122892. getClassName(): string;
  122893. /**
  122894. * Gets a boolean indicating if the current point can be connected to another point
  122895. * @param connectionPoint defines the other connection point
  122896. * @returns a boolean
  122897. */
  122898. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122899. /**
  122900. * Gets a number indicating if the current point can be connected to another point
  122901. * @param connectionPoint defines the other connection point
  122902. * @returns a number defining the compatibility state
  122903. */
  122904. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122905. /**
  122906. * Connect this point to another connection point
  122907. * @param connectionPoint defines the other connection point
  122908. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122909. * @returns the current connection point
  122910. */
  122911. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122912. /**
  122913. * Disconnect this point from one of his endpoint
  122914. * @param endpoint defines the other connection point
  122915. * @returns the current connection point
  122916. */
  122917. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122918. /**
  122919. * Serializes this point in a JSON representation
  122920. * @returns the serialized point object
  122921. */
  122922. serialize(): any;
  122923. /**
  122924. * Release resources
  122925. */
  122926. dispose(): void;
  122927. }
  122928. }
  122929. declare module BABYLON {
  122930. /**
  122931. * Block used to add support for vertex skinning (bones)
  122932. */
  122933. export class BonesBlock extends NodeMaterialBlock {
  122934. /**
  122935. * Creates a new BonesBlock
  122936. * @param name defines the block name
  122937. */
  122938. constructor(name: string);
  122939. /**
  122940. * Initialize the block and prepare the context for build
  122941. * @param state defines the state that will be used for the build
  122942. */
  122943. initialize(state: NodeMaterialBuildState): void;
  122944. /**
  122945. * Gets the current class name
  122946. * @returns the class name
  122947. */
  122948. getClassName(): string;
  122949. /**
  122950. * Gets the matrix indices input component
  122951. */
  122952. readonly matricesIndices: NodeMaterialConnectionPoint;
  122953. /**
  122954. * Gets the matrix weights input component
  122955. */
  122956. readonly matricesWeights: NodeMaterialConnectionPoint;
  122957. /**
  122958. * Gets the extra matrix indices input component
  122959. */
  122960. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122961. /**
  122962. * Gets the extra matrix weights input component
  122963. */
  122964. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122965. /**
  122966. * Gets the world input component
  122967. */
  122968. readonly world: NodeMaterialConnectionPoint;
  122969. /**
  122970. * Gets the output component
  122971. */
  122972. readonly output: NodeMaterialConnectionPoint;
  122973. autoConfigure(material: NodeMaterial): void;
  122974. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122977. protected _buildBlock(state: NodeMaterialBuildState): this;
  122978. }
  122979. }
  122980. declare module BABYLON {
  122981. /**
  122982. * Block used to add support for instances
  122983. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122984. */
  122985. export class InstancesBlock extends NodeMaterialBlock {
  122986. /**
  122987. * Creates a new InstancesBlock
  122988. * @param name defines the block name
  122989. */
  122990. constructor(name: string);
  122991. /**
  122992. * Gets the current class name
  122993. * @returns the class name
  122994. */
  122995. getClassName(): string;
  122996. /**
  122997. * Gets the first world row input component
  122998. */
  122999. readonly world0: NodeMaterialConnectionPoint;
  123000. /**
  123001. * Gets the second world row input component
  123002. */
  123003. readonly world1: NodeMaterialConnectionPoint;
  123004. /**
  123005. * Gets the third world row input component
  123006. */
  123007. readonly world2: NodeMaterialConnectionPoint;
  123008. /**
  123009. * Gets the forth world row input component
  123010. */
  123011. readonly world3: NodeMaterialConnectionPoint;
  123012. /**
  123013. * Gets the world input component
  123014. */
  123015. readonly world: NodeMaterialConnectionPoint;
  123016. /**
  123017. * Gets the output component
  123018. */
  123019. readonly output: NodeMaterialConnectionPoint;
  123020. autoConfigure(material: NodeMaterial): void;
  123021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123022. protected _buildBlock(state: NodeMaterialBuildState): this;
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Block used to add morph targets support to vertex shader
  123028. */
  123029. export class MorphTargetsBlock extends NodeMaterialBlock {
  123030. private _repeatableContentAnchor;
  123031. private _repeatebleContentGenerated;
  123032. /**
  123033. * Create a new MorphTargetsBlock
  123034. * @param name defines the block name
  123035. */
  123036. constructor(name: string);
  123037. /**
  123038. * Gets the current class name
  123039. * @returns the class name
  123040. */
  123041. getClassName(): string;
  123042. /**
  123043. * Gets the position input component
  123044. */
  123045. readonly position: NodeMaterialConnectionPoint;
  123046. /**
  123047. * Gets the normal input component
  123048. */
  123049. readonly normal: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the tangent input component
  123052. */
  123053. readonly tangent: NodeMaterialConnectionPoint;
  123054. /**
  123055. * Gets the tangent input component
  123056. */
  123057. readonly uv: NodeMaterialConnectionPoint;
  123058. /**
  123059. * Gets the position output component
  123060. */
  123061. readonly positionOutput: NodeMaterialConnectionPoint;
  123062. /**
  123063. * Gets the normal output component
  123064. */
  123065. readonly normalOutput: NodeMaterialConnectionPoint;
  123066. /**
  123067. * Gets the tangent output component
  123068. */
  123069. readonly tangentOutput: NodeMaterialConnectionPoint;
  123070. /**
  123071. * Gets the tangent output component
  123072. */
  123073. readonly uvOutput: NodeMaterialConnectionPoint;
  123074. initialize(state: NodeMaterialBuildState): void;
  123075. autoConfigure(material: NodeMaterial): void;
  123076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123078. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123079. protected _buildBlock(state: NodeMaterialBuildState): this;
  123080. }
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * Block used to get data information from a light
  123085. */
  123086. export class LightInformationBlock extends NodeMaterialBlock {
  123087. private _lightDataUniformName;
  123088. private _lightColorUniformName;
  123089. private _lightTypeDefineName;
  123090. /**
  123091. * Gets or sets the light associated with this block
  123092. */
  123093. light: Nullable<Light>;
  123094. /**
  123095. * Creates a new LightInformationBlock
  123096. * @param name defines the block name
  123097. */
  123098. constructor(name: string);
  123099. /**
  123100. * Gets the current class name
  123101. * @returns the class name
  123102. */
  123103. getClassName(): string;
  123104. /**
  123105. * Gets the world position input component
  123106. */
  123107. readonly worldPosition: NodeMaterialConnectionPoint;
  123108. /**
  123109. * Gets the direction output component
  123110. */
  123111. readonly direction: NodeMaterialConnectionPoint;
  123112. /**
  123113. * Gets the direction output component
  123114. */
  123115. readonly color: NodeMaterialConnectionPoint;
  123116. /**
  123117. * Gets the direction output component
  123118. */
  123119. readonly intensity: NodeMaterialConnectionPoint;
  123120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123122. protected _buildBlock(state: NodeMaterialBuildState): this;
  123123. serialize(): any;
  123124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. /**
  123129. * Block used to add image processing support to fragment shader
  123130. */
  123131. export class ImageProcessingBlock extends NodeMaterialBlock {
  123132. /**
  123133. * Create a new ImageProcessingBlock
  123134. * @param name defines the block name
  123135. */
  123136. constructor(name: string);
  123137. /**
  123138. * Gets the current class name
  123139. * @returns the class name
  123140. */
  123141. getClassName(): string;
  123142. /**
  123143. * Gets the color input component
  123144. */
  123145. readonly color: NodeMaterialConnectionPoint;
  123146. /**
  123147. * Gets the output component
  123148. */
  123149. readonly output: NodeMaterialConnectionPoint;
  123150. /**
  123151. * Initialize the block and prepare the context for build
  123152. * @param state defines the state that will be used for the build
  123153. */
  123154. initialize(state: NodeMaterialBuildState): void;
  123155. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123158. protected _buildBlock(state: NodeMaterialBuildState): this;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Block used to pertub normals based on a normal map
  123164. */
  123165. export class PerturbNormalBlock extends NodeMaterialBlock {
  123166. private _tangentSpaceParameterName;
  123167. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123168. invertX: boolean;
  123169. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123170. invertY: boolean;
  123171. /**
  123172. * Create a new PerturbNormalBlock
  123173. * @param name defines the block name
  123174. */
  123175. constructor(name: string);
  123176. /**
  123177. * Gets the current class name
  123178. * @returns the class name
  123179. */
  123180. getClassName(): string;
  123181. /**
  123182. * Gets the world position input component
  123183. */
  123184. readonly worldPosition: NodeMaterialConnectionPoint;
  123185. /**
  123186. * Gets the world normal input component
  123187. */
  123188. readonly worldNormal: NodeMaterialConnectionPoint;
  123189. /**
  123190. * Gets the uv input component
  123191. */
  123192. readonly uv: NodeMaterialConnectionPoint;
  123193. /**
  123194. * Gets the normal map color input component
  123195. */
  123196. readonly normalMapColor: NodeMaterialConnectionPoint;
  123197. /**
  123198. * Gets the strength input component
  123199. */
  123200. readonly strength: NodeMaterialConnectionPoint;
  123201. /**
  123202. * Gets the output component
  123203. */
  123204. readonly output: NodeMaterialConnectionPoint;
  123205. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123207. autoConfigure(material: NodeMaterial): void;
  123208. protected _buildBlock(state: NodeMaterialBuildState): this;
  123209. protected _dumpPropertiesCode(): string;
  123210. serialize(): any;
  123211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123212. }
  123213. }
  123214. declare module BABYLON {
  123215. /**
  123216. * Block used to discard a pixel if a value is smaller than a cutoff
  123217. */
  123218. export class DiscardBlock extends NodeMaterialBlock {
  123219. /**
  123220. * Create a new DiscardBlock
  123221. * @param name defines the block name
  123222. */
  123223. constructor(name: string);
  123224. /**
  123225. * Gets the current class name
  123226. * @returns the class name
  123227. */
  123228. getClassName(): string;
  123229. /**
  123230. * Gets the color input component
  123231. */
  123232. readonly value: NodeMaterialConnectionPoint;
  123233. /**
  123234. * Gets the cutoff input component
  123235. */
  123236. readonly cutoff: NodeMaterialConnectionPoint;
  123237. protected _buildBlock(state: NodeMaterialBuildState): this;
  123238. }
  123239. }
  123240. declare module BABYLON {
  123241. /**
  123242. * Block used to test if the fragment shader is front facing
  123243. */
  123244. export class FrontFacingBlock extends NodeMaterialBlock {
  123245. /**
  123246. * Creates a new FrontFacingBlock
  123247. * @param name defines the block name
  123248. */
  123249. constructor(name: string);
  123250. /**
  123251. * Gets the current class name
  123252. * @returns the class name
  123253. */
  123254. getClassName(): string;
  123255. /**
  123256. * Gets the output component
  123257. */
  123258. readonly output: NodeMaterialConnectionPoint;
  123259. protected _buildBlock(state: NodeMaterialBuildState): this;
  123260. }
  123261. }
  123262. declare module BABYLON {
  123263. /**
  123264. * Block used to add support for scene fog
  123265. */
  123266. export class FogBlock extends NodeMaterialBlock {
  123267. private _fogDistanceName;
  123268. private _fogParameters;
  123269. /**
  123270. * Create a new FogBlock
  123271. * @param name defines the block name
  123272. */
  123273. constructor(name: string);
  123274. /**
  123275. * Gets the current class name
  123276. * @returns the class name
  123277. */
  123278. getClassName(): string;
  123279. /**
  123280. * Gets the world position input component
  123281. */
  123282. readonly worldPosition: NodeMaterialConnectionPoint;
  123283. /**
  123284. * Gets the view input component
  123285. */
  123286. readonly view: NodeMaterialConnectionPoint;
  123287. /**
  123288. * Gets the color input component
  123289. */
  123290. readonly input: NodeMaterialConnectionPoint;
  123291. /**
  123292. * Gets the fog color input component
  123293. */
  123294. readonly fogColor: NodeMaterialConnectionPoint;
  123295. /**
  123296. * Gets the output component
  123297. */
  123298. readonly output: NodeMaterialConnectionPoint;
  123299. autoConfigure(material: NodeMaterial): void;
  123300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123302. protected _buildBlock(state: NodeMaterialBuildState): this;
  123303. }
  123304. }
  123305. declare module BABYLON {
  123306. /**
  123307. * Block used to add light in the fragment shader
  123308. */
  123309. export class LightBlock extends NodeMaterialBlock {
  123310. private _lightId;
  123311. /**
  123312. * Gets or sets the light associated with this block
  123313. */
  123314. light: Nullable<Light>;
  123315. /**
  123316. * Create a new LightBlock
  123317. * @param name defines the block name
  123318. */
  123319. constructor(name: string);
  123320. /**
  123321. * Gets the current class name
  123322. * @returns the class name
  123323. */
  123324. getClassName(): string;
  123325. /**
  123326. * Gets the world position input component
  123327. */
  123328. readonly worldPosition: NodeMaterialConnectionPoint;
  123329. /**
  123330. * Gets the world normal input component
  123331. */
  123332. readonly worldNormal: NodeMaterialConnectionPoint;
  123333. /**
  123334. * Gets the camera (or eye) position component
  123335. */
  123336. readonly cameraPosition: NodeMaterialConnectionPoint;
  123337. /**
  123338. * Gets the glossiness component
  123339. */
  123340. readonly glossiness: NodeMaterialConnectionPoint;
  123341. /**
  123342. * Gets the glossinness power component
  123343. */
  123344. readonly glossPower: NodeMaterialConnectionPoint;
  123345. /**
  123346. * Gets the diffuse color component
  123347. */
  123348. readonly diffuseColor: NodeMaterialConnectionPoint;
  123349. /**
  123350. * Gets the specular color component
  123351. */
  123352. readonly specularColor: NodeMaterialConnectionPoint;
  123353. /**
  123354. * Gets the diffuse output component
  123355. */
  123356. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123357. /**
  123358. * Gets the specular output component
  123359. */
  123360. readonly specularOutput: NodeMaterialConnectionPoint;
  123361. autoConfigure(material: NodeMaterial): void;
  123362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123363. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123365. private _injectVertexCode;
  123366. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123367. serialize(): any;
  123368. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * Block used to multiply 2 values
  123374. */
  123375. export class MultiplyBlock extends NodeMaterialBlock {
  123376. /**
  123377. * Creates a new MultiplyBlock
  123378. * @param name defines the block name
  123379. */
  123380. constructor(name: string);
  123381. /**
  123382. * Gets the current class name
  123383. * @returns the class name
  123384. */
  123385. getClassName(): string;
  123386. /**
  123387. * Gets the left operand input component
  123388. */
  123389. readonly left: NodeMaterialConnectionPoint;
  123390. /**
  123391. * Gets the right operand input component
  123392. */
  123393. readonly right: NodeMaterialConnectionPoint;
  123394. /**
  123395. * Gets the output component
  123396. */
  123397. readonly output: NodeMaterialConnectionPoint;
  123398. protected _buildBlock(state: NodeMaterialBuildState): this;
  123399. }
  123400. }
  123401. declare module BABYLON {
  123402. /**
  123403. * Block used to add 2 vectors
  123404. */
  123405. export class AddBlock extends NodeMaterialBlock {
  123406. /**
  123407. * Creates a new AddBlock
  123408. * @param name defines the block name
  123409. */
  123410. constructor(name: string);
  123411. /**
  123412. * Gets the current class name
  123413. * @returns the class name
  123414. */
  123415. getClassName(): string;
  123416. /**
  123417. * Gets the left operand input component
  123418. */
  123419. readonly left: NodeMaterialConnectionPoint;
  123420. /**
  123421. * Gets the right operand input component
  123422. */
  123423. readonly right: NodeMaterialConnectionPoint;
  123424. /**
  123425. * Gets the output component
  123426. */
  123427. readonly output: NodeMaterialConnectionPoint;
  123428. protected _buildBlock(state: NodeMaterialBuildState): this;
  123429. }
  123430. }
  123431. declare module BABYLON {
  123432. /**
  123433. * Block used to scale a vector by a float
  123434. */
  123435. export class ScaleBlock extends NodeMaterialBlock {
  123436. /**
  123437. * Creates a new ScaleBlock
  123438. * @param name defines the block name
  123439. */
  123440. constructor(name: string);
  123441. /**
  123442. * Gets the current class name
  123443. * @returns the class name
  123444. */
  123445. getClassName(): string;
  123446. /**
  123447. * Gets the input component
  123448. */
  123449. readonly input: NodeMaterialConnectionPoint;
  123450. /**
  123451. * Gets the factor input component
  123452. */
  123453. readonly factor: NodeMaterialConnectionPoint;
  123454. /**
  123455. * Gets the output component
  123456. */
  123457. readonly output: NodeMaterialConnectionPoint;
  123458. protected _buildBlock(state: NodeMaterialBuildState): this;
  123459. }
  123460. }
  123461. declare module BABYLON {
  123462. /**
  123463. * Block used to clamp a float
  123464. */
  123465. export class ClampBlock extends NodeMaterialBlock {
  123466. /** Gets or sets the minimum range */
  123467. minimum: number;
  123468. /** Gets or sets the maximum range */
  123469. maximum: number;
  123470. /**
  123471. * Creates a new ClampBlock
  123472. * @param name defines the block name
  123473. */
  123474. constructor(name: string);
  123475. /**
  123476. * Gets the current class name
  123477. * @returns the class name
  123478. */
  123479. getClassName(): string;
  123480. /**
  123481. * Gets the value input component
  123482. */
  123483. readonly value: NodeMaterialConnectionPoint;
  123484. /**
  123485. * Gets the output component
  123486. */
  123487. readonly output: NodeMaterialConnectionPoint;
  123488. protected _buildBlock(state: NodeMaterialBuildState): this;
  123489. protected _dumpPropertiesCode(): string;
  123490. serialize(): any;
  123491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123492. }
  123493. }
  123494. declare module BABYLON {
  123495. /**
  123496. * Block used to apply a cross product between 2 vectors
  123497. */
  123498. export class CrossBlock extends NodeMaterialBlock {
  123499. /**
  123500. * Creates a new CrossBlock
  123501. * @param name defines the block name
  123502. */
  123503. constructor(name: string);
  123504. /**
  123505. * Gets the current class name
  123506. * @returns the class name
  123507. */
  123508. getClassName(): string;
  123509. /**
  123510. * Gets the left operand input component
  123511. */
  123512. readonly left: NodeMaterialConnectionPoint;
  123513. /**
  123514. * Gets the right operand input component
  123515. */
  123516. readonly right: NodeMaterialConnectionPoint;
  123517. /**
  123518. * Gets the output component
  123519. */
  123520. readonly output: NodeMaterialConnectionPoint;
  123521. protected _buildBlock(state: NodeMaterialBuildState): this;
  123522. }
  123523. }
  123524. declare module BABYLON {
  123525. /**
  123526. * Block used to apply a dot product between 2 vectors
  123527. */
  123528. export class DotBlock extends NodeMaterialBlock {
  123529. /**
  123530. * Creates a new DotBlock
  123531. * @param name defines the block name
  123532. */
  123533. constructor(name: string);
  123534. /**
  123535. * Gets the current class name
  123536. * @returns the class name
  123537. */
  123538. getClassName(): string;
  123539. /**
  123540. * Gets the left operand input component
  123541. */
  123542. readonly left: NodeMaterialConnectionPoint;
  123543. /**
  123544. * Gets the right operand input component
  123545. */
  123546. readonly right: NodeMaterialConnectionPoint;
  123547. /**
  123548. * Gets the output component
  123549. */
  123550. readonly output: NodeMaterialConnectionPoint;
  123551. protected _buildBlock(state: NodeMaterialBuildState): this;
  123552. }
  123553. }
  123554. declare module BABYLON {
  123555. /**
  123556. * Block used to remap a float from a range to a new one
  123557. */
  123558. export class RemapBlock extends NodeMaterialBlock {
  123559. /**
  123560. * Gets or sets the source range
  123561. */
  123562. sourceRange: Vector2;
  123563. /**
  123564. * Gets or sets the target range
  123565. */
  123566. targetRange: Vector2;
  123567. /**
  123568. * Creates a new RemapBlock
  123569. * @param name defines the block name
  123570. */
  123571. constructor(name: string);
  123572. /**
  123573. * Gets the current class name
  123574. * @returns the class name
  123575. */
  123576. getClassName(): string;
  123577. /**
  123578. * Gets the input component
  123579. */
  123580. readonly input: NodeMaterialConnectionPoint;
  123581. /**
  123582. * Gets the source min input component
  123583. */
  123584. readonly sourceMin: NodeMaterialConnectionPoint;
  123585. /**
  123586. * Gets the source max input component
  123587. */
  123588. readonly sourceMax: NodeMaterialConnectionPoint;
  123589. /**
  123590. * Gets the target min input component
  123591. */
  123592. readonly targetMin: NodeMaterialConnectionPoint;
  123593. /**
  123594. * Gets the target max input component
  123595. */
  123596. readonly targetMax: NodeMaterialConnectionPoint;
  123597. /**
  123598. * Gets the output component
  123599. */
  123600. readonly output: NodeMaterialConnectionPoint;
  123601. protected _buildBlock(state: NodeMaterialBuildState): this;
  123602. protected _dumpPropertiesCode(): string;
  123603. serialize(): any;
  123604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123605. }
  123606. }
  123607. declare module BABYLON {
  123608. /**
  123609. * Block used to normalize a vector
  123610. */
  123611. export class NormalizeBlock extends NodeMaterialBlock {
  123612. /**
  123613. * Creates a new NormalizeBlock
  123614. * @param name defines the block name
  123615. */
  123616. constructor(name: string);
  123617. /**
  123618. * Gets the current class name
  123619. * @returns the class name
  123620. */
  123621. getClassName(): string;
  123622. /**
  123623. * Gets the input component
  123624. */
  123625. readonly input: NodeMaterialConnectionPoint;
  123626. /**
  123627. * Gets the output component
  123628. */
  123629. readonly output: NodeMaterialConnectionPoint;
  123630. protected _buildBlock(state: NodeMaterialBuildState): this;
  123631. }
  123632. }
  123633. declare module BABYLON {
  123634. /**
  123635. * Operations supported by the Trigonometry block
  123636. */
  123637. export enum TrigonometryBlockOperations {
  123638. /** Cos */
  123639. Cos = 0,
  123640. /** Sin */
  123641. Sin = 1,
  123642. /** Abs */
  123643. Abs = 2,
  123644. /** Exp */
  123645. Exp = 3,
  123646. /** Exp2 */
  123647. Exp2 = 4,
  123648. /** Round */
  123649. Round = 5,
  123650. /** Floor */
  123651. Floor = 6,
  123652. /** Ceiling */
  123653. Ceiling = 7,
  123654. /** Square root */
  123655. Sqrt = 8,
  123656. /** Log */
  123657. Log = 9,
  123658. /** Tangent */
  123659. Tan = 10,
  123660. /** Arc tangent */
  123661. ArcTan = 11,
  123662. /** Arc cosinus */
  123663. ArcCos = 12,
  123664. /** Arc sinus */
  123665. ArcSin = 13,
  123666. /** Fraction */
  123667. Fract = 14,
  123668. /** Sign */
  123669. Sign = 15,
  123670. /** To radians (from degrees) */
  123671. Radians = 16,
  123672. /** To degrees (from radians) */
  123673. Degrees = 17
  123674. }
  123675. /**
  123676. * Block used to apply trigonometry operation to floats
  123677. */
  123678. export class TrigonometryBlock extends NodeMaterialBlock {
  123679. /**
  123680. * Gets or sets the operation applied by the block
  123681. */
  123682. operation: TrigonometryBlockOperations;
  123683. /**
  123684. * Creates a new TrigonometryBlock
  123685. * @param name defines the block name
  123686. */
  123687. constructor(name: string);
  123688. /**
  123689. * Gets the current class name
  123690. * @returns the class name
  123691. */
  123692. getClassName(): string;
  123693. /**
  123694. * Gets the input component
  123695. */
  123696. readonly input: NodeMaterialConnectionPoint;
  123697. /**
  123698. * Gets the output component
  123699. */
  123700. readonly output: NodeMaterialConnectionPoint;
  123701. protected _buildBlock(state: NodeMaterialBuildState): this;
  123702. serialize(): any;
  123703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123704. }
  123705. }
  123706. declare module BABYLON {
  123707. /**
  123708. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123709. */
  123710. export class ColorMergerBlock extends NodeMaterialBlock {
  123711. /**
  123712. * Create a new ColorMergerBlock
  123713. * @param name defines the block name
  123714. */
  123715. constructor(name: string);
  123716. /**
  123717. * Gets the current class name
  123718. * @returns the class name
  123719. */
  123720. getClassName(): string;
  123721. /**
  123722. * Gets the r component (input)
  123723. */
  123724. readonly r: NodeMaterialConnectionPoint;
  123725. /**
  123726. * Gets the g component (input)
  123727. */
  123728. readonly g: NodeMaterialConnectionPoint;
  123729. /**
  123730. * Gets the b component (input)
  123731. */
  123732. readonly b: NodeMaterialConnectionPoint;
  123733. /**
  123734. * Gets the a component (input)
  123735. */
  123736. readonly a: NodeMaterialConnectionPoint;
  123737. /**
  123738. * Gets the rgba component (output)
  123739. */
  123740. readonly rgba: NodeMaterialConnectionPoint;
  123741. /**
  123742. * Gets the rgb component (output)
  123743. */
  123744. readonly rgb: NodeMaterialConnectionPoint;
  123745. protected _buildBlock(state: NodeMaterialBuildState): this;
  123746. }
  123747. }
  123748. declare module BABYLON {
  123749. /**
  123750. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123751. */
  123752. export class VectorMergerBlock extends NodeMaterialBlock {
  123753. /**
  123754. * Create a new VectorMergerBlock
  123755. * @param name defines the block name
  123756. */
  123757. constructor(name: string);
  123758. /**
  123759. * Gets the current class name
  123760. * @returns the class name
  123761. */
  123762. getClassName(): string;
  123763. /**
  123764. * Gets the x component (input)
  123765. */
  123766. readonly x: NodeMaterialConnectionPoint;
  123767. /**
  123768. * Gets the y component (input)
  123769. */
  123770. readonly y: NodeMaterialConnectionPoint;
  123771. /**
  123772. * Gets the z component (input)
  123773. */
  123774. readonly z: NodeMaterialConnectionPoint;
  123775. /**
  123776. * Gets the w component (input)
  123777. */
  123778. readonly w: NodeMaterialConnectionPoint;
  123779. /**
  123780. * Gets the xyzw component (output)
  123781. */
  123782. readonly xyzw: NodeMaterialConnectionPoint;
  123783. /**
  123784. * Gets the xyz component (output)
  123785. */
  123786. readonly xyz: NodeMaterialConnectionPoint;
  123787. /**
  123788. * Gets the xy component (output)
  123789. */
  123790. readonly xy: NodeMaterialConnectionPoint;
  123791. protected _buildBlock(state: NodeMaterialBuildState): this;
  123792. }
  123793. }
  123794. declare module BABYLON {
  123795. /**
  123796. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123797. */
  123798. export class ColorSplitterBlock extends NodeMaterialBlock {
  123799. /**
  123800. * Create a new ColorSplitterBlock
  123801. * @param name defines the block name
  123802. */
  123803. constructor(name: string);
  123804. /**
  123805. * Gets the current class name
  123806. * @returns the class name
  123807. */
  123808. getClassName(): string;
  123809. /**
  123810. * Gets the rgba component (input)
  123811. */
  123812. readonly rgba: NodeMaterialConnectionPoint;
  123813. /**
  123814. * Gets the rgb component (input)
  123815. */
  123816. readonly rgbIn: NodeMaterialConnectionPoint;
  123817. /**
  123818. * Gets the rgb component (output)
  123819. */
  123820. readonly rgbOut: NodeMaterialConnectionPoint;
  123821. /**
  123822. * Gets the r component (output)
  123823. */
  123824. readonly r: NodeMaterialConnectionPoint;
  123825. /**
  123826. * Gets the g component (output)
  123827. */
  123828. readonly g: NodeMaterialConnectionPoint;
  123829. /**
  123830. * Gets the b component (output)
  123831. */
  123832. readonly b: NodeMaterialConnectionPoint;
  123833. /**
  123834. * Gets the a component (output)
  123835. */
  123836. readonly a: NodeMaterialConnectionPoint;
  123837. protected _inputRename(name: string): string;
  123838. protected _outputRename(name: string): string;
  123839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123840. }
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123845. */
  123846. export class VectorSplitterBlock extends NodeMaterialBlock {
  123847. /**
  123848. * Create a new VectorSplitterBlock
  123849. * @param name defines the block name
  123850. */
  123851. constructor(name: string);
  123852. /**
  123853. * Gets the current class name
  123854. * @returns the class name
  123855. */
  123856. getClassName(): string;
  123857. /**
  123858. * Gets the xyzw component (input)
  123859. */
  123860. readonly xyzw: NodeMaterialConnectionPoint;
  123861. /**
  123862. * Gets the xyz component (input)
  123863. */
  123864. readonly xyzIn: NodeMaterialConnectionPoint;
  123865. /**
  123866. * Gets the xy component (input)
  123867. */
  123868. readonly xyIn: NodeMaterialConnectionPoint;
  123869. /**
  123870. * Gets the xyz component (output)
  123871. */
  123872. readonly xyzOut: NodeMaterialConnectionPoint;
  123873. /**
  123874. * Gets the xy component (output)
  123875. */
  123876. readonly xyOut: NodeMaterialConnectionPoint;
  123877. /**
  123878. * Gets the x component (output)
  123879. */
  123880. readonly x: NodeMaterialConnectionPoint;
  123881. /**
  123882. * Gets the y component (output)
  123883. */
  123884. readonly y: NodeMaterialConnectionPoint;
  123885. /**
  123886. * Gets the z component (output)
  123887. */
  123888. readonly z: NodeMaterialConnectionPoint;
  123889. /**
  123890. * Gets the w component (output)
  123891. */
  123892. readonly w: NodeMaterialConnectionPoint;
  123893. protected _inputRename(name: string): string;
  123894. protected _outputRename(name: string): string;
  123895. protected _buildBlock(state: NodeMaterialBuildState): this;
  123896. }
  123897. }
  123898. declare module BABYLON {
  123899. /**
  123900. * Block used to lerp between 2 values
  123901. */
  123902. export class LerpBlock extends NodeMaterialBlock {
  123903. /**
  123904. * Creates a new LerpBlock
  123905. * @param name defines the block name
  123906. */
  123907. constructor(name: string);
  123908. /**
  123909. * Gets the current class name
  123910. * @returns the class name
  123911. */
  123912. getClassName(): string;
  123913. /**
  123914. * Gets the left operand input component
  123915. */
  123916. readonly left: NodeMaterialConnectionPoint;
  123917. /**
  123918. * Gets the right operand input component
  123919. */
  123920. readonly right: NodeMaterialConnectionPoint;
  123921. /**
  123922. * Gets the gradient operand input component
  123923. */
  123924. readonly gradient: NodeMaterialConnectionPoint;
  123925. /**
  123926. * Gets the output component
  123927. */
  123928. readonly output: NodeMaterialConnectionPoint;
  123929. protected _buildBlock(state: NodeMaterialBuildState): this;
  123930. }
  123931. }
  123932. declare module BABYLON {
  123933. /**
  123934. * Block used to divide 2 vectors
  123935. */
  123936. export class DivideBlock extends NodeMaterialBlock {
  123937. /**
  123938. * Creates a new DivideBlock
  123939. * @param name defines the block name
  123940. */
  123941. constructor(name: string);
  123942. /**
  123943. * Gets the current class name
  123944. * @returns the class name
  123945. */
  123946. getClassName(): string;
  123947. /**
  123948. * Gets the left operand input component
  123949. */
  123950. readonly left: NodeMaterialConnectionPoint;
  123951. /**
  123952. * Gets the right operand input component
  123953. */
  123954. readonly right: NodeMaterialConnectionPoint;
  123955. /**
  123956. * Gets the output component
  123957. */
  123958. readonly output: NodeMaterialConnectionPoint;
  123959. protected _buildBlock(state: NodeMaterialBuildState): this;
  123960. }
  123961. }
  123962. declare module BABYLON {
  123963. /**
  123964. * Block used to subtract 2 vectors
  123965. */
  123966. export class SubtractBlock extends NodeMaterialBlock {
  123967. /**
  123968. * Creates a new SubtractBlock
  123969. * @param name defines the block name
  123970. */
  123971. constructor(name: string);
  123972. /**
  123973. * Gets the current class name
  123974. * @returns the class name
  123975. */
  123976. getClassName(): string;
  123977. /**
  123978. * Gets the left operand input component
  123979. */
  123980. readonly left: NodeMaterialConnectionPoint;
  123981. /**
  123982. * Gets the right operand input component
  123983. */
  123984. readonly right: NodeMaterialConnectionPoint;
  123985. /**
  123986. * Gets the output component
  123987. */
  123988. readonly output: NodeMaterialConnectionPoint;
  123989. protected _buildBlock(state: NodeMaterialBuildState): this;
  123990. }
  123991. }
  123992. declare module BABYLON {
  123993. /**
  123994. * Block used to step a value
  123995. */
  123996. export class StepBlock extends NodeMaterialBlock {
  123997. /**
  123998. * Creates a new StepBlock
  123999. * @param name defines the block name
  124000. */
  124001. constructor(name: string);
  124002. /**
  124003. * Gets the current class name
  124004. * @returns the class name
  124005. */
  124006. getClassName(): string;
  124007. /**
  124008. * Gets the value operand input component
  124009. */
  124010. readonly value: NodeMaterialConnectionPoint;
  124011. /**
  124012. * Gets the edge operand input component
  124013. */
  124014. readonly edge: NodeMaterialConnectionPoint;
  124015. /**
  124016. * Gets the output component
  124017. */
  124018. readonly output: NodeMaterialConnectionPoint;
  124019. protected _buildBlock(state: NodeMaterialBuildState): this;
  124020. }
  124021. }
  124022. declare module BABYLON {
  124023. /**
  124024. * Block used to get the opposite (1 - x) of a value
  124025. */
  124026. export class OneMinusBlock extends NodeMaterialBlock {
  124027. /**
  124028. * Creates a new OneMinusBlock
  124029. * @param name defines the block name
  124030. */
  124031. constructor(name: string);
  124032. /**
  124033. * Gets the current class name
  124034. * @returns the class name
  124035. */
  124036. getClassName(): string;
  124037. /**
  124038. * Gets the input component
  124039. */
  124040. readonly input: NodeMaterialConnectionPoint;
  124041. /**
  124042. * Gets the output component
  124043. */
  124044. readonly output: NodeMaterialConnectionPoint;
  124045. protected _buildBlock(state: NodeMaterialBuildState): this;
  124046. }
  124047. }
  124048. declare module BABYLON {
  124049. /**
  124050. * Block used to get the view direction
  124051. */
  124052. export class ViewDirectionBlock extends NodeMaterialBlock {
  124053. /**
  124054. * Creates a new ViewDirectionBlock
  124055. * @param name defines the block name
  124056. */
  124057. constructor(name: string);
  124058. /**
  124059. * Gets the current class name
  124060. * @returns the class name
  124061. */
  124062. getClassName(): string;
  124063. /**
  124064. * Gets the world position component
  124065. */
  124066. readonly worldPosition: NodeMaterialConnectionPoint;
  124067. /**
  124068. * Gets the camera position component
  124069. */
  124070. readonly cameraPosition: NodeMaterialConnectionPoint;
  124071. /**
  124072. * Gets the output component
  124073. */
  124074. readonly output: NodeMaterialConnectionPoint;
  124075. autoConfigure(material: NodeMaterial): void;
  124076. protected _buildBlock(state: NodeMaterialBuildState): this;
  124077. }
  124078. }
  124079. declare module BABYLON {
  124080. /**
  124081. * Block used to compute fresnel value
  124082. */
  124083. export class FresnelBlock extends NodeMaterialBlock {
  124084. /**
  124085. * Create a new FresnelBlock
  124086. * @param name defines the block name
  124087. */
  124088. constructor(name: string);
  124089. /**
  124090. * Gets the current class name
  124091. * @returns the class name
  124092. */
  124093. getClassName(): string;
  124094. /**
  124095. * Gets the world normal input component
  124096. */
  124097. readonly worldNormal: NodeMaterialConnectionPoint;
  124098. /**
  124099. * Gets the view direction input component
  124100. */
  124101. readonly viewDirection: NodeMaterialConnectionPoint;
  124102. /**
  124103. * Gets the bias input component
  124104. */
  124105. readonly bias: NodeMaterialConnectionPoint;
  124106. /**
  124107. * Gets the camera (or eye) position component
  124108. */
  124109. readonly power: NodeMaterialConnectionPoint;
  124110. /**
  124111. * Gets the fresnel output component
  124112. */
  124113. readonly fresnel: NodeMaterialConnectionPoint;
  124114. autoConfigure(material: NodeMaterial): void;
  124115. protected _buildBlock(state: NodeMaterialBuildState): this;
  124116. }
  124117. }
  124118. declare module BABYLON {
  124119. /**
  124120. * Block used to get the max of 2 values
  124121. */
  124122. export class MaxBlock extends NodeMaterialBlock {
  124123. /**
  124124. * Creates a new MaxBlock
  124125. * @param name defines the block name
  124126. */
  124127. constructor(name: string);
  124128. /**
  124129. * Gets the current class name
  124130. * @returns the class name
  124131. */
  124132. getClassName(): string;
  124133. /**
  124134. * Gets the left operand input component
  124135. */
  124136. readonly left: NodeMaterialConnectionPoint;
  124137. /**
  124138. * Gets the right operand input component
  124139. */
  124140. readonly right: NodeMaterialConnectionPoint;
  124141. /**
  124142. * Gets the output component
  124143. */
  124144. readonly output: NodeMaterialConnectionPoint;
  124145. protected _buildBlock(state: NodeMaterialBuildState): this;
  124146. }
  124147. }
  124148. declare module BABYLON {
  124149. /**
  124150. * Block used to get the min of 2 values
  124151. */
  124152. export class MinBlock extends NodeMaterialBlock {
  124153. /**
  124154. * Creates a new MinBlock
  124155. * @param name defines the block name
  124156. */
  124157. constructor(name: string);
  124158. /**
  124159. * Gets the current class name
  124160. * @returns the class name
  124161. */
  124162. getClassName(): string;
  124163. /**
  124164. * Gets the left operand input component
  124165. */
  124166. readonly left: NodeMaterialConnectionPoint;
  124167. /**
  124168. * Gets the right operand input component
  124169. */
  124170. readonly right: NodeMaterialConnectionPoint;
  124171. /**
  124172. * Gets the output component
  124173. */
  124174. readonly output: NodeMaterialConnectionPoint;
  124175. protected _buildBlock(state: NodeMaterialBuildState): this;
  124176. }
  124177. }
  124178. declare module BABYLON {
  124179. /**
  124180. * Block used to get the distance between 2 values
  124181. */
  124182. export class DistanceBlock extends NodeMaterialBlock {
  124183. /**
  124184. * Creates a new DistanceBlock
  124185. * @param name defines the block name
  124186. */
  124187. constructor(name: string);
  124188. /**
  124189. * Gets the current class name
  124190. * @returns the class name
  124191. */
  124192. getClassName(): string;
  124193. /**
  124194. * Gets the left operand input component
  124195. */
  124196. readonly left: NodeMaterialConnectionPoint;
  124197. /**
  124198. * Gets the right operand input component
  124199. */
  124200. readonly right: NodeMaterialConnectionPoint;
  124201. /**
  124202. * Gets the output component
  124203. */
  124204. readonly output: NodeMaterialConnectionPoint;
  124205. protected _buildBlock(state: NodeMaterialBuildState): this;
  124206. }
  124207. }
  124208. declare module BABYLON {
  124209. /**
  124210. * Block used to get the length of a vector
  124211. */
  124212. export class LengthBlock extends NodeMaterialBlock {
  124213. /**
  124214. * Creates a new LengthBlock
  124215. * @param name defines the block name
  124216. */
  124217. constructor(name: string);
  124218. /**
  124219. * Gets the current class name
  124220. * @returns the class name
  124221. */
  124222. getClassName(): string;
  124223. /**
  124224. * Gets the value input component
  124225. */
  124226. readonly value: NodeMaterialConnectionPoint;
  124227. /**
  124228. * Gets the output component
  124229. */
  124230. readonly output: NodeMaterialConnectionPoint;
  124231. protected _buildBlock(state: NodeMaterialBuildState): this;
  124232. }
  124233. }
  124234. declare module BABYLON {
  124235. /**
  124236. * Block used to get negative version of a value (i.e. x * -1)
  124237. */
  124238. export class NegateBlock extends NodeMaterialBlock {
  124239. /**
  124240. * Creates a new NegateBlock
  124241. * @param name defines the block name
  124242. */
  124243. constructor(name: string);
  124244. /**
  124245. * Gets the current class name
  124246. * @returns the class name
  124247. */
  124248. getClassName(): string;
  124249. /**
  124250. * Gets the value input component
  124251. */
  124252. readonly value: NodeMaterialConnectionPoint;
  124253. /**
  124254. * Gets the output component
  124255. */
  124256. readonly output: NodeMaterialConnectionPoint;
  124257. protected _buildBlock(state: NodeMaterialBuildState): this;
  124258. }
  124259. }
  124260. declare module BABYLON {
  124261. /**
  124262. * Block used to get the value of the first parameter raised to the power of the second
  124263. */
  124264. export class PowBlock extends NodeMaterialBlock {
  124265. /**
  124266. * Creates a new PowBlock
  124267. * @param name defines the block name
  124268. */
  124269. constructor(name: string);
  124270. /**
  124271. * Gets the current class name
  124272. * @returns the class name
  124273. */
  124274. getClassName(): string;
  124275. /**
  124276. * Gets the value operand input component
  124277. */
  124278. readonly value: NodeMaterialConnectionPoint;
  124279. /**
  124280. * Gets the power operand input component
  124281. */
  124282. readonly power: NodeMaterialConnectionPoint;
  124283. /**
  124284. * Gets the output component
  124285. */
  124286. readonly output: NodeMaterialConnectionPoint;
  124287. protected _buildBlock(state: NodeMaterialBuildState): this;
  124288. }
  124289. }
  124290. declare module BABYLON {
  124291. /**
  124292. * Block used to get a random number
  124293. */
  124294. export class RandomNumberBlock extends NodeMaterialBlock {
  124295. /**
  124296. * Creates a new RandomNumberBlock
  124297. * @param name defines the block name
  124298. */
  124299. constructor(name: string);
  124300. /**
  124301. * Gets the current class name
  124302. * @returns the class name
  124303. */
  124304. getClassName(): string;
  124305. /**
  124306. * Gets the seed input component
  124307. */
  124308. readonly seed: NodeMaterialConnectionPoint;
  124309. /**
  124310. * Gets the output component
  124311. */
  124312. readonly output: NodeMaterialConnectionPoint;
  124313. protected _buildBlock(state: NodeMaterialBuildState): this;
  124314. }
  124315. }
  124316. declare module BABYLON {
  124317. /**
  124318. * Block used to compute arc tangent of 2 values
  124319. */
  124320. export class ArcTan2Block extends NodeMaterialBlock {
  124321. /**
  124322. * Creates a new ArcTan2Block
  124323. * @param name defines the block name
  124324. */
  124325. constructor(name: string);
  124326. /**
  124327. * Gets the current class name
  124328. * @returns the class name
  124329. */
  124330. getClassName(): string;
  124331. /**
  124332. * Gets the x operand input component
  124333. */
  124334. readonly x: NodeMaterialConnectionPoint;
  124335. /**
  124336. * Gets the y operand input component
  124337. */
  124338. readonly y: NodeMaterialConnectionPoint;
  124339. /**
  124340. * Gets the output component
  124341. */
  124342. readonly output: NodeMaterialConnectionPoint;
  124343. protected _buildBlock(state: NodeMaterialBuildState): this;
  124344. }
  124345. }
  124346. declare module BABYLON {
  124347. /**
  124348. * Block used to smooth step a value
  124349. */
  124350. export class SmoothStepBlock extends NodeMaterialBlock {
  124351. /**
  124352. * Creates a new SmoothStepBlock
  124353. * @param name defines the block name
  124354. */
  124355. constructor(name: string);
  124356. /**
  124357. * Gets the current class name
  124358. * @returns the class name
  124359. */
  124360. getClassName(): string;
  124361. /**
  124362. * Gets the value operand input component
  124363. */
  124364. readonly value: NodeMaterialConnectionPoint;
  124365. /**
  124366. * Gets the first edge operand input component
  124367. */
  124368. readonly edge0: NodeMaterialConnectionPoint;
  124369. /**
  124370. * Gets the second edge operand input component
  124371. */
  124372. readonly edge1: NodeMaterialConnectionPoint;
  124373. /**
  124374. * Gets the output component
  124375. */
  124376. readonly output: NodeMaterialConnectionPoint;
  124377. protected _buildBlock(state: NodeMaterialBuildState): this;
  124378. }
  124379. }
  124380. declare module BABYLON {
  124381. /**
  124382. * Block used to get the reciprocal (1 / x) of a value
  124383. */
  124384. export class ReciprocalBlock extends NodeMaterialBlock {
  124385. /**
  124386. * Creates a new ReciprocalBlock
  124387. * @param name defines the block name
  124388. */
  124389. constructor(name: string);
  124390. /**
  124391. * Gets the current class name
  124392. * @returns the class name
  124393. */
  124394. getClassName(): string;
  124395. /**
  124396. * Gets the input component
  124397. */
  124398. readonly input: NodeMaterialConnectionPoint;
  124399. /**
  124400. * Gets the output component
  124401. */
  124402. readonly output: NodeMaterialConnectionPoint;
  124403. protected _buildBlock(state: NodeMaterialBuildState): this;
  124404. }
  124405. }
  124406. declare module BABYLON {
  124407. /**
  124408. * Block used to replace a color by another one
  124409. */
  124410. export class ReplaceColorBlock extends NodeMaterialBlock {
  124411. /**
  124412. * Creates a new ReplaceColorBlock
  124413. * @param name defines the block name
  124414. */
  124415. constructor(name: string);
  124416. /**
  124417. * Gets the current class name
  124418. * @returns the class name
  124419. */
  124420. getClassName(): string;
  124421. /**
  124422. * Gets the value input component
  124423. */
  124424. readonly value: NodeMaterialConnectionPoint;
  124425. /**
  124426. * Gets the reference input component
  124427. */
  124428. readonly reference: NodeMaterialConnectionPoint;
  124429. /**
  124430. * Gets the distance input component
  124431. */
  124432. readonly distance: NodeMaterialConnectionPoint;
  124433. /**
  124434. * Gets the replacement input component
  124435. */
  124436. readonly replacement: NodeMaterialConnectionPoint;
  124437. /**
  124438. * Gets the output component
  124439. */
  124440. readonly output: NodeMaterialConnectionPoint;
  124441. protected _buildBlock(state: NodeMaterialBuildState): this;
  124442. }
  124443. }
  124444. declare module BABYLON {
  124445. /**
  124446. * Block used to posterize a value
  124447. * @see https://en.wikipedia.org/wiki/Posterization
  124448. */
  124449. export class PosterizeBlock extends NodeMaterialBlock {
  124450. /**
  124451. * Creates a new PosterizeBlock
  124452. * @param name defines the block name
  124453. */
  124454. constructor(name: string);
  124455. /**
  124456. * Gets the current class name
  124457. * @returns the class name
  124458. */
  124459. getClassName(): string;
  124460. /**
  124461. * Gets the value input component
  124462. */
  124463. readonly value: NodeMaterialConnectionPoint;
  124464. /**
  124465. * Gets the steps input component
  124466. */
  124467. readonly steps: NodeMaterialConnectionPoint;
  124468. /**
  124469. * Gets the output component
  124470. */
  124471. readonly output: NodeMaterialConnectionPoint;
  124472. protected _buildBlock(state: NodeMaterialBuildState): this;
  124473. }
  124474. }
  124475. declare module BABYLON {
  124476. /**
  124477. * Operations supported by the Wave block
  124478. */
  124479. export enum WaveBlockKind {
  124480. /** SawTooth */
  124481. SawTooth = 0,
  124482. /** Square */
  124483. Square = 1,
  124484. /** Triangle */
  124485. Triangle = 2
  124486. }
  124487. /**
  124488. * Block used to apply wave operation to floats
  124489. */
  124490. export class WaveBlock extends NodeMaterialBlock {
  124491. /**
  124492. * Gets or sets the kibnd of wave to be applied by the block
  124493. */
  124494. kind: WaveBlockKind;
  124495. /**
  124496. * Creates a new WaveBlock
  124497. * @param name defines the block name
  124498. */
  124499. constructor(name: string);
  124500. /**
  124501. * Gets the current class name
  124502. * @returns the class name
  124503. */
  124504. getClassName(): string;
  124505. /**
  124506. * Gets the input component
  124507. */
  124508. readonly input: NodeMaterialConnectionPoint;
  124509. /**
  124510. * Gets the output component
  124511. */
  124512. readonly output: NodeMaterialConnectionPoint;
  124513. protected _buildBlock(state: NodeMaterialBuildState): this;
  124514. serialize(): any;
  124515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124516. }
  124517. }
  124518. declare module BABYLON {
  124519. /**
  124520. * Class used to store a color step for the GradientBlock
  124521. */
  124522. export class GradientBlockColorStep {
  124523. /**
  124524. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124525. */
  124526. step: number;
  124527. /**
  124528. * Gets or sets the color associated with this step
  124529. */
  124530. color: Color3;
  124531. /**
  124532. * Creates a new GradientBlockColorStep
  124533. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124534. * @param color defines the color associated with this step
  124535. */
  124536. constructor(
  124537. /**
  124538. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124539. */
  124540. step: number,
  124541. /**
  124542. * Gets or sets the color associated with this step
  124543. */
  124544. color: Color3);
  124545. }
  124546. /**
  124547. * Block used to return a color from a gradient based on an input value between 0 and 1
  124548. */
  124549. export class GradientBlock extends NodeMaterialBlock {
  124550. /**
  124551. * Gets or sets the list of color steps
  124552. */
  124553. colorSteps: GradientBlockColorStep[];
  124554. /**
  124555. * Creates a new GradientBlock
  124556. * @param name defines the block name
  124557. */
  124558. constructor(name: string);
  124559. /**
  124560. * Gets the current class name
  124561. * @returns the class name
  124562. */
  124563. getClassName(): string;
  124564. /**
  124565. * Gets the gradient input component
  124566. */
  124567. readonly gradient: NodeMaterialConnectionPoint;
  124568. /**
  124569. * Gets the output component
  124570. */
  124571. readonly output: NodeMaterialConnectionPoint;
  124572. private _writeColorConstant;
  124573. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124574. serialize(): any;
  124575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124576. protected _dumpPropertiesCode(): string;
  124577. }
  124578. }
  124579. declare module BABYLON {
  124580. /**
  124581. * Block used to normalize lerp between 2 values
  124582. */
  124583. export class NLerpBlock extends NodeMaterialBlock {
  124584. /**
  124585. * Creates a new NLerpBlock
  124586. * @param name defines the block name
  124587. */
  124588. constructor(name: string);
  124589. /**
  124590. * Gets the current class name
  124591. * @returns the class name
  124592. */
  124593. getClassName(): string;
  124594. /**
  124595. * Gets the left operand input component
  124596. */
  124597. readonly left: NodeMaterialConnectionPoint;
  124598. /**
  124599. * Gets the right operand input component
  124600. */
  124601. readonly right: NodeMaterialConnectionPoint;
  124602. /**
  124603. * Gets the gradient operand input component
  124604. */
  124605. readonly gradient: NodeMaterialConnectionPoint;
  124606. /**
  124607. * Gets the output component
  124608. */
  124609. readonly output: NodeMaterialConnectionPoint;
  124610. protected _buildBlock(state: NodeMaterialBuildState): this;
  124611. }
  124612. }
  124613. declare module BABYLON {
  124614. /**
  124615. * block used to Generate a Worley Noise 3D Noise Pattern
  124616. */
  124617. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  124618. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124619. manhattanDistance: boolean;
  124620. /**
  124621. * Creates a new WorleyNoise3DBlock
  124622. * @param name defines the block name
  124623. */
  124624. constructor(name: string);
  124625. /**
  124626. * Gets the current class name
  124627. * @returns the class name
  124628. */
  124629. getClassName(): string;
  124630. /**
  124631. * Gets the position input component
  124632. */
  124633. readonly position: NodeMaterialConnectionPoint;
  124634. /**
  124635. * Gets the jitter input component
  124636. */
  124637. readonly jitter: NodeMaterialConnectionPoint;
  124638. /**
  124639. * Gets the output component
  124640. */
  124641. readonly output: NodeMaterialConnectionPoint;
  124642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124643. /**
  124644. * Exposes the properties to the UI?
  124645. */
  124646. protected _dumpPropertiesCode(): string;
  124647. /**
  124648. * Exposes the properties to the Seralize?
  124649. */
  124650. serialize(): any;
  124651. /**
  124652. * Exposes the properties to the deseralize?
  124653. */
  124654. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124655. }
  124656. }
  124657. declare module BABYLON {
  124658. /**
  124659. * block used to Generate a Simplex Perlin 3d Noise Pattern
  124660. */
  124661. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  124662. /**
  124663. * Creates a new SimplexPerlin3DBlock
  124664. * @param name defines the block name
  124665. */
  124666. constructor(name: string);
  124667. /**
  124668. * Gets the current class name
  124669. * @returns the class name
  124670. */
  124671. getClassName(): string;
  124672. /**
  124673. * Gets the position operand input component
  124674. */
  124675. readonly position: NodeMaterialConnectionPoint;
  124676. /**
  124677. * Gets the output component
  124678. */
  124679. readonly output: NodeMaterialConnectionPoint;
  124680. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124681. }
  124682. }
  124683. declare module BABYLON {
  124684. /**
  124685. * Effect Render Options
  124686. */
  124687. export interface IEffectRendererOptions {
  124688. /**
  124689. * Defines the vertices positions.
  124690. */
  124691. positions?: number[];
  124692. /**
  124693. * Defines the indices.
  124694. */
  124695. indices?: number[];
  124696. }
  124697. /**
  124698. * Helper class to render one or more effects
  124699. */
  124700. export class EffectRenderer {
  124701. private engine;
  124702. private static _DefaultOptions;
  124703. private _vertexBuffers;
  124704. private _indexBuffer;
  124705. private _ringBufferIndex;
  124706. private _ringScreenBuffer;
  124707. private _fullscreenViewport;
  124708. private _getNextFrameBuffer;
  124709. /**
  124710. * Creates an effect renderer
  124711. * @param engine the engine to use for rendering
  124712. * @param options defines the options of the effect renderer
  124713. */
  124714. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124715. /**
  124716. * Sets the current viewport in normalized coordinates 0-1
  124717. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124718. */
  124719. setViewport(viewport?: Viewport): void;
  124720. /**
  124721. * Binds the embedded attributes buffer to the effect.
  124722. * @param effect Defines the effect to bind the attributes for
  124723. */
  124724. bindBuffers(effect: Effect): void;
  124725. /**
  124726. * Sets the current effect wrapper to use during draw.
  124727. * The effect needs to be ready before calling this api.
  124728. * This also sets the default full screen position attribute.
  124729. * @param effectWrapper Defines the effect to draw with
  124730. */
  124731. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124732. /**
  124733. * Draws a full screen quad.
  124734. */
  124735. draw(): void;
  124736. /**
  124737. * renders one or more effects to a specified texture
  124738. * @param effectWrappers list of effects to renderer
  124739. * @param outputTexture texture to draw to, if null it will render to the screen
  124740. */
  124741. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124742. /**
  124743. * Disposes of the effect renderer
  124744. */
  124745. dispose(): void;
  124746. }
  124747. /**
  124748. * Options to create an EffectWrapper
  124749. */
  124750. interface EffectWrapperCreationOptions {
  124751. /**
  124752. * Engine to use to create the effect
  124753. */
  124754. engine: ThinEngine;
  124755. /**
  124756. * Fragment shader for the effect
  124757. */
  124758. fragmentShader: string;
  124759. /**
  124760. * Vertex shader for the effect
  124761. */
  124762. vertexShader?: string;
  124763. /**
  124764. * Attributes to use in the shader
  124765. */
  124766. attributeNames?: Array<string>;
  124767. /**
  124768. * Uniforms to use in the shader
  124769. */
  124770. uniformNames?: Array<string>;
  124771. /**
  124772. * Texture sampler names to use in the shader
  124773. */
  124774. samplerNames?: Array<string>;
  124775. /**
  124776. * The friendly name of the effect displayed in Spector.
  124777. */
  124778. name?: string;
  124779. }
  124780. /**
  124781. * Wraps an effect to be used for rendering
  124782. */
  124783. export class EffectWrapper {
  124784. /**
  124785. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124786. */
  124787. onApplyObservable: Observable<{}>;
  124788. /**
  124789. * The underlying effect
  124790. */
  124791. effect: Effect;
  124792. /**
  124793. * Creates an effect to be renderer
  124794. * @param creationOptions options to create the effect
  124795. */
  124796. constructor(creationOptions: EffectWrapperCreationOptions);
  124797. /**
  124798. * Disposes of the effect wrapper
  124799. */
  124800. dispose(): void;
  124801. }
  124802. }
  124803. declare module BABYLON {
  124804. /**
  124805. * Helper class to push actions to a pool of workers.
  124806. */
  124807. export class WorkerPool implements IDisposable {
  124808. private _workerInfos;
  124809. private _pendingActions;
  124810. /**
  124811. * Constructor
  124812. * @param workers Array of workers to use for actions
  124813. */
  124814. constructor(workers: Array<Worker>);
  124815. /**
  124816. * Terminates all workers and clears any pending actions.
  124817. */
  124818. dispose(): void;
  124819. /**
  124820. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124821. * pended until a worker has completed its action.
  124822. * @param action The action to perform. Call onComplete when the action is complete.
  124823. */
  124824. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124825. private _execute;
  124826. }
  124827. }
  124828. declare module BABYLON {
  124829. /**
  124830. * Configuration for Draco compression
  124831. */
  124832. export interface IDracoCompressionConfiguration {
  124833. /**
  124834. * Configuration for the decoder.
  124835. */
  124836. decoder: {
  124837. /**
  124838. * The url to the WebAssembly module.
  124839. */
  124840. wasmUrl?: string;
  124841. /**
  124842. * The url to the WebAssembly binary.
  124843. */
  124844. wasmBinaryUrl?: string;
  124845. /**
  124846. * The url to the fallback JavaScript module.
  124847. */
  124848. fallbackUrl?: string;
  124849. };
  124850. }
  124851. /**
  124852. * Draco compression (https://google.github.io/draco/)
  124853. *
  124854. * This class wraps the Draco module.
  124855. *
  124856. * **Encoder**
  124857. *
  124858. * The encoder is not currently implemented.
  124859. *
  124860. * **Decoder**
  124861. *
  124862. * 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.
  124863. *
  124864. * To update the configuration, use the following code:
  124865. * ```javascript
  124866. * DracoCompression.Configuration = {
  124867. * decoder: {
  124868. * wasmUrl: "<url to the WebAssembly library>",
  124869. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124870. * fallbackUrl: "<url to the fallback JavaScript library>",
  124871. * }
  124872. * };
  124873. * ```
  124874. *
  124875. * 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.
  124876. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124877. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124878. *
  124879. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124880. * ```javascript
  124881. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124882. * ```
  124883. *
  124884. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124885. */
  124886. export class DracoCompression implements IDisposable {
  124887. private _workerPoolPromise?;
  124888. private _decoderModulePromise?;
  124889. /**
  124890. * The configuration. Defaults to the following urls:
  124891. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124892. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124893. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124894. */
  124895. static Configuration: IDracoCompressionConfiguration;
  124896. /**
  124897. * Returns true if the decoder configuration is available.
  124898. */
  124899. static readonly DecoderAvailable: boolean;
  124900. /**
  124901. * Default number of workers to create when creating the draco compression object.
  124902. */
  124903. static DefaultNumWorkers: number;
  124904. private static GetDefaultNumWorkers;
  124905. private static _Default;
  124906. /**
  124907. * Default instance for the draco compression object.
  124908. */
  124909. static readonly Default: DracoCompression;
  124910. /**
  124911. * Constructor
  124912. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124913. */
  124914. constructor(numWorkers?: number);
  124915. /**
  124916. * Stop all async operations and release resources.
  124917. */
  124918. dispose(): void;
  124919. /**
  124920. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124921. * @returns a promise that resolves when ready
  124922. */
  124923. whenReadyAsync(): Promise<void>;
  124924. /**
  124925. * Decode Draco compressed mesh data to vertex data.
  124926. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124927. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124928. * @returns A promise that resolves with the decoded vertex data
  124929. */
  124930. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124931. [kind: string]: number;
  124932. }): Promise<VertexData>;
  124933. }
  124934. }
  124935. declare module BABYLON {
  124936. /**
  124937. * Class for building Constructive Solid Geometry
  124938. */
  124939. export class CSG {
  124940. private polygons;
  124941. /**
  124942. * The world matrix
  124943. */
  124944. matrix: Matrix;
  124945. /**
  124946. * Stores the position
  124947. */
  124948. position: Vector3;
  124949. /**
  124950. * Stores the rotation
  124951. */
  124952. rotation: Vector3;
  124953. /**
  124954. * Stores the rotation quaternion
  124955. */
  124956. rotationQuaternion: Nullable<Quaternion>;
  124957. /**
  124958. * Stores the scaling vector
  124959. */
  124960. scaling: Vector3;
  124961. /**
  124962. * Convert the Mesh to CSG
  124963. * @param mesh The Mesh to convert to CSG
  124964. * @returns A new CSG from the Mesh
  124965. */
  124966. static FromMesh(mesh: Mesh): CSG;
  124967. /**
  124968. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124969. * @param polygons Polygons used to construct a CSG solid
  124970. */
  124971. private static FromPolygons;
  124972. /**
  124973. * Clones, or makes a deep copy, of the CSG
  124974. * @returns A new CSG
  124975. */
  124976. clone(): CSG;
  124977. /**
  124978. * Unions this CSG with another CSG
  124979. * @param csg The CSG to union against this CSG
  124980. * @returns The unioned CSG
  124981. */
  124982. union(csg: CSG): CSG;
  124983. /**
  124984. * Unions this CSG with another CSG in place
  124985. * @param csg The CSG to union against this CSG
  124986. */
  124987. unionInPlace(csg: CSG): void;
  124988. /**
  124989. * Subtracts this CSG with another CSG
  124990. * @param csg The CSG to subtract against this CSG
  124991. * @returns A new CSG
  124992. */
  124993. subtract(csg: CSG): CSG;
  124994. /**
  124995. * Subtracts this CSG with another CSG in place
  124996. * @param csg The CSG to subtact against this CSG
  124997. */
  124998. subtractInPlace(csg: CSG): void;
  124999. /**
  125000. * Intersect this CSG with another CSG
  125001. * @param csg The CSG to intersect against this CSG
  125002. * @returns A new CSG
  125003. */
  125004. intersect(csg: CSG): CSG;
  125005. /**
  125006. * Intersects this CSG with another CSG in place
  125007. * @param csg The CSG to intersect against this CSG
  125008. */
  125009. intersectInPlace(csg: CSG): void;
  125010. /**
  125011. * Return a new CSG solid with solid and empty space switched. This solid is
  125012. * not modified.
  125013. * @returns A new CSG solid with solid and empty space switched
  125014. */
  125015. inverse(): CSG;
  125016. /**
  125017. * Inverses the CSG in place
  125018. */
  125019. inverseInPlace(): void;
  125020. /**
  125021. * This is used to keep meshes transformations so they can be restored
  125022. * when we build back a Babylon Mesh
  125023. * NB : All CSG operations are performed in world coordinates
  125024. * @param csg The CSG to copy the transform attributes from
  125025. * @returns This CSG
  125026. */
  125027. copyTransformAttributes(csg: CSG): CSG;
  125028. /**
  125029. * Build Raw mesh from CSG
  125030. * Coordinates here are in world space
  125031. * @param name The name of the mesh geometry
  125032. * @param scene The Scene
  125033. * @param keepSubMeshes Specifies if the submeshes should be kept
  125034. * @returns A new Mesh
  125035. */
  125036. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125037. /**
  125038. * Build Mesh from CSG taking material and transforms into account
  125039. * @param name The name of the Mesh
  125040. * @param material The material of the Mesh
  125041. * @param scene The Scene
  125042. * @param keepSubMeshes Specifies if submeshes should be kept
  125043. * @returns The new Mesh
  125044. */
  125045. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125046. }
  125047. }
  125048. declare module BABYLON {
  125049. /**
  125050. * Class used to create a trail following a mesh
  125051. */
  125052. export class TrailMesh extends Mesh {
  125053. private _generator;
  125054. private _autoStart;
  125055. private _running;
  125056. private _diameter;
  125057. private _length;
  125058. private _sectionPolygonPointsCount;
  125059. private _sectionVectors;
  125060. private _sectionNormalVectors;
  125061. private _beforeRenderObserver;
  125062. /**
  125063. * @constructor
  125064. * @param name The value used by scene.getMeshByName() to do a lookup.
  125065. * @param generator The mesh to generate a trail.
  125066. * @param scene The scene to add this mesh to.
  125067. * @param diameter Diameter of trailing mesh. Default is 1.
  125068. * @param length Length of trailing mesh. Default is 60.
  125069. * @param autoStart Automatically start trailing mesh. Default true.
  125070. */
  125071. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  125072. /**
  125073. * "TrailMesh"
  125074. * @returns "TrailMesh"
  125075. */
  125076. getClassName(): string;
  125077. private _createMesh;
  125078. /**
  125079. * Start trailing mesh.
  125080. */
  125081. start(): void;
  125082. /**
  125083. * Stop trailing mesh.
  125084. */
  125085. stop(): void;
  125086. /**
  125087. * Update trailing mesh geometry.
  125088. */
  125089. update(): void;
  125090. /**
  125091. * Returns a new TrailMesh object.
  125092. * @param name is a string, the name given to the new mesh
  125093. * @param newGenerator use new generator object for cloned trail mesh
  125094. * @returns a new mesh
  125095. */
  125096. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  125097. /**
  125098. * Serializes this trail mesh
  125099. * @param serializationObject object to write serialization to
  125100. */
  125101. serialize(serializationObject: any): void;
  125102. /**
  125103. * Parses a serialized trail mesh
  125104. * @param parsedMesh the serialized mesh
  125105. * @param scene the scene to create the trail mesh in
  125106. * @returns the created trail mesh
  125107. */
  125108. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  125109. }
  125110. }
  125111. declare module BABYLON {
  125112. /**
  125113. * Class containing static functions to help procedurally build meshes
  125114. */
  125115. export class TiledBoxBuilder {
  125116. /**
  125117. * Creates a box mesh
  125118. * 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)
  125119. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125123. * @param name defines the name of the mesh
  125124. * @param options defines the options used to create the mesh
  125125. * @param scene defines the hosting scene
  125126. * @returns the box mesh
  125127. */
  125128. static CreateTiledBox(name: string, options: {
  125129. pattern?: number;
  125130. width?: number;
  125131. height?: number;
  125132. depth?: number;
  125133. tileSize?: number;
  125134. tileWidth?: number;
  125135. tileHeight?: number;
  125136. alignHorizontal?: number;
  125137. alignVertical?: number;
  125138. faceUV?: Vector4[];
  125139. faceColors?: Color4[];
  125140. sideOrientation?: number;
  125141. updatable?: boolean;
  125142. }, scene?: Nullable<Scene>): Mesh;
  125143. }
  125144. }
  125145. declare module BABYLON {
  125146. /**
  125147. * Class containing static functions to help procedurally build meshes
  125148. */
  125149. export class TorusKnotBuilder {
  125150. /**
  125151. * Creates a torus knot mesh
  125152. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125153. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125154. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125155. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125159. * @param name defines the name of the mesh
  125160. * @param options defines the options used to create the mesh
  125161. * @param scene defines the hosting scene
  125162. * @returns the torus knot mesh
  125163. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125164. */
  125165. static CreateTorusKnot(name: string, options: {
  125166. radius?: number;
  125167. tube?: number;
  125168. radialSegments?: number;
  125169. tubularSegments?: number;
  125170. p?: number;
  125171. q?: number;
  125172. updatable?: boolean;
  125173. sideOrientation?: number;
  125174. frontUVs?: Vector4;
  125175. backUVs?: Vector4;
  125176. }, scene: any): Mesh;
  125177. }
  125178. }
  125179. declare module BABYLON {
  125180. /**
  125181. * Polygon
  125182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125183. */
  125184. export class Polygon {
  125185. /**
  125186. * Creates a rectangle
  125187. * @param xmin bottom X coord
  125188. * @param ymin bottom Y coord
  125189. * @param xmax top X coord
  125190. * @param ymax top Y coord
  125191. * @returns points that make the resulting rectation
  125192. */
  125193. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125194. /**
  125195. * Creates a circle
  125196. * @param radius radius of circle
  125197. * @param cx scale in x
  125198. * @param cy scale in y
  125199. * @param numberOfSides number of sides that make up the circle
  125200. * @returns points that make the resulting circle
  125201. */
  125202. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125203. /**
  125204. * Creates a polygon from input string
  125205. * @param input Input polygon data
  125206. * @returns the parsed points
  125207. */
  125208. static Parse(input: string): Vector2[];
  125209. /**
  125210. * Starts building a polygon from x and y coordinates
  125211. * @param x x coordinate
  125212. * @param y y coordinate
  125213. * @returns the started path2
  125214. */
  125215. static StartingAt(x: number, y: number): Path2;
  125216. }
  125217. /**
  125218. * Builds a polygon
  125219. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125220. */
  125221. export class PolygonMeshBuilder {
  125222. private _points;
  125223. private _outlinepoints;
  125224. private _holes;
  125225. private _name;
  125226. private _scene;
  125227. private _epoints;
  125228. private _eholes;
  125229. private _addToepoint;
  125230. /**
  125231. * Babylon reference to the earcut plugin.
  125232. */
  125233. bjsEarcut: any;
  125234. /**
  125235. * Creates a PolygonMeshBuilder
  125236. * @param name name of the builder
  125237. * @param contours Path of the polygon
  125238. * @param scene scene to add to when creating the mesh
  125239. * @param earcutInjection can be used to inject your own earcut reference
  125240. */
  125241. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125242. /**
  125243. * Adds a whole within the polygon
  125244. * @param hole Array of points defining the hole
  125245. * @returns this
  125246. */
  125247. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125248. /**
  125249. * Creates the polygon
  125250. * @param updatable If the mesh should be updatable
  125251. * @param depth The depth of the mesh created
  125252. * @returns the created mesh
  125253. */
  125254. build(updatable?: boolean, depth?: number): Mesh;
  125255. /**
  125256. * Creates the polygon
  125257. * @param depth The depth of the mesh created
  125258. * @returns the created VertexData
  125259. */
  125260. buildVertexData(depth?: number): VertexData;
  125261. /**
  125262. * Adds a side to the polygon
  125263. * @param positions points that make the polygon
  125264. * @param normals normals of the polygon
  125265. * @param uvs uvs of the polygon
  125266. * @param indices indices of the polygon
  125267. * @param bounds bounds of the polygon
  125268. * @param points points of the polygon
  125269. * @param depth depth of the polygon
  125270. * @param flip flip of the polygon
  125271. */
  125272. private addSide;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. /**
  125277. * Class containing static functions to help procedurally build meshes
  125278. */
  125279. export class PolygonBuilder {
  125280. /**
  125281. * Creates a polygon mesh
  125282. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125283. * * 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
  125284. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125287. * * Remember you can only change the shape positions, not their number when updating a polygon
  125288. * @param name defines the name of the mesh
  125289. * @param options defines the options used to create the mesh
  125290. * @param scene defines the hosting scene
  125291. * @param earcutInjection can be used to inject your own earcut reference
  125292. * @returns the polygon mesh
  125293. */
  125294. static CreatePolygon(name: string, options: {
  125295. shape: Vector3[];
  125296. holes?: Vector3[][];
  125297. depth?: number;
  125298. faceUV?: Vector4[];
  125299. faceColors?: Color4[];
  125300. updatable?: boolean;
  125301. sideOrientation?: number;
  125302. frontUVs?: Vector4;
  125303. backUVs?: Vector4;
  125304. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125305. /**
  125306. * Creates an extruded polygon mesh, with depth in the Y direction.
  125307. * * 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)
  125308. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125309. * @param name defines the name of the mesh
  125310. * @param options defines the options used to create the mesh
  125311. * @param scene defines the hosting scene
  125312. * @param earcutInjection can be used to inject your own earcut reference
  125313. * @returns the polygon mesh
  125314. */
  125315. static ExtrudePolygon(name: string, options: {
  125316. shape: Vector3[];
  125317. holes?: Vector3[][];
  125318. depth?: number;
  125319. faceUV?: Vector4[];
  125320. faceColors?: Color4[];
  125321. updatable?: boolean;
  125322. sideOrientation?: number;
  125323. frontUVs?: Vector4;
  125324. backUVs?: Vector4;
  125325. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125326. }
  125327. }
  125328. declare module BABYLON {
  125329. /**
  125330. * Class containing static functions to help procedurally build meshes
  125331. */
  125332. export class LatheBuilder {
  125333. /**
  125334. * Creates lathe mesh.
  125335. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125336. * * 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
  125337. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125338. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125339. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125340. * * 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
  125341. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125342. * * 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
  125343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125347. * @param name defines the name of the mesh
  125348. * @param options defines the options used to create the mesh
  125349. * @param scene defines the hosting scene
  125350. * @returns the lathe mesh
  125351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125352. */
  125353. static CreateLathe(name: string, options: {
  125354. shape: Vector3[];
  125355. radius?: number;
  125356. tessellation?: number;
  125357. clip?: number;
  125358. arc?: number;
  125359. closed?: boolean;
  125360. updatable?: boolean;
  125361. sideOrientation?: number;
  125362. frontUVs?: Vector4;
  125363. backUVs?: Vector4;
  125364. cap?: number;
  125365. invertUV?: boolean;
  125366. }, scene?: Nullable<Scene>): Mesh;
  125367. }
  125368. }
  125369. declare module BABYLON {
  125370. /**
  125371. * Class containing static functions to help procedurally build meshes
  125372. */
  125373. export class TiledPlaneBuilder {
  125374. /**
  125375. * Creates a tiled plane mesh
  125376. * * The parameter `pattern` will, depending on value, do nothing or
  125377. * * * flip (reflect about central vertical) alternate tiles across and up
  125378. * * * flip every tile on alternate rows
  125379. * * * rotate (180 degs) alternate tiles across and up
  125380. * * * rotate every tile on alternate rows
  125381. * * * flip and rotate alternate tiles across and up
  125382. * * * flip and rotate every tile on alternate rows
  125383. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125384. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125387. * * 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)
  125388. * * 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)
  125389. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125390. * @param name defines the name of the mesh
  125391. * @param options defines the options used to create the mesh
  125392. * @param scene defines the hosting scene
  125393. * @returns the box mesh
  125394. */
  125395. static CreateTiledPlane(name: string, options: {
  125396. pattern?: number;
  125397. tileSize?: number;
  125398. tileWidth?: number;
  125399. tileHeight?: number;
  125400. size?: number;
  125401. width?: number;
  125402. height?: number;
  125403. alignHorizontal?: number;
  125404. alignVertical?: number;
  125405. sideOrientation?: number;
  125406. frontUVs?: Vector4;
  125407. backUVs?: Vector4;
  125408. updatable?: boolean;
  125409. }, scene?: Nullable<Scene>): Mesh;
  125410. }
  125411. }
  125412. declare module BABYLON {
  125413. /**
  125414. * Class containing static functions to help procedurally build meshes
  125415. */
  125416. export class TubeBuilder {
  125417. /**
  125418. * Creates a tube mesh.
  125419. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125420. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125421. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125422. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125423. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125424. * * 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)
  125425. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125426. * * 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
  125427. * * 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
  125428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125430. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125432. * @param name defines the name of the mesh
  125433. * @param options defines the options used to create the mesh
  125434. * @param scene defines the hosting scene
  125435. * @returns the tube mesh
  125436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125437. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125438. */
  125439. static CreateTube(name: string, options: {
  125440. path: Vector3[];
  125441. radius?: number;
  125442. tessellation?: number;
  125443. radiusFunction?: {
  125444. (i: number, distance: number): number;
  125445. };
  125446. cap?: number;
  125447. arc?: number;
  125448. updatable?: boolean;
  125449. sideOrientation?: number;
  125450. frontUVs?: Vector4;
  125451. backUVs?: Vector4;
  125452. instance?: Mesh;
  125453. invertUV?: boolean;
  125454. }, scene?: Nullable<Scene>): Mesh;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Class containing static functions to help procedurally build meshes
  125460. */
  125461. export class IcoSphereBuilder {
  125462. /**
  125463. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125464. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125465. * * 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`)
  125466. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125467. * * 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
  125468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125471. * @param name defines the name of the mesh
  125472. * @param options defines the options used to create the mesh
  125473. * @param scene defines the hosting scene
  125474. * @returns the icosahedron mesh
  125475. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125476. */
  125477. static CreateIcoSphere(name: string, options: {
  125478. radius?: number;
  125479. radiusX?: number;
  125480. radiusY?: number;
  125481. radiusZ?: number;
  125482. flat?: boolean;
  125483. subdivisions?: number;
  125484. sideOrientation?: number;
  125485. frontUVs?: Vector4;
  125486. backUVs?: Vector4;
  125487. updatable?: boolean;
  125488. }, scene?: Nullable<Scene>): Mesh;
  125489. }
  125490. }
  125491. declare module BABYLON {
  125492. /**
  125493. * Class containing static functions to help procedurally build meshes
  125494. */
  125495. export class DecalBuilder {
  125496. /**
  125497. * Creates a decal mesh.
  125498. * 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
  125499. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125500. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125501. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125502. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125503. * @param name defines the name of the mesh
  125504. * @param sourceMesh defines the mesh where the decal must be applied
  125505. * @param options defines the options used to create the mesh
  125506. * @param scene defines the hosting scene
  125507. * @returns the decal mesh
  125508. * @see https://doc.babylonjs.com/how_to/decals
  125509. */
  125510. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125511. position?: Vector3;
  125512. normal?: Vector3;
  125513. size?: Vector3;
  125514. angle?: number;
  125515. }): Mesh;
  125516. }
  125517. }
  125518. declare module BABYLON {
  125519. /**
  125520. * Class containing static functions to help procedurally build meshes
  125521. */
  125522. export class MeshBuilder {
  125523. /**
  125524. * Creates a box mesh
  125525. * * The parameter `size` sets the size (float) of each box side (default 1)
  125526. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125527. * * 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)
  125528. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125532. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125533. * @param name defines the name of the mesh
  125534. * @param options defines the options used to create the mesh
  125535. * @param scene defines the hosting scene
  125536. * @returns the box mesh
  125537. */
  125538. static CreateBox(name: string, options: {
  125539. size?: number;
  125540. width?: number;
  125541. height?: number;
  125542. depth?: number;
  125543. faceUV?: Vector4[];
  125544. faceColors?: Color4[];
  125545. sideOrientation?: number;
  125546. frontUVs?: Vector4;
  125547. backUVs?: Vector4;
  125548. updatable?: boolean;
  125549. }, scene?: Nullable<Scene>): Mesh;
  125550. /**
  125551. * Creates a tiled box mesh
  125552. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125554. * @param name defines the name of the mesh
  125555. * @param options defines the options used to create the mesh
  125556. * @param scene defines the hosting scene
  125557. * @returns the tiled box mesh
  125558. */
  125559. static CreateTiledBox(name: string, options: {
  125560. pattern?: number;
  125561. size?: number;
  125562. width?: number;
  125563. height?: number;
  125564. depth: number;
  125565. tileSize?: number;
  125566. tileWidth?: number;
  125567. tileHeight?: number;
  125568. faceUV?: Vector4[];
  125569. faceColors?: Color4[];
  125570. alignHorizontal?: number;
  125571. alignVertical?: number;
  125572. sideOrientation?: number;
  125573. updatable?: boolean;
  125574. }, scene?: Nullable<Scene>): Mesh;
  125575. /**
  125576. * Creates a sphere mesh
  125577. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125578. * * 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`)
  125579. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125580. * * 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
  125581. * * 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)
  125582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125585. * @param name defines the name of the mesh
  125586. * @param options defines the options used to create the mesh
  125587. * @param scene defines the hosting scene
  125588. * @returns the sphere mesh
  125589. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125590. */
  125591. static CreateSphere(name: string, options: {
  125592. segments?: number;
  125593. diameter?: number;
  125594. diameterX?: number;
  125595. diameterY?: number;
  125596. diameterZ?: number;
  125597. arc?: number;
  125598. slice?: number;
  125599. sideOrientation?: number;
  125600. frontUVs?: Vector4;
  125601. backUVs?: Vector4;
  125602. updatable?: boolean;
  125603. }, scene?: Nullable<Scene>): Mesh;
  125604. /**
  125605. * Creates a plane polygonal mesh. By default, this is a disc
  125606. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125607. * * 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
  125608. * * 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
  125609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125612. * @param name defines the name of the mesh
  125613. * @param options defines the options used to create the mesh
  125614. * @param scene defines the hosting scene
  125615. * @returns the plane polygonal mesh
  125616. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125617. */
  125618. static CreateDisc(name: string, options: {
  125619. radius?: number;
  125620. tessellation?: number;
  125621. arc?: number;
  125622. updatable?: boolean;
  125623. sideOrientation?: number;
  125624. frontUVs?: Vector4;
  125625. backUVs?: Vector4;
  125626. }, scene?: Nullable<Scene>): Mesh;
  125627. /**
  125628. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125629. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125630. * * 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`)
  125631. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125632. * * 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
  125633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125636. * @param name defines the name of the mesh
  125637. * @param options defines the options used to create the mesh
  125638. * @param scene defines the hosting scene
  125639. * @returns the icosahedron mesh
  125640. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125641. */
  125642. static CreateIcoSphere(name: string, options: {
  125643. radius?: number;
  125644. radiusX?: number;
  125645. radiusY?: number;
  125646. radiusZ?: number;
  125647. flat?: boolean;
  125648. subdivisions?: number;
  125649. sideOrientation?: number;
  125650. frontUVs?: Vector4;
  125651. backUVs?: Vector4;
  125652. updatable?: boolean;
  125653. }, scene?: Nullable<Scene>): Mesh;
  125654. /**
  125655. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125656. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125657. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125658. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125659. * * 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
  125660. * * 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
  125661. * * 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
  125662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125665. * * 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
  125666. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125667. * * 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
  125668. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125670. * @param name defines the name of the mesh
  125671. * @param options defines the options used to create the mesh
  125672. * @param scene defines the hosting scene
  125673. * @returns the ribbon mesh
  125674. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125675. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125676. */
  125677. static CreateRibbon(name: string, options: {
  125678. pathArray: Vector3[][];
  125679. closeArray?: boolean;
  125680. closePath?: boolean;
  125681. offset?: number;
  125682. updatable?: boolean;
  125683. sideOrientation?: number;
  125684. frontUVs?: Vector4;
  125685. backUVs?: Vector4;
  125686. instance?: Mesh;
  125687. invertUV?: boolean;
  125688. uvs?: Vector2[];
  125689. colors?: Color4[];
  125690. }, scene?: Nullable<Scene>): Mesh;
  125691. /**
  125692. * Creates a cylinder or a cone mesh
  125693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125695. * * 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.
  125696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125700. * * 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).
  125701. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125702. * * 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).
  125703. * * 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
  125704. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125705. * * 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
  125706. * * 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.
  125707. * * If `enclose` is false, a ring surface is one element.
  125708. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125709. * * 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
  125710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125713. * @param name defines the name of the mesh
  125714. * @param options defines the options used to create the mesh
  125715. * @param scene defines the hosting scene
  125716. * @returns the cylinder mesh
  125717. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125718. */
  125719. static CreateCylinder(name: string, options: {
  125720. height?: number;
  125721. diameterTop?: number;
  125722. diameterBottom?: number;
  125723. diameter?: number;
  125724. tessellation?: number;
  125725. subdivisions?: number;
  125726. arc?: number;
  125727. faceColors?: Color4[];
  125728. faceUV?: Vector4[];
  125729. updatable?: boolean;
  125730. hasRings?: boolean;
  125731. enclose?: boolean;
  125732. cap?: number;
  125733. sideOrientation?: number;
  125734. frontUVs?: Vector4;
  125735. backUVs?: Vector4;
  125736. }, scene?: Nullable<Scene>): Mesh;
  125737. /**
  125738. * Creates a torus mesh
  125739. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125740. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125741. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125745. * @param name defines the name of the mesh
  125746. * @param options defines the options used to create the mesh
  125747. * @param scene defines the hosting scene
  125748. * @returns the torus mesh
  125749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125750. */
  125751. static CreateTorus(name: string, options: {
  125752. diameter?: number;
  125753. thickness?: number;
  125754. tessellation?: number;
  125755. updatable?: boolean;
  125756. sideOrientation?: number;
  125757. frontUVs?: Vector4;
  125758. backUVs?: Vector4;
  125759. }, scene?: Nullable<Scene>): Mesh;
  125760. /**
  125761. * Creates a torus knot mesh
  125762. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125763. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125764. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125765. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125769. * @param name defines the name of the mesh
  125770. * @param options defines the options used to create the mesh
  125771. * @param scene defines the hosting scene
  125772. * @returns the torus knot mesh
  125773. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125774. */
  125775. static CreateTorusKnot(name: string, options: {
  125776. radius?: number;
  125777. tube?: number;
  125778. radialSegments?: number;
  125779. tubularSegments?: number;
  125780. p?: number;
  125781. q?: number;
  125782. updatable?: boolean;
  125783. sideOrientation?: number;
  125784. frontUVs?: Vector4;
  125785. backUVs?: Vector4;
  125786. }, scene?: Nullable<Scene>): Mesh;
  125787. /**
  125788. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125789. * * 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
  125790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125791. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125792. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125793. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125794. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125795. * * 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
  125796. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125799. * @param name defines the name of the new line system
  125800. * @param options defines the options used to create the line system
  125801. * @param scene defines the hosting scene
  125802. * @returns a new line system mesh
  125803. */
  125804. static CreateLineSystem(name: string, options: {
  125805. lines: Vector3[][];
  125806. updatable?: boolean;
  125807. instance?: Nullable<LinesMesh>;
  125808. colors?: Nullable<Color4[][]>;
  125809. useVertexAlpha?: boolean;
  125810. }, scene: Nullable<Scene>): LinesMesh;
  125811. /**
  125812. * Creates a line mesh
  125813. * 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
  125814. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125815. * * The parameter `points` is an array successive Vector3
  125816. * * 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
  125817. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125818. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125819. * * When updating an instance, remember that only point positions can change, not the number of points
  125820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125822. * @param name defines the name of the new line system
  125823. * @param options defines the options used to create the line system
  125824. * @param scene defines the hosting scene
  125825. * @returns a new line mesh
  125826. */
  125827. static CreateLines(name: string, options: {
  125828. points: Vector3[];
  125829. updatable?: boolean;
  125830. instance?: Nullable<LinesMesh>;
  125831. colors?: Color4[];
  125832. useVertexAlpha?: boolean;
  125833. }, scene?: Nullable<Scene>): LinesMesh;
  125834. /**
  125835. * Creates a dashed line mesh
  125836. * * 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
  125837. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125838. * * The parameter `points` is an array successive Vector3
  125839. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125840. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125841. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125842. * * 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
  125843. * * When updating an instance, remember that only point positions can change, not the number of points
  125844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125845. * @param name defines the name of the mesh
  125846. * @param options defines the options used to create the mesh
  125847. * @param scene defines the hosting scene
  125848. * @returns the dashed line mesh
  125849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125850. */
  125851. static CreateDashedLines(name: string, options: {
  125852. points: Vector3[];
  125853. dashSize?: number;
  125854. gapSize?: number;
  125855. dashNb?: number;
  125856. updatable?: boolean;
  125857. instance?: LinesMesh;
  125858. }, scene?: Nullable<Scene>): LinesMesh;
  125859. /**
  125860. * 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.
  125861. * * 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.
  125862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125863. * * 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.
  125864. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125865. * * 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
  125866. * * 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
  125867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125872. * @param name defines the name of the mesh
  125873. * @param options defines the options used to create the mesh
  125874. * @param scene defines the hosting scene
  125875. * @returns the extruded shape mesh
  125876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125878. */
  125879. static ExtrudeShape(name: string, options: {
  125880. shape: Vector3[];
  125881. path: Vector3[];
  125882. scale?: number;
  125883. rotation?: number;
  125884. cap?: number;
  125885. updatable?: boolean;
  125886. sideOrientation?: number;
  125887. frontUVs?: Vector4;
  125888. backUVs?: Vector4;
  125889. instance?: Mesh;
  125890. invertUV?: boolean;
  125891. }, scene?: Nullable<Scene>): Mesh;
  125892. /**
  125893. * Creates an custom extruded shape mesh.
  125894. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125895. * * 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.
  125896. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125897. * * 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
  125898. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125899. * * 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
  125900. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125901. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125902. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125903. * * 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
  125904. * * 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
  125905. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125910. * @param name defines the name of the mesh
  125911. * @param options defines the options used to create the mesh
  125912. * @param scene defines the hosting scene
  125913. * @returns the custom extruded shape mesh
  125914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125917. */
  125918. static ExtrudeShapeCustom(name: string, options: {
  125919. shape: Vector3[];
  125920. path: Vector3[];
  125921. scaleFunction?: any;
  125922. rotationFunction?: any;
  125923. ribbonCloseArray?: boolean;
  125924. ribbonClosePath?: boolean;
  125925. cap?: number;
  125926. updatable?: boolean;
  125927. sideOrientation?: number;
  125928. frontUVs?: Vector4;
  125929. backUVs?: Vector4;
  125930. instance?: Mesh;
  125931. invertUV?: boolean;
  125932. }, scene?: Nullable<Scene>): Mesh;
  125933. /**
  125934. * Creates lathe mesh.
  125935. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125936. * * 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
  125937. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125938. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125939. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125940. * * 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
  125941. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125942. * * 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
  125943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125947. * @param name defines the name of the mesh
  125948. * @param options defines the options used to create the mesh
  125949. * @param scene defines the hosting scene
  125950. * @returns the lathe mesh
  125951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125952. */
  125953. static CreateLathe(name: string, options: {
  125954. shape: Vector3[];
  125955. radius?: number;
  125956. tessellation?: number;
  125957. clip?: number;
  125958. arc?: number;
  125959. closed?: boolean;
  125960. updatable?: boolean;
  125961. sideOrientation?: number;
  125962. frontUVs?: Vector4;
  125963. backUVs?: Vector4;
  125964. cap?: number;
  125965. invertUV?: boolean;
  125966. }, scene?: Nullable<Scene>): Mesh;
  125967. /**
  125968. * Creates a tiled plane mesh
  125969. * * You can set a limited pattern arrangement with the tiles
  125970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125973. * @param name defines the name of the mesh
  125974. * @param options defines the options used to create the mesh
  125975. * @param scene defines the hosting scene
  125976. * @returns the plane mesh
  125977. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125978. */
  125979. static CreateTiledPlane(name: string, options: {
  125980. pattern?: number;
  125981. tileSize?: number;
  125982. tileWidth?: number;
  125983. tileHeight?: number;
  125984. size?: number;
  125985. width?: number;
  125986. height?: number;
  125987. alignHorizontal?: number;
  125988. alignVertical?: number;
  125989. sideOrientation?: number;
  125990. frontUVs?: Vector4;
  125991. backUVs?: Vector4;
  125992. updatable?: boolean;
  125993. }, scene?: Nullable<Scene>): Mesh;
  125994. /**
  125995. * Creates a plane mesh
  125996. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125997. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125998. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126002. * @param name defines the name of the mesh
  126003. * @param options defines the options used to create the mesh
  126004. * @param scene defines the hosting scene
  126005. * @returns the plane mesh
  126006. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126007. */
  126008. static CreatePlane(name: string, options: {
  126009. size?: number;
  126010. width?: number;
  126011. height?: number;
  126012. sideOrientation?: number;
  126013. frontUVs?: Vector4;
  126014. backUVs?: Vector4;
  126015. updatable?: boolean;
  126016. sourcePlane?: Plane;
  126017. }, scene?: Nullable<Scene>): Mesh;
  126018. /**
  126019. * Creates a ground mesh
  126020. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126021. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126023. * @param name defines the name of the mesh
  126024. * @param options defines the options used to create the mesh
  126025. * @param scene defines the hosting scene
  126026. * @returns the ground mesh
  126027. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126028. */
  126029. static CreateGround(name: string, options: {
  126030. width?: number;
  126031. height?: number;
  126032. subdivisions?: number;
  126033. subdivisionsX?: number;
  126034. subdivisionsY?: number;
  126035. updatable?: boolean;
  126036. }, scene?: Nullable<Scene>): Mesh;
  126037. /**
  126038. * Creates a tiled ground mesh
  126039. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126040. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126041. * * 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
  126042. * * 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
  126043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126044. * @param name defines the name of the mesh
  126045. * @param options defines the options used to create the mesh
  126046. * @param scene defines the hosting scene
  126047. * @returns the tiled ground mesh
  126048. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126049. */
  126050. static CreateTiledGround(name: string, options: {
  126051. xmin: number;
  126052. zmin: number;
  126053. xmax: number;
  126054. zmax: number;
  126055. subdivisions?: {
  126056. w: number;
  126057. h: number;
  126058. };
  126059. precision?: {
  126060. w: number;
  126061. h: number;
  126062. };
  126063. updatable?: boolean;
  126064. }, scene?: Nullable<Scene>): Mesh;
  126065. /**
  126066. * Creates a ground mesh from a height map
  126067. * * The parameter `url` sets the URL of the height map image resource.
  126068. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126069. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126070. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126071. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126072. * * 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.
  126073. * * 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).
  126074. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126076. * @param name defines the name of the mesh
  126077. * @param url defines the url to the height map
  126078. * @param options defines the options used to create the mesh
  126079. * @param scene defines the hosting scene
  126080. * @returns the ground mesh
  126081. * @see https://doc.babylonjs.com/babylon101/height_map
  126082. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126083. */
  126084. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126085. width?: number;
  126086. height?: number;
  126087. subdivisions?: number;
  126088. minHeight?: number;
  126089. maxHeight?: number;
  126090. colorFilter?: Color3;
  126091. alphaFilter?: number;
  126092. updatable?: boolean;
  126093. onReady?: (mesh: GroundMesh) => void;
  126094. }, scene?: Nullable<Scene>): GroundMesh;
  126095. /**
  126096. * Creates a polygon mesh
  126097. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126098. * * 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
  126099. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126102. * * Remember you can only change the shape positions, not their number when updating a polygon
  126103. * @param name defines the name of the mesh
  126104. * @param options defines the options used to create the mesh
  126105. * @param scene defines the hosting scene
  126106. * @param earcutInjection can be used to inject your own earcut reference
  126107. * @returns the polygon mesh
  126108. */
  126109. static CreatePolygon(name: string, options: {
  126110. shape: Vector3[];
  126111. holes?: Vector3[][];
  126112. depth?: number;
  126113. faceUV?: Vector4[];
  126114. faceColors?: Color4[];
  126115. updatable?: boolean;
  126116. sideOrientation?: number;
  126117. frontUVs?: Vector4;
  126118. backUVs?: Vector4;
  126119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126120. /**
  126121. * Creates an extruded polygon mesh, with depth in the Y direction.
  126122. * * 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)
  126123. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126124. * @param name defines the name of the mesh
  126125. * @param options defines the options used to create the mesh
  126126. * @param scene defines the hosting scene
  126127. * @param earcutInjection can be used to inject your own earcut reference
  126128. * @returns the polygon mesh
  126129. */
  126130. static ExtrudePolygon(name: string, options: {
  126131. shape: Vector3[];
  126132. holes?: Vector3[][];
  126133. depth?: number;
  126134. faceUV?: Vector4[];
  126135. faceColors?: Color4[];
  126136. updatable?: boolean;
  126137. sideOrientation?: number;
  126138. frontUVs?: Vector4;
  126139. backUVs?: Vector4;
  126140. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126141. /**
  126142. * Creates a tube mesh.
  126143. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126144. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126145. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126146. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126147. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126148. * * 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)
  126149. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126150. * * 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
  126151. * * 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
  126152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126156. * @param name defines the name of the mesh
  126157. * @param options defines the options used to create the mesh
  126158. * @param scene defines the hosting scene
  126159. * @returns the tube mesh
  126160. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126161. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126162. */
  126163. static CreateTube(name: string, options: {
  126164. path: Vector3[];
  126165. radius?: number;
  126166. tessellation?: number;
  126167. radiusFunction?: {
  126168. (i: number, distance: number): number;
  126169. };
  126170. cap?: number;
  126171. arc?: number;
  126172. updatable?: boolean;
  126173. sideOrientation?: number;
  126174. frontUVs?: Vector4;
  126175. backUVs?: Vector4;
  126176. instance?: Mesh;
  126177. invertUV?: boolean;
  126178. }, scene?: Nullable<Scene>): Mesh;
  126179. /**
  126180. * Creates a polyhedron mesh
  126181. * * 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
  126182. * * The parameter `size` (positive float, default 1) sets the polygon size
  126183. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126184. * * 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`
  126185. * * 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
  126186. * * 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)`)
  126187. * * 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
  126188. * * 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
  126189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126192. * @param name defines the name of the mesh
  126193. * @param options defines the options used to create the mesh
  126194. * @param scene defines the hosting scene
  126195. * @returns the polyhedron mesh
  126196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126197. */
  126198. static CreatePolyhedron(name: string, options: {
  126199. type?: number;
  126200. size?: number;
  126201. sizeX?: number;
  126202. sizeY?: number;
  126203. sizeZ?: number;
  126204. custom?: any;
  126205. faceUV?: Vector4[];
  126206. faceColors?: Color4[];
  126207. flat?: boolean;
  126208. updatable?: boolean;
  126209. sideOrientation?: number;
  126210. frontUVs?: Vector4;
  126211. backUVs?: Vector4;
  126212. }, scene?: Nullable<Scene>): Mesh;
  126213. /**
  126214. * Creates a decal mesh.
  126215. * 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
  126216. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126217. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126218. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126219. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126220. * @param name defines the name of the mesh
  126221. * @param sourceMesh defines the mesh where the decal must be applied
  126222. * @param options defines the options used to create the mesh
  126223. * @param scene defines the hosting scene
  126224. * @returns the decal mesh
  126225. * @see https://doc.babylonjs.com/how_to/decals
  126226. */
  126227. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126228. position?: Vector3;
  126229. normal?: Vector3;
  126230. size?: Vector3;
  126231. angle?: number;
  126232. }): Mesh;
  126233. }
  126234. }
  126235. declare module BABYLON {
  126236. /**
  126237. * A simplifier interface for future simplification implementations
  126238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126239. */
  126240. export interface ISimplifier {
  126241. /**
  126242. * Simplification of a given mesh according to the given settings.
  126243. * Since this requires computation, it is assumed that the function runs async.
  126244. * @param settings The settings of the simplification, including quality and distance
  126245. * @param successCallback A callback that will be called after the mesh was simplified.
  126246. * @param errorCallback in case of an error, this callback will be called. optional.
  126247. */
  126248. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126249. }
  126250. /**
  126251. * Expected simplification settings.
  126252. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126253. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126254. */
  126255. export interface ISimplificationSettings {
  126256. /**
  126257. * Gets or sets the expected quality
  126258. */
  126259. quality: number;
  126260. /**
  126261. * Gets or sets the distance when this optimized version should be used
  126262. */
  126263. distance: number;
  126264. /**
  126265. * Gets an already optimized mesh
  126266. */
  126267. optimizeMesh?: boolean;
  126268. }
  126269. /**
  126270. * Class used to specify simplification options
  126271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126272. */
  126273. export class SimplificationSettings implements ISimplificationSettings {
  126274. /** expected quality */
  126275. quality: number;
  126276. /** distance when this optimized version should be used */
  126277. distance: number;
  126278. /** already optimized mesh */
  126279. optimizeMesh?: boolean | undefined;
  126280. /**
  126281. * Creates a SimplificationSettings
  126282. * @param quality expected quality
  126283. * @param distance distance when this optimized version should be used
  126284. * @param optimizeMesh already optimized mesh
  126285. */
  126286. constructor(
  126287. /** expected quality */
  126288. quality: number,
  126289. /** distance when this optimized version should be used */
  126290. distance: number,
  126291. /** already optimized mesh */
  126292. optimizeMesh?: boolean | undefined);
  126293. }
  126294. /**
  126295. * Interface used to define a simplification task
  126296. */
  126297. export interface ISimplificationTask {
  126298. /**
  126299. * Array of settings
  126300. */
  126301. settings: Array<ISimplificationSettings>;
  126302. /**
  126303. * Simplification type
  126304. */
  126305. simplificationType: SimplificationType;
  126306. /**
  126307. * Mesh to simplify
  126308. */
  126309. mesh: Mesh;
  126310. /**
  126311. * Callback called on success
  126312. */
  126313. successCallback?: () => void;
  126314. /**
  126315. * Defines if parallel processing can be used
  126316. */
  126317. parallelProcessing: boolean;
  126318. }
  126319. /**
  126320. * Queue used to order the simplification tasks
  126321. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126322. */
  126323. export class SimplificationQueue {
  126324. private _simplificationArray;
  126325. /**
  126326. * Gets a boolean indicating that the process is still running
  126327. */
  126328. running: boolean;
  126329. /**
  126330. * Creates a new queue
  126331. */
  126332. constructor();
  126333. /**
  126334. * Adds a new simplification task
  126335. * @param task defines a task to add
  126336. */
  126337. addTask(task: ISimplificationTask): void;
  126338. /**
  126339. * Execute next task
  126340. */
  126341. executeNext(): void;
  126342. /**
  126343. * Execute a simplification task
  126344. * @param task defines the task to run
  126345. */
  126346. runSimplification(task: ISimplificationTask): void;
  126347. private getSimplifier;
  126348. }
  126349. /**
  126350. * The implemented types of simplification
  126351. * At the moment only Quadratic Error Decimation is implemented
  126352. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126353. */
  126354. export enum SimplificationType {
  126355. /** Quadratic error decimation */
  126356. QUADRATIC = 0
  126357. }
  126358. }
  126359. declare module BABYLON {
  126360. interface Scene {
  126361. /** @hidden (Backing field) */
  126362. _simplificationQueue: SimplificationQueue;
  126363. /**
  126364. * Gets or sets the simplification queue attached to the scene
  126365. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126366. */
  126367. simplificationQueue: SimplificationQueue;
  126368. }
  126369. interface Mesh {
  126370. /**
  126371. * Simplify the mesh according to the given array of settings.
  126372. * Function will return immediately and will simplify async
  126373. * @param settings a collection of simplification settings
  126374. * @param parallelProcessing should all levels calculate parallel or one after the other
  126375. * @param simplificationType the type of simplification to run
  126376. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126377. * @returns the current mesh
  126378. */
  126379. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126380. }
  126381. /**
  126382. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126383. * created in a scene
  126384. */
  126385. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126386. /**
  126387. * The component name helpfull to identify the component in the list of scene components.
  126388. */
  126389. readonly name: string;
  126390. /**
  126391. * The scene the component belongs to.
  126392. */
  126393. scene: Scene;
  126394. /**
  126395. * Creates a new instance of the component for the given scene
  126396. * @param scene Defines the scene to register the component in
  126397. */
  126398. constructor(scene: Scene);
  126399. /**
  126400. * Registers the component in a given scene
  126401. */
  126402. register(): void;
  126403. /**
  126404. * Rebuilds the elements related to this component in case of
  126405. * context lost for instance.
  126406. */
  126407. rebuild(): void;
  126408. /**
  126409. * Disposes the component and the associated ressources
  126410. */
  126411. dispose(): void;
  126412. private _beforeCameraUpdate;
  126413. }
  126414. }
  126415. declare module BABYLON {
  126416. /**
  126417. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126418. */
  126419. export interface INavigationEnginePlugin {
  126420. /**
  126421. * plugin name
  126422. */
  126423. name: string;
  126424. /**
  126425. * Creates a navigation mesh
  126426. * @param meshes array of all the geometry used to compute the navigatio mesh
  126427. * @param parameters bunch of parameters used to filter geometry
  126428. */
  126429. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126430. /**
  126431. * Create a navigation mesh debug mesh
  126432. * @param scene is where the mesh will be added
  126433. * @returns debug display mesh
  126434. */
  126435. createDebugNavMesh(scene: Scene): Mesh;
  126436. /**
  126437. * Get a navigation mesh constrained position, closest to the parameter position
  126438. * @param position world position
  126439. * @returns the closest point to position constrained by the navigation mesh
  126440. */
  126441. getClosestPoint(position: Vector3): Vector3;
  126442. /**
  126443. * Get a navigation mesh constrained position, within a particular radius
  126444. * @param position world position
  126445. * @param maxRadius the maximum distance to the constrained world position
  126446. * @returns the closest point to position constrained by the navigation mesh
  126447. */
  126448. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126449. /**
  126450. * Compute the final position from a segment made of destination-position
  126451. * @param position world position
  126452. * @param destination world position
  126453. * @returns the resulting point along the navmesh
  126454. */
  126455. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126456. /**
  126457. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126458. * @param start world position
  126459. * @param end world position
  126460. * @returns array containing world position composing the path
  126461. */
  126462. computePath(start: Vector3, end: Vector3): Vector3[];
  126463. /**
  126464. * If this plugin is supported
  126465. * @returns true if plugin is supported
  126466. */
  126467. isSupported(): boolean;
  126468. /**
  126469. * Create a new Crowd so you can add agents
  126470. * @param maxAgents the maximum agent count in the crowd
  126471. * @param maxAgentRadius the maximum radius an agent can have
  126472. * @param scene to attach the crowd to
  126473. * @returns the crowd you can add agents to
  126474. */
  126475. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126476. /**
  126477. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126478. * The queries will try to find a solution within those bounds
  126479. * default is (1,1,1)
  126480. * @param extent x,y,z value that define the extent around the queries point of reference
  126481. */
  126482. setDefaultQueryExtent(extent: Vector3): void;
  126483. /**
  126484. * Get the Bounding box extent specified by setDefaultQueryExtent
  126485. * @returns the box extent values
  126486. */
  126487. getDefaultQueryExtent(): Vector3;
  126488. /**
  126489. * Release all resources
  126490. */
  126491. dispose(): void;
  126492. }
  126493. /**
  126494. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126495. */
  126496. export interface ICrowd {
  126497. /**
  126498. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126499. * You can attach anything to that node. The node position is updated in the scene update tick.
  126500. * @param pos world position that will be constrained by the navigation mesh
  126501. * @param parameters agent parameters
  126502. * @param transform hooked to the agent that will be update by the scene
  126503. * @returns agent index
  126504. */
  126505. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126506. /**
  126507. * Returns the agent position in world space
  126508. * @param index agent index returned by addAgent
  126509. * @returns world space position
  126510. */
  126511. getAgentPosition(index: number): Vector3;
  126512. /**
  126513. * Gets the agent velocity in world space
  126514. * @param index agent index returned by addAgent
  126515. * @returns world space velocity
  126516. */
  126517. getAgentVelocity(index: number): Vector3;
  126518. /**
  126519. * remove a particular agent previously created
  126520. * @param index agent index returned by addAgent
  126521. */
  126522. removeAgent(index: number): void;
  126523. /**
  126524. * get the list of all agents attached to this crowd
  126525. * @returns list of agent indices
  126526. */
  126527. getAgents(): number[];
  126528. /**
  126529. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126530. * @param deltaTime in seconds
  126531. */
  126532. update(deltaTime: number): void;
  126533. /**
  126534. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126535. * @param index agent index returned by addAgent
  126536. * @param destination targeted world position
  126537. */
  126538. agentGoto(index: number, destination: Vector3): void;
  126539. /**
  126540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126541. * The queries will try to find a solution within those bounds
  126542. * default is (1,1,1)
  126543. * @param extent x,y,z value that define the extent around the queries point of reference
  126544. */
  126545. setDefaultQueryExtent(extent: Vector3): void;
  126546. /**
  126547. * Get the Bounding box extent specified by setDefaultQueryExtent
  126548. * @returns the box extent values
  126549. */
  126550. getDefaultQueryExtent(): Vector3;
  126551. /**
  126552. * Release all resources
  126553. */
  126554. dispose(): void;
  126555. }
  126556. /**
  126557. * Configures an agent
  126558. */
  126559. export interface IAgentParameters {
  126560. /**
  126561. * Agent radius. [Limit: >= 0]
  126562. */
  126563. radius: number;
  126564. /**
  126565. * Agent height. [Limit: > 0]
  126566. */
  126567. height: number;
  126568. /**
  126569. * Maximum allowed acceleration. [Limit: >= 0]
  126570. */
  126571. maxAcceleration: number;
  126572. /**
  126573. * Maximum allowed speed. [Limit: >= 0]
  126574. */
  126575. maxSpeed: number;
  126576. /**
  126577. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126578. */
  126579. collisionQueryRange: number;
  126580. /**
  126581. * The path visibility optimization range. [Limit: > 0]
  126582. */
  126583. pathOptimizationRange: number;
  126584. /**
  126585. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126586. */
  126587. separationWeight: number;
  126588. }
  126589. /**
  126590. * Configures the navigation mesh creation
  126591. */
  126592. export interface INavMeshParameters {
  126593. /**
  126594. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126595. */
  126596. cs: number;
  126597. /**
  126598. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126599. */
  126600. ch: number;
  126601. /**
  126602. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126603. */
  126604. walkableSlopeAngle: number;
  126605. /**
  126606. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126607. * be considered walkable. [Limit: >= 3] [Units: vx]
  126608. */
  126609. walkableHeight: number;
  126610. /**
  126611. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126612. */
  126613. walkableClimb: number;
  126614. /**
  126615. * The distance to erode/shrink the walkable area of the heightfield away from
  126616. * obstructions. [Limit: >=0] [Units: vx]
  126617. */
  126618. walkableRadius: number;
  126619. /**
  126620. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126621. */
  126622. maxEdgeLen: number;
  126623. /**
  126624. * The maximum distance a simplfied contour's border edges should deviate
  126625. * the original raw contour. [Limit: >=0] [Units: vx]
  126626. */
  126627. maxSimplificationError: number;
  126628. /**
  126629. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126630. */
  126631. minRegionArea: number;
  126632. /**
  126633. * Any regions with a span count smaller than this value will, if possible,
  126634. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126635. */
  126636. mergeRegionArea: number;
  126637. /**
  126638. * The maximum number of vertices allowed for polygons generated during the
  126639. * contour to polygon conversion process. [Limit: >= 3]
  126640. */
  126641. maxVertsPerPoly: number;
  126642. /**
  126643. * Sets the sampling distance to use when generating the detail mesh.
  126644. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126645. */
  126646. detailSampleDist: number;
  126647. /**
  126648. * The maximum distance the detail mesh surface should deviate from heightfield
  126649. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126650. */
  126651. detailSampleMaxError: number;
  126652. }
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * RecastJS navigation plugin
  126657. */
  126658. export class RecastJSPlugin implements INavigationEnginePlugin {
  126659. /**
  126660. * Reference to the Recast library
  126661. */
  126662. bjsRECAST: any;
  126663. /**
  126664. * plugin name
  126665. */
  126666. name: string;
  126667. /**
  126668. * the first navmesh created. We might extend this to support multiple navmeshes
  126669. */
  126670. navMesh: any;
  126671. /**
  126672. * Initializes the recastJS plugin
  126673. * @param recastInjection can be used to inject your own recast reference
  126674. */
  126675. constructor(recastInjection?: any);
  126676. /**
  126677. * Creates a navigation mesh
  126678. * @param meshes array of all the geometry used to compute the navigatio mesh
  126679. * @param parameters bunch of parameters used to filter geometry
  126680. */
  126681. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126682. /**
  126683. * Create a navigation mesh debug mesh
  126684. * @param scene is where the mesh will be added
  126685. * @returns debug display mesh
  126686. */
  126687. createDebugNavMesh(scene: Scene): Mesh;
  126688. /**
  126689. * Get a navigation mesh constrained position, closest to the parameter position
  126690. * @param position world position
  126691. * @returns the closest point to position constrained by the navigation mesh
  126692. */
  126693. getClosestPoint(position: Vector3): Vector3;
  126694. /**
  126695. * Get a navigation mesh constrained position, within a particular radius
  126696. * @param position world position
  126697. * @param maxRadius the maximum distance to the constrained world position
  126698. * @returns the closest point to position constrained by the navigation mesh
  126699. */
  126700. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126701. /**
  126702. * Compute the final position from a segment made of destination-position
  126703. * @param position world position
  126704. * @param destination world position
  126705. * @returns the resulting point along the navmesh
  126706. */
  126707. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126708. /**
  126709. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126710. * @param start world position
  126711. * @param end world position
  126712. * @returns array containing world position composing the path
  126713. */
  126714. computePath(start: Vector3, end: Vector3): Vector3[];
  126715. /**
  126716. * Create a new Crowd so you can add agents
  126717. * @param maxAgents the maximum agent count in the crowd
  126718. * @param maxAgentRadius the maximum radius an agent can have
  126719. * @param scene to attach the crowd to
  126720. * @returns the crowd you can add agents to
  126721. */
  126722. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126723. /**
  126724. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126725. * The queries will try to find a solution within those bounds
  126726. * default is (1,1,1)
  126727. * @param extent x,y,z value that define the extent around the queries point of reference
  126728. */
  126729. setDefaultQueryExtent(extent: Vector3): void;
  126730. /**
  126731. * Get the Bounding box extent specified by setDefaultQueryExtent
  126732. * @returns the box extent values
  126733. */
  126734. getDefaultQueryExtent(): Vector3;
  126735. /**
  126736. * Disposes
  126737. */
  126738. dispose(): void;
  126739. /**
  126740. * If this plugin is supported
  126741. * @returns true if plugin is supported
  126742. */
  126743. isSupported(): boolean;
  126744. }
  126745. /**
  126746. * Recast detour crowd implementation
  126747. */
  126748. export class RecastJSCrowd implements ICrowd {
  126749. /**
  126750. * Recast/detour plugin
  126751. */
  126752. bjsRECASTPlugin: RecastJSPlugin;
  126753. /**
  126754. * Link to the detour crowd
  126755. */
  126756. recastCrowd: any;
  126757. /**
  126758. * One transform per agent
  126759. */
  126760. transforms: TransformNode[];
  126761. /**
  126762. * All agents created
  126763. */
  126764. agents: number[];
  126765. /**
  126766. * Link to the scene is kept to unregister the crowd from the scene
  126767. */
  126768. private _scene;
  126769. /**
  126770. * Observer for crowd updates
  126771. */
  126772. private _onBeforeAnimationsObserver;
  126773. /**
  126774. * Constructor
  126775. * @param plugin recastJS plugin
  126776. * @param maxAgents the maximum agent count in the crowd
  126777. * @param maxAgentRadius the maximum radius an agent can have
  126778. * @param scene to attach the crowd to
  126779. * @returns the crowd you can add agents to
  126780. */
  126781. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126782. /**
  126783. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126784. * You can attach anything to that node. The node position is updated in the scene update tick.
  126785. * @param pos world position that will be constrained by the navigation mesh
  126786. * @param parameters agent parameters
  126787. * @param transform hooked to the agent that will be update by the scene
  126788. * @returns agent index
  126789. */
  126790. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126791. /**
  126792. * Returns the agent position in world space
  126793. * @param index agent index returned by addAgent
  126794. * @returns world space position
  126795. */
  126796. getAgentPosition(index: number): Vector3;
  126797. /**
  126798. * Returns the agent velocity in world space
  126799. * @param index agent index returned by addAgent
  126800. * @returns world space velocity
  126801. */
  126802. getAgentVelocity(index: number): Vector3;
  126803. /**
  126804. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126805. * @param index agent index returned by addAgent
  126806. * @param destination targeted world position
  126807. */
  126808. agentGoto(index: number, destination: Vector3): void;
  126809. /**
  126810. * remove a particular agent previously created
  126811. * @param index agent index returned by addAgent
  126812. */
  126813. removeAgent(index: number): void;
  126814. /**
  126815. * get the list of all agents attached to this crowd
  126816. * @returns list of agent indices
  126817. */
  126818. getAgents(): number[];
  126819. /**
  126820. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126821. * @param deltaTime in seconds
  126822. */
  126823. update(deltaTime: number): void;
  126824. /**
  126825. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126826. * The queries will try to find a solution within those bounds
  126827. * default is (1,1,1)
  126828. * @param extent x,y,z value that define the extent around the queries point of reference
  126829. */
  126830. setDefaultQueryExtent(extent: Vector3): void;
  126831. /**
  126832. * Get the Bounding box extent specified by setDefaultQueryExtent
  126833. * @returns the box extent values
  126834. */
  126835. getDefaultQueryExtent(): Vector3;
  126836. /**
  126837. * Release all resources
  126838. */
  126839. dispose(): void;
  126840. }
  126841. }
  126842. declare module BABYLON {
  126843. /**
  126844. * Class used to enable access to IndexedDB
  126845. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126846. */
  126847. export class Database implements IOfflineProvider {
  126848. private _callbackManifestChecked;
  126849. private _currentSceneUrl;
  126850. private _db;
  126851. private _enableSceneOffline;
  126852. private _enableTexturesOffline;
  126853. private _manifestVersionFound;
  126854. private _mustUpdateRessources;
  126855. private _hasReachedQuota;
  126856. private _isSupported;
  126857. private _idbFactory;
  126858. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126859. private static IsUASupportingBlobStorage;
  126860. /**
  126861. * Gets a boolean indicating if Database storate is enabled (off by default)
  126862. */
  126863. static IDBStorageEnabled: boolean;
  126864. /**
  126865. * Gets a boolean indicating if scene must be saved in the database
  126866. */
  126867. readonly enableSceneOffline: boolean;
  126868. /**
  126869. * Gets a boolean indicating if textures must be saved in the database
  126870. */
  126871. readonly enableTexturesOffline: boolean;
  126872. /**
  126873. * Creates a new Database
  126874. * @param urlToScene defines the url to load the scene
  126875. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126876. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126877. */
  126878. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126879. private static _ParseURL;
  126880. private static _ReturnFullUrlLocation;
  126881. private _checkManifestFile;
  126882. /**
  126883. * Open the database and make it available
  126884. * @param successCallback defines the callback to call on success
  126885. * @param errorCallback defines the callback to call on error
  126886. */
  126887. open(successCallback: () => void, errorCallback: () => void): void;
  126888. /**
  126889. * Loads an image from the database
  126890. * @param url defines the url to load from
  126891. * @param image defines the target DOM image
  126892. */
  126893. loadImage(url: string, image: HTMLImageElement): void;
  126894. private _loadImageFromDBAsync;
  126895. private _saveImageIntoDBAsync;
  126896. private _checkVersionFromDB;
  126897. private _loadVersionFromDBAsync;
  126898. private _saveVersionIntoDBAsync;
  126899. /**
  126900. * Loads a file from database
  126901. * @param url defines the URL to load from
  126902. * @param sceneLoaded defines a callback to call on success
  126903. * @param progressCallBack defines a callback to call when progress changed
  126904. * @param errorCallback defines a callback to call on error
  126905. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126906. */
  126907. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126908. private _loadFileAsync;
  126909. private _saveFileAsync;
  126910. /**
  126911. * Validates if xhr data is correct
  126912. * @param xhr defines the request to validate
  126913. * @param dataType defines the expected data type
  126914. * @returns true if data is correct
  126915. */
  126916. private static _ValidateXHRData;
  126917. }
  126918. }
  126919. declare module BABYLON {
  126920. /** @hidden */
  126921. export var gpuUpdateParticlesPixelShader: {
  126922. name: string;
  126923. shader: string;
  126924. };
  126925. }
  126926. declare module BABYLON {
  126927. /** @hidden */
  126928. export var gpuUpdateParticlesVertexShader: {
  126929. name: string;
  126930. shader: string;
  126931. };
  126932. }
  126933. declare module BABYLON {
  126934. /** @hidden */
  126935. export var clipPlaneFragmentDeclaration2: {
  126936. name: string;
  126937. shader: string;
  126938. };
  126939. }
  126940. declare module BABYLON {
  126941. /** @hidden */
  126942. export var gpuRenderParticlesPixelShader: {
  126943. name: string;
  126944. shader: string;
  126945. };
  126946. }
  126947. declare module BABYLON {
  126948. /** @hidden */
  126949. export var clipPlaneVertexDeclaration2: {
  126950. name: string;
  126951. shader: string;
  126952. };
  126953. }
  126954. declare module BABYLON {
  126955. /** @hidden */
  126956. export var gpuRenderParticlesVertexShader: {
  126957. name: string;
  126958. shader: string;
  126959. };
  126960. }
  126961. declare module BABYLON {
  126962. /**
  126963. * This represents a GPU particle system in Babylon
  126964. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126965. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126966. */
  126967. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126968. /**
  126969. * The layer mask we are rendering the particles through.
  126970. */
  126971. layerMask: number;
  126972. private _capacity;
  126973. private _activeCount;
  126974. private _currentActiveCount;
  126975. private _accumulatedCount;
  126976. private _renderEffect;
  126977. private _updateEffect;
  126978. private _buffer0;
  126979. private _buffer1;
  126980. private _spriteBuffer;
  126981. private _updateVAO;
  126982. private _renderVAO;
  126983. private _targetIndex;
  126984. private _sourceBuffer;
  126985. private _targetBuffer;
  126986. private _engine;
  126987. private _currentRenderId;
  126988. private _started;
  126989. private _stopped;
  126990. private _timeDelta;
  126991. private _randomTexture;
  126992. private _randomTexture2;
  126993. private _attributesStrideSize;
  126994. private _updateEffectOptions;
  126995. private _randomTextureSize;
  126996. private _actualFrame;
  126997. private readonly _rawTextureWidth;
  126998. /**
  126999. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  127000. */
  127001. static readonly IsSupported: boolean;
  127002. /**
  127003. * An event triggered when the system is disposed.
  127004. */
  127005. onDisposeObservable: Observable<GPUParticleSystem>;
  127006. /**
  127007. * Gets the maximum number of particles active at the same time.
  127008. * @returns The max number of active particles.
  127009. */
  127010. getCapacity(): number;
  127011. /**
  127012. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  127013. * to override the particles.
  127014. */
  127015. forceDepthWrite: boolean;
  127016. /**
  127017. * Gets or set the number of active particles
  127018. */
  127019. activeParticleCount: number;
  127020. private _preWarmDone;
  127021. /**
  127022. * Is this system ready to be used/rendered
  127023. * @return true if the system is ready
  127024. */
  127025. isReady(): boolean;
  127026. /**
  127027. * Gets if the system has been started. (Note: this will still be true after stop is called)
  127028. * @returns True if it has been started, otherwise false.
  127029. */
  127030. isStarted(): boolean;
  127031. /**
  127032. * Starts the particle system and begins to emit
  127033. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  127034. */
  127035. start(delay?: number): void;
  127036. /**
  127037. * Stops the particle system.
  127038. */
  127039. stop(): void;
  127040. /**
  127041. * Remove all active particles
  127042. */
  127043. reset(): void;
  127044. /**
  127045. * Returns the string "GPUParticleSystem"
  127046. * @returns a string containing the class name
  127047. */
  127048. getClassName(): string;
  127049. private _colorGradientsTexture;
  127050. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  127051. /**
  127052. * Adds a new color gradient
  127053. * @param gradient defines the gradient to use (between 0 and 1)
  127054. * @param color1 defines the color to affect to the specified gradient
  127055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  127056. * @returns the current particle system
  127057. */
  127058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  127059. /**
  127060. * Remove a specific color gradient
  127061. * @param gradient defines the gradient to remove
  127062. * @returns the current particle system
  127063. */
  127064. removeColorGradient(gradient: number): GPUParticleSystem;
  127065. private _angularSpeedGradientsTexture;
  127066. private _sizeGradientsTexture;
  127067. private _velocityGradientsTexture;
  127068. private _limitVelocityGradientsTexture;
  127069. private _dragGradientsTexture;
  127070. private _addFactorGradient;
  127071. /**
  127072. * Adds a new size gradient
  127073. * @param gradient defines the gradient to use (between 0 and 1)
  127074. * @param factor defines the size factor to affect to the specified gradient
  127075. * @returns the current particle system
  127076. */
  127077. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  127078. /**
  127079. * Remove a specific size gradient
  127080. * @param gradient defines the gradient to remove
  127081. * @returns the current particle system
  127082. */
  127083. removeSizeGradient(gradient: number): GPUParticleSystem;
  127084. /**
  127085. * Adds a new angular speed gradient
  127086. * @param gradient defines the gradient to use (between 0 and 1)
  127087. * @param factor defines the angular speed to affect to the specified gradient
  127088. * @returns the current particle system
  127089. */
  127090. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  127091. /**
  127092. * Remove a specific angular speed gradient
  127093. * @param gradient defines the gradient to remove
  127094. * @returns the current particle system
  127095. */
  127096. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  127097. /**
  127098. * Adds a new velocity gradient
  127099. * @param gradient defines the gradient to use (between 0 and 1)
  127100. * @param factor defines the velocity to affect to the specified gradient
  127101. * @returns the current particle system
  127102. */
  127103. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127104. /**
  127105. * Remove a specific velocity gradient
  127106. * @param gradient defines the gradient to remove
  127107. * @returns the current particle system
  127108. */
  127109. removeVelocityGradient(gradient: number): GPUParticleSystem;
  127110. /**
  127111. * Adds a new limit velocity gradient
  127112. * @param gradient defines the gradient to use (between 0 and 1)
  127113. * @param factor defines the limit velocity value to affect to the specified gradient
  127114. * @returns the current particle system
  127115. */
  127116. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127117. /**
  127118. * Remove a specific limit velocity gradient
  127119. * @param gradient defines the gradient to remove
  127120. * @returns the current particle system
  127121. */
  127122. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  127123. /**
  127124. * Adds a new drag gradient
  127125. * @param gradient defines the gradient to use (between 0 and 1)
  127126. * @param factor defines the drag value to affect to the specified gradient
  127127. * @returns the current particle system
  127128. */
  127129. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  127130. /**
  127131. * Remove a specific drag gradient
  127132. * @param gradient defines the gradient to remove
  127133. * @returns the current particle system
  127134. */
  127135. removeDragGradient(gradient: number): GPUParticleSystem;
  127136. /**
  127137. * Not supported by GPUParticleSystem
  127138. * @param gradient defines the gradient to use (between 0 and 1)
  127139. * @param factor defines the emit rate value to affect to the specified gradient
  127140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127141. * @returns the current particle system
  127142. */
  127143. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127144. /**
  127145. * Not supported by GPUParticleSystem
  127146. * @param gradient defines the gradient to remove
  127147. * @returns the current particle system
  127148. */
  127149. removeEmitRateGradient(gradient: number): IParticleSystem;
  127150. /**
  127151. * Not supported by GPUParticleSystem
  127152. * @param gradient defines the gradient to use (between 0 and 1)
  127153. * @param factor defines the start size value to affect to the specified gradient
  127154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127155. * @returns the current particle system
  127156. */
  127157. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127158. /**
  127159. * Not supported by GPUParticleSystem
  127160. * @param gradient defines the gradient to remove
  127161. * @returns the current particle system
  127162. */
  127163. removeStartSizeGradient(gradient: number): IParticleSystem;
  127164. /**
  127165. * Not supported by GPUParticleSystem
  127166. * @param gradient defines the gradient to use (between 0 and 1)
  127167. * @param min defines the color remap minimal range
  127168. * @param max defines the color remap maximal range
  127169. * @returns the current particle system
  127170. */
  127171. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127172. /**
  127173. * Not supported by GPUParticleSystem
  127174. * @param gradient defines the gradient to remove
  127175. * @returns the current particle system
  127176. */
  127177. removeColorRemapGradient(): IParticleSystem;
  127178. /**
  127179. * Not supported by GPUParticleSystem
  127180. * @param gradient defines the gradient to use (between 0 and 1)
  127181. * @param min defines the alpha remap minimal range
  127182. * @param max defines the alpha remap maximal range
  127183. * @returns the current particle system
  127184. */
  127185. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127186. /**
  127187. * Not supported by GPUParticleSystem
  127188. * @param gradient defines the gradient to remove
  127189. * @returns the current particle system
  127190. */
  127191. removeAlphaRemapGradient(): IParticleSystem;
  127192. /**
  127193. * Not supported by GPUParticleSystem
  127194. * @param gradient defines the gradient to use (between 0 and 1)
  127195. * @param color defines the color to affect to the specified gradient
  127196. * @returns the current particle system
  127197. */
  127198. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127199. /**
  127200. * Not supported by GPUParticleSystem
  127201. * @param gradient defines the gradient to remove
  127202. * @returns the current particle system
  127203. */
  127204. removeRampGradient(): IParticleSystem;
  127205. /**
  127206. * Not supported by GPUParticleSystem
  127207. * @returns the list of ramp gradients
  127208. */
  127209. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127210. /**
  127211. * Not supported by GPUParticleSystem
  127212. * Gets or sets a boolean indicating that ramp gradients must be used
  127213. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127214. */
  127215. useRampGradients: boolean;
  127216. /**
  127217. * Not supported by GPUParticleSystem
  127218. * @param gradient defines the gradient to use (between 0 and 1)
  127219. * @param factor defines the life time factor to affect to the specified gradient
  127220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127221. * @returns the current particle system
  127222. */
  127223. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127224. /**
  127225. * Not supported by GPUParticleSystem
  127226. * @param gradient defines the gradient to remove
  127227. * @returns the current particle system
  127228. */
  127229. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127230. /**
  127231. * Instantiates a GPU particle system.
  127232. * 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.
  127233. * @param name The name of the particle system
  127234. * @param options The options used to create the system
  127235. * @param scene The scene the particle system belongs to
  127236. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127237. */
  127238. constructor(name: string, options: Partial<{
  127239. capacity: number;
  127240. randomTextureSize: number;
  127241. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127242. protected _reset(): void;
  127243. private _createUpdateVAO;
  127244. private _createRenderVAO;
  127245. private _initialize;
  127246. /** @hidden */
  127247. _recreateUpdateEffect(): void;
  127248. /** @hidden */
  127249. _recreateRenderEffect(): void;
  127250. /**
  127251. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127252. * @param preWarm defines if we are in the pre-warmimg phase
  127253. */
  127254. animate(preWarm?: boolean): void;
  127255. private _createFactorGradientTexture;
  127256. private _createSizeGradientTexture;
  127257. private _createAngularSpeedGradientTexture;
  127258. private _createVelocityGradientTexture;
  127259. private _createLimitVelocityGradientTexture;
  127260. private _createDragGradientTexture;
  127261. private _createColorGradientTexture;
  127262. /**
  127263. * Renders the particle system in its current state
  127264. * @param preWarm defines if the system should only update the particles but not render them
  127265. * @returns the current number of particles
  127266. */
  127267. render(preWarm?: boolean): number;
  127268. /**
  127269. * Rebuilds the particle system
  127270. */
  127271. rebuild(): void;
  127272. private _releaseBuffers;
  127273. private _releaseVAOs;
  127274. /**
  127275. * Disposes the particle system and free the associated resources
  127276. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127277. */
  127278. dispose(disposeTexture?: boolean): void;
  127279. /**
  127280. * Clones the particle system.
  127281. * @param name The name of the cloned object
  127282. * @param newEmitter The new emitter to use
  127283. * @returns the cloned particle system
  127284. */
  127285. clone(name: string, newEmitter: any): GPUParticleSystem;
  127286. /**
  127287. * Serializes the particle system to a JSON object.
  127288. * @returns the JSON object
  127289. */
  127290. serialize(): any;
  127291. /**
  127292. * Parses a JSON object to create a GPU particle system.
  127293. * @param parsedParticleSystem The JSON object to parse
  127294. * @param scene The scene to create the particle system in
  127295. * @param rootUrl The root url to use to load external dependencies like texture
  127296. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127297. * @returns the parsed GPU particle system
  127298. */
  127299. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127300. }
  127301. }
  127302. declare module BABYLON {
  127303. /**
  127304. * Represents a set of particle systems working together to create a specific effect
  127305. */
  127306. export class ParticleSystemSet implements IDisposable {
  127307. /**
  127308. * Gets or sets base Assets URL
  127309. */
  127310. static BaseAssetsUrl: string;
  127311. private _emitterCreationOptions;
  127312. private _emitterNode;
  127313. /**
  127314. * Gets the particle system list
  127315. */
  127316. systems: IParticleSystem[];
  127317. /**
  127318. * Gets the emitter node used with this set
  127319. */
  127320. readonly emitterNode: Nullable<TransformNode>;
  127321. /**
  127322. * Creates a new emitter mesh as a sphere
  127323. * @param options defines the options used to create the sphere
  127324. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127325. * @param scene defines the hosting scene
  127326. */
  127327. setEmitterAsSphere(options: {
  127328. diameter: number;
  127329. segments: number;
  127330. color: Color3;
  127331. }, renderingGroupId: number, scene: Scene): void;
  127332. /**
  127333. * Starts all particle systems of the set
  127334. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127335. */
  127336. start(emitter?: AbstractMesh): void;
  127337. /**
  127338. * Release all associated resources
  127339. */
  127340. dispose(): void;
  127341. /**
  127342. * Serialize the set into a JSON compatible object
  127343. * @returns a JSON compatible representation of the set
  127344. */
  127345. serialize(): any;
  127346. /**
  127347. * Parse a new ParticleSystemSet from a serialized source
  127348. * @param data defines a JSON compatible representation of the set
  127349. * @param scene defines the hosting scene
  127350. * @param gpu defines if we want GPU particles or CPU particles
  127351. * @returns a new ParticleSystemSet
  127352. */
  127353. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127354. }
  127355. }
  127356. declare module BABYLON {
  127357. /**
  127358. * This class is made for on one-liner static method to help creating particle system set.
  127359. */
  127360. export class ParticleHelper {
  127361. /**
  127362. * Gets or sets base Assets URL
  127363. */
  127364. static BaseAssetsUrl: string;
  127365. /**
  127366. * Create a default particle system that you can tweak
  127367. * @param emitter defines the emitter to use
  127368. * @param capacity defines the system capacity (default is 500 particles)
  127369. * @param scene defines the hosting scene
  127370. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127371. * @returns the new Particle system
  127372. */
  127373. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127374. /**
  127375. * This is the main static method (one-liner) of this helper to create different particle systems
  127376. * @param type This string represents the type to the particle system to create
  127377. * @param scene The scene where the particle system should live
  127378. * @param gpu If the system will use gpu
  127379. * @returns the ParticleSystemSet created
  127380. */
  127381. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127382. /**
  127383. * Static function used to export a particle system to a ParticleSystemSet variable.
  127384. * Please note that the emitter shape is not exported
  127385. * @param systems defines the particle systems to export
  127386. * @returns the created particle system set
  127387. */
  127388. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127389. }
  127390. }
  127391. declare module BABYLON {
  127392. interface Engine {
  127393. /**
  127394. * Create an effect to use with particle systems.
  127395. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127396. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127397. * @param uniformsNames defines a list of attribute names
  127398. * @param samplers defines an array of string used to represent textures
  127399. * @param defines defines the string containing the defines to use to compile the shaders
  127400. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127401. * @param onCompiled defines a function to call when the effect creation is successful
  127402. * @param onError defines a function to call when the effect creation has failed
  127403. * @returns the new Effect
  127404. */
  127405. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127406. }
  127407. interface Mesh {
  127408. /**
  127409. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127410. * @returns an array of IParticleSystem
  127411. */
  127412. getEmittedParticleSystems(): IParticleSystem[];
  127413. /**
  127414. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127415. * @returns an array of IParticleSystem
  127416. */
  127417. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127418. }
  127419. /**
  127420. * @hidden
  127421. */
  127422. export var _IDoNeedToBeInTheBuild: number;
  127423. }
  127424. declare module BABYLON {
  127425. /** Defines the 4 color options */
  127426. export enum PointColor {
  127427. /** color value */
  127428. Color = 2,
  127429. /** uv value */
  127430. UV = 1,
  127431. /** random value */
  127432. Random = 0,
  127433. /** stated value */
  127434. Stated = 3
  127435. }
  127436. /**
  127437. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127438. * 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.
  127439. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127440. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127441. *
  127442. * Full documentation here : TO BE ENTERED
  127443. */
  127444. export class PointsCloudSystem implements IDisposable {
  127445. /**
  127446. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127447. * Example : var p = SPS.particles[i];
  127448. */
  127449. particles: CloudPoint[];
  127450. /**
  127451. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127452. */
  127453. nbParticles: number;
  127454. /**
  127455. * This a counter for your own usage. It's not set by any SPS functions.
  127456. */
  127457. counter: number;
  127458. /**
  127459. * The PCS name. This name is also given to the underlying mesh.
  127460. */
  127461. name: string;
  127462. /**
  127463. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127464. */
  127465. mesh: Mesh;
  127466. /**
  127467. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127468. * Please read :
  127469. */
  127470. vars: any;
  127471. /**
  127472. * @hidden
  127473. */
  127474. _size: number;
  127475. private _scene;
  127476. private _promises;
  127477. private _positions;
  127478. private _indices;
  127479. private _normals;
  127480. private _colors;
  127481. private _uvs;
  127482. private _indices32;
  127483. private _positions32;
  127484. private _colors32;
  127485. private _uvs32;
  127486. private _updatable;
  127487. private _isVisibilityBoxLocked;
  127488. private _alwaysVisible;
  127489. private _groups;
  127490. private _groupCounter;
  127491. private _computeParticleColor;
  127492. private _computeParticleTexture;
  127493. private _computeParticleRotation;
  127494. private _computeBoundingBox;
  127495. private _isReady;
  127496. /**
  127497. * Creates a PCS (Points Cloud System) object
  127498. * @param name (String) is the PCS name, this will be the underlying mesh name
  127499. * @param pointSize (number) is the size for each point
  127500. * @param scene (Scene) is the scene in which the PCS is added
  127501. * @param options defines the options of the PCS e.g.
  127502. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127503. */
  127504. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127505. updatable?: boolean;
  127506. });
  127507. /**
  127508. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127509. * If no points were added to the PCS, the returned mesh is just a single point.
  127510. * @returns a promise for the created mesh
  127511. */
  127512. buildMeshAsync(): Promise<Mesh>;
  127513. /**
  127514. * @hidden
  127515. */
  127516. private _buildMesh;
  127517. private _addParticle;
  127518. private _randomUnitVector;
  127519. private _getColorIndicesForCoord;
  127520. private _setPointsColorOrUV;
  127521. private _colorFromTexture;
  127522. private _calculateDensity;
  127523. /**
  127524. * Adds points to the PCS in random positions within a unit sphere
  127525. * @param nb (positive integer) the number of particles to be created from this model
  127526. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127527. * @returns the number of groups in the system
  127528. */
  127529. addPoints(nb: number, pointFunction?: any): number;
  127530. /**
  127531. * Adds points to the PCS from the surface of the model shape
  127532. * @param mesh is any Mesh object that will be used as a surface model for the points
  127533. * @param nb (positive integer) the number of particles to be created from this model
  127534. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127535. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127536. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127537. * @returns the number of groups in the system
  127538. */
  127539. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127540. /**
  127541. * Adds points to the PCS inside the model shape
  127542. * @param mesh is any Mesh object that will be used as a surface model for the points
  127543. * @param nb (positive integer) the number of particles to be created from this model
  127544. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127545. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127546. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127547. * @returns the number of groups in the system
  127548. */
  127549. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127550. /**
  127551. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127552. * This method calls `updateParticle()` for each particle of the SPS.
  127553. * For an animated SPS, it is usually called within the render loop.
  127554. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127555. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127556. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127557. * @returns the PCS.
  127558. */
  127559. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127560. /**
  127561. * Disposes the PCS.
  127562. */
  127563. dispose(): void;
  127564. /**
  127565. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127566. * doc :
  127567. * @returns the PCS.
  127568. */
  127569. refreshVisibleSize(): PointsCloudSystem;
  127570. /**
  127571. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127572. * @param size the size (float) of the visibility box
  127573. * note : this doesn't lock the PCS mesh bounding box.
  127574. * doc :
  127575. */
  127576. setVisibilityBox(size: number): void;
  127577. /**
  127578. * Gets whether the PCS is always visible or not
  127579. * doc :
  127580. */
  127581. /**
  127582. * Sets the PCS as always visible or not
  127583. * doc :
  127584. */
  127585. isAlwaysVisible: boolean;
  127586. /**
  127587. * Tells to `setParticles()` to compute the particle rotations or not
  127588. * Default value : false. The PCS is faster when it's set to false
  127589. * Note : particle rotations are only applied to parent particles
  127590. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127591. */
  127592. computeParticleRotation: boolean;
  127593. /**
  127594. * Tells to `setParticles()` to compute the particle colors or not.
  127595. * Default value : true. The PCS is faster when it's set to false.
  127596. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127597. */
  127598. /**
  127599. * Gets if `setParticles()` computes the particle colors or not.
  127600. * Default value : false. The PCS is faster when it's set to false.
  127601. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127602. */
  127603. computeParticleColor: boolean;
  127604. /**
  127605. * Gets if `setParticles()` computes the particle textures or not.
  127606. * Default value : false. The PCS is faster when it's set to false.
  127607. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127608. */
  127609. computeParticleTexture: boolean;
  127610. /**
  127611. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127612. */
  127613. /**
  127614. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127615. */
  127616. computeBoundingBox: boolean;
  127617. /**
  127618. * This function does nothing. It may be overwritten to set all the particle first values.
  127619. * The PCS doesn't call this function, you may have to call it by your own.
  127620. * doc :
  127621. */
  127622. initParticles(): void;
  127623. /**
  127624. * This function does nothing. It may be overwritten to recycle a particle
  127625. * The PCS doesn't call this function, you can to call it
  127626. * doc :
  127627. * @param particle The particle to recycle
  127628. * @returns the recycled particle
  127629. */
  127630. recycleParticle(particle: CloudPoint): CloudPoint;
  127631. /**
  127632. * Updates a particle : this function should be overwritten by the user.
  127633. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127634. * doc :
  127635. * @example : just set a particle position or velocity and recycle conditions
  127636. * @param particle The particle to update
  127637. * @returns the updated particle
  127638. */
  127639. updateParticle(particle: CloudPoint): CloudPoint;
  127640. /**
  127641. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127642. * This does nothing and may be overwritten by the user.
  127643. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127644. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127645. * @param update the boolean update value actually passed to setParticles()
  127646. */
  127647. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127648. /**
  127649. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127650. * This will be passed three parameters.
  127651. * This does nothing and may be overwritten by the user.
  127652. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127653. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127654. * @param update the boolean update value actually passed to setParticles()
  127655. */
  127656. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127657. }
  127658. }
  127659. declare module BABYLON {
  127660. /**
  127661. * Represents one particle of a points cloud system.
  127662. */
  127663. export class CloudPoint {
  127664. /**
  127665. * particle global index
  127666. */
  127667. idx: number;
  127668. /**
  127669. * The color of the particle
  127670. */
  127671. color: Nullable<Color4>;
  127672. /**
  127673. * The world space position of the particle.
  127674. */
  127675. position: Vector3;
  127676. /**
  127677. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127678. */
  127679. rotation: Vector3;
  127680. /**
  127681. * The world space rotation quaternion of the particle.
  127682. */
  127683. rotationQuaternion: Nullable<Quaternion>;
  127684. /**
  127685. * The uv of the particle.
  127686. */
  127687. uv: Nullable<Vector2>;
  127688. /**
  127689. * The current speed of the particle.
  127690. */
  127691. velocity: Vector3;
  127692. /**
  127693. * The pivot point in the particle local space.
  127694. */
  127695. pivot: Vector3;
  127696. /**
  127697. * Must the particle be translated from its pivot point in its local space ?
  127698. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127699. * Default : false
  127700. */
  127701. translateFromPivot: boolean;
  127702. /**
  127703. * Index of this particle in the global "positions" array (Internal use)
  127704. * @hidden
  127705. */
  127706. _pos: number;
  127707. /**
  127708. * @hidden Index of this particle in the global "indices" array (Internal use)
  127709. */
  127710. _ind: number;
  127711. /**
  127712. * Group this particle belongs to
  127713. */
  127714. _group: PointsGroup;
  127715. /**
  127716. * Group id of this particle
  127717. */
  127718. groupId: number;
  127719. /**
  127720. * Index of the particle in its group id (Internal use)
  127721. */
  127722. idxInGroup: number;
  127723. /**
  127724. * @hidden Particle BoundingInfo object (Internal use)
  127725. */
  127726. _boundingInfo: BoundingInfo;
  127727. /**
  127728. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127729. */
  127730. _pcs: PointsCloudSystem;
  127731. /**
  127732. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127733. */
  127734. _stillInvisible: boolean;
  127735. /**
  127736. * @hidden Last computed particle rotation matrix
  127737. */
  127738. _rotationMatrix: number[];
  127739. /**
  127740. * Parent particle Id, if any.
  127741. * Default null.
  127742. */
  127743. parentId: Nullable<number>;
  127744. /**
  127745. * @hidden Internal global position in the PCS.
  127746. */
  127747. _globalPosition: Vector3;
  127748. /**
  127749. * Creates a Point Cloud object.
  127750. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127751. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127752. * @param group (PointsGroup) is the group the particle belongs to
  127753. * @param groupId (integer) is the group identifier in the PCS.
  127754. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127755. * @param pcs defines the PCS it is associated to
  127756. */
  127757. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127758. /**
  127759. * get point size
  127760. */
  127761. /**
  127762. * Set point size
  127763. */
  127764. size: Vector3;
  127765. /**
  127766. * Legacy support, changed quaternion to rotationQuaternion
  127767. */
  127768. /**
  127769. * Legacy support, changed quaternion to rotationQuaternion
  127770. */
  127771. quaternion: Nullable<Quaternion>;
  127772. /**
  127773. * Returns a boolean. True if the particle intersects a mesh, else false
  127774. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127775. * @param target is the object (point or mesh) what the intersection is computed against
  127776. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127777. * @returns true if it intersects
  127778. */
  127779. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127780. /**
  127781. * get the rotation matrix of the particle
  127782. * @hidden
  127783. */
  127784. getRotationMatrix(m: Matrix): void;
  127785. }
  127786. /**
  127787. * Represents a group of points in a points cloud system
  127788. * * PCS internal tool, don't use it manually.
  127789. */
  127790. export class PointsGroup {
  127791. /**
  127792. * The group id
  127793. * @hidden
  127794. */
  127795. groupID: number;
  127796. /**
  127797. * image data for group (internal use)
  127798. * @hidden
  127799. */
  127800. _groupImageData: Nullable<ArrayBufferView>;
  127801. /**
  127802. * Image Width (internal use)
  127803. * @hidden
  127804. */
  127805. _groupImgWidth: number;
  127806. /**
  127807. * Image Height (internal use)
  127808. * @hidden
  127809. */
  127810. _groupImgHeight: number;
  127811. /**
  127812. * Custom position function (internal use)
  127813. * @hidden
  127814. */
  127815. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127816. /**
  127817. * density per facet for surface points
  127818. * @hidden
  127819. */
  127820. _groupDensity: number[];
  127821. /**
  127822. * Only when points are colored by texture carries pointer to texture list array
  127823. * @hidden
  127824. */
  127825. _textureNb: number;
  127826. /**
  127827. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127828. * PCS internal tool, don't use it manually.
  127829. * @hidden
  127830. */
  127831. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127832. }
  127833. }
  127834. declare module BABYLON {
  127835. interface Scene {
  127836. /** @hidden (Backing field) */
  127837. _physicsEngine: Nullable<IPhysicsEngine>;
  127838. /**
  127839. * Gets the current physics engine
  127840. * @returns a IPhysicsEngine or null if none attached
  127841. */
  127842. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127843. /**
  127844. * Enables physics to the current scene
  127845. * @param gravity defines the scene's gravity for the physics engine
  127846. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127847. * @return a boolean indicating if the physics engine was initialized
  127848. */
  127849. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127850. /**
  127851. * Disables and disposes the physics engine associated with the scene
  127852. */
  127853. disablePhysicsEngine(): void;
  127854. /**
  127855. * Gets a boolean indicating if there is an active physics engine
  127856. * @returns a boolean indicating if there is an active physics engine
  127857. */
  127858. isPhysicsEnabled(): boolean;
  127859. /**
  127860. * Deletes a physics compound impostor
  127861. * @param compound defines the compound to delete
  127862. */
  127863. deleteCompoundImpostor(compound: any): void;
  127864. /**
  127865. * An event triggered when physic simulation is about to be run
  127866. */
  127867. onBeforePhysicsObservable: Observable<Scene>;
  127868. /**
  127869. * An event triggered when physic simulation has been done
  127870. */
  127871. onAfterPhysicsObservable: Observable<Scene>;
  127872. }
  127873. interface AbstractMesh {
  127874. /** @hidden */
  127875. _physicsImpostor: Nullable<PhysicsImpostor>;
  127876. /**
  127877. * Gets or sets impostor used for physic simulation
  127878. * @see http://doc.babylonjs.com/features/physics_engine
  127879. */
  127880. physicsImpostor: Nullable<PhysicsImpostor>;
  127881. /**
  127882. * Gets the current physics impostor
  127883. * @see http://doc.babylonjs.com/features/physics_engine
  127884. * @returns a physics impostor or null
  127885. */
  127886. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127887. /** Apply a physic impulse to the mesh
  127888. * @param force defines the force to apply
  127889. * @param contactPoint defines where to apply the force
  127890. * @returns the current mesh
  127891. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127892. */
  127893. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127894. /**
  127895. * Creates a physic joint between two meshes
  127896. * @param otherMesh defines the other mesh to use
  127897. * @param pivot1 defines the pivot to use on this mesh
  127898. * @param pivot2 defines the pivot to use on the other mesh
  127899. * @param options defines additional options (can be plugin dependent)
  127900. * @returns the current mesh
  127901. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127902. */
  127903. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127904. /** @hidden */
  127905. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127906. }
  127907. /**
  127908. * Defines the physics engine scene component responsible to manage a physics engine
  127909. */
  127910. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127911. /**
  127912. * The component name helpful to identify the component in the list of scene components.
  127913. */
  127914. readonly name: string;
  127915. /**
  127916. * The scene the component belongs to.
  127917. */
  127918. scene: Scene;
  127919. /**
  127920. * Creates a new instance of the component for the given scene
  127921. * @param scene Defines the scene to register the component in
  127922. */
  127923. constructor(scene: Scene);
  127924. /**
  127925. * Registers the component in a given scene
  127926. */
  127927. register(): void;
  127928. /**
  127929. * Rebuilds the elements related to this component in case of
  127930. * context lost for instance.
  127931. */
  127932. rebuild(): void;
  127933. /**
  127934. * Disposes the component and the associated ressources
  127935. */
  127936. dispose(): void;
  127937. }
  127938. }
  127939. declare module BABYLON {
  127940. /**
  127941. * A helper for physics simulations
  127942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127943. */
  127944. export class PhysicsHelper {
  127945. private _scene;
  127946. private _physicsEngine;
  127947. /**
  127948. * Initializes the Physics helper
  127949. * @param scene Babylon.js scene
  127950. */
  127951. constructor(scene: Scene);
  127952. /**
  127953. * Applies a radial explosion impulse
  127954. * @param origin the origin of the explosion
  127955. * @param radiusOrEventOptions the radius or the options of radial explosion
  127956. * @param strength the explosion strength
  127957. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127958. * @returns A physics radial explosion event, or null
  127959. */
  127960. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127961. /**
  127962. * Applies a radial explosion force
  127963. * @param origin the origin of the explosion
  127964. * @param radiusOrEventOptions the radius or the options of radial explosion
  127965. * @param strength the explosion strength
  127966. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127967. * @returns A physics radial explosion event, or null
  127968. */
  127969. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127970. /**
  127971. * Creates a gravitational field
  127972. * @param origin the origin of the explosion
  127973. * @param radiusOrEventOptions the radius or the options of radial explosion
  127974. * @param strength the explosion strength
  127975. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127976. * @returns A physics gravitational field event, or null
  127977. */
  127978. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127979. /**
  127980. * Creates a physics updraft event
  127981. * @param origin the origin of the updraft
  127982. * @param radiusOrEventOptions the radius or the options of the updraft
  127983. * @param strength the strength of the updraft
  127984. * @param height the height of the updraft
  127985. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127986. * @returns A physics updraft event, or null
  127987. */
  127988. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127989. /**
  127990. * Creates a physics vortex event
  127991. * @param origin the of the vortex
  127992. * @param radiusOrEventOptions the radius or the options of the vortex
  127993. * @param strength the strength of the vortex
  127994. * @param height the height of the vortex
  127995. * @returns a Physics vortex event, or null
  127996. * A physics vortex event or null
  127997. */
  127998. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127999. }
  128000. /**
  128001. * Represents a physics radial explosion event
  128002. */
  128003. class PhysicsRadialExplosionEvent {
  128004. private _scene;
  128005. private _options;
  128006. private _sphere;
  128007. private _dataFetched;
  128008. /**
  128009. * Initializes a radial explosioin event
  128010. * @param _scene BabylonJS scene
  128011. * @param _options The options for the vortex event
  128012. */
  128013. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  128014. /**
  128015. * Returns the data related to the radial explosion event (sphere).
  128016. * @returns The radial explosion event data
  128017. */
  128018. getData(): PhysicsRadialExplosionEventData;
  128019. /**
  128020. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  128021. * @param impostor A physics imposter
  128022. * @param origin the origin of the explosion
  128023. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  128024. */
  128025. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  128026. /**
  128027. * Triggers affecterd impostors callbacks
  128028. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  128029. */
  128030. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  128031. /**
  128032. * Disposes the sphere.
  128033. * @param force Specifies if the sphere should be disposed by force
  128034. */
  128035. dispose(force?: boolean): void;
  128036. /*** Helpers ***/
  128037. private _prepareSphere;
  128038. private _intersectsWithSphere;
  128039. }
  128040. /**
  128041. * Represents a gravitational field event
  128042. */
  128043. class PhysicsGravitationalFieldEvent {
  128044. private _physicsHelper;
  128045. private _scene;
  128046. private _origin;
  128047. private _options;
  128048. private _tickCallback;
  128049. private _sphere;
  128050. private _dataFetched;
  128051. /**
  128052. * Initializes the physics gravitational field event
  128053. * @param _physicsHelper A physics helper
  128054. * @param _scene BabylonJS scene
  128055. * @param _origin The origin position of the gravitational field event
  128056. * @param _options The options for the vortex event
  128057. */
  128058. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  128059. /**
  128060. * Returns the data related to the gravitational field event (sphere).
  128061. * @returns A gravitational field event
  128062. */
  128063. getData(): PhysicsGravitationalFieldEventData;
  128064. /**
  128065. * Enables the gravitational field.
  128066. */
  128067. enable(): void;
  128068. /**
  128069. * Disables the gravitational field.
  128070. */
  128071. disable(): void;
  128072. /**
  128073. * Disposes the sphere.
  128074. * @param force The force to dispose from the gravitational field event
  128075. */
  128076. dispose(force?: boolean): void;
  128077. private _tick;
  128078. }
  128079. /**
  128080. * Represents a physics updraft event
  128081. */
  128082. class PhysicsUpdraftEvent {
  128083. private _scene;
  128084. private _origin;
  128085. private _options;
  128086. private _physicsEngine;
  128087. private _originTop;
  128088. private _originDirection;
  128089. private _tickCallback;
  128090. private _cylinder;
  128091. private _cylinderPosition;
  128092. private _dataFetched;
  128093. /**
  128094. * Initializes the physics updraft event
  128095. * @param _scene BabylonJS scene
  128096. * @param _origin The origin position of the updraft
  128097. * @param _options The options for the updraft event
  128098. */
  128099. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  128100. /**
  128101. * Returns the data related to the updraft event (cylinder).
  128102. * @returns A physics updraft event
  128103. */
  128104. getData(): PhysicsUpdraftEventData;
  128105. /**
  128106. * Enables the updraft.
  128107. */
  128108. enable(): void;
  128109. /**
  128110. * Disables the updraft.
  128111. */
  128112. disable(): void;
  128113. /**
  128114. * Disposes the cylinder.
  128115. * @param force Specifies if the updraft should be disposed by force
  128116. */
  128117. dispose(force?: boolean): void;
  128118. private getImpostorHitData;
  128119. private _tick;
  128120. /*** Helpers ***/
  128121. private _prepareCylinder;
  128122. private _intersectsWithCylinder;
  128123. }
  128124. /**
  128125. * Represents a physics vortex event
  128126. */
  128127. class PhysicsVortexEvent {
  128128. private _scene;
  128129. private _origin;
  128130. private _options;
  128131. private _physicsEngine;
  128132. private _originTop;
  128133. private _tickCallback;
  128134. private _cylinder;
  128135. private _cylinderPosition;
  128136. private _dataFetched;
  128137. /**
  128138. * Initializes the physics vortex event
  128139. * @param _scene The BabylonJS scene
  128140. * @param _origin The origin position of the vortex
  128141. * @param _options The options for the vortex event
  128142. */
  128143. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  128144. /**
  128145. * Returns the data related to the vortex event (cylinder).
  128146. * @returns The physics vortex event data
  128147. */
  128148. getData(): PhysicsVortexEventData;
  128149. /**
  128150. * Enables the vortex.
  128151. */
  128152. enable(): void;
  128153. /**
  128154. * Disables the cortex.
  128155. */
  128156. disable(): void;
  128157. /**
  128158. * Disposes the sphere.
  128159. * @param force
  128160. */
  128161. dispose(force?: boolean): void;
  128162. private getImpostorHitData;
  128163. private _tick;
  128164. /*** Helpers ***/
  128165. private _prepareCylinder;
  128166. private _intersectsWithCylinder;
  128167. }
  128168. /**
  128169. * Options fot the radial explosion event
  128170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128171. */
  128172. export class PhysicsRadialExplosionEventOptions {
  128173. /**
  128174. * The radius of the sphere for the radial explosion.
  128175. */
  128176. radius: number;
  128177. /**
  128178. * The strenth of the explosion.
  128179. */
  128180. strength: number;
  128181. /**
  128182. * The strenght of the force in correspondence to the distance of the affected object
  128183. */
  128184. falloff: PhysicsRadialImpulseFalloff;
  128185. /**
  128186. * Sphere options for the radial explosion.
  128187. */
  128188. sphere: {
  128189. segments: number;
  128190. diameter: number;
  128191. };
  128192. /**
  128193. * Sphere options for the radial explosion.
  128194. */
  128195. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128196. }
  128197. /**
  128198. * Options fot the updraft event
  128199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128200. */
  128201. export class PhysicsUpdraftEventOptions {
  128202. /**
  128203. * The radius of the cylinder for the vortex
  128204. */
  128205. radius: number;
  128206. /**
  128207. * The strenth of the updraft.
  128208. */
  128209. strength: number;
  128210. /**
  128211. * The height of the cylinder for the updraft.
  128212. */
  128213. height: number;
  128214. /**
  128215. * The mode for the the updraft.
  128216. */
  128217. updraftMode: PhysicsUpdraftMode;
  128218. }
  128219. /**
  128220. * Options fot the vortex event
  128221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128222. */
  128223. export class PhysicsVortexEventOptions {
  128224. /**
  128225. * The radius of the cylinder for the vortex
  128226. */
  128227. radius: number;
  128228. /**
  128229. * The strenth of the vortex.
  128230. */
  128231. strength: number;
  128232. /**
  128233. * The height of the cylinder for the vortex.
  128234. */
  128235. height: number;
  128236. /**
  128237. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128238. */
  128239. centripetalForceThreshold: number;
  128240. /**
  128241. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128242. */
  128243. centripetalForceMultiplier: number;
  128244. /**
  128245. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128246. */
  128247. centrifugalForceMultiplier: number;
  128248. /**
  128249. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128250. */
  128251. updraftForceMultiplier: number;
  128252. }
  128253. /**
  128254. * The strenght of the force in correspondence to the distance of the affected object
  128255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128256. */
  128257. export enum PhysicsRadialImpulseFalloff {
  128258. /** Defines that impulse is constant in strength across it's whole radius */
  128259. Constant = 0,
  128260. /** Defines that impulse gets weaker if it's further from the origin */
  128261. Linear = 1
  128262. }
  128263. /**
  128264. * The strength of the force in correspondence to the distance of the affected object
  128265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128266. */
  128267. export enum PhysicsUpdraftMode {
  128268. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128269. Center = 0,
  128270. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128271. Perpendicular = 1
  128272. }
  128273. /**
  128274. * Interface for a physics hit data
  128275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128276. */
  128277. export interface PhysicsHitData {
  128278. /**
  128279. * The force applied at the contact point
  128280. */
  128281. force: Vector3;
  128282. /**
  128283. * The contact point
  128284. */
  128285. contactPoint: Vector3;
  128286. /**
  128287. * The distance from the origin to the contact point
  128288. */
  128289. distanceFromOrigin: number;
  128290. }
  128291. /**
  128292. * Interface for radial explosion event data
  128293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128294. */
  128295. export interface PhysicsRadialExplosionEventData {
  128296. /**
  128297. * A sphere used for the radial explosion event
  128298. */
  128299. sphere: Mesh;
  128300. }
  128301. /**
  128302. * Interface for gravitational field event data
  128303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128304. */
  128305. export interface PhysicsGravitationalFieldEventData {
  128306. /**
  128307. * A sphere mesh used for the gravitational field event
  128308. */
  128309. sphere: Mesh;
  128310. }
  128311. /**
  128312. * Interface for updraft event data
  128313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128314. */
  128315. export interface PhysicsUpdraftEventData {
  128316. /**
  128317. * A cylinder used for the updraft event
  128318. */
  128319. cylinder: Mesh;
  128320. }
  128321. /**
  128322. * Interface for vortex event data
  128323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128324. */
  128325. export interface PhysicsVortexEventData {
  128326. /**
  128327. * A cylinder used for the vortex event
  128328. */
  128329. cylinder: Mesh;
  128330. }
  128331. /**
  128332. * Interface for an affected physics impostor
  128333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128334. */
  128335. export interface PhysicsAffectedImpostorWithData {
  128336. /**
  128337. * The impostor affected by the effect
  128338. */
  128339. impostor: PhysicsImpostor;
  128340. /**
  128341. * The data about the hit/horce from the explosion
  128342. */
  128343. hitData: PhysicsHitData;
  128344. }
  128345. }
  128346. declare module BABYLON {
  128347. /** @hidden */
  128348. export var blackAndWhitePixelShader: {
  128349. name: string;
  128350. shader: string;
  128351. };
  128352. }
  128353. declare module BABYLON {
  128354. /**
  128355. * Post process used to render in black and white
  128356. */
  128357. export class BlackAndWhitePostProcess extends PostProcess {
  128358. /**
  128359. * Linear about to convert he result to black and white (default: 1)
  128360. */
  128361. degree: number;
  128362. /**
  128363. * Creates a black and white post process
  128364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128365. * @param name The name of the effect.
  128366. * @param options The required width/height ratio to downsize to before computing the render pass.
  128367. * @param camera The camera to apply the render pass to.
  128368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128369. * @param engine The engine which the post process will be applied. (default: current engine)
  128370. * @param reusable If the post process can be reused on the same frame. (default: false)
  128371. */
  128372. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128373. }
  128374. }
  128375. declare module BABYLON {
  128376. /**
  128377. * This represents a set of one or more post processes in Babylon.
  128378. * A post process can be used to apply a shader to a texture after it is rendered.
  128379. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128380. */
  128381. export class PostProcessRenderEffect {
  128382. private _postProcesses;
  128383. private _getPostProcesses;
  128384. private _singleInstance;
  128385. private _cameras;
  128386. private _indicesForCamera;
  128387. /**
  128388. * Name of the effect
  128389. * @hidden
  128390. */
  128391. _name: string;
  128392. /**
  128393. * Instantiates a post process render effect.
  128394. * A post process can be used to apply a shader to a texture after it is rendered.
  128395. * @param engine The engine the effect is tied to
  128396. * @param name The name of the effect
  128397. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128398. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128399. */
  128400. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128401. /**
  128402. * Checks if all the post processes in the effect are supported.
  128403. */
  128404. readonly isSupported: boolean;
  128405. /**
  128406. * Updates the current state of the effect
  128407. * @hidden
  128408. */
  128409. _update(): void;
  128410. /**
  128411. * Attaches the effect on cameras
  128412. * @param cameras The camera to attach to.
  128413. * @hidden
  128414. */
  128415. _attachCameras(cameras: Camera): void;
  128416. /**
  128417. * Attaches the effect on cameras
  128418. * @param cameras The camera to attach to.
  128419. * @hidden
  128420. */
  128421. _attachCameras(cameras: Camera[]): void;
  128422. /**
  128423. * Detaches the effect on cameras
  128424. * @param cameras The camera to detatch from.
  128425. * @hidden
  128426. */
  128427. _detachCameras(cameras: Camera): void;
  128428. /**
  128429. * Detatches the effect on cameras
  128430. * @param cameras The camera to detatch from.
  128431. * @hidden
  128432. */
  128433. _detachCameras(cameras: Camera[]): void;
  128434. /**
  128435. * Enables the effect on given cameras
  128436. * @param cameras The camera to enable.
  128437. * @hidden
  128438. */
  128439. _enable(cameras: Camera): void;
  128440. /**
  128441. * Enables the effect on given cameras
  128442. * @param cameras The camera to enable.
  128443. * @hidden
  128444. */
  128445. _enable(cameras: Nullable<Camera[]>): void;
  128446. /**
  128447. * Disables the effect on the given cameras
  128448. * @param cameras The camera to disable.
  128449. * @hidden
  128450. */
  128451. _disable(cameras: Camera): void;
  128452. /**
  128453. * Disables the effect on the given cameras
  128454. * @param cameras The camera to disable.
  128455. * @hidden
  128456. */
  128457. _disable(cameras: Nullable<Camera[]>): void;
  128458. /**
  128459. * Gets a list of the post processes contained in the effect.
  128460. * @param camera The camera to get the post processes on.
  128461. * @returns The list of the post processes in the effect.
  128462. */
  128463. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128464. }
  128465. }
  128466. declare module BABYLON {
  128467. /** @hidden */
  128468. export var extractHighlightsPixelShader: {
  128469. name: string;
  128470. shader: string;
  128471. };
  128472. }
  128473. declare module BABYLON {
  128474. /**
  128475. * 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.
  128476. */
  128477. export class ExtractHighlightsPostProcess extends PostProcess {
  128478. /**
  128479. * The luminance threshold, pixels below this value will be set to black.
  128480. */
  128481. threshold: number;
  128482. /** @hidden */
  128483. _exposure: number;
  128484. /**
  128485. * Post process which has the input texture to be used when performing highlight extraction
  128486. * @hidden
  128487. */
  128488. _inputPostProcess: Nullable<PostProcess>;
  128489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128490. }
  128491. }
  128492. declare module BABYLON {
  128493. /** @hidden */
  128494. export var bloomMergePixelShader: {
  128495. name: string;
  128496. shader: string;
  128497. };
  128498. }
  128499. declare module BABYLON {
  128500. /**
  128501. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128502. */
  128503. export class BloomMergePostProcess extends PostProcess {
  128504. /** Weight of the bloom to be added to the original input. */
  128505. weight: number;
  128506. /**
  128507. * Creates a new instance of @see BloomMergePostProcess
  128508. * @param name The name of the effect.
  128509. * @param originalFromInput Post process which's input will be used for the merge.
  128510. * @param blurred Blurred highlights post process which's output will be used.
  128511. * @param weight Weight of the bloom to be added to the original input.
  128512. * @param options The required width/height ratio to downsize to before computing the render pass.
  128513. * @param camera The camera to apply the render pass to.
  128514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128515. * @param engine The engine which the post process will be applied. (default: current engine)
  128516. * @param reusable If the post process can be reused on the same frame. (default: false)
  128517. * @param textureType Type of textures used when performing the post process. (default: 0)
  128518. * @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)
  128519. */
  128520. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128521. /** Weight of the bloom to be added to the original input. */
  128522. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128523. }
  128524. }
  128525. declare module BABYLON {
  128526. /**
  128527. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128528. */
  128529. export class BloomEffect extends PostProcessRenderEffect {
  128530. private bloomScale;
  128531. /**
  128532. * @hidden Internal
  128533. */
  128534. _effects: Array<PostProcess>;
  128535. /**
  128536. * @hidden Internal
  128537. */
  128538. _downscale: ExtractHighlightsPostProcess;
  128539. private _blurX;
  128540. private _blurY;
  128541. private _merge;
  128542. /**
  128543. * The luminance threshold to find bright areas of the image to bloom.
  128544. */
  128545. threshold: number;
  128546. /**
  128547. * The strength of the bloom.
  128548. */
  128549. weight: number;
  128550. /**
  128551. * Specifies the size of the bloom blur kernel, relative to the final output size
  128552. */
  128553. kernel: number;
  128554. /**
  128555. * Creates a new instance of @see BloomEffect
  128556. * @param scene The scene the effect belongs to.
  128557. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128558. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128559. * @param bloomWeight The the strength of bloom.
  128560. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128561. * @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)
  128562. */
  128563. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128564. /**
  128565. * Disposes each of the internal effects for a given camera.
  128566. * @param camera The camera to dispose the effect on.
  128567. */
  128568. disposeEffects(camera: Camera): void;
  128569. /**
  128570. * @hidden Internal
  128571. */
  128572. _updateEffects(): void;
  128573. /**
  128574. * Internal
  128575. * @returns if all the contained post processes are ready.
  128576. * @hidden
  128577. */
  128578. _isReady(): boolean;
  128579. }
  128580. }
  128581. declare module BABYLON {
  128582. /** @hidden */
  128583. export var chromaticAberrationPixelShader: {
  128584. name: string;
  128585. shader: string;
  128586. };
  128587. }
  128588. declare module BABYLON {
  128589. /**
  128590. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128591. */
  128592. export class ChromaticAberrationPostProcess extends PostProcess {
  128593. /**
  128594. * The amount of seperation of rgb channels (default: 30)
  128595. */
  128596. aberrationAmount: number;
  128597. /**
  128598. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128599. */
  128600. radialIntensity: number;
  128601. /**
  128602. * 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))
  128603. */
  128604. direction: Vector2;
  128605. /**
  128606. * 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))
  128607. */
  128608. centerPosition: Vector2;
  128609. /**
  128610. * Creates a new instance ChromaticAberrationPostProcess
  128611. * @param name The name of the effect.
  128612. * @param screenWidth The width of the screen to apply the effect on.
  128613. * @param screenHeight The height of the screen to apply the effect on.
  128614. * @param options The required width/height ratio to downsize to before computing the render pass.
  128615. * @param camera The camera to apply the render pass to.
  128616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128617. * @param engine The engine which the post process will be applied. (default: current engine)
  128618. * @param reusable If the post process can be reused on the same frame. (default: false)
  128619. * @param textureType Type of textures used when performing the post process. (default: 0)
  128620. * @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)
  128621. */
  128622. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /** @hidden */
  128627. export var circleOfConfusionPixelShader: {
  128628. name: string;
  128629. shader: string;
  128630. };
  128631. }
  128632. declare module BABYLON {
  128633. /**
  128634. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128635. */
  128636. export class CircleOfConfusionPostProcess extends PostProcess {
  128637. /**
  128638. * 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.
  128639. */
  128640. lensSize: number;
  128641. /**
  128642. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128643. */
  128644. fStop: number;
  128645. /**
  128646. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128647. */
  128648. focusDistance: number;
  128649. /**
  128650. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128651. */
  128652. focalLength: number;
  128653. private _depthTexture;
  128654. /**
  128655. * Creates a new instance CircleOfConfusionPostProcess
  128656. * @param name The name of the effect.
  128657. * @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.
  128658. * @param options The required width/height ratio to downsize to before computing the render pass.
  128659. * @param camera The camera to apply the render pass to.
  128660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128661. * @param engine The engine which the post process will be applied. (default: current engine)
  128662. * @param reusable If the post process can be reused on the same frame. (default: false)
  128663. * @param textureType Type of textures used when performing the post process. (default: 0)
  128664. * @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)
  128665. */
  128666. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128667. /**
  128668. * 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.
  128669. */
  128670. depthTexture: RenderTargetTexture;
  128671. }
  128672. }
  128673. declare module BABYLON {
  128674. /** @hidden */
  128675. export var colorCorrectionPixelShader: {
  128676. name: string;
  128677. shader: string;
  128678. };
  128679. }
  128680. declare module BABYLON {
  128681. /**
  128682. *
  128683. * This post-process allows the modification of rendered colors by using
  128684. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128685. *
  128686. * The object needs to be provided an url to a texture containing the color
  128687. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128688. * Use an image editing software to tweak the LUT to match your needs.
  128689. *
  128690. * For an example of a color LUT, see here:
  128691. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128692. * For explanations on color grading, see here:
  128693. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128694. *
  128695. */
  128696. export class ColorCorrectionPostProcess extends PostProcess {
  128697. private _colorTableTexture;
  128698. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128699. }
  128700. }
  128701. declare module BABYLON {
  128702. /** @hidden */
  128703. export var convolutionPixelShader: {
  128704. name: string;
  128705. shader: string;
  128706. };
  128707. }
  128708. declare module BABYLON {
  128709. /**
  128710. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128711. * input texture to perform effects such as edge detection or sharpening
  128712. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128713. */
  128714. export class ConvolutionPostProcess extends PostProcess {
  128715. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128716. kernel: number[];
  128717. /**
  128718. * Creates a new instance ConvolutionPostProcess
  128719. * @param name The name of the effect.
  128720. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128721. * @param options The required width/height ratio to downsize to before computing the render pass.
  128722. * @param camera The camera to apply the render pass to.
  128723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128724. * @param engine The engine which the post process will be applied. (default: current engine)
  128725. * @param reusable If the post process can be reused on the same frame. (default: false)
  128726. * @param textureType Type of textures used when performing the post process. (default: 0)
  128727. */
  128728. constructor(name: string,
  128729. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128730. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128731. /**
  128732. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128733. */
  128734. static EdgeDetect0Kernel: number[];
  128735. /**
  128736. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128737. */
  128738. static EdgeDetect1Kernel: number[];
  128739. /**
  128740. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128741. */
  128742. static EdgeDetect2Kernel: number[];
  128743. /**
  128744. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128745. */
  128746. static SharpenKernel: number[];
  128747. /**
  128748. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128749. */
  128750. static EmbossKernel: number[];
  128751. /**
  128752. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128753. */
  128754. static GaussianKernel: number[];
  128755. }
  128756. }
  128757. declare module BABYLON {
  128758. /**
  128759. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128760. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128761. * based on samples that have a large difference in distance than the center pixel.
  128762. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128763. */
  128764. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128765. direction: Vector2;
  128766. /**
  128767. * Creates a new instance CircleOfConfusionPostProcess
  128768. * @param name The name of the effect.
  128769. * @param scene The scene the effect belongs to.
  128770. * @param direction The direction the blur should be applied.
  128771. * @param kernel The size of the kernel used to blur.
  128772. * @param options The required width/height ratio to downsize to before computing the render pass.
  128773. * @param camera The camera to apply the render pass to.
  128774. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128775. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128777. * @param engine The engine which the post process will be applied. (default: current engine)
  128778. * @param reusable If the post process can be reused on the same frame. (default: false)
  128779. * @param textureType Type of textures used when performing the post process. (default: 0)
  128780. * @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)
  128781. */
  128782. 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);
  128783. }
  128784. }
  128785. declare module BABYLON {
  128786. /** @hidden */
  128787. export var depthOfFieldMergePixelShader: {
  128788. name: string;
  128789. shader: string;
  128790. };
  128791. }
  128792. declare module BABYLON {
  128793. /**
  128794. * Options to be set when merging outputs from the default pipeline.
  128795. */
  128796. export class DepthOfFieldMergePostProcessOptions {
  128797. /**
  128798. * The original image to merge on top of
  128799. */
  128800. originalFromInput: PostProcess;
  128801. /**
  128802. * Parameters to perform the merge of the depth of field effect
  128803. */
  128804. depthOfField?: {
  128805. circleOfConfusion: PostProcess;
  128806. blurSteps: Array<PostProcess>;
  128807. };
  128808. /**
  128809. * Parameters to perform the merge of bloom effect
  128810. */
  128811. bloom?: {
  128812. blurred: PostProcess;
  128813. weight: number;
  128814. };
  128815. }
  128816. /**
  128817. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128818. */
  128819. export class DepthOfFieldMergePostProcess extends PostProcess {
  128820. private blurSteps;
  128821. /**
  128822. * Creates a new instance of DepthOfFieldMergePostProcess
  128823. * @param name The name of the effect.
  128824. * @param originalFromInput Post process which's input will be used for the merge.
  128825. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128826. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128827. * @param options The required width/height ratio to downsize to before computing the render pass.
  128828. * @param camera The camera to apply the render pass to.
  128829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128830. * @param engine The engine which the post process will be applied. (default: current engine)
  128831. * @param reusable If the post process can be reused on the same frame. (default: false)
  128832. * @param textureType Type of textures used when performing the post process. (default: 0)
  128833. * @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)
  128834. */
  128835. 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);
  128836. /**
  128837. * Updates the effect with the current post process compile time values and recompiles the shader.
  128838. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128839. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128840. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128841. * @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
  128842. * @param onCompiled Called when the shader has been compiled.
  128843. * @param onError Called if there is an error when compiling a shader.
  128844. */
  128845. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128846. }
  128847. }
  128848. declare module BABYLON {
  128849. /**
  128850. * Specifies the level of max blur that should be applied when using the depth of field effect
  128851. */
  128852. export enum DepthOfFieldEffectBlurLevel {
  128853. /**
  128854. * Subtle blur
  128855. */
  128856. Low = 0,
  128857. /**
  128858. * Medium blur
  128859. */
  128860. Medium = 1,
  128861. /**
  128862. * Large blur
  128863. */
  128864. High = 2
  128865. }
  128866. /**
  128867. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128868. */
  128869. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128870. private _circleOfConfusion;
  128871. /**
  128872. * @hidden Internal, blurs from high to low
  128873. */
  128874. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128875. private _depthOfFieldBlurY;
  128876. private _dofMerge;
  128877. /**
  128878. * @hidden Internal post processes in depth of field effect
  128879. */
  128880. _effects: Array<PostProcess>;
  128881. /**
  128882. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128883. */
  128884. focalLength: number;
  128885. /**
  128886. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128887. */
  128888. fStop: number;
  128889. /**
  128890. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128891. */
  128892. focusDistance: number;
  128893. /**
  128894. * 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.
  128895. */
  128896. lensSize: number;
  128897. /**
  128898. * Creates a new instance DepthOfFieldEffect
  128899. * @param scene The scene the effect belongs to.
  128900. * @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.
  128901. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128902. * @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)
  128903. */
  128904. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128905. /**
  128906. * Get the current class name of the current effet
  128907. * @returns "DepthOfFieldEffect"
  128908. */
  128909. getClassName(): string;
  128910. /**
  128911. * 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.
  128912. */
  128913. depthTexture: RenderTargetTexture;
  128914. /**
  128915. * Disposes each of the internal effects for a given camera.
  128916. * @param camera The camera to dispose the effect on.
  128917. */
  128918. disposeEffects(camera: Camera): void;
  128919. /**
  128920. * @hidden Internal
  128921. */
  128922. _updateEffects(): void;
  128923. /**
  128924. * Internal
  128925. * @returns if all the contained post processes are ready.
  128926. * @hidden
  128927. */
  128928. _isReady(): boolean;
  128929. }
  128930. }
  128931. declare module BABYLON {
  128932. /** @hidden */
  128933. export var displayPassPixelShader: {
  128934. name: string;
  128935. shader: string;
  128936. };
  128937. }
  128938. declare module BABYLON {
  128939. /**
  128940. * DisplayPassPostProcess which produces an output the same as it's input
  128941. */
  128942. export class DisplayPassPostProcess extends PostProcess {
  128943. /**
  128944. * Creates the DisplayPassPostProcess
  128945. * @param name The name of the effect.
  128946. * @param options The required width/height ratio to downsize to before computing the render pass.
  128947. * @param camera The camera to apply the render pass to.
  128948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128949. * @param engine The engine which the post process will be applied. (default: current engine)
  128950. * @param reusable If the post process can be reused on the same frame. (default: false)
  128951. */
  128952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128953. }
  128954. }
  128955. declare module BABYLON {
  128956. /** @hidden */
  128957. export var filterPixelShader: {
  128958. name: string;
  128959. shader: string;
  128960. };
  128961. }
  128962. declare module BABYLON {
  128963. /**
  128964. * Applies a kernel filter to the image
  128965. */
  128966. export class FilterPostProcess extends PostProcess {
  128967. /** The matrix to be applied to the image */
  128968. kernelMatrix: Matrix;
  128969. /**
  128970. *
  128971. * @param name The name of the effect.
  128972. * @param kernelMatrix The matrix to be applied to the image
  128973. * @param options The required width/height ratio to downsize to before computing the render pass.
  128974. * @param camera The camera to apply the render pass to.
  128975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128976. * @param engine The engine which the post process will be applied. (default: current engine)
  128977. * @param reusable If the post process can be reused on the same frame. (default: false)
  128978. */
  128979. constructor(name: string,
  128980. /** The matrix to be applied to the image */
  128981. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128982. }
  128983. }
  128984. declare module BABYLON {
  128985. /** @hidden */
  128986. export var fxaaPixelShader: {
  128987. name: string;
  128988. shader: string;
  128989. };
  128990. }
  128991. declare module BABYLON {
  128992. /** @hidden */
  128993. export var fxaaVertexShader: {
  128994. name: string;
  128995. shader: string;
  128996. };
  128997. }
  128998. declare module BABYLON {
  128999. /**
  129000. * Fxaa post process
  129001. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  129002. */
  129003. export class FxaaPostProcess extends PostProcess {
  129004. /** @hidden */
  129005. texelWidth: number;
  129006. /** @hidden */
  129007. texelHeight: number;
  129008. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129009. private _getDefines;
  129010. }
  129011. }
  129012. declare module BABYLON {
  129013. /** @hidden */
  129014. export var grainPixelShader: {
  129015. name: string;
  129016. shader: string;
  129017. };
  129018. }
  129019. declare module BABYLON {
  129020. /**
  129021. * The GrainPostProcess adds noise to the image at mid luminance levels
  129022. */
  129023. export class GrainPostProcess extends PostProcess {
  129024. /**
  129025. * The intensity of the grain added (default: 30)
  129026. */
  129027. intensity: number;
  129028. /**
  129029. * If the grain should be randomized on every frame
  129030. */
  129031. animated: boolean;
  129032. /**
  129033. * Creates a new instance of @see GrainPostProcess
  129034. * @param name The name of the effect.
  129035. * @param options The required width/height ratio to downsize to before computing the render pass.
  129036. * @param camera The camera to apply the render pass to.
  129037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129038. * @param engine The engine which the post process will be applied. (default: current engine)
  129039. * @param reusable If the post process can be reused on the same frame. (default: false)
  129040. * @param textureType Type of textures used when performing the post process. (default: 0)
  129041. * @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)
  129042. */
  129043. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129044. }
  129045. }
  129046. declare module BABYLON {
  129047. /** @hidden */
  129048. export var highlightsPixelShader: {
  129049. name: string;
  129050. shader: string;
  129051. };
  129052. }
  129053. declare module BABYLON {
  129054. /**
  129055. * Extracts highlights from the image
  129056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129057. */
  129058. export class HighlightsPostProcess extends PostProcess {
  129059. /**
  129060. * Extracts highlights from the image
  129061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129062. * @param name The name of the effect.
  129063. * @param options The required width/height ratio to downsize to before computing the render pass.
  129064. * @param camera The camera to apply the render pass to.
  129065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129066. * @param engine The engine which the post process will be applied. (default: current engine)
  129067. * @param reusable If the post process can be reused on the same frame. (default: false)
  129068. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  129069. */
  129070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129071. }
  129072. }
  129073. declare module BABYLON {
  129074. /** @hidden */
  129075. export var mrtFragmentDeclaration: {
  129076. name: string;
  129077. shader: string;
  129078. };
  129079. }
  129080. declare module BABYLON {
  129081. /** @hidden */
  129082. export var geometryPixelShader: {
  129083. name: string;
  129084. shader: string;
  129085. };
  129086. }
  129087. declare module BABYLON {
  129088. /** @hidden */
  129089. export var geometryVertexShader: {
  129090. name: string;
  129091. shader: string;
  129092. };
  129093. }
  129094. declare module BABYLON {
  129095. /** @hidden */
  129096. interface ISavedTransformationMatrix {
  129097. world: Matrix;
  129098. viewProjection: Matrix;
  129099. }
  129100. /**
  129101. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129102. */
  129103. export class GeometryBufferRenderer {
  129104. /**
  129105. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129106. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129107. */
  129108. static readonly POSITION_TEXTURE_TYPE: number;
  129109. /**
  129110. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129111. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129112. */
  129113. static readonly VELOCITY_TEXTURE_TYPE: number;
  129114. /**
  129115. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129116. * in order to compute objects velocities when enableVelocity is set to "true"
  129117. * @hidden
  129118. */
  129119. _previousTransformationMatrices: {
  129120. [index: number]: ISavedTransformationMatrix;
  129121. };
  129122. /**
  129123. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129124. * in order to compute objects velocities when enableVelocity is set to "true"
  129125. * @hidden
  129126. */
  129127. _previousBonesTransformationMatrices: {
  129128. [index: number]: Float32Array;
  129129. };
  129130. /**
  129131. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129132. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129133. */
  129134. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  129135. private _scene;
  129136. private _multiRenderTarget;
  129137. private _ratio;
  129138. private _enablePosition;
  129139. private _enableVelocity;
  129140. private _positionIndex;
  129141. private _velocityIndex;
  129142. protected _effect: Effect;
  129143. protected _cachedDefines: string;
  129144. /**
  129145. * Set the render list (meshes to be rendered) used in the G buffer.
  129146. */
  129147. renderList: Mesh[];
  129148. /**
  129149. * Gets wether or not G buffer are supported by the running hardware.
  129150. * This requires draw buffer supports
  129151. */
  129152. readonly isSupported: boolean;
  129153. /**
  129154. * Returns the index of the given texture type in the G-Buffer textures array
  129155. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129156. * @returns the index of the given texture type in the G-Buffer textures array
  129157. */
  129158. getTextureIndex(textureType: number): number;
  129159. /**
  129160. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129161. */
  129162. /**
  129163. * Sets whether or not objects positions are enabled for the G buffer.
  129164. */
  129165. enablePosition: boolean;
  129166. /**
  129167. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129168. */
  129169. /**
  129170. * Sets wether or not objects velocities are enabled for the G buffer.
  129171. */
  129172. enableVelocity: boolean;
  129173. /**
  129174. * Gets the scene associated with the buffer.
  129175. */
  129176. readonly scene: Scene;
  129177. /**
  129178. * Gets the ratio used by the buffer during its creation.
  129179. * How big is the buffer related to the main canvas.
  129180. */
  129181. readonly ratio: number;
  129182. /** @hidden */
  129183. static _SceneComponentInitialization: (scene: Scene) => void;
  129184. /**
  129185. * Creates a new G Buffer for the scene
  129186. * @param scene The scene the buffer belongs to
  129187. * @param ratio How big is the buffer related to the main canvas.
  129188. */
  129189. constructor(scene: Scene, ratio?: number);
  129190. /**
  129191. * Checks wether everything is ready to render a submesh to the G buffer.
  129192. * @param subMesh the submesh to check readiness for
  129193. * @param useInstances is the mesh drawn using instance or not
  129194. * @returns true if ready otherwise false
  129195. */
  129196. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129197. /**
  129198. * Gets the current underlying G Buffer.
  129199. * @returns the buffer
  129200. */
  129201. getGBuffer(): MultiRenderTarget;
  129202. /**
  129203. * Gets the number of samples used to render the buffer (anti aliasing).
  129204. */
  129205. /**
  129206. * Sets the number of samples used to render the buffer (anti aliasing).
  129207. */
  129208. samples: number;
  129209. /**
  129210. * Disposes the renderer and frees up associated resources.
  129211. */
  129212. dispose(): void;
  129213. protected _createRenderTargets(): void;
  129214. private _copyBonesTransformationMatrices;
  129215. }
  129216. }
  129217. declare module BABYLON {
  129218. interface Scene {
  129219. /** @hidden (Backing field) */
  129220. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129221. /**
  129222. * Gets or Sets the current geometry buffer associated to the scene.
  129223. */
  129224. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129225. /**
  129226. * Enables a GeometryBufferRender and associates it with the scene
  129227. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129228. * @returns the GeometryBufferRenderer
  129229. */
  129230. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129231. /**
  129232. * Disables the GeometryBufferRender associated with the scene
  129233. */
  129234. disableGeometryBufferRenderer(): void;
  129235. }
  129236. /**
  129237. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129238. * in several rendering techniques.
  129239. */
  129240. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129241. /**
  129242. * The component name helpful to identify the component in the list of scene components.
  129243. */
  129244. readonly name: string;
  129245. /**
  129246. * The scene the component belongs to.
  129247. */
  129248. scene: Scene;
  129249. /**
  129250. * Creates a new instance of the component for the given scene
  129251. * @param scene Defines the scene to register the component in
  129252. */
  129253. constructor(scene: Scene);
  129254. /**
  129255. * Registers the component in a given scene
  129256. */
  129257. register(): void;
  129258. /**
  129259. * Rebuilds the elements related to this component in case of
  129260. * context lost for instance.
  129261. */
  129262. rebuild(): void;
  129263. /**
  129264. * Disposes the component and the associated ressources
  129265. */
  129266. dispose(): void;
  129267. private _gatherRenderTargets;
  129268. }
  129269. }
  129270. declare module BABYLON {
  129271. /** @hidden */
  129272. export var motionBlurPixelShader: {
  129273. name: string;
  129274. shader: string;
  129275. };
  129276. }
  129277. declare module BABYLON {
  129278. /**
  129279. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129280. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129281. * As an example, all you have to do is to create the post-process:
  129282. * var mb = new BABYLON.MotionBlurPostProcess(
  129283. * 'mb', // The name of the effect.
  129284. * scene, // The scene containing the objects to blur according to their velocity.
  129285. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129286. * camera // The camera to apply the render pass to.
  129287. * );
  129288. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129289. */
  129290. export class MotionBlurPostProcess extends PostProcess {
  129291. /**
  129292. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129293. */
  129294. motionStrength: number;
  129295. /**
  129296. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129297. */
  129298. /**
  129299. * Sets the number of iterations to be used for motion blur quality
  129300. */
  129301. motionBlurSamples: number;
  129302. private _motionBlurSamples;
  129303. private _geometryBufferRenderer;
  129304. /**
  129305. * Creates a new instance MotionBlurPostProcess
  129306. * @param name The name of the effect.
  129307. * @param scene The scene containing the objects to blur according to their velocity.
  129308. * @param options The required width/height ratio to downsize to before computing the render pass.
  129309. * @param camera The camera to apply the render pass to.
  129310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129311. * @param engine The engine which the post process will be applied. (default: current engine)
  129312. * @param reusable If the post process can be reused on the same frame. (default: false)
  129313. * @param textureType Type of textures used when performing the post process. (default: 0)
  129314. * @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)
  129315. */
  129316. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129317. /**
  129318. * Excludes the given skinned mesh from computing bones velocities.
  129319. * 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.
  129320. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129321. */
  129322. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129323. /**
  129324. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129325. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129326. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129327. */
  129328. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129329. /**
  129330. * Disposes the post process.
  129331. * @param camera The camera to dispose the post process on.
  129332. */
  129333. dispose(camera?: Camera): void;
  129334. }
  129335. }
  129336. declare module BABYLON {
  129337. /** @hidden */
  129338. export var refractionPixelShader: {
  129339. name: string;
  129340. shader: string;
  129341. };
  129342. }
  129343. declare module BABYLON {
  129344. /**
  129345. * Post process which applies a refractin texture
  129346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129347. */
  129348. export class RefractionPostProcess extends PostProcess {
  129349. /** the base color of the refraction (used to taint the rendering) */
  129350. color: Color3;
  129351. /** simulated refraction depth */
  129352. depth: number;
  129353. /** the coefficient of the base color (0 to remove base color tainting) */
  129354. colorLevel: number;
  129355. private _refTexture;
  129356. private _ownRefractionTexture;
  129357. /**
  129358. * Gets or sets the refraction texture
  129359. * Please note that you are responsible for disposing the texture if you set it manually
  129360. */
  129361. refractionTexture: Texture;
  129362. /**
  129363. * Initializes the RefractionPostProcess
  129364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129365. * @param name The name of the effect.
  129366. * @param refractionTextureUrl Url of the refraction texture to use
  129367. * @param color the base color of the refraction (used to taint the rendering)
  129368. * @param depth simulated refraction depth
  129369. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129370. * @param camera The camera to apply the render pass to.
  129371. * @param options The required width/height ratio to downsize to before computing the render pass.
  129372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129373. * @param engine The engine which the post process will be applied. (default: current engine)
  129374. * @param reusable If the post process can be reused on the same frame. (default: false)
  129375. */
  129376. constructor(name: string, refractionTextureUrl: string,
  129377. /** the base color of the refraction (used to taint the rendering) */
  129378. color: Color3,
  129379. /** simulated refraction depth */
  129380. depth: number,
  129381. /** the coefficient of the base color (0 to remove base color tainting) */
  129382. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129383. /**
  129384. * Disposes of the post process
  129385. * @param camera Camera to dispose post process on
  129386. */
  129387. dispose(camera: Camera): void;
  129388. }
  129389. }
  129390. declare module BABYLON {
  129391. /** @hidden */
  129392. export var sharpenPixelShader: {
  129393. name: string;
  129394. shader: string;
  129395. };
  129396. }
  129397. declare module BABYLON {
  129398. /**
  129399. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129400. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129401. */
  129402. export class SharpenPostProcess extends PostProcess {
  129403. /**
  129404. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129405. */
  129406. colorAmount: number;
  129407. /**
  129408. * How much sharpness should be applied (default: 0.3)
  129409. */
  129410. edgeAmount: number;
  129411. /**
  129412. * Creates a new instance ConvolutionPostProcess
  129413. * @param name The name of the effect.
  129414. * @param options The required width/height ratio to downsize to before computing the render pass.
  129415. * @param camera The camera to apply the render pass to.
  129416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129417. * @param engine The engine which the post process will be applied. (default: current engine)
  129418. * @param reusable If the post process can be reused on the same frame. (default: false)
  129419. * @param textureType Type of textures used when performing the post process. (default: 0)
  129420. * @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)
  129421. */
  129422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129423. }
  129424. }
  129425. declare module BABYLON {
  129426. /**
  129427. * PostProcessRenderPipeline
  129428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129429. */
  129430. export class PostProcessRenderPipeline {
  129431. private engine;
  129432. private _renderEffects;
  129433. private _renderEffectsForIsolatedPass;
  129434. /**
  129435. * List of inspectable custom properties (used by the Inspector)
  129436. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129437. */
  129438. inspectableCustomProperties: IInspectable[];
  129439. /**
  129440. * @hidden
  129441. */
  129442. protected _cameras: Camera[];
  129443. /** @hidden */
  129444. _name: string;
  129445. /**
  129446. * Gets pipeline name
  129447. */
  129448. readonly name: string;
  129449. /** Gets the list of attached cameras */
  129450. readonly cameras: Camera[];
  129451. /**
  129452. * Initializes a PostProcessRenderPipeline
  129453. * @param engine engine to add the pipeline to
  129454. * @param name name of the pipeline
  129455. */
  129456. constructor(engine: Engine, name: string);
  129457. /**
  129458. * Gets the class name
  129459. * @returns "PostProcessRenderPipeline"
  129460. */
  129461. getClassName(): string;
  129462. /**
  129463. * If all the render effects in the pipeline are supported
  129464. */
  129465. readonly isSupported: boolean;
  129466. /**
  129467. * Adds an effect to the pipeline
  129468. * @param renderEffect the effect to add
  129469. */
  129470. addEffect(renderEffect: PostProcessRenderEffect): void;
  129471. /** @hidden */
  129472. _rebuild(): void;
  129473. /** @hidden */
  129474. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129475. /** @hidden */
  129476. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129477. /** @hidden */
  129478. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129479. /** @hidden */
  129480. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129481. /** @hidden */
  129482. _attachCameras(cameras: Camera, unique: boolean): void;
  129483. /** @hidden */
  129484. _attachCameras(cameras: Camera[], unique: boolean): void;
  129485. /** @hidden */
  129486. _detachCameras(cameras: Camera): void;
  129487. /** @hidden */
  129488. _detachCameras(cameras: Nullable<Camera[]>): void;
  129489. /** @hidden */
  129490. _update(): void;
  129491. /** @hidden */
  129492. _reset(): void;
  129493. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129494. /**
  129495. * Disposes of the pipeline
  129496. */
  129497. dispose(): void;
  129498. }
  129499. }
  129500. declare module BABYLON {
  129501. /**
  129502. * PostProcessRenderPipelineManager class
  129503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129504. */
  129505. export class PostProcessRenderPipelineManager {
  129506. private _renderPipelines;
  129507. /**
  129508. * Initializes a PostProcessRenderPipelineManager
  129509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129510. */
  129511. constructor();
  129512. /**
  129513. * Gets the list of supported render pipelines
  129514. */
  129515. readonly supportedPipelines: PostProcessRenderPipeline[];
  129516. /**
  129517. * Adds a pipeline to the manager
  129518. * @param renderPipeline The pipeline to add
  129519. */
  129520. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129521. /**
  129522. * Attaches a camera to the pipeline
  129523. * @param renderPipelineName The name of the pipeline to attach to
  129524. * @param cameras the camera to attach
  129525. * @param unique if the camera can be attached multiple times to the pipeline
  129526. */
  129527. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129528. /**
  129529. * Detaches a camera from the pipeline
  129530. * @param renderPipelineName The name of the pipeline to detach from
  129531. * @param cameras the camera to detach
  129532. */
  129533. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129534. /**
  129535. * Enables an effect by name on a pipeline
  129536. * @param renderPipelineName the name of the pipeline to enable the effect in
  129537. * @param renderEffectName the name of the effect to enable
  129538. * @param cameras the cameras that the effect should be enabled on
  129539. */
  129540. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129541. /**
  129542. * Disables an effect by name on a pipeline
  129543. * @param renderPipelineName the name of the pipeline to disable the effect in
  129544. * @param renderEffectName the name of the effect to disable
  129545. * @param cameras the cameras that the effect should be disabled on
  129546. */
  129547. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129548. /**
  129549. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129550. */
  129551. update(): void;
  129552. /** @hidden */
  129553. _rebuild(): void;
  129554. /**
  129555. * Disposes of the manager and pipelines
  129556. */
  129557. dispose(): void;
  129558. }
  129559. }
  129560. declare module BABYLON {
  129561. interface Scene {
  129562. /** @hidden (Backing field) */
  129563. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129564. /**
  129565. * Gets the postprocess render pipeline manager
  129566. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129567. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129568. */
  129569. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129570. }
  129571. /**
  129572. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129573. */
  129574. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129575. /**
  129576. * The component name helpfull to identify the component in the list of scene components.
  129577. */
  129578. readonly name: string;
  129579. /**
  129580. * The scene the component belongs to.
  129581. */
  129582. scene: Scene;
  129583. /**
  129584. * Creates a new instance of the component for the given scene
  129585. * @param scene Defines the scene to register the component in
  129586. */
  129587. constructor(scene: Scene);
  129588. /**
  129589. * Registers the component in a given scene
  129590. */
  129591. register(): void;
  129592. /**
  129593. * Rebuilds the elements related to this component in case of
  129594. * context lost for instance.
  129595. */
  129596. rebuild(): void;
  129597. /**
  129598. * Disposes the component and the associated ressources
  129599. */
  129600. dispose(): void;
  129601. private _gatherRenderTargets;
  129602. }
  129603. }
  129604. declare module BABYLON {
  129605. /**
  129606. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129607. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129608. */
  129609. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129610. private _scene;
  129611. private _camerasToBeAttached;
  129612. /**
  129613. * ID of the sharpen post process,
  129614. */
  129615. private readonly SharpenPostProcessId;
  129616. /**
  129617. * @ignore
  129618. * ID of the image processing post process;
  129619. */
  129620. readonly ImageProcessingPostProcessId: string;
  129621. /**
  129622. * @ignore
  129623. * ID of the Fast Approximate Anti-Aliasing post process;
  129624. */
  129625. readonly FxaaPostProcessId: string;
  129626. /**
  129627. * ID of the chromatic aberration post process,
  129628. */
  129629. private readonly ChromaticAberrationPostProcessId;
  129630. /**
  129631. * ID of the grain post process
  129632. */
  129633. private readonly GrainPostProcessId;
  129634. /**
  129635. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129636. */
  129637. sharpen: SharpenPostProcess;
  129638. private _sharpenEffect;
  129639. private bloom;
  129640. /**
  129641. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129642. */
  129643. depthOfField: DepthOfFieldEffect;
  129644. /**
  129645. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129646. */
  129647. fxaa: FxaaPostProcess;
  129648. /**
  129649. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129650. */
  129651. imageProcessing: ImageProcessingPostProcess;
  129652. /**
  129653. * Chromatic aberration post process which will shift rgb colors in the image
  129654. */
  129655. chromaticAberration: ChromaticAberrationPostProcess;
  129656. private _chromaticAberrationEffect;
  129657. /**
  129658. * Grain post process which add noise to the image
  129659. */
  129660. grain: GrainPostProcess;
  129661. private _grainEffect;
  129662. /**
  129663. * Glow post process which adds a glow to emissive areas of the image
  129664. */
  129665. private _glowLayer;
  129666. /**
  129667. * Animations which can be used to tweak settings over a period of time
  129668. */
  129669. animations: Animation[];
  129670. private _imageProcessingConfigurationObserver;
  129671. private _sharpenEnabled;
  129672. private _bloomEnabled;
  129673. private _depthOfFieldEnabled;
  129674. private _depthOfFieldBlurLevel;
  129675. private _fxaaEnabled;
  129676. private _imageProcessingEnabled;
  129677. private _defaultPipelineTextureType;
  129678. private _bloomScale;
  129679. private _chromaticAberrationEnabled;
  129680. private _grainEnabled;
  129681. private _buildAllowed;
  129682. /**
  129683. * Gets active scene
  129684. */
  129685. readonly scene: Scene;
  129686. /**
  129687. * Enable or disable the sharpen process from the pipeline
  129688. */
  129689. sharpenEnabled: boolean;
  129690. private _resizeObserver;
  129691. private _hardwareScaleLevel;
  129692. private _bloomKernel;
  129693. /**
  129694. * Specifies the size of the bloom blur kernel, relative to the final output size
  129695. */
  129696. bloomKernel: number;
  129697. /**
  129698. * Specifies the weight of the bloom in the final rendering
  129699. */
  129700. private _bloomWeight;
  129701. /**
  129702. * Specifies the luma threshold for the area that will be blurred by the bloom
  129703. */
  129704. private _bloomThreshold;
  129705. private _hdr;
  129706. /**
  129707. * The strength of the bloom.
  129708. */
  129709. bloomWeight: number;
  129710. /**
  129711. * The strength of the bloom.
  129712. */
  129713. bloomThreshold: number;
  129714. /**
  129715. * The scale of the bloom, lower value will provide better performance.
  129716. */
  129717. bloomScale: number;
  129718. /**
  129719. * Enable or disable the bloom from the pipeline
  129720. */
  129721. bloomEnabled: boolean;
  129722. private _rebuildBloom;
  129723. /**
  129724. * If the depth of field is enabled.
  129725. */
  129726. depthOfFieldEnabled: boolean;
  129727. /**
  129728. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129729. */
  129730. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129731. /**
  129732. * If the anti aliasing is enabled.
  129733. */
  129734. fxaaEnabled: boolean;
  129735. private _samples;
  129736. /**
  129737. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129738. */
  129739. samples: number;
  129740. /**
  129741. * If image processing is enabled.
  129742. */
  129743. imageProcessingEnabled: boolean;
  129744. /**
  129745. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129746. */
  129747. glowLayerEnabled: boolean;
  129748. /**
  129749. * Gets the glow layer (or null if not defined)
  129750. */
  129751. readonly glowLayer: Nullable<GlowLayer>;
  129752. /**
  129753. * Enable or disable the chromaticAberration process from the pipeline
  129754. */
  129755. chromaticAberrationEnabled: boolean;
  129756. /**
  129757. * Enable or disable the grain process from the pipeline
  129758. */
  129759. grainEnabled: boolean;
  129760. /**
  129761. * @constructor
  129762. * @param name - The rendering pipeline name (default: "")
  129763. * @param hdr - If high dynamic range textures should be used (default: true)
  129764. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129765. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129766. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129767. */
  129768. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129769. /**
  129770. * Get the class name
  129771. * @returns "DefaultRenderingPipeline"
  129772. */
  129773. getClassName(): string;
  129774. /**
  129775. * Force the compilation of the entire pipeline.
  129776. */
  129777. prepare(): void;
  129778. private _hasCleared;
  129779. private _prevPostProcess;
  129780. private _prevPrevPostProcess;
  129781. private _setAutoClearAndTextureSharing;
  129782. private _depthOfFieldSceneObserver;
  129783. private _buildPipeline;
  129784. private _disposePostProcesses;
  129785. /**
  129786. * Adds a camera to the pipeline
  129787. * @param camera the camera to be added
  129788. */
  129789. addCamera(camera: Camera): void;
  129790. /**
  129791. * Removes a camera from the pipeline
  129792. * @param camera the camera to remove
  129793. */
  129794. removeCamera(camera: Camera): void;
  129795. /**
  129796. * Dispose of the pipeline and stop all post processes
  129797. */
  129798. dispose(): void;
  129799. /**
  129800. * Serialize the rendering pipeline (Used when exporting)
  129801. * @returns the serialized object
  129802. */
  129803. serialize(): any;
  129804. /**
  129805. * Parse the serialized pipeline
  129806. * @param source Source pipeline.
  129807. * @param scene The scene to load the pipeline to.
  129808. * @param rootUrl The URL of the serialized pipeline.
  129809. * @returns An instantiated pipeline from the serialized object.
  129810. */
  129811. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /** @hidden */
  129816. export var lensHighlightsPixelShader: {
  129817. name: string;
  129818. shader: string;
  129819. };
  129820. }
  129821. declare module BABYLON {
  129822. /** @hidden */
  129823. export var depthOfFieldPixelShader: {
  129824. name: string;
  129825. shader: string;
  129826. };
  129827. }
  129828. declare module BABYLON {
  129829. /**
  129830. * BABYLON.JS Chromatic Aberration GLSL Shader
  129831. * Author: Olivier Guyot
  129832. * Separates very slightly R, G and B colors on the edges of the screen
  129833. * Inspired by Francois Tarlier & Martins Upitis
  129834. */
  129835. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129836. /**
  129837. * @ignore
  129838. * The chromatic aberration PostProcess id in the pipeline
  129839. */
  129840. LensChromaticAberrationEffect: string;
  129841. /**
  129842. * @ignore
  129843. * The highlights enhancing PostProcess id in the pipeline
  129844. */
  129845. HighlightsEnhancingEffect: string;
  129846. /**
  129847. * @ignore
  129848. * The depth-of-field PostProcess id in the pipeline
  129849. */
  129850. LensDepthOfFieldEffect: string;
  129851. private _scene;
  129852. private _depthTexture;
  129853. private _grainTexture;
  129854. private _chromaticAberrationPostProcess;
  129855. private _highlightsPostProcess;
  129856. private _depthOfFieldPostProcess;
  129857. private _edgeBlur;
  129858. private _grainAmount;
  129859. private _chromaticAberration;
  129860. private _distortion;
  129861. private _highlightsGain;
  129862. private _highlightsThreshold;
  129863. private _dofDistance;
  129864. private _dofAperture;
  129865. private _dofDarken;
  129866. private _dofPentagon;
  129867. private _blurNoise;
  129868. /**
  129869. * @constructor
  129870. *
  129871. * Effect parameters are as follow:
  129872. * {
  129873. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129874. * edge_blur: number; // from 0 to x (1 for realism)
  129875. * distortion: number; // from 0 to x (1 for realism)
  129876. * grain_amount: number; // from 0 to 1
  129877. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129878. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129879. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129880. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129881. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129882. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129883. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129884. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129885. * }
  129886. * Note: if an effect parameter is unset, effect is disabled
  129887. *
  129888. * @param name The rendering pipeline name
  129889. * @param parameters - An object containing all parameters (see above)
  129890. * @param scene The scene linked to this pipeline
  129891. * @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)
  129892. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129893. */
  129894. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129895. /**
  129896. * Get the class name
  129897. * @returns "LensRenderingPipeline"
  129898. */
  129899. getClassName(): string;
  129900. /**
  129901. * Gets associated scene
  129902. */
  129903. readonly scene: Scene;
  129904. /**
  129905. * Gets or sets the edge blur
  129906. */
  129907. edgeBlur: number;
  129908. /**
  129909. * Gets or sets the grain amount
  129910. */
  129911. grainAmount: number;
  129912. /**
  129913. * Gets or sets the chromatic aberration amount
  129914. */
  129915. chromaticAberration: number;
  129916. /**
  129917. * Gets or sets the depth of field aperture
  129918. */
  129919. dofAperture: number;
  129920. /**
  129921. * Gets or sets the edge distortion
  129922. */
  129923. edgeDistortion: number;
  129924. /**
  129925. * Gets or sets the depth of field distortion
  129926. */
  129927. dofDistortion: number;
  129928. /**
  129929. * Gets or sets the darken out of focus amount
  129930. */
  129931. darkenOutOfFocus: number;
  129932. /**
  129933. * Gets or sets a boolean indicating if blur noise is enabled
  129934. */
  129935. blurNoise: boolean;
  129936. /**
  129937. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129938. */
  129939. pentagonBokeh: boolean;
  129940. /**
  129941. * Gets or sets the highlight grain amount
  129942. */
  129943. highlightsGain: number;
  129944. /**
  129945. * Gets or sets the highlight threshold
  129946. */
  129947. highlightsThreshold: number;
  129948. /**
  129949. * Sets the amount of blur at the edges
  129950. * @param amount blur amount
  129951. */
  129952. setEdgeBlur(amount: number): void;
  129953. /**
  129954. * Sets edge blur to 0
  129955. */
  129956. disableEdgeBlur(): void;
  129957. /**
  129958. * Sets the amout of grain
  129959. * @param amount Amount of grain
  129960. */
  129961. setGrainAmount(amount: number): void;
  129962. /**
  129963. * Set grain amount to 0
  129964. */
  129965. disableGrain(): void;
  129966. /**
  129967. * Sets the chromatic aberration amount
  129968. * @param amount amount of chromatic aberration
  129969. */
  129970. setChromaticAberration(amount: number): void;
  129971. /**
  129972. * Sets chromatic aberration amount to 0
  129973. */
  129974. disableChromaticAberration(): void;
  129975. /**
  129976. * Sets the EdgeDistortion amount
  129977. * @param amount amount of EdgeDistortion
  129978. */
  129979. setEdgeDistortion(amount: number): void;
  129980. /**
  129981. * Sets edge distortion to 0
  129982. */
  129983. disableEdgeDistortion(): void;
  129984. /**
  129985. * Sets the FocusDistance amount
  129986. * @param amount amount of FocusDistance
  129987. */
  129988. setFocusDistance(amount: number): void;
  129989. /**
  129990. * Disables depth of field
  129991. */
  129992. disableDepthOfField(): void;
  129993. /**
  129994. * Sets the Aperture amount
  129995. * @param amount amount of Aperture
  129996. */
  129997. setAperture(amount: number): void;
  129998. /**
  129999. * Sets the DarkenOutOfFocus amount
  130000. * @param amount amount of DarkenOutOfFocus
  130001. */
  130002. setDarkenOutOfFocus(amount: number): void;
  130003. private _pentagonBokehIsEnabled;
  130004. /**
  130005. * Creates a pentagon bokeh effect
  130006. */
  130007. enablePentagonBokeh(): void;
  130008. /**
  130009. * Disables the pentagon bokeh effect
  130010. */
  130011. disablePentagonBokeh(): void;
  130012. /**
  130013. * Enables noise blur
  130014. */
  130015. enableNoiseBlur(): void;
  130016. /**
  130017. * Disables noise blur
  130018. */
  130019. disableNoiseBlur(): void;
  130020. /**
  130021. * Sets the HighlightsGain amount
  130022. * @param amount amount of HighlightsGain
  130023. */
  130024. setHighlightsGain(amount: number): void;
  130025. /**
  130026. * Sets the HighlightsThreshold amount
  130027. * @param amount amount of HighlightsThreshold
  130028. */
  130029. setHighlightsThreshold(amount: number): void;
  130030. /**
  130031. * Disables highlights
  130032. */
  130033. disableHighlights(): void;
  130034. /**
  130035. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  130036. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  130037. */
  130038. dispose(disableDepthRender?: boolean): void;
  130039. private _createChromaticAberrationPostProcess;
  130040. private _createHighlightsPostProcess;
  130041. private _createDepthOfFieldPostProcess;
  130042. private _createGrainTexture;
  130043. }
  130044. }
  130045. declare module BABYLON {
  130046. /** @hidden */
  130047. export var ssao2PixelShader: {
  130048. name: string;
  130049. shader: string;
  130050. };
  130051. }
  130052. declare module BABYLON {
  130053. /** @hidden */
  130054. export var ssaoCombinePixelShader: {
  130055. name: string;
  130056. shader: string;
  130057. };
  130058. }
  130059. declare module BABYLON {
  130060. /**
  130061. * Render pipeline to produce ssao effect
  130062. */
  130063. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  130064. /**
  130065. * @ignore
  130066. * The PassPostProcess id in the pipeline that contains the original scene color
  130067. */
  130068. SSAOOriginalSceneColorEffect: string;
  130069. /**
  130070. * @ignore
  130071. * The SSAO PostProcess id in the pipeline
  130072. */
  130073. SSAORenderEffect: string;
  130074. /**
  130075. * @ignore
  130076. * The horizontal blur PostProcess id in the pipeline
  130077. */
  130078. SSAOBlurHRenderEffect: string;
  130079. /**
  130080. * @ignore
  130081. * The vertical blur PostProcess id in the pipeline
  130082. */
  130083. SSAOBlurVRenderEffect: string;
  130084. /**
  130085. * @ignore
  130086. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130087. */
  130088. SSAOCombineRenderEffect: string;
  130089. /**
  130090. * The output strength of the SSAO post-process. Default value is 1.0.
  130091. */
  130092. totalStrength: number;
  130093. /**
  130094. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  130095. */
  130096. maxZ: number;
  130097. /**
  130098. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  130099. */
  130100. minZAspect: number;
  130101. private _samples;
  130102. /**
  130103. * Number of samples used for the SSAO calculations. Default value is 8
  130104. */
  130105. samples: number;
  130106. private _textureSamples;
  130107. /**
  130108. * Number of samples to use for antialiasing
  130109. */
  130110. textureSamples: number;
  130111. /**
  130112. * Ratio object used for SSAO ratio and blur ratio
  130113. */
  130114. private _ratio;
  130115. /**
  130116. * Dynamically generated sphere sampler.
  130117. */
  130118. private _sampleSphere;
  130119. /**
  130120. * Blur filter offsets
  130121. */
  130122. private _samplerOffsets;
  130123. private _expensiveBlur;
  130124. /**
  130125. * If bilateral blur should be used
  130126. */
  130127. expensiveBlur: boolean;
  130128. /**
  130129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  130130. */
  130131. radius: number;
  130132. /**
  130133. * The base color of the SSAO post-process
  130134. * The final result is "base + ssao" between [0, 1]
  130135. */
  130136. base: number;
  130137. /**
  130138. * Support test.
  130139. */
  130140. static readonly IsSupported: boolean;
  130141. private _scene;
  130142. private _depthTexture;
  130143. private _normalTexture;
  130144. private _randomTexture;
  130145. private _originalColorPostProcess;
  130146. private _ssaoPostProcess;
  130147. private _blurHPostProcess;
  130148. private _blurVPostProcess;
  130149. private _ssaoCombinePostProcess;
  130150. /**
  130151. * Gets active scene
  130152. */
  130153. readonly scene: Scene;
  130154. /**
  130155. * @constructor
  130156. * @param name The rendering pipeline name
  130157. * @param scene The scene linked to this pipeline
  130158. * @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 }
  130159. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130160. */
  130161. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130162. /**
  130163. * Get the class name
  130164. * @returns "SSAO2RenderingPipeline"
  130165. */
  130166. getClassName(): string;
  130167. /**
  130168. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130169. */
  130170. dispose(disableGeometryBufferRenderer?: boolean): void;
  130171. private _createBlurPostProcess;
  130172. /** @hidden */
  130173. _rebuild(): void;
  130174. private _bits;
  130175. private _radicalInverse_VdC;
  130176. private _hammersley;
  130177. private _hemisphereSample_uniform;
  130178. private _generateHemisphere;
  130179. private _createSSAOPostProcess;
  130180. private _createSSAOCombinePostProcess;
  130181. private _createRandomTexture;
  130182. /**
  130183. * Serialize the rendering pipeline (Used when exporting)
  130184. * @returns the serialized object
  130185. */
  130186. serialize(): any;
  130187. /**
  130188. * Parse the serialized pipeline
  130189. * @param source Source pipeline.
  130190. * @param scene The scene to load the pipeline to.
  130191. * @param rootUrl The URL of the serialized pipeline.
  130192. * @returns An instantiated pipeline from the serialized object.
  130193. */
  130194. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130195. }
  130196. }
  130197. declare module BABYLON {
  130198. /** @hidden */
  130199. export var ssaoPixelShader: {
  130200. name: string;
  130201. shader: string;
  130202. };
  130203. }
  130204. declare module BABYLON {
  130205. /**
  130206. * Render pipeline to produce ssao effect
  130207. */
  130208. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130209. /**
  130210. * @ignore
  130211. * The PassPostProcess id in the pipeline that contains the original scene color
  130212. */
  130213. SSAOOriginalSceneColorEffect: string;
  130214. /**
  130215. * @ignore
  130216. * The SSAO PostProcess id in the pipeline
  130217. */
  130218. SSAORenderEffect: string;
  130219. /**
  130220. * @ignore
  130221. * The horizontal blur PostProcess id in the pipeline
  130222. */
  130223. SSAOBlurHRenderEffect: string;
  130224. /**
  130225. * @ignore
  130226. * The vertical blur PostProcess id in the pipeline
  130227. */
  130228. SSAOBlurVRenderEffect: string;
  130229. /**
  130230. * @ignore
  130231. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130232. */
  130233. SSAOCombineRenderEffect: string;
  130234. /**
  130235. * The output strength of the SSAO post-process. Default value is 1.0.
  130236. */
  130237. totalStrength: number;
  130238. /**
  130239. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130240. */
  130241. radius: number;
  130242. /**
  130243. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130244. * Must not be equal to fallOff and superior to fallOff.
  130245. * Default value is 0.0075
  130246. */
  130247. area: number;
  130248. /**
  130249. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130250. * Must not be equal to area and inferior to area.
  130251. * Default value is 0.000001
  130252. */
  130253. fallOff: number;
  130254. /**
  130255. * The base color of the SSAO post-process
  130256. * The final result is "base + ssao" between [0, 1]
  130257. */
  130258. base: number;
  130259. private _scene;
  130260. private _depthTexture;
  130261. private _randomTexture;
  130262. private _originalColorPostProcess;
  130263. private _ssaoPostProcess;
  130264. private _blurHPostProcess;
  130265. private _blurVPostProcess;
  130266. private _ssaoCombinePostProcess;
  130267. private _firstUpdate;
  130268. /**
  130269. * Gets active scene
  130270. */
  130271. readonly scene: Scene;
  130272. /**
  130273. * @constructor
  130274. * @param name - The rendering pipeline name
  130275. * @param scene - The scene linked to this pipeline
  130276. * @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 }
  130277. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130278. */
  130279. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130280. /**
  130281. * Get the class name
  130282. * @returns "SSAORenderingPipeline"
  130283. */
  130284. getClassName(): string;
  130285. /**
  130286. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130287. */
  130288. dispose(disableDepthRender?: boolean): void;
  130289. private _createBlurPostProcess;
  130290. /** @hidden */
  130291. _rebuild(): void;
  130292. private _createSSAOPostProcess;
  130293. private _createSSAOCombinePostProcess;
  130294. private _createRandomTexture;
  130295. }
  130296. }
  130297. declare module BABYLON {
  130298. /** @hidden */
  130299. export var standardPixelShader: {
  130300. name: string;
  130301. shader: string;
  130302. };
  130303. }
  130304. declare module BABYLON {
  130305. /**
  130306. * Standard rendering pipeline
  130307. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130308. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130309. */
  130310. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130311. /**
  130312. * Public members
  130313. */
  130314. /**
  130315. * Post-process which contains the original scene color before the pipeline applies all the effects
  130316. */
  130317. originalPostProcess: Nullable<PostProcess>;
  130318. /**
  130319. * Post-process used to down scale an image x4
  130320. */
  130321. downSampleX4PostProcess: Nullable<PostProcess>;
  130322. /**
  130323. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130324. */
  130325. brightPassPostProcess: Nullable<PostProcess>;
  130326. /**
  130327. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130328. */
  130329. blurHPostProcesses: PostProcess[];
  130330. /**
  130331. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130332. */
  130333. blurVPostProcesses: PostProcess[];
  130334. /**
  130335. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130336. */
  130337. textureAdderPostProcess: Nullable<PostProcess>;
  130338. /**
  130339. * Post-process used to create volumetric lighting effect
  130340. */
  130341. volumetricLightPostProcess: Nullable<PostProcess>;
  130342. /**
  130343. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130344. */
  130345. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130346. /**
  130347. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130348. */
  130349. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130350. /**
  130351. * Post-process used to merge the volumetric light effect and the real scene color
  130352. */
  130353. volumetricLightMergePostProces: Nullable<PostProcess>;
  130354. /**
  130355. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130356. */
  130357. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130358. /**
  130359. * Base post-process used to calculate the average luminance of the final image for HDR
  130360. */
  130361. luminancePostProcess: Nullable<PostProcess>;
  130362. /**
  130363. * Post-processes used to create down sample post-processes in order to get
  130364. * the average luminance of the final image for HDR
  130365. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130366. */
  130367. luminanceDownSamplePostProcesses: PostProcess[];
  130368. /**
  130369. * Post-process used to create a HDR effect (light adaptation)
  130370. */
  130371. hdrPostProcess: Nullable<PostProcess>;
  130372. /**
  130373. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130374. */
  130375. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130376. /**
  130377. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130378. */
  130379. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130380. /**
  130381. * Post-process used to merge the final HDR post-process and the real scene color
  130382. */
  130383. hdrFinalPostProcess: Nullable<PostProcess>;
  130384. /**
  130385. * Post-process used to create a lens flare effect
  130386. */
  130387. lensFlarePostProcess: Nullable<PostProcess>;
  130388. /**
  130389. * Post-process that merges the result of the lens flare post-process and the real scene color
  130390. */
  130391. lensFlareComposePostProcess: Nullable<PostProcess>;
  130392. /**
  130393. * Post-process used to create a motion blur effect
  130394. */
  130395. motionBlurPostProcess: Nullable<PostProcess>;
  130396. /**
  130397. * Post-process used to create a depth of field effect
  130398. */
  130399. depthOfFieldPostProcess: Nullable<PostProcess>;
  130400. /**
  130401. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130402. */
  130403. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130404. /**
  130405. * Represents the brightness threshold in order to configure the illuminated surfaces
  130406. */
  130407. brightThreshold: number;
  130408. /**
  130409. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130410. */
  130411. blurWidth: number;
  130412. /**
  130413. * Sets if the blur for highlighted surfaces must be only horizontal
  130414. */
  130415. horizontalBlur: boolean;
  130416. /**
  130417. * Gets the overall exposure used by the pipeline
  130418. */
  130419. /**
  130420. * Sets the overall exposure used by the pipeline
  130421. */
  130422. exposure: number;
  130423. /**
  130424. * Texture used typically to simulate "dirty" on camera lens
  130425. */
  130426. lensTexture: Nullable<Texture>;
  130427. /**
  130428. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130429. */
  130430. volumetricLightCoefficient: number;
  130431. /**
  130432. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130433. */
  130434. volumetricLightPower: number;
  130435. /**
  130436. * Used the set the blur intensity to smooth the volumetric lights
  130437. */
  130438. volumetricLightBlurScale: number;
  130439. /**
  130440. * Light (spot or directional) used to generate the volumetric lights rays
  130441. * The source light must have a shadow generate so the pipeline can get its
  130442. * depth map
  130443. */
  130444. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130445. /**
  130446. * For eye adaptation, represents the minimum luminance the eye can see
  130447. */
  130448. hdrMinimumLuminance: number;
  130449. /**
  130450. * For eye adaptation, represents the decrease luminance speed
  130451. */
  130452. hdrDecreaseRate: number;
  130453. /**
  130454. * For eye adaptation, represents the increase luminance speed
  130455. */
  130456. hdrIncreaseRate: number;
  130457. /**
  130458. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130459. */
  130460. /**
  130461. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130462. */
  130463. hdrAutoExposure: boolean;
  130464. /**
  130465. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130466. */
  130467. lensColorTexture: Nullable<Texture>;
  130468. /**
  130469. * The overall strengh for the lens flare effect
  130470. */
  130471. lensFlareStrength: number;
  130472. /**
  130473. * Dispersion coefficient for lens flare ghosts
  130474. */
  130475. lensFlareGhostDispersal: number;
  130476. /**
  130477. * Main lens flare halo width
  130478. */
  130479. lensFlareHaloWidth: number;
  130480. /**
  130481. * Based on the lens distortion effect, defines how much the lens flare result
  130482. * is distorted
  130483. */
  130484. lensFlareDistortionStrength: number;
  130485. /**
  130486. * Configures the blur intensity used for for lens flare (halo)
  130487. */
  130488. lensFlareBlurWidth: number;
  130489. /**
  130490. * Lens star texture must be used to simulate rays on the flares and is available
  130491. * in the documentation
  130492. */
  130493. lensStarTexture: Nullable<Texture>;
  130494. /**
  130495. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130496. * flare effect by taking account of the dirt texture
  130497. */
  130498. lensFlareDirtTexture: Nullable<Texture>;
  130499. /**
  130500. * Represents the focal length for the depth of field effect
  130501. */
  130502. depthOfFieldDistance: number;
  130503. /**
  130504. * Represents the blur intensity for the blurred part of the depth of field effect
  130505. */
  130506. depthOfFieldBlurWidth: number;
  130507. /**
  130508. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130509. */
  130510. /**
  130511. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130512. */
  130513. motionStrength: number;
  130514. /**
  130515. * Gets wether or not the motion blur post-process is object based or screen based.
  130516. */
  130517. /**
  130518. * Sets wether or not the motion blur post-process should be object based or screen based
  130519. */
  130520. objectBasedMotionBlur: boolean;
  130521. /**
  130522. * List of animations for the pipeline (IAnimatable implementation)
  130523. */
  130524. animations: Animation[];
  130525. /**
  130526. * Private members
  130527. */
  130528. private _scene;
  130529. private _currentDepthOfFieldSource;
  130530. private _basePostProcess;
  130531. private _fixedExposure;
  130532. private _currentExposure;
  130533. private _hdrAutoExposure;
  130534. private _hdrCurrentLuminance;
  130535. private _motionStrength;
  130536. private _isObjectBasedMotionBlur;
  130537. private _floatTextureType;
  130538. private _camerasToBeAttached;
  130539. private _ratio;
  130540. private _bloomEnabled;
  130541. private _depthOfFieldEnabled;
  130542. private _vlsEnabled;
  130543. private _lensFlareEnabled;
  130544. private _hdrEnabled;
  130545. private _motionBlurEnabled;
  130546. private _fxaaEnabled;
  130547. private _motionBlurSamples;
  130548. private _volumetricLightStepsCount;
  130549. private _samples;
  130550. /**
  130551. * @ignore
  130552. * Specifies if the bloom pipeline is enabled
  130553. */
  130554. BloomEnabled: boolean;
  130555. /**
  130556. * @ignore
  130557. * Specifies if the depth of field pipeline is enabed
  130558. */
  130559. DepthOfFieldEnabled: boolean;
  130560. /**
  130561. * @ignore
  130562. * Specifies if the lens flare pipeline is enabed
  130563. */
  130564. LensFlareEnabled: boolean;
  130565. /**
  130566. * @ignore
  130567. * Specifies if the HDR pipeline is enabled
  130568. */
  130569. HDREnabled: boolean;
  130570. /**
  130571. * @ignore
  130572. * Specifies if the volumetric lights scattering effect is enabled
  130573. */
  130574. VLSEnabled: boolean;
  130575. /**
  130576. * @ignore
  130577. * Specifies if the motion blur effect is enabled
  130578. */
  130579. MotionBlurEnabled: boolean;
  130580. /**
  130581. * Specifies if anti-aliasing is enabled
  130582. */
  130583. fxaaEnabled: boolean;
  130584. /**
  130585. * Specifies the number of steps used to calculate the volumetric lights
  130586. * Typically in interval [50, 200]
  130587. */
  130588. volumetricLightStepsCount: number;
  130589. /**
  130590. * Specifies the number of samples used for the motion blur effect
  130591. * Typically in interval [16, 64]
  130592. */
  130593. motionBlurSamples: number;
  130594. /**
  130595. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130596. */
  130597. samples: number;
  130598. /**
  130599. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130600. * @constructor
  130601. * @param name The rendering pipeline name
  130602. * @param scene The scene linked to this pipeline
  130603. * @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)
  130604. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130605. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130606. */
  130607. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130608. private _buildPipeline;
  130609. private _createDownSampleX4PostProcess;
  130610. private _createBrightPassPostProcess;
  130611. private _createBlurPostProcesses;
  130612. private _createTextureAdderPostProcess;
  130613. private _createVolumetricLightPostProcess;
  130614. private _createLuminancePostProcesses;
  130615. private _createHdrPostProcess;
  130616. private _createLensFlarePostProcess;
  130617. private _createDepthOfFieldPostProcess;
  130618. private _createMotionBlurPostProcess;
  130619. private _getDepthTexture;
  130620. private _disposePostProcesses;
  130621. /**
  130622. * Dispose of the pipeline and stop all post processes
  130623. */
  130624. dispose(): void;
  130625. /**
  130626. * Serialize the rendering pipeline (Used when exporting)
  130627. * @returns the serialized object
  130628. */
  130629. serialize(): any;
  130630. /**
  130631. * Parse the serialized pipeline
  130632. * @param source Source pipeline.
  130633. * @param scene The scene to load the pipeline to.
  130634. * @param rootUrl The URL of the serialized pipeline.
  130635. * @returns An instantiated pipeline from the serialized object.
  130636. */
  130637. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130638. /**
  130639. * Luminance steps
  130640. */
  130641. static LuminanceSteps: number;
  130642. }
  130643. }
  130644. declare module BABYLON {
  130645. /** @hidden */
  130646. export var tonemapPixelShader: {
  130647. name: string;
  130648. shader: string;
  130649. };
  130650. }
  130651. declare module BABYLON {
  130652. /** Defines operator used for tonemapping */
  130653. export enum TonemappingOperator {
  130654. /** Hable */
  130655. Hable = 0,
  130656. /** Reinhard */
  130657. Reinhard = 1,
  130658. /** HejiDawson */
  130659. HejiDawson = 2,
  130660. /** Photographic */
  130661. Photographic = 3
  130662. }
  130663. /**
  130664. * Defines a post process to apply tone mapping
  130665. */
  130666. export class TonemapPostProcess extends PostProcess {
  130667. private _operator;
  130668. /** Defines the required exposure adjustement */
  130669. exposureAdjustment: number;
  130670. /**
  130671. * Creates a new TonemapPostProcess
  130672. * @param name defines the name of the postprocess
  130673. * @param _operator defines the operator to use
  130674. * @param exposureAdjustment defines the required exposure adjustement
  130675. * @param camera defines the camera to use (can be null)
  130676. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130677. * @param engine defines the hosting engine (can be ignore if camera is set)
  130678. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130679. */
  130680. constructor(name: string, _operator: TonemappingOperator,
  130681. /** Defines the required exposure adjustement */
  130682. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130683. }
  130684. }
  130685. declare module BABYLON {
  130686. /** @hidden */
  130687. export var depthVertexShader: {
  130688. name: string;
  130689. shader: string;
  130690. };
  130691. }
  130692. declare module BABYLON {
  130693. /** @hidden */
  130694. export var volumetricLightScatteringPixelShader: {
  130695. name: string;
  130696. shader: string;
  130697. };
  130698. }
  130699. declare module BABYLON {
  130700. /** @hidden */
  130701. export var volumetricLightScatteringPassVertexShader: {
  130702. name: string;
  130703. shader: string;
  130704. };
  130705. }
  130706. declare module BABYLON {
  130707. /** @hidden */
  130708. export var volumetricLightScatteringPassPixelShader: {
  130709. name: string;
  130710. shader: string;
  130711. };
  130712. }
  130713. declare module BABYLON {
  130714. /**
  130715. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130716. */
  130717. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130718. private _volumetricLightScatteringPass;
  130719. private _volumetricLightScatteringRTT;
  130720. private _viewPort;
  130721. private _screenCoordinates;
  130722. private _cachedDefines;
  130723. /**
  130724. * If not undefined, the mesh position is computed from the attached node position
  130725. */
  130726. attachedNode: {
  130727. position: Vector3;
  130728. };
  130729. /**
  130730. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130731. */
  130732. customMeshPosition: Vector3;
  130733. /**
  130734. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130735. */
  130736. useCustomMeshPosition: boolean;
  130737. /**
  130738. * If the post-process should inverse the light scattering direction
  130739. */
  130740. invert: boolean;
  130741. /**
  130742. * The internal mesh used by the post-process
  130743. */
  130744. mesh: Mesh;
  130745. /**
  130746. * @hidden
  130747. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130748. */
  130749. useDiffuseColor: boolean;
  130750. /**
  130751. * Array containing the excluded meshes not rendered in the internal pass
  130752. */
  130753. excludedMeshes: AbstractMesh[];
  130754. /**
  130755. * Controls the overall intensity of the post-process
  130756. */
  130757. exposure: number;
  130758. /**
  130759. * Dissipates each sample's contribution in range [0, 1]
  130760. */
  130761. decay: number;
  130762. /**
  130763. * Controls the overall intensity of each sample
  130764. */
  130765. weight: number;
  130766. /**
  130767. * Controls the density of each sample
  130768. */
  130769. density: number;
  130770. /**
  130771. * @constructor
  130772. * @param name The post-process name
  130773. * @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)
  130774. * @param camera The camera that the post-process will be attached to
  130775. * @param mesh The mesh used to create the light scattering
  130776. * @param samples The post-process quality, default 100
  130777. * @param samplingModeThe post-process filtering mode
  130778. * @param engine The babylon engine
  130779. * @param reusable If the post-process is reusable
  130780. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130781. */
  130782. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130783. /**
  130784. * Returns the string "VolumetricLightScatteringPostProcess"
  130785. * @returns "VolumetricLightScatteringPostProcess"
  130786. */
  130787. getClassName(): string;
  130788. private _isReady;
  130789. /**
  130790. * Sets the new light position for light scattering effect
  130791. * @param position The new custom light position
  130792. */
  130793. setCustomMeshPosition(position: Vector3): void;
  130794. /**
  130795. * Returns the light position for light scattering effect
  130796. * @return Vector3 The custom light position
  130797. */
  130798. getCustomMeshPosition(): Vector3;
  130799. /**
  130800. * Disposes the internal assets and detaches the post-process from the camera
  130801. */
  130802. dispose(camera: Camera): void;
  130803. /**
  130804. * Returns the render target texture used by the post-process
  130805. * @return the render target texture used by the post-process
  130806. */
  130807. getPass(): RenderTargetTexture;
  130808. private _meshExcluded;
  130809. private _createPass;
  130810. private _updateMeshScreenCoordinates;
  130811. /**
  130812. * Creates a default mesh for the Volumeric Light Scattering post-process
  130813. * @param name The mesh name
  130814. * @param scene The scene where to create the mesh
  130815. * @return the default mesh
  130816. */
  130817. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130818. }
  130819. }
  130820. declare module BABYLON {
  130821. interface Scene {
  130822. /** @hidden (Backing field) */
  130823. _boundingBoxRenderer: BoundingBoxRenderer;
  130824. /** @hidden (Backing field) */
  130825. _forceShowBoundingBoxes: boolean;
  130826. /**
  130827. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130828. */
  130829. forceShowBoundingBoxes: boolean;
  130830. /**
  130831. * Gets the bounding box renderer associated with the scene
  130832. * @returns a BoundingBoxRenderer
  130833. */
  130834. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130835. }
  130836. interface AbstractMesh {
  130837. /** @hidden (Backing field) */
  130838. _showBoundingBox: boolean;
  130839. /**
  130840. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130841. */
  130842. showBoundingBox: boolean;
  130843. }
  130844. /**
  130845. * Component responsible of rendering the bounding box of the meshes in a scene.
  130846. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130847. */
  130848. export class BoundingBoxRenderer implements ISceneComponent {
  130849. /**
  130850. * The component name helpfull to identify the component in the list of scene components.
  130851. */
  130852. readonly name: string;
  130853. /**
  130854. * The scene the component belongs to.
  130855. */
  130856. scene: Scene;
  130857. /**
  130858. * Color of the bounding box lines placed in front of an object
  130859. */
  130860. frontColor: Color3;
  130861. /**
  130862. * Color of the bounding box lines placed behind an object
  130863. */
  130864. backColor: Color3;
  130865. /**
  130866. * Defines if the renderer should show the back lines or not
  130867. */
  130868. showBackLines: boolean;
  130869. /**
  130870. * @hidden
  130871. */
  130872. renderList: SmartArray<BoundingBox>;
  130873. private _colorShader;
  130874. private _vertexBuffers;
  130875. private _indexBuffer;
  130876. private _fillIndexBuffer;
  130877. private _fillIndexData;
  130878. /**
  130879. * Instantiates a new bounding box renderer in a scene.
  130880. * @param scene the scene the renderer renders in
  130881. */
  130882. constructor(scene: Scene);
  130883. /**
  130884. * Registers the component in a given scene
  130885. */
  130886. register(): void;
  130887. private _evaluateSubMesh;
  130888. private _activeMesh;
  130889. private _prepareRessources;
  130890. private _createIndexBuffer;
  130891. /**
  130892. * Rebuilds the elements related to this component in case of
  130893. * context lost for instance.
  130894. */
  130895. rebuild(): void;
  130896. /**
  130897. * @hidden
  130898. */
  130899. reset(): void;
  130900. /**
  130901. * Render the bounding boxes of a specific rendering group
  130902. * @param renderingGroupId defines the rendering group to render
  130903. */
  130904. render(renderingGroupId: number): void;
  130905. /**
  130906. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130907. * @param mesh Define the mesh to render the occlusion bounding box for
  130908. */
  130909. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130910. /**
  130911. * Dispose and release the resources attached to this renderer.
  130912. */
  130913. dispose(): void;
  130914. }
  130915. }
  130916. declare module BABYLON {
  130917. /** @hidden */
  130918. export var depthPixelShader: {
  130919. name: string;
  130920. shader: string;
  130921. };
  130922. }
  130923. declare module BABYLON {
  130924. /**
  130925. * This represents a depth renderer in Babylon.
  130926. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130927. */
  130928. export class DepthRenderer {
  130929. private _scene;
  130930. private _depthMap;
  130931. private _effect;
  130932. private readonly _storeNonLinearDepth;
  130933. private readonly _clearColor;
  130934. /** Get if the depth renderer is using packed depth or not */
  130935. readonly isPacked: boolean;
  130936. private _cachedDefines;
  130937. private _camera;
  130938. /**
  130939. * Specifiess that the depth renderer will only be used within
  130940. * the camera it is created for.
  130941. * This can help forcing its rendering during the camera processing.
  130942. */
  130943. useOnlyInActiveCamera: boolean;
  130944. /** @hidden */
  130945. static _SceneComponentInitialization: (scene: Scene) => void;
  130946. /**
  130947. * Instantiates a depth renderer
  130948. * @param scene The scene the renderer belongs to
  130949. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130950. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130951. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130952. */
  130953. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130954. /**
  130955. * Creates the depth rendering effect and checks if the effect is ready.
  130956. * @param subMesh The submesh to be used to render the depth map of
  130957. * @param useInstances If multiple world instances should be used
  130958. * @returns if the depth renderer is ready to render the depth map
  130959. */
  130960. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130961. /**
  130962. * Gets the texture which the depth map will be written to.
  130963. * @returns The depth map texture
  130964. */
  130965. getDepthMap(): RenderTargetTexture;
  130966. /**
  130967. * Disposes of the depth renderer.
  130968. */
  130969. dispose(): void;
  130970. }
  130971. }
  130972. declare module BABYLON {
  130973. interface Scene {
  130974. /** @hidden (Backing field) */
  130975. _depthRenderer: {
  130976. [id: string]: DepthRenderer;
  130977. };
  130978. /**
  130979. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130980. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130981. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130982. * @returns the created depth renderer
  130983. */
  130984. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130985. /**
  130986. * Disables a depth renderer for a given camera
  130987. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130988. */
  130989. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130990. }
  130991. /**
  130992. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130993. * in several rendering techniques.
  130994. */
  130995. export class DepthRendererSceneComponent implements ISceneComponent {
  130996. /**
  130997. * The component name helpfull to identify the component in the list of scene components.
  130998. */
  130999. readonly name: string;
  131000. /**
  131001. * The scene the component belongs to.
  131002. */
  131003. scene: Scene;
  131004. /**
  131005. * Creates a new instance of the component for the given scene
  131006. * @param scene Defines the scene to register the component in
  131007. */
  131008. constructor(scene: Scene);
  131009. /**
  131010. * Registers the component in a given scene
  131011. */
  131012. register(): void;
  131013. /**
  131014. * Rebuilds the elements related to this component in case of
  131015. * context lost for instance.
  131016. */
  131017. rebuild(): void;
  131018. /**
  131019. * Disposes the component and the associated ressources
  131020. */
  131021. dispose(): void;
  131022. private _gatherRenderTargets;
  131023. private _gatherActiveCameraRenderTargets;
  131024. }
  131025. }
  131026. declare module BABYLON {
  131027. /** @hidden */
  131028. export var outlinePixelShader: {
  131029. name: string;
  131030. shader: string;
  131031. };
  131032. }
  131033. declare module BABYLON {
  131034. /** @hidden */
  131035. export var outlineVertexShader: {
  131036. name: string;
  131037. shader: string;
  131038. };
  131039. }
  131040. declare module BABYLON {
  131041. interface Scene {
  131042. /** @hidden */
  131043. _outlineRenderer: OutlineRenderer;
  131044. /**
  131045. * Gets the outline renderer associated with the scene
  131046. * @returns a OutlineRenderer
  131047. */
  131048. getOutlineRenderer(): OutlineRenderer;
  131049. }
  131050. interface AbstractMesh {
  131051. /** @hidden (Backing field) */
  131052. _renderOutline: boolean;
  131053. /**
  131054. * Gets or sets a boolean indicating if the outline must be rendered as well
  131055. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  131056. */
  131057. renderOutline: boolean;
  131058. /** @hidden (Backing field) */
  131059. _renderOverlay: boolean;
  131060. /**
  131061. * Gets or sets a boolean indicating if the overlay must be rendered as well
  131062. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  131063. */
  131064. renderOverlay: boolean;
  131065. }
  131066. /**
  131067. * This class is responsible to draw bothe outline/overlay of meshes.
  131068. * It should not be used directly but through the available method on mesh.
  131069. */
  131070. export class OutlineRenderer implements ISceneComponent {
  131071. /**
  131072. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  131073. */
  131074. private static _StencilReference;
  131075. /**
  131076. * The name of the component. Each component must have a unique name.
  131077. */
  131078. name: string;
  131079. /**
  131080. * The scene the component belongs to.
  131081. */
  131082. scene: Scene;
  131083. /**
  131084. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  131085. */
  131086. zOffset: number;
  131087. private _engine;
  131088. private _effect;
  131089. private _cachedDefines;
  131090. private _savedDepthWrite;
  131091. /**
  131092. * Instantiates a new outline renderer. (There could be only one per scene).
  131093. * @param scene Defines the scene it belongs to
  131094. */
  131095. constructor(scene: Scene);
  131096. /**
  131097. * Register the component to one instance of a scene.
  131098. */
  131099. register(): void;
  131100. /**
  131101. * Rebuilds the elements related to this component in case of
  131102. * context lost for instance.
  131103. */
  131104. rebuild(): void;
  131105. /**
  131106. * Disposes the component and the associated ressources.
  131107. */
  131108. dispose(): void;
  131109. /**
  131110. * Renders the outline in the canvas.
  131111. * @param subMesh Defines the sumesh to render
  131112. * @param batch Defines the batch of meshes in case of instances
  131113. * @param useOverlay Defines if the rendering is for the overlay or the outline
  131114. */
  131115. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  131116. /**
  131117. * Returns whether or not the outline renderer is ready for a given submesh.
  131118. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  131119. * @param subMesh Defines the submesh to check readyness for
  131120. * @param useInstances Defines wheter wee are trying to render instances or not
  131121. * @returns true if ready otherwise false
  131122. */
  131123. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131124. private _beforeRenderingMesh;
  131125. private _afterRenderingMesh;
  131126. }
  131127. }
  131128. declare module BABYLON {
  131129. /**
  131130. * Class used to manage multiple sprites of different sizes on the same spritesheet
  131131. * @see http://doc.babylonjs.com/babylon101/sprites
  131132. */
  131133. export class SpritePackedManager extends SpriteManager {
  131134. /** defines the packed manager's name */
  131135. name: string;
  131136. /**
  131137. * Creates a new sprite manager from a packed sprite sheet
  131138. * @param name defines the manager's name
  131139. * @param imgUrl defines the sprite sheet url
  131140. * @param capacity defines the maximum allowed number of sprites
  131141. * @param scene defines the hosting scene
  131142. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  131143. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131144. * @param samplingMode defines the smapling mode to use with spritesheet
  131145. * @param fromPacked set to true; do not alter
  131146. */
  131147. constructor(
  131148. /** defines the packed manager's name */
  131149. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  131150. }
  131151. }
  131152. declare module BABYLON {
  131153. /**
  131154. * Defines the list of states available for a task inside a AssetsManager
  131155. */
  131156. export enum AssetTaskState {
  131157. /**
  131158. * Initialization
  131159. */
  131160. INIT = 0,
  131161. /**
  131162. * Running
  131163. */
  131164. RUNNING = 1,
  131165. /**
  131166. * Done
  131167. */
  131168. DONE = 2,
  131169. /**
  131170. * Error
  131171. */
  131172. ERROR = 3
  131173. }
  131174. /**
  131175. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131176. */
  131177. export abstract class AbstractAssetTask {
  131178. /**
  131179. * Task name
  131180. */ name: string;
  131181. /**
  131182. * Callback called when the task is successful
  131183. */
  131184. onSuccess: (task: any) => void;
  131185. /**
  131186. * Callback called when the task is not successful
  131187. */
  131188. onError: (task: any, message?: string, exception?: any) => void;
  131189. /**
  131190. * Creates a new AssetsManager
  131191. * @param name defines the name of the task
  131192. */
  131193. constructor(
  131194. /**
  131195. * Task name
  131196. */ name: string);
  131197. private _isCompleted;
  131198. private _taskState;
  131199. private _errorObject;
  131200. /**
  131201. * Get if the task is completed
  131202. */
  131203. readonly isCompleted: boolean;
  131204. /**
  131205. * Gets the current state of the task
  131206. */
  131207. readonly taskState: AssetTaskState;
  131208. /**
  131209. * Gets the current error object (if task is in error)
  131210. */
  131211. readonly errorObject: {
  131212. message?: string;
  131213. exception?: any;
  131214. };
  131215. /**
  131216. * Internal only
  131217. * @hidden
  131218. */
  131219. _setErrorObject(message?: string, exception?: any): void;
  131220. /**
  131221. * Execute the current task
  131222. * @param scene defines the scene where you want your assets to be loaded
  131223. * @param onSuccess is a callback called when the task is successfully executed
  131224. * @param onError is a callback called if an error occurs
  131225. */
  131226. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131227. /**
  131228. * Execute the current task
  131229. * @param scene defines the scene where you want your assets to be loaded
  131230. * @param onSuccess is a callback called when the task is successfully executed
  131231. * @param onError is a callback called if an error occurs
  131232. */
  131233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131234. /**
  131235. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131236. * This can be used with failed tasks that have the reason for failure fixed.
  131237. */
  131238. reset(): void;
  131239. private onErrorCallback;
  131240. private onDoneCallback;
  131241. }
  131242. /**
  131243. * Define the interface used by progress events raised during assets loading
  131244. */
  131245. export interface IAssetsProgressEvent {
  131246. /**
  131247. * Defines the number of remaining tasks to process
  131248. */
  131249. remainingCount: number;
  131250. /**
  131251. * Defines the total number of tasks
  131252. */
  131253. totalCount: number;
  131254. /**
  131255. * Defines the task that was just processed
  131256. */
  131257. task: AbstractAssetTask;
  131258. }
  131259. /**
  131260. * Class used to share progress information about assets loading
  131261. */
  131262. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131263. /**
  131264. * Defines the number of remaining tasks to process
  131265. */
  131266. remainingCount: number;
  131267. /**
  131268. * Defines the total number of tasks
  131269. */
  131270. totalCount: number;
  131271. /**
  131272. * Defines the task that was just processed
  131273. */
  131274. task: AbstractAssetTask;
  131275. /**
  131276. * Creates a AssetsProgressEvent
  131277. * @param remainingCount defines the number of remaining tasks to process
  131278. * @param totalCount defines the total number of tasks
  131279. * @param task defines the task that was just processed
  131280. */
  131281. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131282. }
  131283. /**
  131284. * Define a task used by AssetsManager to load meshes
  131285. */
  131286. export class MeshAssetTask extends AbstractAssetTask {
  131287. /**
  131288. * Defines the name of the task
  131289. */
  131290. name: string;
  131291. /**
  131292. * Defines the list of mesh's names you want to load
  131293. */
  131294. meshesNames: any;
  131295. /**
  131296. * Defines the root url to use as a base to load your meshes and associated resources
  131297. */
  131298. rootUrl: string;
  131299. /**
  131300. * Defines the filename of the scene to load from
  131301. */
  131302. sceneFilename: string;
  131303. /**
  131304. * Gets the list of loaded meshes
  131305. */
  131306. loadedMeshes: Array<AbstractMesh>;
  131307. /**
  131308. * Gets the list of loaded particle systems
  131309. */
  131310. loadedParticleSystems: Array<IParticleSystem>;
  131311. /**
  131312. * Gets the list of loaded skeletons
  131313. */
  131314. loadedSkeletons: Array<Skeleton>;
  131315. /**
  131316. * Gets the list of loaded animation groups
  131317. */
  131318. loadedAnimationGroups: Array<AnimationGroup>;
  131319. /**
  131320. * Callback called when the task is successful
  131321. */
  131322. onSuccess: (task: MeshAssetTask) => void;
  131323. /**
  131324. * Callback called when the task is successful
  131325. */
  131326. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131327. /**
  131328. * Creates a new MeshAssetTask
  131329. * @param name defines the name of the task
  131330. * @param meshesNames defines the list of mesh's names you want to load
  131331. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131332. * @param sceneFilename defines the filename of the scene to load from
  131333. */
  131334. constructor(
  131335. /**
  131336. * Defines the name of the task
  131337. */
  131338. name: string,
  131339. /**
  131340. * Defines the list of mesh's names you want to load
  131341. */
  131342. meshesNames: any,
  131343. /**
  131344. * Defines the root url to use as a base to load your meshes and associated resources
  131345. */
  131346. rootUrl: string,
  131347. /**
  131348. * Defines the filename of the scene to load from
  131349. */
  131350. sceneFilename: string);
  131351. /**
  131352. * Execute the current task
  131353. * @param scene defines the scene where you want your assets to be loaded
  131354. * @param onSuccess is a callback called when the task is successfully executed
  131355. * @param onError is a callback called if an error occurs
  131356. */
  131357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131358. }
  131359. /**
  131360. * Define a task used by AssetsManager to load text content
  131361. */
  131362. export class TextFileAssetTask extends AbstractAssetTask {
  131363. /**
  131364. * Defines the name of the task
  131365. */
  131366. name: string;
  131367. /**
  131368. * Defines the location of the file to load
  131369. */
  131370. url: string;
  131371. /**
  131372. * Gets the loaded text string
  131373. */
  131374. text: string;
  131375. /**
  131376. * Callback called when the task is successful
  131377. */
  131378. onSuccess: (task: TextFileAssetTask) => void;
  131379. /**
  131380. * Callback called when the task is successful
  131381. */
  131382. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131383. /**
  131384. * Creates a new TextFileAssetTask object
  131385. * @param name defines the name of the task
  131386. * @param url defines the location of the file to load
  131387. */
  131388. constructor(
  131389. /**
  131390. * Defines the name of the task
  131391. */
  131392. name: string,
  131393. /**
  131394. * Defines the location of the file to load
  131395. */
  131396. url: string);
  131397. /**
  131398. * Execute the current task
  131399. * @param scene defines the scene where you want your assets to be loaded
  131400. * @param onSuccess is a callback called when the task is successfully executed
  131401. * @param onError is a callback called if an error occurs
  131402. */
  131403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131404. }
  131405. /**
  131406. * Define a task used by AssetsManager to load binary data
  131407. */
  131408. export class BinaryFileAssetTask extends AbstractAssetTask {
  131409. /**
  131410. * Defines the name of the task
  131411. */
  131412. name: string;
  131413. /**
  131414. * Defines the location of the file to load
  131415. */
  131416. url: string;
  131417. /**
  131418. * Gets the lodaded data (as an array buffer)
  131419. */
  131420. data: ArrayBuffer;
  131421. /**
  131422. * Callback called when the task is successful
  131423. */
  131424. onSuccess: (task: BinaryFileAssetTask) => void;
  131425. /**
  131426. * Callback called when the task is successful
  131427. */
  131428. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131429. /**
  131430. * Creates a new BinaryFileAssetTask object
  131431. * @param name defines the name of the new task
  131432. * @param url defines the location of the file to load
  131433. */
  131434. constructor(
  131435. /**
  131436. * Defines the name of the task
  131437. */
  131438. name: string,
  131439. /**
  131440. * Defines the location of the file to load
  131441. */
  131442. url: string);
  131443. /**
  131444. * Execute the current task
  131445. * @param scene defines the scene where you want your assets to be loaded
  131446. * @param onSuccess is a callback called when the task is successfully executed
  131447. * @param onError is a callback called if an error occurs
  131448. */
  131449. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131450. }
  131451. /**
  131452. * Define a task used by AssetsManager to load images
  131453. */
  131454. export class ImageAssetTask extends AbstractAssetTask {
  131455. /**
  131456. * Defines the name of the task
  131457. */
  131458. name: string;
  131459. /**
  131460. * Defines the location of the image to load
  131461. */
  131462. url: string;
  131463. /**
  131464. * Gets the loaded images
  131465. */
  131466. image: HTMLImageElement;
  131467. /**
  131468. * Callback called when the task is successful
  131469. */
  131470. onSuccess: (task: ImageAssetTask) => void;
  131471. /**
  131472. * Callback called when the task is successful
  131473. */
  131474. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131475. /**
  131476. * Creates a new ImageAssetTask
  131477. * @param name defines the name of the task
  131478. * @param url defines the location of the image to load
  131479. */
  131480. constructor(
  131481. /**
  131482. * Defines the name of the task
  131483. */
  131484. name: string,
  131485. /**
  131486. * Defines the location of the image to load
  131487. */
  131488. url: string);
  131489. /**
  131490. * Execute the current task
  131491. * @param scene defines the scene where you want your assets to be loaded
  131492. * @param onSuccess is a callback called when the task is successfully executed
  131493. * @param onError is a callback called if an error occurs
  131494. */
  131495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131496. }
  131497. /**
  131498. * Defines the interface used by texture loading tasks
  131499. */
  131500. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131501. /**
  131502. * Gets the loaded texture
  131503. */
  131504. texture: TEX;
  131505. }
  131506. /**
  131507. * Define a task used by AssetsManager to load 2D textures
  131508. */
  131509. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131510. /**
  131511. * Defines the name of the task
  131512. */
  131513. name: string;
  131514. /**
  131515. * Defines the location of the file to load
  131516. */
  131517. url: string;
  131518. /**
  131519. * Defines if mipmap should not be generated (default is false)
  131520. */
  131521. noMipmap?: boolean | undefined;
  131522. /**
  131523. * Defines if texture must be inverted on Y axis (default is false)
  131524. */
  131525. invertY?: boolean | undefined;
  131526. /**
  131527. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131528. */
  131529. samplingMode: number;
  131530. /**
  131531. * Gets the loaded texture
  131532. */
  131533. texture: Texture;
  131534. /**
  131535. * Callback called when the task is successful
  131536. */
  131537. onSuccess: (task: TextureAssetTask) => void;
  131538. /**
  131539. * Callback called when the task is successful
  131540. */
  131541. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131542. /**
  131543. * Creates a new TextureAssetTask object
  131544. * @param name defines the name of the task
  131545. * @param url defines the location of the file to load
  131546. * @param noMipmap defines if mipmap should not be generated (default is false)
  131547. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131548. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131549. */
  131550. constructor(
  131551. /**
  131552. * Defines the name of the task
  131553. */
  131554. name: string,
  131555. /**
  131556. * Defines the location of the file to load
  131557. */
  131558. url: string,
  131559. /**
  131560. * Defines if mipmap should not be generated (default is false)
  131561. */
  131562. noMipmap?: boolean | undefined,
  131563. /**
  131564. * Defines if texture must be inverted on Y axis (default is false)
  131565. */
  131566. invertY?: boolean | undefined,
  131567. /**
  131568. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131569. */
  131570. samplingMode?: number);
  131571. /**
  131572. * Execute the current task
  131573. * @param scene defines the scene where you want your assets to be loaded
  131574. * @param onSuccess is a callback called when the task is successfully executed
  131575. * @param onError is a callback called if an error occurs
  131576. */
  131577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131578. }
  131579. /**
  131580. * Define a task used by AssetsManager to load cube textures
  131581. */
  131582. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131583. /**
  131584. * Defines the name of the task
  131585. */
  131586. name: string;
  131587. /**
  131588. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131589. */
  131590. url: string;
  131591. /**
  131592. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131593. */
  131594. extensions?: string[] | undefined;
  131595. /**
  131596. * Defines if mipmaps should not be generated (default is false)
  131597. */
  131598. noMipmap?: boolean | undefined;
  131599. /**
  131600. * Defines the explicit list of files (undefined by default)
  131601. */
  131602. files?: string[] | undefined;
  131603. /**
  131604. * Gets the loaded texture
  131605. */
  131606. texture: CubeTexture;
  131607. /**
  131608. * Callback called when the task is successful
  131609. */
  131610. onSuccess: (task: CubeTextureAssetTask) => void;
  131611. /**
  131612. * Callback called when the task is successful
  131613. */
  131614. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131615. /**
  131616. * Creates a new CubeTextureAssetTask
  131617. * @param name defines the name of the task
  131618. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131619. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131620. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131621. * @param files defines the explicit list of files (undefined by default)
  131622. */
  131623. constructor(
  131624. /**
  131625. * Defines the name of the task
  131626. */
  131627. name: string,
  131628. /**
  131629. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131630. */
  131631. url: string,
  131632. /**
  131633. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131634. */
  131635. extensions?: string[] | undefined,
  131636. /**
  131637. * Defines if mipmaps should not be generated (default is false)
  131638. */
  131639. noMipmap?: boolean | undefined,
  131640. /**
  131641. * Defines the explicit list of files (undefined by default)
  131642. */
  131643. files?: string[] | undefined);
  131644. /**
  131645. * Execute the current task
  131646. * @param scene defines the scene where you want your assets to be loaded
  131647. * @param onSuccess is a callback called when the task is successfully executed
  131648. * @param onError is a callback called if an error occurs
  131649. */
  131650. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131651. }
  131652. /**
  131653. * Define a task used by AssetsManager to load HDR cube textures
  131654. */
  131655. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131656. /**
  131657. * Defines the name of the task
  131658. */
  131659. name: string;
  131660. /**
  131661. * Defines the location of the file to load
  131662. */
  131663. url: string;
  131664. /**
  131665. * Defines the desired size (the more it increases the longer the generation will be)
  131666. */
  131667. size: number;
  131668. /**
  131669. * Defines if mipmaps should not be generated (default is false)
  131670. */
  131671. noMipmap: boolean;
  131672. /**
  131673. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131674. */
  131675. generateHarmonics: boolean;
  131676. /**
  131677. * 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)
  131678. */
  131679. gammaSpace: boolean;
  131680. /**
  131681. * Internal Use Only
  131682. */
  131683. reserved: boolean;
  131684. /**
  131685. * Gets the loaded texture
  131686. */
  131687. texture: HDRCubeTexture;
  131688. /**
  131689. * Callback called when the task is successful
  131690. */
  131691. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131692. /**
  131693. * Callback called when the task is successful
  131694. */
  131695. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131696. /**
  131697. * Creates a new HDRCubeTextureAssetTask object
  131698. * @param name defines the name of the task
  131699. * @param url defines the location of the file to load
  131700. * @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.
  131701. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131702. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131703. * @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)
  131704. * @param reserved Internal use only
  131705. */
  131706. constructor(
  131707. /**
  131708. * Defines the name of the task
  131709. */
  131710. name: string,
  131711. /**
  131712. * Defines the location of the file to load
  131713. */
  131714. url: string,
  131715. /**
  131716. * Defines the desired size (the more it increases the longer the generation will be)
  131717. */
  131718. size: number,
  131719. /**
  131720. * Defines if mipmaps should not be generated (default is false)
  131721. */
  131722. noMipmap?: boolean,
  131723. /**
  131724. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131725. */
  131726. generateHarmonics?: boolean,
  131727. /**
  131728. * 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)
  131729. */
  131730. gammaSpace?: boolean,
  131731. /**
  131732. * Internal Use Only
  131733. */
  131734. reserved?: boolean);
  131735. /**
  131736. * Execute the current task
  131737. * @param scene defines the scene where you want your assets to be loaded
  131738. * @param onSuccess is a callback called when the task is successfully executed
  131739. * @param onError is a callback called if an error occurs
  131740. */
  131741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131742. }
  131743. /**
  131744. * Define a task used by AssetsManager to load Equirectangular cube textures
  131745. */
  131746. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131747. /**
  131748. * Defines the name of the task
  131749. */
  131750. name: string;
  131751. /**
  131752. * Defines the location of the file to load
  131753. */
  131754. url: string;
  131755. /**
  131756. * Defines the desired size (the more it increases the longer the generation will be)
  131757. */
  131758. size: number;
  131759. /**
  131760. * Defines if mipmaps should not be generated (default is false)
  131761. */
  131762. noMipmap: boolean;
  131763. /**
  131764. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131765. * but the standard material would require them in Gamma space) (default is true)
  131766. */
  131767. gammaSpace: boolean;
  131768. /**
  131769. * Gets the loaded texture
  131770. */
  131771. texture: EquiRectangularCubeTexture;
  131772. /**
  131773. * Callback called when the task is successful
  131774. */
  131775. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131776. /**
  131777. * Callback called when the task is successful
  131778. */
  131779. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131780. /**
  131781. * Creates a new EquiRectangularCubeTextureAssetTask object
  131782. * @param name defines the name of the task
  131783. * @param url defines the location of the file to load
  131784. * @param size defines the desired size (the more it increases the longer the generation will be)
  131785. * If the size is omitted this implies you are using a preprocessed cubemap.
  131786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131787. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131788. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131789. * (default is true)
  131790. */
  131791. constructor(
  131792. /**
  131793. * Defines the name of the task
  131794. */
  131795. name: string,
  131796. /**
  131797. * Defines the location of the file to load
  131798. */
  131799. url: string,
  131800. /**
  131801. * Defines the desired size (the more it increases the longer the generation will be)
  131802. */
  131803. size: number,
  131804. /**
  131805. * Defines if mipmaps should not be generated (default is false)
  131806. */
  131807. noMipmap?: boolean,
  131808. /**
  131809. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131810. * but the standard material would require them in Gamma space) (default is true)
  131811. */
  131812. gammaSpace?: boolean);
  131813. /**
  131814. * Execute the current task
  131815. * @param scene defines the scene where you want your assets to be loaded
  131816. * @param onSuccess is a callback called when the task is successfully executed
  131817. * @param onError is a callback called if an error occurs
  131818. */
  131819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131820. }
  131821. /**
  131822. * This class can be used to easily import assets into a scene
  131823. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131824. */
  131825. export class AssetsManager {
  131826. private _scene;
  131827. private _isLoading;
  131828. protected _tasks: AbstractAssetTask[];
  131829. protected _waitingTasksCount: number;
  131830. protected _totalTasksCount: number;
  131831. /**
  131832. * Callback called when all tasks are processed
  131833. */
  131834. onFinish: (tasks: AbstractAssetTask[]) => void;
  131835. /**
  131836. * Callback called when a task is successful
  131837. */
  131838. onTaskSuccess: (task: AbstractAssetTask) => void;
  131839. /**
  131840. * Callback called when a task had an error
  131841. */
  131842. onTaskError: (task: AbstractAssetTask) => void;
  131843. /**
  131844. * Callback called when a task is done (whatever the result is)
  131845. */
  131846. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131847. /**
  131848. * Observable called when all tasks are processed
  131849. */
  131850. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131851. /**
  131852. * Observable called when a task had an error
  131853. */
  131854. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131855. /**
  131856. * Observable called when all tasks were executed
  131857. */
  131858. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131859. /**
  131860. * Observable called when a task is done (whatever the result is)
  131861. */
  131862. onProgressObservable: Observable<IAssetsProgressEvent>;
  131863. /**
  131864. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131866. */
  131867. useDefaultLoadingScreen: boolean;
  131868. /**
  131869. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131870. * when all assets have been downloaded.
  131871. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131872. */
  131873. autoHideLoadingUI: boolean;
  131874. /**
  131875. * Creates a new AssetsManager
  131876. * @param scene defines the scene to work on
  131877. */
  131878. constructor(scene: Scene);
  131879. /**
  131880. * Add a MeshAssetTask to the list of active tasks
  131881. * @param taskName defines the name of the new task
  131882. * @param meshesNames defines the name of meshes to load
  131883. * @param rootUrl defines the root url to use to locate files
  131884. * @param sceneFilename defines the filename of the scene file
  131885. * @returns a new MeshAssetTask object
  131886. */
  131887. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131888. /**
  131889. * Add a TextFileAssetTask to the list of active tasks
  131890. * @param taskName defines the name of the new task
  131891. * @param url defines the url of the file to load
  131892. * @returns a new TextFileAssetTask object
  131893. */
  131894. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131895. /**
  131896. * Add a BinaryFileAssetTask to the list of active tasks
  131897. * @param taskName defines the name of the new task
  131898. * @param url defines the url of the file to load
  131899. * @returns a new BinaryFileAssetTask object
  131900. */
  131901. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131902. /**
  131903. * Add a ImageAssetTask to the list of active tasks
  131904. * @param taskName defines the name of the new task
  131905. * @param url defines the url of the file to load
  131906. * @returns a new ImageAssetTask object
  131907. */
  131908. addImageTask(taskName: string, url: string): ImageAssetTask;
  131909. /**
  131910. * Add a TextureAssetTask to the list of active tasks
  131911. * @param taskName defines the name of the new task
  131912. * @param url defines the url of the file to load
  131913. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131914. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131915. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131916. * @returns a new TextureAssetTask object
  131917. */
  131918. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131919. /**
  131920. * Add a CubeTextureAssetTask to the list of active tasks
  131921. * @param taskName defines the name of the new task
  131922. * @param url defines the url of the file to load
  131923. * @param extensions defines the extension to use to load the cube map (can be null)
  131924. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131925. * @param files defines the list of files to load (can be null)
  131926. * @returns a new CubeTextureAssetTask object
  131927. */
  131928. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131929. /**
  131930. *
  131931. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131932. * @param taskName defines the name of the new task
  131933. * @param url defines the url of the file to load
  131934. * @param size defines the size you want for the cubemap (can be null)
  131935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131936. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131937. * @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)
  131938. * @param reserved Internal use only
  131939. * @returns a new HDRCubeTextureAssetTask object
  131940. */
  131941. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131942. /**
  131943. *
  131944. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131945. * @param taskName defines the name of the new task
  131946. * @param url defines the url of the file to load
  131947. * @param size defines the size you want for the cubemap (can be null)
  131948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131949. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131950. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131951. * @returns a new EquiRectangularCubeTextureAssetTask object
  131952. */
  131953. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131954. /**
  131955. * Remove a task from the assets manager.
  131956. * @param task the task to remove
  131957. */
  131958. removeTask(task: AbstractAssetTask): void;
  131959. private _decreaseWaitingTasksCount;
  131960. private _runTask;
  131961. /**
  131962. * Reset the AssetsManager and remove all tasks
  131963. * @return the current instance of the AssetsManager
  131964. */
  131965. reset(): AssetsManager;
  131966. /**
  131967. * Start the loading process
  131968. * @return the current instance of the AssetsManager
  131969. */
  131970. load(): AssetsManager;
  131971. /**
  131972. * Start the loading process as an async operation
  131973. * @return a promise returning the list of failed tasks
  131974. */
  131975. loadAsync(): Promise<void>;
  131976. }
  131977. }
  131978. declare module BABYLON {
  131979. /**
  131980. * Wrapper class for promise with external resolve and reject.
  131981. */
  131982. export class Deferred<T> {
  131983. /**
  131984. * The promise associated with this deferred object.
  131985. */
  131986. readonly promise: Promise<T>;
  131987. private _resolve;
  131988. private _reject;
  131989. /**
  131990. * The resolve method of the promise associated with this deferred object.
  131991. */
  131992. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131993. /**
  131994. * The reject method of the promise associated with this deferred object.
  131995. */
  131996. readonly reject: (reason?: any) => void;
  131997. /**
  131998. * Constructor for this deferred object.
  131999. */
  132000. constructor();
  132001. }
  132002. }
  132003. declare module BABYLON {
  132004. /**
  132005. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  132006. */
  132007. export class MeshExploder {
  132008. private _centerMesh;
  132009. private _meshes;
  132010. private _meshesOrigins;
  132011. private _toCenterVectors;
  132012. private _scaledDirection;
  132013. private _newPosition;
  132014. private _centerPosition;
  132015. /**
  132016. * Explodes meshes from a center mesh.
  132017. * @param meshes The meshes to explode.
  132018. * @param centerMesh The mesh to be center of explosion.
  132019. */
  132020. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  132021. private _setCenterMesh;
  132022. /**
  132023. * Get class name
  132024. * @returns "MeshExploder"
  132025. */
  132026. getClassName(): string;
  132027. /**
  132028. * "Exploded meshes"
  132029. * @returns Array of meshes with the centerMesh at index 0.
  132030. */
  132031. getMeshes(): Array<Mesh>;
  132032. /**
  132033. * Explodes meshes giving a specific direction
  132034. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  132035. */
  132036. explode(direction?: number): void;
  132037. }
  132038. }
  132039. declare module BABYLON {
  132040. /**
  132041. * Class used to help managing file picking and drag'n'drop
  132042. */
  132043. export class FilesInput {
  132044. /**
  132045. * List of files ready to be loaded
  132046. */
  132047. static readonly FilesToLoad: {
  132048. [key: string]: File;
  132049. };
  132050. /**
  132051. * Callback called when a file is processed
  132052. */
  132053. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  132054. private _engine;
  132055. private _currentScene;
  132056. private _sceneLoadedCallback;
  132057. private _progressCallback;
  132058. private _additionalRenderLoopLogicCallback;
  132059. private _textureLoadingCallback;
  132060. private _startingProcessingFilesCallback;
  132061. private _onReloadCallback;
  132062. private _errorCallback;
  132063. private _elementToMonitor;
  132064. private _sceneFileToLoad;
  132065. private _filesToLoad;
  132066. /**
  132067. * Creates a new FilesInput
  132068. * @param engine defines the rendering engine
  132069. * @param scene defines the hosting scene
  132070. * @param sceneLoadedCallback callback called when scene is loaded
  132071. * @param progressCallback callback called to track progress
  132072. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  132073. * @param textureLoadingCallback callback called when a texture is loading
  132074. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  132075. * @param onReloadCallback callback called when a reload is requested
  132076. * @param errorCallback callback call if an error occurs
  132077. */
  132078. 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);
  132079. private _dragEnterHandler;
  132080. private _dragOverHandler;
  132081. private _dropHandler;
  132082. /**
  132083. * Calls this function to listen to drag'n'drop events on a specific DOM element
  132084. * @param elementToMonitor defines the DOM element to track
  132085. */
  132086. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  132087. /**
  132088. * Release all associated resources
  132089. */
  132090. dispose(): void;
  132091. private renderFunction;
  132092. private drag;
  132093. private drop;
  132094. private _traverseFolder;
  132095. private _processFiles;
  132096. /**
  132097. * Load files from a drop event
  132098. * @param event defines the drop event to use as source
  132099. */
  132100. loadFiles(event: any): void;
  132101. private _processReload;
  132102. /**
  132103. * Reload the current scene from the loaded files
  132104. */
  132105. reload(): void;
  132106. }
  132107. }
  132108. declare module BABYLON {
  132109. /**
  132110. * Defines the root class used to create scene optimization to use with SceneOptimizer
  132111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132112. */
  132113. export class SceneOptimization {
  132114. /**
  132115. * Defines the priority of this optimization (0 by default which means first in the list)
  132116. */
  132117. priority: number;
  132118. /**
  132119. * Gets a string describing the action executed by the current optimization
  132120. * @returns description string
  132121. */
  132122. getDescription(): string;
  132123. /**
  132124. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132125. * @param scene defines the current scene where to apply this optimization
  132126. * @param optimizer defines the current optimizer
  132127. * @returns true if everything that can be done was applied
  132128. */
  132129. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132130. /**
  132131. * Creates the SceneOptimization object
  132132. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132133. * @param desc defines the description associated with the optimization
  132134. */
  132135. constructor(
  132136. /**
  132137. * Defines the priority of this optimization (0 by default which means first in the list)
  132138. */
  132139. priority?: number);
  132140. }
  132141. /**
  132142. * Defines an optimization used to reduce the size of render target textures
  132143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132144. */
  132145. export class TextureOptimization extends SceneOptimization {
  132146. /**
  132147. * Defines the priority of this optimization (0 by default which means first in the list)
  132148. */
  132149. priority: number;
  132150. /**
  132151. * 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
  132152. */
  132153. maximumSize: number;
  132154. /**
  132155. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132156. */
  132157. step: number;
  132158. /**
  132159. * Gets a string describing the action executed by the current optimization
  132160. * @returns description string
  132161. */
  132162. getDescription(): string;
  132163. /**
  132164. * Creates the TextureOptimization object
  132165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132166. * @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
  132167. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132168. */
  132169. constructor(
  132170. /**
  132171. * Defines the priority of this optimization (0 by default which means first in the list)
  132172. */
  132173. priority?: number,
  132174. /**
  132175. * 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
  132176. */
  132177. maximumSize?: number,
  132178. /**
  132179. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132180. */
  132181. step?: number);
  132182. /**
  132183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132184. * @param scene defines the current scene where to apply this optimization
  132185. * @param optimizer defines the current optimizer
  132186. * @returns true if everything that can be done was applied
  132187. */
  132188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132189. }
  132190. /**
  132191. * Defines an optimization used to increase or decrease the rendering resolution
  132192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132193. */
  132194. export class HardwareScalingOptimization extends SceneOptimization {
  132195. /**
  132196. * Defines the priority of this optimization (0 by default which means first in the list)
  132197. */
  132198. priority: number;
  132199. /**
  132200. * Defines the maximum scale to use (2 by default)
  132201. */
  132202. maximumScale: number;
  132203. /**
  132204. * Defines the step to use between two passes (0.5 by default)
  132205. */
  132206. step: number;
  132207. private _currentScale;
  132208. private _directionOffset;
  132209. /**
  132210. * Gets a string describing the action executed by the current optimization
  132211. * @return description string
  132212. */
  132213. getDescription(): string;
  132214. /**
  132215. * Creates the HardwareScalingOptimization object
  132216. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132217. * @param maximumScale defines the maximum scale to use (2 by default)
  132218. * @param step defines the step to use between two passes (0.5 by default)
  132219. */
  132220. constructor(
  132221. /**
  132222. * Defines the priority of this optimization (0 by default which means first in the list)
  132223. */
  132224. priority?: number,
  132225. /**
  132226. * Defines the maximum scale to use (2 by default)
  132227. */
  132228. maximumScale?: number,
  132229. /**
  132230. * Defines the step to use between two passes (0.5 by default)
  132231. */
  132232. step?: number);
  132233. /**
  132234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132235. * @param scene defines the current scene where to apply this optimization
  132236. * @param optimizer defines the current optimizer
  132237. * @returns true if everything that can be done was applied
  132238. */
  132239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132240. }
  132241. /**
  132242. * Defines an optimization used to remove shadows
  132243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132244. */
  132245. export class ShadowsOptimization extends SceneOptimization {
  132246. /**
  132247. * Gets a string describing the action executed by the current optimization
  132248. * @return description string
  132249. */
  132250. getDescription(): string;
  132251. /**
  132252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132253. * @param scene defines the current scene where to apply this optimization
  132254. * @param optimizer defines the current optimizer
  132255. * @returns true if everything that can be done was applied
  132256. */
  132257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132258. }
  132259. /**
  132260. * Defines an optimization used to turn post-processes off
  132261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132262. */
  132263. export class PostProcessesOptimization extends SceneOptimization {
  132264. /**
  132265. * Gets a string describing the action executed by the current optimization
  132266. * @return description string
  132267. */
  132268. getDescription(): string;
  132269. /**
  132270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132271. * @param scene defines the current scene where to apply this optimization
  132272. * @param optimizer defines the current optimizer
  132273. * @returns true if everything that can be done was applied
  132274. */
  132275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132276. }
  132277. /**
  132278. * Defines an optimization used to turn lens flares off
  132279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132280. */
  132281. export class LensFlaresOptimization extends SceneOptimization {
  132282. /**
  132283. * Gets a string describing the action executed by the current optimization
  132284. * @return description string
  132285. */
  132286. getDescription(): string;
  132287. /**
  132288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132289. * @param scene defines the current scene where to apply this optimization
  132290. * @param optimizer defines the current optimizer
  132291. * @returns true if everything that can be done was applied
  132292. */
  132293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132294. }
  132295. /**
  132296. * Defines an optimization based on user defined callback.
  132297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132298. */
  132299. export class CustomOptimization extends SceneOptimization {
  132300. /**
  132301. * Callback called to apply the custom optimization.
  132302. */
  132303. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132304. /**
  132305. * Callback called to get custom description
  132306. */
  132307. onGetDescription: () => string;
  132308. /**
  132309. * Gets a string describing the action executed by the current optimization
  132310. * @returns description string
  132311. */
  132312. getDescription(): string;
  132313. /**
  132314. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132315. * @param scene defines the current scene where to apply this optimization
  132316. * @param optimizer defines the current optimizer
  132317. * @returns true if everything that can be done was applied
  132318. */
  132319. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132320. }
  132321. /**
  132322. * Defines an optimization used to turn particles off
  132323. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132324. */
  132325. export class ParticlesOptimization extends SceneOptimization {
  132326. /**
  132327. * Gets a string describing the action executed by the current optimization
  132328. * @return description string
  132329. */
  132330. getDescription(): string;
  132331. /**
  132332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132333. * @param scene defines the current scene where to apply this optimization
  132334. * @param optimizer defines the current optimizer
  132335. * @returns true if everything that can be done was applied
  132336. */
  132337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132338. }
  132339. /**
  132340. * Defines an optimization used to turn render targets off
  132341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132342. */
  132343. export class RenderTargetsOptimization extends SceneOptimization {
  132344. /**
  132345. * Gets a string describing the action executed by the current optimization
  132346. * @return description string
  132347. */
  132348. getDescription(): string;
  132349. /**
  132350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132351. * @param scene defines the current scene where to apply this optimization
  132352. * @param optimizer defines the current optimizer
  132353. * @returns true if everything that can be done was applied
  132354. */
  132355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132356. }
  132357. /**
  132358. * Defines an optimization used to merge meshes with compatible materials
  132359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132360. */
  132361. export class MergeMeshesOptimization extends SceneOptimization {
  132362. private static _UpdateSelectionTree;
  132363. /**
  132364. * Gets or sets a boolean which defines if optimization octree has to be updated
  132365. */
  132366. /**
  132367. * Gets or sets a boolean which defines if optimization octree has to be updated
  132368. */
  132369. static UpdateSelectionTree: boolean;
  132370. /**
  132371. * Gets a string describing the action executed by the current optimization
  132372. * @return description string
  132373. */
  132374. getDescription(): string;
  132375. private _canBeMerged;
  132376. /**
  132377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132378. * @param scene defines the current scene where to apply this optimization
  132379. * @param optimizer defines the current optimizer
  132380. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132381. * @returns true if everything that can be done was applied
  132382. */
  132383. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132384. }
  132385. /**
  132386. * Defines a list of options used by SceneOptimizer
  132387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132388. */
  132389. export class SceneOptimizerOptions {
  132390. /**
  132391. * Defines the target frame rate to reach (60 by default)
  132392. */
  132393. targetFrameRate: number;
  132394. /**
  132395. * Defines the interval between two checkes (2000ms by default)
  132396. */
  132397. trackerDuration: number;
  132398. /**
  132399. * Gets the list of optimizations to apply
  132400. */
  132401. optimizations: SceneOptimization[];
  132402. /**
  132403. * Creates a new list of options used by SceneOptimizer
  132404. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132405. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132406. */
  132407. constructor(
  132408. /**
  132409. * Defines the target frame rate to reach (60 by default)
  132410. */
  132411. targetFrameRate?: number,
  132412. /**
  132413. * Defines the interval between two checkes (2000ms by default)
  132414. */
  132415. trackerDuration?: number);
  132416. /**
  132417. * Add a new optimization
  132418. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132419. * @returns the current SceneOptimizerOptions
  132420. */
  132421. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132422. /**
  132423. * Add a new custom optimization
  132424. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132425. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132426. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132427. * @returns the current SceneOptimizerOptions
  132428. */
  132429. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132430. /**
  132431. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132432. * @param targetFrameRate defines the target frame rate (60 by default)
  132433. * @returns a SceneOptimizerOptions object
  132434. */
  132435. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132436. /**
  132437. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132438. * @param targetFrameRate defines the target frame rate (60 by default)
  132439. * @returns a SceneOptimizerOptions object
  132440. */
  132441. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132442. /**
  132443. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132444. * @param targetFrameRate defines the target frame rate (60 by default)
  132445. * @returns a SceneOptimizerOptions object
  132446. */
  132447. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132448. }
  132449. /**
  132450. * Class used to run optimizations in order to reach a target frame rate
  132451. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132452. */
  132453. export class SceneOptimizer implements IDisposable {
  132454. private _isRunning;
  132455. private _options;
  132456. private _scene;
  132457. private _currentPriorityLevel;
  132458. private _targetFrameRate;
  132459. private _trackerDuration;
  132460. private _currentFrameRate;
  132461. private _sceneDisposeObserver;
  132462. private _improvementMode;
  132463. /**
  132464. * Defines an observable called when the optimizer reaches the target frame rate
  132465. */
  132466. onSuccessObservable: Observable<SceneOptimizer>;
  132467. /**
  132468. * Defines an observable called when the optimizer enables an optimization
  132469. */
  132470. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132471. /**
  132472. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132473. */
  132474. onFailureObservable: Observable<SceneOptimizer>;
  132475. /**
  132476. * Gets a boolean indicating if the optimizer is in improvement mode
  132477. */
  132478. readonly isInImprovementMode: boolean;
  132479. /**
  132480. * Gets the current priority level (0 at start)
  132481. */
  132482. readonly currentPriorityLevel: number;
  132483. /**
  132484. * Gets the current frame rate checked by the SceneOptimizer
  132485. */
  132486. readonly currentFrameRate: number;
  132487. /**
  132488. * Gets or sets the current target frame rate (60 by default)
  132489. */
  132490. /**
  132491. * Gets or sets the current target frame rate (60 by default)
  132492. */
  132493. targetFrameRate: number;
  132494. /**
  132495. * Gets or sets the current interval between two checks (every 2000ms by default)
  132496. */
  132497. /**
  132498. * Gets or sets the current interval between two checks (every 2000ms by default)
  132499. */
  132500. trackerDuration: number;
  132501. /**
  132502. * Gets the list of active optimizations
  132503. */
  132504. readonly optimizations: SceneOptimization[];
  132505. /**
  132506. * Creates a new SceneOptimizer
  132507. * @param scene defines the scene to work on
  132508. * @param options defines the options to use with the SceneOptimizer
  132509. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132510. * @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)
  132511. */
  132512. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132513. /**
  132514. * Stops the current optimizer
  132515. */
  132516. stop(): void;
  132517. /**
  132518. * Reset the optimizer to initial step (current priority level = 0)
  132519. */
  132520. reset(): void;
  132521. /**
  132522. * Start the optimizer. By default it will try to reach a specific framerate
  132523. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132524. */
  132525. start(): void;
  132526. private _checkCurrentState;
  132527. /**
  132528. * Release all resources
  132529. */
  132530. dispose(): void;
  132531. /**
  132532. * Helper function to create a SceneOptimizer with one single line of code
  132533. * @param scene defines the scene to work on
  132534. * @param options defines the options to use with the SceneOptimizer
  132535. * @param onSuccess defines a callback to call on success
  132536. * @param onFailure defines a callback to call on failure
  132537. * @returns the new SceneOptimizer object
  132538. */
  132539. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132540. }
  132541. }
  132542. declare module BABYLON {
  132543. /**
  132544. * Class used to serialize a scene into a string
  132545. */
  132546. export class SceneSerializer {
  132547. /**
  132548. * Clear cache used by a previous serialization
  132549. */
  132550. static ClearCache(): void;
  132551. /**
  132552. * Serialize a scene into a JSON compatible object
  132553. * @param scene defines the scene to serialize
  132554. * @returns a JSON compatible object
  132555. */
  132556. static Serialize(scene: Scene): any;
  132557. /**
  132558. * Serialize a mesh into a JSON compatible object
  132559. * @param toSerialize defines the mesh to serialize
  132560. * @param withParents defines if parents must be serialized as well
  132561. * @param withChildren defines if children must be serialized as well
  132562. * @returns a JSON compatible object
  132563. */
  132564. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132565. }
  132566. }
  132567. declare module BABYLON {
  132568. /**
  132569. * Class used to host texture specific utilities
  132570. */
  132571. export class TextureTools {
  132572. /**
  132573. * Uses the GPU to create a copy texture rescaled at a given size
  132574. * @param texture Texture to copy from
  132575. * @param width defines the desired width
  132576. * @param height defines the desired height
  132577. * @param useBilinearMode defines if bilinear mode has to be used
  132578. * @return the generated texture
  132579. */
  132580. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132581. }
  132582. }
  132583. declare module BABYLON {
  132584. /**
  132585. * This represents the different options available for the video capture.
  132586. */
  132587. export interface VideoRecorderOptions {
  132588. /** Defines the mime type of the video. */
  132589. mimeType: string;
  132590. /** Defines the FPS the video should be recorded at. */
  132591. fps: number;
  132592. /** Defines the chunk size for the recording data. */
  132593. recordChunckSize: number;
  132594. /** The audio tracks to attach to the recording. */
  132595. audioTracks?: MediaStreamTrack[];
  132596. }
  132597. /**
  132598. * This can help with recording videos from BabylonJS.
  132599. * This is based on the available WebRTC functionalities of the browser.
  132600. *
  132601. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132602. */
  132603. export class VideoRecorder {
  132604. private static readonly _defaultOptions;
  132605. /**
  132606. * Returns whether or not the VideoRecorder is available in your browser.
  132607. * @param engine Defines the Babylon Engine.
  132608. * @returns true if supported otherwise false.
  132609. */
  132610. static IsSupported(engine: Engine): boolean;
  132611. private readonly _options;
  132612. private _canvas;
  132613. private _mediaRecorder;
  132614. private _recordedChunks;
  132615. private _fileName;
  132616. private _resolve;
  132617. private _reject;
  132618. /**
  132619. * True when a recording is already in progress.
  132620. */
  132621. readonly isRecording: boolean;
  132622. /**
  132623. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132624. * @param engine Defines the BabylonJS Engine you wish to record.
  132625. * @param options Defines options that can be used to customize the capture.
  132626. */
  132627. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132628. /**
  132629. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132630. */
  132631. stopRecording(): void;
  132632. /**
  132633. * Starts recording the canvas for a max duration specified in parameters.
  132634. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132635. * If null no automatic download will start and you can rely on the promise to get the data back.
  132636. * @param maxDuration Defines the maximum recording time in seconds.
  132637. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132638. * @return A promise callback at the end of the recording with the video data in Blob.
  132639. */
  132640. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132641. /**
  132642. * Releases internal resources used during the recording.
  132643. */
  132644. dispose(): void;
  132645. private _handleDataAvailable;
  132646. private _handleError;
  132647. private _handleStop;
  132648. }
  132649. }
  132650. declare module BABYLON {
  132651. /**
  132652. * Class containing a set of static utilities functions for screenshots
  132653. */
  132654. export class ScreenshotTools {
  132655. /**
  132656. * Captures a screenshot of the current rendering
  132657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132658. * @param engine defines the rendering engine
  132659. * @param camera defines the source camera
  132660. * @param size This parameter can be set to a single number or to an object with the
  132661. * following (optional) properties: precision, width, height. If a single number is passed,
  132662. * it will be used for both width and height. If an object is passed, the screenshot size
  132663. * will be derived from the parameters. The precision property is a multiplier allowing
  132664. * rendering at a higher or lower resolution
  132665. * @param successCallback defines the callback receives a single parameter which contains the
  132666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132667. * src parameter of an <img> to display it
  132668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132669. * Check your browser for supported MIME types
  132670. */
  132671. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132672. /**
  132673. * Captures a screenshot of the current rendering
  132674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132675. * @param engine defines the rendering engine
  132676. * @param camera defines the source camera
  132677. * @param size This parameter can be set to a single number or to an object with the
  132678. * following (optional) properties: precision, width, height. If a single number is passed,
  132679. * it will be used for both width and height. If an object is passed, the screenshot size
  132680. * will be derived from the parameters. The precision property is a multiplier allowing
  132681. * rendering at a higher or lower resolution
  132682. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132683. * Check your browser for supported MIME types
  132684. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132685. * to the src parameter of an <img> to display it
  132686. */
  132687. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132688. /**
  132689. * Generates an image screenshot from the specified camera.
  132690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132691. * @param engine The engine to use for rendering
  132692. * @param camera The camera to use for rendering
  132693. * @param size This parameter can be set to a single number or to an object with the
  132694. * following (optional) properties: precision, width, height. If a single number is passed,
  132695. * it will be used for both width and height. If an object is passed, the screenshot size
  132696. * will be derived from the parameters. The precision property is a multiplier allowing
  132697. * rendering at a higher or lower resolution
  132698. * @param successCallback The callback receives a single parameter which contains the
  132699. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132700. * src parameter of an <img> to display it
  132701. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132702. * Check your browser for supported MIME types
  132703. * @param samples Texture samples (default: 1)
  132704. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132705. * @param fileName A name for for the downloaded file.
  132706. */
  132707. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132708. /**
  132709. * Generates an image screenshot from the specified camera.
  132710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132711. * @param engine The engine to use for rendering
  132712. * @param camera The camera to use for rendering
  132713. * @param size This parameter can be set to a single number or to an object with the
  132714. * following (optional) properties: precision, width, height. If a single number is passed,
  132715. * it will be used for both width and height. If an object is passed, the screenshot size
  132716. * will be derived from the parameters. The precision property is a multiplier allowing
  132717. * rendering at a higher or lower resolution
  132718. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132719. * Check your browser for supported MIME types
  132720. * @param samples Texture samples (default: 1)
  132721. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132722. * @param fileName A name for for the downloaded file.
  132723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132724. * to the src parameter of an <img> to display it
  132725. */
  132726. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132727. /**
  132728. * Gets height and width for screenshot size
  132729. * @private
  132730. */
  132731. private static _getScreenshotSize;
  132732. }
  132733. }
  132734. declare module BABYLON {
  132735. /**
  132736. * Interface for a data buffer
  132737. */
  132738. export interface IDataBuffer {
  132739. /**
  132740. * Reads bytes from the data buffer.
  132741. * @param byteOffset The byte offset to read
  132742. * @param byteLength The byte length to read
  132743. * @returns A promise that resolves when the bytes are read
  132744. */
  132745. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132746. /**
  132747. * The byte length of the buffer.
  132748. */
  132749. readonly byteLength: number;
  132750. }
  132751. /**
  132752. * Utility class for reading from a data buffer
  132753. */
  132754. export class DataReader {
  132755. /**
  132756. * The data buffer associated with this data reader.
  132757. */
  132758. readonly buffer: IDataBuffer;
  132759. /**
  132760. * The current byte offset from the beginning of the data buffer.
  132761. */
  132762. byteOffset: number;
  132763. private _dataView;
  132764. private _dataByteOffset;
  132765. /**
  132766. * Constructor
  132767. * @param buffer The buffer to read
  132768. */
  132769. constructor(buffer: IDataBuffer);
  132770. /**
  132771. * Loads the given byte length.
  132772. * @param byteLength The byte length to load
  132773. * @returns A promise that resolves when the load is complete
  132774. */
  132775. loadAsync(byteLength: number): Promise<void>;
  132776. /**
  132777. * Read a unsigned 32-bit integer from the currently loaded data range.
  132778. * @returns The 32-bit integer read
  132779. */
  132780. readUint32(): number;
  132781. /**
  132782. * Read a byte array from the currently loaded data range.
  132783. * @param byteLength The byte length to read
  132784. * @returns The byte array read
  132785. */
  132786. readUint8Array(byteLength: number): Uint8Array;
  132787. /**
  132788. * Read a string from the currently loaded data range.
  132789. * @param byteLength The byte length to read
  132790. * @returns The string read
  132791. */
  132792. readString(byteLength: number): string;
  132793. /**
  132794. * Skips the given byte length the currently loaded data range.
  132795. * @param byteLength The byte length to skip
  132796. */
  132797. skipBytes(byteLength: number): void;
  132798. }
  132799. }
  132800. declare module BABYLON {
  132801. /**
  132802. * A cursor which tracks a point on a path
  132803. */
  132804. export class PathCursor {
  132805. private path;
  132806. /**
  132807. * Stores path cursor callbacks for when an onchange event is triggered
  132808. */
  132809. private _onchange;
  132810. /**
  132811. * The value of the path cursor
  132812. */
  132813. value: number;
  132814. /**
  132815. * The animation array of the path cursor
  132816. */
  132817. animations: Animation[];
  132818. /**
  132819. * Initializes the path cursor
  132820. * @param path The path to track
  132821. */
  132822. constructor(path: Path2);
  132823. /**
  132824. * Gets the cursor point on the path
  132825. * @returns A point on the path cursor at the cursor location
  132826. */
  132827. getPoint(): Vector3;
  132828. /**
  132829. * Moves the cursor ahead by the step amount
  132830. * @param step The amount to move the cursor forward
  132831. * @returns This path cursor
  132832. */
  132833. moveAhead(step?: number): PathCursor;
  132834. /**
  132835. * Moves the cursor behind by the step amount
  132836. * @param step The amount to move the cursor back
  132837. * @returns This path cursor
  132838. */
  132839. moveBack(step?: number): PathCursor;
  132840. /**
  132841. * Moves the cursor by the step amount
  132842. * If the step amount is greater than one, an exception is thrown
  132843. * @param step The amount to move the cursor
  132844. * @returns This path cursor
  132845. */
  132846. move(step: number): PathCursor;
  132847. /**
  132848. * Ensures that the value is limited between zero and one
  132849. * @returns This path cursor
  132850. */
  132851. private ensureLimits;
  132852. /**
  132853. * Runs onchange callbacks on change (used by the animation engine)
  132854. * @returns This path cursor
  132855. */
  132856. private raiseOnChange;
  132857. /**
  132858. * Executes a function on change
  132859. * @param f A path cursor onchange callback
  132860. * @returns This path cursor
  132861. */
  132862. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132863. }
  132864. }
  132865. declare module BABYLON {
  132866. /** @hidden */
  132867. export var blurPixelShader: {
  132868. name: string;
  132869. shader: string;
  132870. };
  132871. }
  132872. declare module BABYLON {
  132873. /** @hidden */
  132874. export var pointCloudVertexDeclaration: {
  132875. name: string;
  132876. shader: string;
  132877. };
  132878. }
  132879. // Mixins
  132880. interface Window {
  132881. mozIndexedDB: IDBFactory;
  132882. webkitIndexedDB: IDBFactory;
  132883. msIndexedDB: IDBFactory;
  132884. webkitURL: typeof URL;
  132885. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132886. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132887. WebGLRenderingContext: WebGLRenderingContext;
  132888. MSGesture: MSGesture;
  132889. CANNON: any;
  132890. AudioContext: AudioContext;
  132891. webkitAudioContext: AudioContext;
  132892. PointerEvent: any;
  132893. Math: Math;
  132894. Uint8Array: Uint8ArrayConstructor;
  132895. Float32Array: Float32ArrayConstructor;
  132896. mozURL: typeof URL;
  132897. msURL: typeof URL;
  132898. VRFrameData: any; // WebVR, from specs 1.1
  132899. DracoDecoderModule: any;
  132900. setImmediate(handler: (...args: any[]) => void): number;
  132901. }
  132902. interface HTMLCanvasElement {
  132903. requestPointerLock(): void;
  132904. msRequestPointerLock?(): void;
  132905. mozRequestPointerLock?(): void;
  132906. webkitRequestPointerLock?(): void;
  132907. /** Track wether a record is in progress */
  132908. isRecording: boolean;
  132909. /** Capture Stream method defined by some browsers */
  132910. captureStream(fps?: number): MediaStream;
  132911. }
  132912. interface CanvasRenderingContext2D {
  132913. msImageSmoothingEnabled: boolean;
  132914. }
  132915. interface MouseEvent {
  132916. mozMovementX: number;
  132917. mozMovementY: number;
  132918. webkitMovementX: number;
  132919. webkitMovementY: number;
  132920. msMovementX: number;
  132921. msMovementY: number;
  132922. }
  132923. interface Navigator {
  132924. mozGetVRDevices: (any: any) => any;
  132925. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132926. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132927. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132928. webkitGetGamepads(): Gamepad[];
  132929. msGetGamepads(): Gamepad[];
  132930. webkitGamepads(): Gamepad[];
  132931. }
  132932. interface HTMLVideoElement {
  132933. mozSrcObject: any;
  132934. }
  132935. interface Math {
  132936. fround(x: number): number;
  132937. imul(a: number, b: number): number;
  132938. }
  132939. interface WebGLRenderingContext {
  132940. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132941. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132942. vertexAttribDivisor(index: number, divisor: number): void;
  132943. createVertexArray(): any;
  132944. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132945. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132946. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132947. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132948. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132949. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132950. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132951. // Queries
  132952. createQuery(): WebGLQuery;
  132953. deleteQuery(query: WebGLQuery): void;
  132954. beginQuery(target: number, query: WebGLQuery): void;
  132955. endQuery(target: number): void;
  132956. getQueryParameter(query: WebGLQuery, pname: number): any;
  132957. getQuery(target: number, pname: number): any;
  132958. MAX_SAMPLES: number;
  132959. RGBA8: number;
  132960. READ_FRAMEBUFFER: number;
  132961. DRAW_FRAMEBUFFER: number;
  132962. UNIFORM_BUFFER: number;
  132963. HALF_FLOAT_OES: number;
  132964. RGBA16F: number;
  132965. RGBA32F: number;
  132966. R32F: number;
  132967. RG32F: number;
  132968. RGB32F: number;
  132969. R16F: number;
  132970. RG16F: number;
  132971. RGB16F: number;
  132972. RED: number;
  132973. RG: number;
  132974. R8: number;
  132975. RG8: number;
  132976. UNSIGNED_INT_24_8: number;
  132977. DEPTH24_STENCIL8: number;
  132978. MIN: number;
  132979. MAX: number;
  132980. /* Multiple Render Targets */
  132981. drawBuffers(buffers: number[]): void;
  132982. readBuffer(src: number): void;
  132983. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132984. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132985. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132986. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132987. // Occlusion Query
  132988. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132989. ANY_SAMPLES_PASSED: number;
  132990. QUERY_RESULT_AVAILABLE: number;
  132991. QUERY_RESULT: number;
  132992. }
  132993. interface WebGLProgram {
  132994. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132995. }
  132996. interface EXT_disjoint_timer_query {
  132997. QUERY_COUNTER_BITS_EXT: number;
  132998. TIME_ELAPSED_EXT: number;
  132999. TIMESTAMP_EXT: number;
  133000. GPU_DISJOINT_EXT: number;
  133001. QUERY_RESULT_EXT: number;
  133002. QUERY_RESULT_AVAILABLE_EXT: number;
  133003. queryCounterEXT(query: WebGLQuery, target: number): void;
  133004. createQueryEXT(): WebGLQuery;
  133005. beginQueryEXT(target: number, query: WebGLQuery): void;
  133006. endQueryEXT(target: number): void;
  133007. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  133008. deleteQueryEXT(query: WebGLQuery): void;
  133009. }
  133010. interface WebGLUniformLocation {
  133011. _currentState: any;
  133012. }
  133013. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  133014. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  133015. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  133016. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133017. interface WebGLRenderingContext {
  133018. readonly RASTERIZER_DISCARD: number;
  133019. readonly DEPTH_COMPONENT24: number;
  133020. readonly TEXTURE_3D: number;
  133021. readonly TEXTURE_2D_ARRAY: number;
  133022. readonly TEXTURE_COMPARE_FUNC: number;
  133023. readonly TEXTURE_COMPARE_MODE: number;
  133024. readonly COMPARE_REF_TO_TEXTURE: number;
  133025. readonly TEXTURE_WRAP_R: number;
  133026. readonly HALF_FLOAT: number;
  133027. readonly RGB8: number;
  133028. readonly RED_INTEGER: number;
  133029. readonly RG_INTEGER: number;
  133030. readonly RGB_INTEGER: number;
  133031. readonly RGBA_INTEGER: number;
  133032. readonly R8_SNORM: number;
  133033. readonly RG8_SNORM: number;
  133034. readonly RGB8_SNORM: number;
  133035. readonly RGBA8_SNORM: number;
  133036. readonly R8I: number;
  133037. readonly RG8I: number;
  133038. readonly RGB8I: number;
  133039. readonly RGBA8I: number;
  133040. readonly R8UI: number;
  133041. readonly RG8UI: number;
  133042. readonly RGB8UI: number;
  133043. readonly RGBA8UI: number;
  133044. readonly R16I: number;
  133045. readonly RG16I: number;
  133046. readonly RGB16I: number;
  133047. readonly RGBA16I: number;
  133048. readonly R16UI: number;
  133049. readonly RG16UI: number;
  133050. readonly RGB16UI: number;
  133051. readonly RGBA16UI: number;
  133052. readonly R32I: number;
  133053. readonly RG32I: number;
  133054. readonly RGB32I: number;
  133055. readonly RGBA32I: number;
  133056. readonly R32UI: number;
  133057. readonly RG32UI: number;
  133058. readonly RGB32UI: number;
  133059. readonly RGBA32UI: number;
  133060. readonly RGB10_A2UI: number;
  133061. readonly R11F_G11F_B10F: number;
  133062. readonly RGB9_E5: number;
  133063. readonly RGB10_A2: number;
  133064. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  133065. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  133066. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  133067. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  133068. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  133069. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  133070. 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;
  133071. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  133072. readonly TRANSFORM_FEEDBACK: number;
  133073. readonly INTERLEAVED_ATTRIBS: number;
  133074. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  133075. createTransformFeedback(): WebGLTransformFeedback;
  133076. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  133077. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  133078. beginTransformFeedback(primitiveMode: number): void;
  133079. endTransformFeedback(): void;
  133080. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  133081. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133082. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133083. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133084. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  133085. }
  133086. interface ImageBitmap {
  133087. readonly width: number;
  133088. readonly height: number;
  133089. close(): void;
  133090. }
  133091. interface WebGLQuery extends WebGLObject {
  133092. }
  133093. declare var WebGLQuery: {
  133094. prototype: WebGLQuery;
  133095. new(): WebGLQuery;
  133096. };
  133097. interface WebGLSampler extends WebGLObject {
  133098. }
  133099. declare var WebGLSampler: {
  133100. prototype: WebGLSampler;
  133101. new(): WebGLSampler;
  133102. };
  133103. interface WebGLSync extends WebGLObject {
  133104. }
  133105. declare var WebGLSync: {
  133106. prototype: WebGLSync;
  133107. new(): WebGLSync;
  133108. };
  133109. interface WebGLTransformFeedback extends WebGLObject {
  133110. }
  133111. declare var WebGLTransformFeedback: {
  133112. prototype: WebGLTransformFeedback;
  133113. new(): WebGLTransformFeedback;
  133114. };
  133115. interface WebGLVertexArrayObject extends WebGLObject {
  133116. }
  133117. declare var WebGLVertexArrayObject: {
  133118. prototype: WebGLVertexArrayObject;
  133119. new(): WebGLVertexArrayObject;
  133120. };
  133121. // Type definitions for WebVR API
  133122. // Project: https://w3c.github.io/webvr/
  133123. // Definitions by: six a <https://github.com/lostfictions>
  133124. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133125. interface VRDisplay extends EventTarget {
  133126. /**
  133127. * Dictionary of capabilities describing the VRDisplay.
  133128. */
  133129. readonly capabilities: VRDisplayCapabilities;
  133130. /**
  133131. * z-depth defining the far plane of the eye view frustum
  133132. * enables mapping of values in the render target depth
  133133. * attachment to scene coordinates. Initially set to 10000.0.
  133134. */
  133135. depthFar: number;
  133136. /**
  133137. * z-depth defining the near plane of the eye view frustum
  133138. * enables mapping of values in the render target depth
  133139. * attachment to scene coordinates. Initially set to 0.01.
  133140. */
  133141. depthNear: number;
  133142. /**
  133143. * An identifier for this distinct VRDisplay. Used as an
  133144. * association point in the Gamepad API.
  133145. */
  133146. readonly displayId: number;
  133147. /**
  133148. * A display name, a user-readable name identifying it.
  133149. */
  133150. readonly displayName: string;
  133151. readonly isConnected: boolean;
  133152. readonly isPresenting: boolean;
  133153. /**
  133154. * If this VRDisplay supports room-scale experiences, the optional
  133155. * stage attribute contains details on the room-scale parameters.
  133156. */
  133157. readonly stageParameters: VRStageParameters | null;
  133158. /**
  133159. * Passing the value returned by `requestAnimationFrame` to
  133160. * `cancelAnimationFrame` will unregister the callback.
  133161. * @param handle Define the hanle of the request to cancel
  133162. */
  133163. cancelAnimationFrame(handle: number): void;
  133164. /**
  133165. * Stops presenting to the VRDisplay.
  133166. * @returns a promise to know when it stopped
  133167. */
  133168. exitPresent(): Promise<void>;
  133169. /**
  133170. * Return the current VREyeParameters for the given eye.
  133171. * @param whichEye Define the eye we want the parameter for
  133172. * @returns the eye parameters
  133173. */
  133174. getEyeParameters(whichEye: string): VREyeParameters;
  133175. /**
  133176. * Populates the passed VRFrameData with the information required to render
  133177. * the current frame.
  133178. * @param frameData Define the data structure to populate
  133179. * @returns true if ok otherwise false
  133180. */
  133181. getFrameData(frameData: VRFrameData): boolean;
  133182. /**
  133183. * Get the layers currently being presented.
  133184. * @returns the list of VR layers
  133185. */
  133186. getLayers(): VRLayer[];
  133187. /**
  133188. * Return a VRPose containing the future predicted pose of the VRDisplay
  133189. * when the current frame will be presented. The value returned will not
  133190. * change until JavaScript has returned control to the browser.
  133191. *
  133192. * The VRPose will contain the position, orientation, velocity,
  133193. * and acceleration of each of these properties.
  133194. * @returns the pose object
  133195. */
  133196. getPose(): VRPose;
  133197. /**
  133198. * Return the current instantaneous pose of the VRDisplay, with no
  133199. * prediction applied.
  133200. * @returns the current instantaneous pose
  133201. */
  133202. getImmediatePose(): VRPose;
  133203. /**
  133204. * The callback passed to `requestAnimationFrame` will be called
  133205. * any time a new frame should be rendered. When the VRDisplay is
  133206. * presenting the callback will be called at the native refresh
  133207. * rate of the HMD. When not presenting this function acts
  133208. * identically to how window.requestAnimationFrame acts. Content should
  133209. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133210. * asynchronously from other displays and at differing refresh rates.
  133211. * @param callback Define the eaction to run next frame
  133212. * @returns the request handle it
  133213. */
  133214. requestAnimationFrame(callback: FrameRequestCallback): number;
  133215. /**
  133216. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133217. * Repeat calls while already presenting will update the VRLayers being displayed.
  133218. * @param layers Define the list of layer to present
  133219. * @returns a promise to know when the request has been fulfilled
  133220. */
  133221. requestPresent(layers: VRLayer[]): Promise<void>;
  133222. /**
  133223. * Reset the pose for this display, treating its current position and
  133224. * orientation as the "origin/zero" values. VRPose.position,
  133225. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133226. * updated when calling resetPose(). This should be called in only
  133227. * sitting-space experiences.
  133228. */
  133229. resetPose(): void;
  133230. /**
  133231. * The VRLayer provided to the VRDisplay will be captured and presented
  133232. * in the HMD. Calling this function has the same effect on the source
  133233. * canvas as any other operation that uses its source image, and canvases
  133234. * created without preserveDrawingBuffer set to true will be cleared.
  133235. * @param pose Define the pose to submit
  133236. */
  133237. submitFrame(pose?: VRPose): void;
  133238. }
  133239. declare var VRDisplay: {
  133240. prototype: VRDisplay;
  133241. new(): VRDisplay;
  133242. };
  133243. interface VRLayer {
  133244. leftBounds?: number[] | Float32Array | null;
  133245. rightBounds?: number[] | Float32Array | null;
  133246. source?: HTMLCanvasElement | null;
  133247. }
  133248. interface VRDisplayCapabilities {
  133249. readonly canPresent: boolean;
  133250. readonly hasExternalDisplay: boolean;
  133251. readonly hasOrientation: boolean;
  133252. readonly hasPosition: boolean;
  133253. readonly maxLayers: number;
  133254. }
  133255. interface VREyeParameters {
  133256. /** @deprecated */
  133257. readonly fieldOfView: VRFieldOfView;
  133258. readonly offset: Float32Array;
  133259. readonly renderHeight: number;
  133260. readonly renderWidth: number;
  133261. }
  133262. interface VRFieldOfView {
  133263. readonly downDegrees: number;
  133264. readonly leftDegrees: number;
  133265. readonly rightDegrees: number;
  133266. readonly upDegrees: number;
  133267. }
  133268. interface VRFrameData {
  133269. readonly leftProjectionMatrix: Float32Array;
  133270. readonly leftViewMatrix: Float32Array;
  133271. readonly pose: VRPose;
  133272. readonly rightProjectionMatrix: Float32Array;
  133273. readonly rightViewMatrix: Float32Array;
  133274. readonly timestamp: number;
  133275. }
  133276. interface VRPose {
  133277. readonly angularAcceleration: Float32Array | null;
  133278. readonly angularVelocity: Float32Array | null;
  133279. readonly linearAcceleration: Float32Array | null;
  133280. readonly linearVelocity: Float32Array | null;
  133281. readonly orientation: Float32Array | null;
  133282. readonly position: Float32Array | null;
  133283. readonly timestamp: number;
  133284. }
  133285. interface VRStageParameters {
  133286. sittingToStandingTransform?: Float32Array;
  133287. sizeX?: number;
  133288. sizeY?: number;
  133289. }
  133290. interface Navigator {
  133291. getVRDisplays(): Promise<VRDisplay[]>;
  133292. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133293. }
  133294. interface Window {
  133295. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133296. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133297. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133298. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133299. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133300. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133301. }
  133302. interface Gamepad {
  133303. readonly displayId: number;
  133304. }
  133305. type XRSessionMode =
  133306. | "inline"
  133307. | "immersive-vr"
  133308. | "immersive-ar";
  133309. type XRReferenceSpaceType =
  133310. | "viewer"
  133311. | "local"
  133312. | "local-floor"
  133313. | "bounded-floor"
  133314. | "unbounded";
  133315. type XREnvironmentBlendMode =
  133316. | "opaque"
  133317. | "additive"
  133318. | "alpha-blend";
  133319. type XRVisibilityState =
  133320. | "visible"
  133321. | "visible-blurred"
  133322. | "hidden";
  133323. type XRHandedness =
  133324. | "none"
  133325. | "left"
  133326. | "right";
  133327. type XRTargetRayMode =
  133328. | "gaze"
  133329. | "tracked-pointer"
  133330. | "screen";
  133331. type XREye =
  133332. | "none"
  133333. | "left"
  133334. | "right";
  133335. interface XRSpace extends EventTarget {
  133336. }
  133337. interface XRRenderState {
  133338. depthNear?: number;
  133339. depthFar?: number;
  133340. inlineVerticalFieldOfView?: number;
  133341. baseLayer?: XRWebGLLayer;
  133342. }
  133343. interface XRInputSource {
  133344. handedness: XRHandedness;
  133345. targetRayMode: XRTargetRayMode;
  133346. targetRaySpace: XRSpace;
  133347. gripSpace: XRSpace | undefined;
  133348. gamepad: Gamepad | undefined;
  133349. profiles: Array<string>;
  133350. }
  133351. interface XRSession {
  133352. addEventListener: Function;
  133353. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133354. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133355. requestAnimationFrame: Function;
  133356. end(): Promise<void>;
  133357. renderState: XRRenderState;
  133358. inputSources: Array<XRInputSource>;
  133359. }
  133360. interface XRReferenceSpace extends XRSpace {
  133361. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133362. onreset: any;
  133363. }
  133364. interface XRFrame {
  133365. session: XRSession;
  133366. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133367. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133368. }
  133369. interface XRViewerPose extends XRPose {
  133370. views: Array<XRView>;
  133371. }
  133372. interface XRPose {
  133373. transform: XRRigidTransform;
  133374. emulatedPosition: boolean;
  133375. }
  133376. interface XRWebGLLayerOptions {
  133377. antialias ?: boolean;
  133378. depth ?: boolean;
  133379. stencil ?: boolean;
  133380. alpha ?: boolean;
  133381. multiview ?: boolean;
  133382. framebufferScaleFactor ?: number;
  133383. }
  133384. declare var XRWebGLLayer: {
  133385. prototype: XRWebGLLayer;
  133386. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  133387. };
  133388. interface XRWebGLLayer {
  133389. framebuffer: WebGLFramebuffer;
  133390. framebufferWidth: number;
  133391. framebufferHeight: number;
  133392. getViewport: Function;
  133393. }
  133394. interface XRRigidTransform {
  133395. position: DOMPointReadOnly;
  133396. orientation: DOMPointReadOnly;
  133397. matrix: Float32Array;
  133398. inverse: XRRigidTransform;
  133399. }
  133400. interface XRView {
  133401. eye: XREye;
  133402. projectionMatrix: Float32Array;
  133403. transform: XRRigidTransform;
  133404. }
  133405. interface XRInputSourceChangeEvent {
  133406. session: XRSession;
  133407. removed: Array<XRInputSource>;
  133408. added: Array<XRInputSource>;
  133409. }